@tamagui/button 1.143.0 → 2.0.0-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Button.cjs +126 -158
- package/dist/cjs/Button.js +102 -120
- package/dist/cjs/Button.js.map +2 -2
- package/dist/cjs/Button.native.js +128 -160
- package/dist/cjs/Button.native.js.map +1 -1
- package/dist/esm/Button.js +108 -126
- package/dist/esm/Button.js.map +2 -2
- package/dist/esm/Button.mjs +127 -155
- package/dist/esm/Button.mjs.map +1 -1
- package/dist/esm/Button.native.js +130 -158
- package/dist/esm/Button.native.js.map +1 -1
- package/dist/jsx/Button.js +108 -126
- package/dist/jsx/Button.js.map +2 -2
- package/dist/jsx/Button.mjs +127 -155
- package/dist/jsx/Button.mjs.map +1 -1
- package/dist/jsx/Button.native.js +128 -160
- package/dist/jsx/Button.native.js.map +1 -1
- package/package.json +12 -11
- package/src/Button.tsx +172 -243
- package/src/v1/Button.test.tsx +21 -0
- package/src/v1/Button.tsx +336 -0
- package/src/v1/index.ts +1 -0
- package/types/Button.d.ts +80 -323
- package/types/Button.d.ts.map +1 -1
- package/types/v1/Button.d.ts +338 -0
- package/types/v1/Button.test.d.ts +2 -0
- package/types/v1/index.d.ts +2 -0
package/dist/cjs/Button.cjs
CHANGED
|
@@ -20,46 +20,32 @@ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
|
20
20
|
}), mod);
|
|
21
21
|
var Button_exports = {};
|
|
22
22
|
__export(Button_exports, {
|
|
23
|
-
Button: () =>
|
|
24
|
-
ButtonContext: () => ButtonContext
|
|
25
|
-
ButtonFrame: () => ButtonFrame,
|
|
26
|
-
ButtonIcon: () => ButtonIcon,
|
|
27
|
-
ButtonText: () => ButtonText,
|
|
28
|
-
useButton: () => useButton
|
|
23
|
+
Button: () => Button,
|
|
24
|
+
ButtonContext: () => ButtonContext
|
|
29
25
|
});
|
|
30
26
|
module.exports = __toCommonJS(Button_exports);
|
|
31
27
|
var import_font_size = require("@tamagui/font-size"),
|
|
32
28
|
import_get_button_sized = require("@tamagui/get-button-sized"),
|
|
33
|
-
import_helpers = require("@tamagui/helpers"),
|
|
34
|
-
import_helpers_tamagui = require("@tamagui/helpers-tamagui"),
|
|
35
29
|
import_stacks = require("@tamagui/stacks"),
|
|
36
30
|
import_text = require("@tamagui/text"),
|
|
37
31
|
import_web = require("@tamagui/web"),
|
|
38
32
|
import_react = require("react"),
|
|
33
|
+
import_helpers_tamagui = require("@tamagui/helpers-tamagui"),
|
|
39
34
|
import_jsx_runtime = require("react/jsx-runtime");
|
|
40
|
-
const
|
|
41
|
-
// keeping these here means they work with styled() passing down color to text
|
|
42
|
-
color: void 0,
|
|
43
|
-
ellipse: void 0,
|
|
44
|
-
fontFamily: void 0,
|
|
45
|
-
fontSize: void 0,
|
|
46
|
-
fontStyle: void 0,
|
|
47
|
-
fontWeight: void 0,
|
|
48
|
-
letterSpacing: void 0,
|
|
49
|
-
maxFontSizeMultiplier: void 0,
|
|
35
|
+
const context = (0, import_web.createStyledContext)({
|
|
50
36
|
size: void 0,
|
|
51
|
-
|
|
52
|
-
|
|
37
|
+
variant: void 0,
|
|
38
|
+
color: void 0,
|
|
39
|
+
elevation: void 0
|
|
53
40
|
}),
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
name:
|
|
57
|
-
|
|
58
|
-
|
|
41
|
+
Frame = (0, import_web.styled)(import_web.View, {
|
|
42
|
+
context,
|
|
43
|
+
name: "Button",
|
|
44
|
+
group: "Button",
|
|
45
|
+
containerType: "normal",
|
|
59
46
|
role: "button",
|
|
47
|
+
tag: "button",
|
|
60
48
|
focusable: !0,
|
|
61
|
-
// forces runtime pressStyle so it passes through context text colors
|
|
62
|
-
disableClassName: !0,
|
|
63
49
|
variants: {
|
|
64
50
|
unstyled: {
|
|
65
51
|
false: {
|
|
@@ -69,11 +55,17 @@ const ButtonContext = (0, import_web.createStyledContext)({
|
|
|
69
55
|
flexWrap: "nowrap",
|
|
70
56
|
flexDirection: "row",
|
|
71
57
|
cursor: "pointer",
|
|
72
|
-
|
|
73
|
-
pressTheme: !0,
|
|
74
|
-
backgrounded: !0,
|
|
58
|
+
backgroundColor: "$background",
|
|
75
59
|
borderWidth: 1,
|
|
76
60
|
borderColor: "transparent",
|
|
61
|
+
hoverStyle: {
|
|
62
|
+
backgroundColor: "$backgroundHover",
|
|
63
|
+
borderColor: "$borderColorHover"
|
|
64
|
+
},
|
|
65
|
+
pressStyle: {
|
|
66
|
+
backgroundColor: "$backgroundPress",
|
|
67
|
+
borderColor: "$borderColorHover"
|
|
68
|
+
},
|
|
77
69
|
focusVisibleStyle: {
|
|
78
70
|
outlineColor: "$outlineColor",
|
|
79
71
|
outlineStyle: "solid",
|
|
@@ -82,7 +74,7 @@ const ButtonContext = (0, import_web.createStyledContext)({
|
|
|
82
74
|
}
|
|
83
75
|
},
|
|
84
76
|
variant: {
|
|
85
|
-
outlined: {
|
|
77
|
+
outlined: process.env.TAMAGUI_HEADLESS === "1" ? {} : {
|
|
86
78
|
backgroundColor: "transparent",
|
|
87
79
|
borderWidth: 2,
|
|
88
80
|
borderColor: "$borderColor",
|
|
@@ -96,13 +88,37 @@ const ButtonContext = (0, import_web.createStyledContext)({
|
|
|
96
88
|
},
|
|
97
89
|
focusVisibleStyle: {
|
|
98
90
|
backgroundColor: "transparent",
|
|
99
|
-
borderColor: "$borderColorFocus"
|
|
91
|
+
borderColor: "$borderColorFocus",
|
|
92
|
+
outlineColor: "$outlineColor",
|
|
93
|
+
outlineStyle: "solid",
|
|
94
|
+
outlineWidth: 2
|
|
100
95
|
}
|
|
101
96
|
}
|
|
102
97
|
},
|
|
98
|
+
circular: import_stacks.themeableVariants.circular,
|
|
99
|
+
chromeless: import_stacks.themeableVariants.chromeless,
|
|
100
|
+
bordered: import_stacks.themeableVariants.bordered,
|
|
103
101
|
size: {
|
|
104
|
-
"...size":
|
|
105
|
-
|
|
102
|
+
"...size": (val, extras) => {
|
|
103
|
+
const buttonStyle = (0, import_get_button_sized.getButtonSized)(val, extras),
|
|
104
|
+
gap = (0, import_web.getTokenValue)(val) * 0.4;
|
|
105
|
+
return {
|
|
106
|
+
...buttonStyle,
|
|
107
|
+
gap
|
|
108
|
+
};
|
|
109
|
+
},
|
|
110
|
+
":number": (val, extras) => {
|
|
111
|
+
const buttonStyle = (0, import_get_button_sized.getButtonSized)(val, extras),
|
|
112
|
+
gap = val * 0.4;
|
|
113
|
+
return {
|
|
114
|
+
...buttonStyle,
|
|
115
|
+
gap
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
elevation: {
|
|
120
|
+
"...size": import_stacks.getElevation,
|
|
121
|
+
":number": import_stacks.getElevation
|
|
106
122
|
},
|
|
107
123
|
disabled: {
|
|
108
124
|
true: {
|
|
@@ -114,9 +130,8 @@ const ButtonContext = (0, import_web.createStyledContext)({
|
|
|
114
130
|
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
115
131
|
}
|
|
116
132
|
}),
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
context: ButtonContext,
|
|
133
|
+
Text = (0, import_web.styled)(import_text.SizableText, {
|
|
134
|
+
context,
|
|
120
135
|
variants: {
|
|
121
136
|
unstyled: {
|
|
122
137
|
false: {
|
|
@@ -125,7 +140,7 @@ const ButtonContext = (0, import_web.createStyledContext)({
|
|
|
125
140
|
// flexGrow 1 leads to inconsistent native style where text pushes to start of view
|
|
126
141
|
flexGrow: 0,
|
|
127
142
|
flexShrink: 1,
|
|
128
|
-
|
|
143
|
+
ellipsis: !0,
|
|
129
144
|
color: "$color"
|
|
130
145
|
}
|
|
131
146
|
}
|
|
@@ -134,130 +149,83 @@ const ButtonContext = (0, import_web.createStyledContext)({
|
|
|
134
149
|
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
135
150
|
}
|
|
136
151
|
}),
|
|
137
|
-
|
|
152
|
+
Icon = props => {
|
|
138
153
|
const {
|
|
139
154
|
children,
|
|
140
|
-
scaleIcon = 1
|
|
155
|
+
scaleIcon = 1,
|
|
156
|
+
marginLeft,
|
|
157
|
+
marginRight,
|
|
158
|
+
size
|
|
141
159
|
} = props,
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
iconSize = (typeof
|
|
147
|
-
return (
|
|
160
|
+
styledContext = context.useStyledContext();
|
|
161
|
+
if (!styledContext) throw new Error("Button.Icon must be used within a Button");
|
|
162
|
+
const getIcon = (0, import_helpers_tamagui.useGetIcon)(),
|
|
163
|
+
sizeToken = size ?? styledContext.size,
|
|
164
|
+
iconSize = (typeof sizeToken == "number" ? sizeToken * 0.5 : (0, import_font_size.getFontSize)(sizeToken)) * scaleIcon;
|
|
165
|
+
return getIcon(children, {
|
|
148
166
|
size: iconSize,
|
|
149
|
-
color
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
ButtonComponent = ButtonFrame.styleable(function (props, ref) {
|
|
153
|
-
const {
|
|
154
|
-
props: buttonProps
|
|
155
|
-
} = useButton(props);
|
|
156
|
-
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(ButtonFrame, {
|
|
157
|
-
"data-disable-theme": !0,
|
|
158
|
-
...buttonProps,
|
|
159
|
-
ref
|
|
167
|
+
color: styledContext.color,
|
|
168
|
+
marginLeft,
|
|
169
|
+
marginRight
|
|
160
170
|
});
|
|
171
|
+
},
|
|
172
|
+
ButtonContext = (0, import_web.createStyledContext)({
|
|
173
|
+
size: void 0,
|
|
174
|
+
variant: void 0,
|
|
175
|
+
color: void 0
|
|
161
176
|
}),
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
textProps,
|
|
168
|
-
...propsIn
|
|
169
|
-
}, {
|
|
170
|
-
Text = Button2.Text
|
|
171
|
-
} = {
|
|
172
|
-
Text: Button2.Text
|
|
173
|
-
}) {
|
|
174
|
-
const isNested = (0, import_react.useContext)(import_stacks.ButtonNestingContext),
|
|
175
|
-
propsActive = (0, import_web.useProps)(propsIn, {
|
|
176
|
-
noNormalize: !0,
|
|
177
|
-
noExpand: !0
|
|
178
|
-
}),
|
|
179
|
-
{
|
|
180
|
-
icon,
|
|
181
|
-
iconAfter,
|
|
182
|
-
space,
|
|
183
|
-
spaceFlex,
|
|
184
|
-
scaleIcon = 1,
|
|
185
|
-
scaleSpace = 0.66,
|
|
186
|
-
separator,
|
|
187
|
-
noTextWrap,
|
|
188
|
-
fontFamily,
|
|
189
|
-
fontSize,
|
|
190
|
-
fontWeight,
|
|
191
|
-
fontStyle,
|
|
192
|
-
letterSpacing,
|
|
193
|
-
tag,
|
|
194
|
-
ellipse,
|
|
195
|
-
maxFontSizeMultiplier,
|
|
196
|
-
...restProps
|
|
197
|
-
} = propsActive,
|
|
198
|
-
size = propsActive.size || (propsActive.unstyled ? void 0 : "$true"),
|
|
199
|
-
color = propsActive.color,
|
|
200
|
-
iconSize = (typeof size == "number" ? size * 0.5 : (0, import_font_size.getFontSize)(size, {
|
|
201
|
-
font: fontFamily?.[0] === "$" ? fontFamily : void 0
|
|
202
|
-
})) * scaleIcon,
|
|
203
|
-
getThemedIcon = (0, import_helpers_tamagui.useGetThemedIcon)({
|
|
204
|
-
size: iconSize,
|
|
205
|
-
color
|
|
206
|
-
}),
|
|
207
|
-
[themedIcon, themedIconAfter] = [icon, iconAfter].map(getThemedIcon),
|
|
208
|
-
spaceSize = space ?? (0, import_web.getVariableValue)(iconSize) * scaleSpace,
|
|
209
|
-
contents = noTextWrap ? [propsIn.children] : (0, import_text.wrapChildrenInText)(Text, {
|
|
210
|
-
children: propsIn.children,
|
|
211
|
-
color,
|
|
212
|
-
fontFamily,
|
|
213
|
-
fontSize,
|
|
214
|
-
textProps,
|
|
215
|
-
fontWeight,
|
|
216
|
-
fontStyle,
|
|
217
|
-
letterSpacing,
|
|
218
|
-
ellipse,
|
|
219
|
-
maxFontSizeMultiplier
|
|
220
|
-
}, Text === ButtonText && propsActive.unstyled !== !0 ? {
|
|
221
|
-
unstyled: process.env.TAMAGUI_HEADLESS === "1",
|
|
222
|
-
size
|
|
223
|
-
} : void 0),
|
|
224
|
-
inner = (0, import_web.spacedChildren)({
|
|
225
|
-
// a bit arbitrary but scaling to font size is necessary so long as button does
|
|
226
|
-
space: spaceSize === !1 ? 0 : spaceSize == !0 ? "$true" : spaceSize,
|
|
227
|
-
spaceFlex,
|
|
228
|
-
ensureKeys: !0,
|
|
229
|
-
separator,
|
|
230
|
-
direction: propsActive.flexDirection === "column" || propsActive.flexDirection === "column-reverse" ? "vertical" : "horizontal",
|
|
231
|
-
// for keys to stay the same we keep indices as similar a possible
|
|
232
|
-
// so even if icons are undefined we still pass them
|
|
233
|
-
children: [themedIcon, ...contents, themedIconAfter]
|
|
234
|
-
}),
|
|
235
|
-
props = {
|
|
236
|
-
size,
|
|
237
|
-
...(propsIn.disabled && {
|
|
238
|
-
// in rnw - false still has keyboard tabIndex, undefined = not actually focusable
|
|
239
|
-
focusable: void 0,
|
|
240
|
-
// even with tabIndex unset, it will keep focusVisibleStyle on web so disable it here
|
|
241
|
-
focusVisibleStyle: {
|
|
242
|
-
borderColor: "$background"
|
|
243
|
-
}
|
|
244
|
-
}),
|
|
245
|
-
// fixes SSR issue + DOM nesting issue of not allowing button in button
|
|
246
|
-
tag: tag ?? (isNested ? "span" :
|
|
247
|
-
// defaults to <a /> when accessibilityRole = link
|
|
248
|
-
// see https://github.com/tamagui/tamagui/issues/505
|
|
249
|
-
propsActive.accessibilityRole === "link" || propsActive.role === "link" ? "a" : "button"),
|
|
250
|
-
...restProps,
|
|
251
|
-
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_stacks.ButtonNestingContext.Provider, {
|
|
252
|
-
value: !0,
|
|
253
|
-
children: inner
|
|
177
|
+
ButtonComponent = Frame.styleable((propsIn, ref) => {
|
|
178
|
+
const isNested = (0, import_react.useContext)(import_stacks.ButtonNestingContext),
|
|
179
|
+
processedProps = (0, import_web.useProps)(propsIn, {
|
|
180
|
+
noNormalize: !0,
|
|
181
|
+
noExpand: !0
|
|
254
182
|
}),
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
}
|
|
183
|
+
{
|
|
184
|
+
children,
|
|
185
|
+
iconSize,
|
|
186
|
+
icon,
|
|
187
|
+
iconAfter,
|
|
188
|
+
scaleIcon = 1,
|
|
189
|
+
noTextWrap,
|
|
190
|
+
...props
|
|
191
|
+
} = processedProps,
|
|
192
|
+
size = propsIn.size || (propsIn.unstyled ? void 0 : "$true"),
|
|
193
|
+
styledContext = context.useStyledContext(),
|
|
194
|
+
finalSize = iconSize ?? size ?? styledContext?.size,
|
|
195
|
+
iconSizeNumber = (typeof finalSize == "number" ? finalSize * 0.5 : (0, import_font_size.getFontSize)(finalSize)) * scaleIcon,
|
|
196
|
+
getIcon = (0, import_helpers_tamagui.useGetIcon)(),
|
|
197
|
+
[themedIcon, themedIconAfter] = [icon, iconAfter].map(icon2 => icon2 ? getIcon(icon2, {
|
|
198
|
+
size: iconSizeNumber,
|
|
199
|
+
color: styledContext?.color
|
|
200
|
+
// No marginLeft or marginRight needed - spacing is handled by the gap property in Frame's size variants
|
|
201
|
+
}) : null),
|
|
202
|
+
wrappedChildren = (0, import_text.wrapChildrenInText)(Text, {
|
|
203
|
+
children,
|
|
204
|
+
noTextWrap
|
|
205
|
+
}, {
|
|
206
|
+
unstyled: process.env.TAMAGUI_HEADLESS === "1",
|
|
207
|
+
size: finalSize ?? styledContext?.size
|
|
208
|
+
});
|
|
209
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_stacks.ButtonNestingContext.Provider, {
|
|
210
|
+
value: !0,
|
|
211
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsxs)(Frame, {
|
|
212
|
+
ref,
|
|
213
|
+
...props,
|
|
214
|
+
...(isNested && {
|
|
215
|
+
tag: "span"
|
|
216
|
+
}),
|
|
217
|
+
...(props.circular && !propsIn.size && {
|
|
218
|
+
size
|
|
219
|
+
}),
|
|
220
|
+
tabIndex: 0,
|
|
221
|
+
focusable: !0,
|
|
222
|
+
children: [themedIcon, wrappedChildren, themedIconAfter]
|
|
223
|
+
})
|
|
224
|
+
});
|
|
225
|
+
}),
|
|
226
|
+
Button = (0, import_web.withStaticProperties)(ButtonComponent, {
|
|
227
|
+
Apply: context.Provider,
|
|
228
|
+
Frame,
|
|
229
|
+
Text,
|
|
230
|
+
Icon
|
|
231
|
+
});
|
package/dist/cjs/Button.js
CHANGED
|
@@ -14,36 +14,24 @@ var __export = (target, all) => {
|
|
|
14
14
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
15
|
var Button_exports = {};
|
|
16
16
|
__export(Button_exports, {
|
|
17
|
-
Button: () =>
|
|
18
|
-
ButtonContext: () => ButtonContext
|
|
19
|
-
ButtonFrame: () => ButtonFrame,
|
|
20
|
-
ButtonIcon: () => ButtonIcon,
|
|
21
|
-
ButtonText: () => ButtonText,
|
|
22
|
-
useButton: () => useButton
|
|
17
|
+
Button: () => Button,
|
|
18
|
+
ButtonContext: () => ButtonContext
|
|
23
19
|
});
|
|
24
20
|
module.exports = __toCommonJS(Button_exports);
|
|
25
|
-
var import_font_size = require("@tamagui/font-size"), import_get_button_sized = require("@tamagui/get-button-sized"),
|
|
26
|
-
const
|
|
27
|
-
// keeping these here means they work with styled() passing down color to text
|
|
28
|
-
color: void 0,
|
|
29
|
-
ellipse: void 0,
|
|
30
|
-
fontFamily: void 0,
|
|
31
|
-
fontSize: void 0,
|
|
32
|
-
fontStyle: void 0,
|
|
33
|
-
fontWeight: void 0,
|
|
34
|
-
letterSpacing: void 0,
|
|
35
|
-
maxFontSizeMultiplier: void 0,
|
|
21
|
+
var import_font_size = require("@tamagui/font-size"), import_get_button_sized = require("@tamagui/get-button-sized"), import_stacks = require("@tamagui/stacks"), import_text = require("@tamagui/text"), import_web = require("@tamagui/web"), import_react = require("react"), import_helpers_tamagui = require("@tamagui/helpers-tamagui"), import_jsx_runtime = require("react/jsx-runtime");
|
|
22
|
+
const context = (0, import_web.createStyledContext)({
|
|
36
23
|
size: void 0,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
24
|
+
variant: void 0,
|
|
25
|
+
color: void 0,
|
|
26
|
+
elevation: void 0
|
|
27
|
+
}), Frame = (0, import_web.styled)(import_web.View, {
|
|
28
|
+
context,
|
|
29
|
+
name: "Button",
|
|
30
|
+
group: "Button",
|
|
31
|
+
containerType: "normal",
|
|
43
32
|
role: "button",
|
|
33
|
+
tag: "button",
|
|
44
34
|
focusable: !0,
|
|
45
|
-
// forces runtime pressStyle so it passes through context text colors
|
|
46
|
-
disableClassName: !0,
|
|
47
35
|
variants: {
|
|
48
36
|
unstyled: {
|
|
49
37
|
false: {
|
|
@@ -53,11 +41,17 @@ const ButtonContext = (0, import_web.createStyledContext)({
|
|
|
53
41
|
flexWrap: "nowrap",
|
|
54
42
|
flexDirection: "row",
|
|
55
43
|
cursor: "pointer",
|
|
56
|
-
|
|
57
|
-
pressTheme: !0,
|
|
58
|
-
backgrounded: !0,
|
|
44
|
+
backgroundColor: "$background",
|
|
59
45
|
borderWidth: 1,
|
|
60
46
|
borderColor: "transparent",
|
|
47
|
+
hoverStyle: {
|
|
48
|
+
backgroundColor: "$backgroundHover",
|
|
49
|
+
borderColor: "$borderColorHover"
|
|
50
|
+
},
|
|
51
|
+
pressStyle: {
|
|
52
|
+
backgroundColor: "$backgroundPress",
|
|
53
|
+
borderColor: "$borderColorHover"
|
|
54
|
+
},
|
|
61
55
|
focusVisibleStyle: {
|
|
62
56
|
outlineColor: "$outlineColor",
|
|
63
57
|
outlineStyle: "solid",
|
|
@@ -66,7 +60,7 @@ const ButtonContext = (0, import_web.createStyledContext)({
|
|
|
66
60
|
}
|
|
67
61
|
},
|
|
68
62
|
variant: {
|
|
69
|
-
outlined: {
|
|
63
|
+
outlined: process.env.TAMAGUI_HEADLESS === "1" ? {} : {
|
|
70
64
|
backgroundColor: "transparent",
|
|
71
65
|
borderWidth: 2,
|
|
72
66
|
borderColor: "$borderColor",
|
|
@@ -80,13 +74,35 @@ const ButtonContext = (0, import_web.createStyledContext)({
|
|
|
80
74
|
},
|
|
81
75
|
focusVisibleStyle: {
|
|
82
76
|
backgroundColor: "transparent",
|
|
83
|
-
borderColor: "$borderColorFocus"
|
|
77
|
+
borderColor: "$borderColorFocus",
|
|
78
|
+
outlineColor: "$outlineColor",
|
|
79
|
+
outlineStyle: "solid",
|
|
80
|
+
outlineWidth: 2
|
|
84
81
|
}
|
|
85
82
|
}
|
|
86
83
|
},
|
|
84
|
+
circular: import_stacks.themeableVariants.circular,
|
|
85
|
+
chromeless: import_stacks.themeableVariants.chromeless,
|
|
86
|
+
bordered: import_stacks.themeableVariants.bordered,
|
|
87
87
|
size: {
|
|
88
|
-
"...size":
|
|
89
|
-
|
|
88
|
+
"...size": (val, extras) => {
|
|
89
|
+
const buttonStyle = (0, import_get_button_sized.getButtonSized)(val, extras), gap = (0, import_web.getTokenValue)(val) * 0.4;
|
|
90
|
+
return {
|
|
91
|
+
...buttonStyle,
|
|
92
|
+
gap
|
|
93
|
+
};
|
|
94
|
+
},
|
|
95
|
+
":number": (val, extras) => {
|
|
96
|
+
const buttonStyle = (0, import_get_button_sized.getButtonSized)(val, extras), gap = val * 0.4;
|
|
97
|
+
return {
|
|
98
|
+
...buttonStyle,
|
|
99
|
+
gap
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
elevation: {
|
|
104
|
+
"...size": import_stacks.getElevation,
|
|
105
|
+
":number": import_stacks.getElevation
|
|
90
106
|
},
|
|
91
107
|
disabled: {
|
|
92
108
|
true: {
|
|
@@ -97,9 +113,8 @@ const ButtonContext = (0, import_web.createStyledContext)({
|
|
|
97
113
|
defaultVariants: {
|
|
98
114
|
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
99
115
|
}
|
|
100
|
-
}),
|
|
101
|
-
|
|
102
|
-
context: ButtonContext,
|
|
116
|
+
}), Text = (0, import_web.styled)(import_text.SizableText, {
|
|
117
|
+
context,
|
|
103
118
|
variants: {
|
|
104
119
|
unstyled: {
|
|
105
120
|
false: {
|
|
@@ -108,7 +123,7 @@ const ButtonContext = (0, import_web.createStyledContext)({
|
|
|
108
123
|
// flexGrow 1 leads to inconsistent native style where text pushes to start of view
|
|
109
124
|
flexGrow: 0,
|
|
110
125
|
flexShrink: 1,
|
|
111
|
-
|
|
126
|
+
ellipsis: !0,
|
|
112
127
|
color: "$color"
|
|
113
128
|
}
|
|
114
129
|
}
|
|
@@ -116,98 +131,65 @@ const ButtonContext = (0, import_web.createStyledContext)({
|
|
|
116
131
|
defaultVariants: {
|
|
117
132
|
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
118
133
|
}
|
|
119
|
-
}),
|
|
120
|
-
const { children, scaleIcon = 1
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
})
|
|
131
|
-
|
|
132
|
-
|
|
134
|
+
}), Icon = (props) => {
|
|
135
|
+
const { children, scaleIcon = 1, marginLeft, marginRight, size } = props, styledContext = context.useStyledContext();
|
|
136
|
+
if (!styledContext)
|
|
137
|
+
throw new Error("Button.Icon must be used within a Button");
|
|
138
|
+
const getIcon = (0, import_helpers_tamagui.useGetIcon)(), sizeToken = size ?? styledContext.size, iconSize = (typeof sizeToken == "number" ? sizeToken * 0.5 : (0, import_font_size.getFontSize)(sizeToken)) * scaleIcon;
|
|
139
|
+
return getIcon(children, {
|
|
140
|
+
size: iconSize,
|
|
141
|
+
color: styledContext.color,
|
|
142
|
+
marginLeft,
|
|
143
|
+
marginRight
|
|
144
|
+
});
|
|
145
|
+
}, ButtonContext = (0, import_web.createStyledContext)({
|
|
146
|
+
size: void 0,
|
|
147
|
+
variant: void 0,
|
|
148
|
+
color: void 0
|
|
149
|
+
}), ButtonComponent = Frame.styleable((propsIn, ref) => {
|
|
150
|
+
const isNested = (0, import_react.useContext)(import_stacks.ButtonNestingContext), processedProps = (0, import_web.useProps)(propsIn, {
|
|
133
151
|
noNormalize: !0,
|
|
134
152
|
noExpand: !0
|
|
135
153
|
}), {
|
|
154
|
+
children,
|
|
155
|
+
iconSize,
|
|
136
156
|
icon,
|
|
137
157
|
iconAfter,
|
|
138
|
-
space,
|
|
139
|
-
spaceFlex,
|
|
140
158
|
scaleIcon = 1,
|
|
141
|
-
scaleSpace = 0.66,
|
|
142
|
-
separator,
|
|
143
159
|
noTextWrap,
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
ellipse,
|
|
151
|
-
maxFontSizeMultiplier,
|
|
152
|
-
...restProps
|
|
153
|
-
} = propsActive, size = propsActive.size || (propsActive.unstyled ? void 0 : "$true"), color = propsActive.color, iconSize = (typeof size == "number" ? size * 0.5 : (0, import_font_size.getFontSize)(size, {
|
|
154
|
-
font: fontFamily?.[0] === "$" ? fontFamily : void 0
|
|
155
|
-
})) * scaleIcon, getThemedIcon = (0, import_helpers_tamagui.useGetThemedIcon)({
|
|
156
|
-
size: iconSize,
|
|
157
|
-
color
|
|
158
|
-
}), [themedIcon, themedIconAfter] = [icon, iconAfter].map(getThemedIcon), spaceSize = space ?? (0, import_web.getVariableValue)(iconSize) * scaleSpace, contents = noTextWrap ? [propsIn.children] : (0, import_text.wrapChildrenInText)(
|
|
160
|
+
...props
|
|
161
|
+
} = processedProps, size = propsIn.size || (propsIn.unstyled ? void 0 : "$true"), styledContext = context.useStyledContext(), finalSize = iconSize ?? size ?? styledContext?.size, iconSizeNumber = (typeof finalSize == "number" ? finalSize * 0.5 : (0, import_font_size.getFontSize)(finalSize)) * scaleIcon, getIcon = (0, import_helpers_tamagui.useGetIcon)(), [themedIcon, themedIconAfter] = [icon, iconAfter].map((icon2) => icon2 ? getIcon(icon2, {
|
|
162
|
+
size: iconSizeNumber,
|
|
163
|
+
color: styledContext?.color
|
|
164
|
+
// No marginLeft or marginRight needed - spacing is handled by the gap property in Frame's size variants
|
|
165
|
+
}) : null), wrappedChildren = (0, import_text.wrapChildrenInText)(
|
|
159
166
|
Text,
|
|
167
|
+
{ children, noTextWrap },
|
|
160
168
|
{
|
|
161
|
-
children: propsIn.children,
|
|
162
|
-
color,
|
|
163
|
-
fontFamily,
|
|
164
|
-
fontSize,
|
|
165
|
-
textProps,
|
|
166
|
-
fontWeight,
|
|
167
|
-
fontStyle,
|
|
168
|
-
letterSpacing,
|
|
169
|
-
ellipse,
|
|
170
|
-
maxFontSizeMultiplier
|
|
171
|
-
},
|
|
172
|
-
Text === ButtonText && propsActive.unstyled !== !0 ? {
|
|
173
169
|
unstyled: process.env.TAMAGUI_HEADLESS === "1",
|
|
174
|
-
size
|
|
175
|
-
}
|
|
176
|
-
)
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
// see https://github.com/tamagui/tamagui/issues/505
|
|
200
|
-
propsActive.accessibilityRole === "link" || propsActive.role === "link" ? "a" : "button"
|
|
201
|
-
)),
|
|
202
|
-
...restProps,
|
|
203
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stacks.ButtonNestingContext.Provider, { value: !0, children: inner }),
|
|
204
|
-
// forces it to be a runtime pressStyle so it passes through context text colors
|
|
205
|
-
disableClassName: !0
|
|
206
|
-
};
|
|
207
|
-
return {
|
|
208
|
-
spaceSize,
|
|
209
|
-
isNested,
|
|
210
|
-
props
|
|
211
|
-
};
|
|
212
|
-
}
|
|
170
|
+
size: finalSize ?? styledContext?.size
|
|
171
|
+
}
|
|
172
|
+
);
|
|
173
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stacks.ButtonNestingContext.Provider, { value: !0, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
174
|
+
Frame,
|
|
175
|
+
{
|
|
176
|
+
ref,
|
|
177
|
+
...props,
|
|
178
|
+
...isNested && { tag: "span" },
|
|
179
|
+
...props.circular && !propsIn.size && { size },
|
|
180
|
+
tabIndex: 0,
|
|
181
|
+
focusable: !0,
|
|
182
|
+
children: [
|
|
183
|
+
themedIcon,
|
|
184
|
+
wrappedChildren,
|
|
185
|
+
themedIconAfter
|
|
186
|
+
]
|
|
187
|
+
}
|
|
188
|
+
) });
|
|
189
|
+
}), Button = (0, import_web.withStaticProperties)(ButtonComponent, {
|
|
190
|
+
Apply: context.Provider,
|
|
191
|
+
Frame,
|
|
192
|
+
Text,
|
|
193
|
+
Icon
|
|
194
|
+
});
|
|
213
195
|
//# sourceMappingURL=Button.js.map
|