@tamagui/button 2.7.7 → 3.0.0-beta.1091.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 +97 -268
- package/dist/cjs/Button.native.cjs +122 -0
- package/dist/cjs/Button.native.js +100 -273
- package/dist/cjs/Button.native.js.map +1 -1
- package/dist/cjs/index.cjs +9 -11
- package/dist/cjs/index.native.cjs +20 -0
- package/dist/cjs/index.native.js +9 -10
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/esm/Button.mjs +88 -257
- package/dist/esm/Button.mjs.map +1 -1
- package/dist/esm/Button.native.js +91 -263
- package/dist/esm/Button.native.js.map +1 -1
- package/dist/esm/index.js +1 -2
- package/dist/esm/index.mjs +1 -2
- package/dist/esm/index.native.js +1 -2
- package/dist/jsx/Button.mjs +88 -257
- package/dist/jsx/Button.mjs.map +1 -1
- package/dist/jsx/Button.native.cjs +122 -0
- package/dist/jsx/Button.native.js +100 -273
- package/dist/jsx/Button.native.js.map +1 -1
- package/dist/jsx/index.js +1 -2
- package/dist/jsx/index.mjs +1 -2
- package/dist/jsx/index.native.cjs +20 -0
- package/dist/jsx/index.native.js +9 -10
- package/dist/jsx/index.native.js.map +1 -1
- package/package.json +14 -14
- package/src/Button.tsx +152 -309
- package/types/Button.d.ts +75 -208
- package/types/Button.d.ts.map +1 -1
- package/dist/cjs/Button.test.cjs +0 -37
- package/dist/cjs/Button.test.native.js +0 -40
- package/dist/cjs/Button.test.native.js.map +0 -1
- package/dist/esm/Button.test.mjs +0 -38
- package/dist/esm/Button.test.mjs.map +0 -1
- package/dist/esm/Button.test.native.js +0 -38
- package/dist/esm/Button.test.native.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/index.native.js.map +0 -1
- package/dist/jsx/Button.test.mjs +0 -38
- package/dist/jsx/Button.test.mjs.map +0 -1
- package/dist/jsx/Button.test.native.js +0 -40
- package/dist/jsx/Button.test.native.js.map +0 -1
- package/dist/jsx/index.js.map +0 -1
- package/dist/jsx/index.mjs.map +0 -1
- package/src/Button.test.tsx +0 -45
- package/types/Button.test.d.ts +0 -2
- package/types/Button.test.d.ts.map +0 -1
package/dist/cjs/Button.cjs
CHANGED
|
@@ -3,287 +3,116 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
5
|
var __export = (target, all) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
10
|
};
|
|
11
11
|
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
+
get: () => from[key],
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
19
|
};
|
|
20
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
-
value: true
|
|
22
|
-
}), mod);
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
21
|
var Button_exports = {};
|
|
24
22
|
__export(Button_exports, {
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
ButtonFrame: () => ButtonFrame,
|
|
24
|
+
ButtonIcon: () => ButtonIcon,
|
|
25
|
+
ButtonText: () => ButtonText,
|
|
26
|
+
useButton: () => useButton
|
|
27
27
|
});
|
|
28
28
|
module.exports = __toCommonJS(Button_exports);
|
|
29
|
-
var import_font_size = require("@tamagui/font-size");
|
|
30
|
-
var import_get_button_sized = require("@tamagui/get-button-sized");
|
|
31
29
|
var import_helpers_tamagui = require("@tamagui/helpers-tamagui");
|
|
32
30
|
var import_stacks = require("@tamagui/stacks");
|
|
33
31
|
var import_text = require("@tamagui/text");
|
|
34
32
|
var import_web = require("@tamagui/web");
|
|
35
33
|
var import_react = require("react");
|
|
36
34
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
fontWeight: void 0,
|
|
47
|
-
letterSpacing: void 0,
|
|
48
|
-
maxFontSizeMultiplier: void 0,
|
|
49
|
-
textAlign: void 0
|
|
35
|
+
const ButtonFrame = (0, import_web.styled)(import_web.View, {
|
|
36
|
+
role: "button",
|
|
37
|
+
render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button" }),
|
|
38
|
+
tabIndex: 0,
|
|
39
|
+
alignItems: "center",
|
|
40
|
+
flexDirection: "row",
|
|
41
|
+
flexWrap: "nowrap",
|
|
42
|
+
justifyContent: "center",
|
|
43
|
+
variants: { disabled: { true: { pointerEvents: "none" } } }
|
|
50
44
|
});
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
role: "button",
|
|
55
|
-
render: /* @__PURE__ */(0, import_jsx_runtime.jsx)("button", {
|
|
56
|
-
type: "button"
|
|
57
|
-
}),
|
|
58
|
-
tabIndex: 0,
|
|
59
|
-
variants: {
|
|
60
|
-
unstyled: {
|
|
61
|
-
true: {
|
|
62
|
-
// reset browser <button> defaults
|
|
63
|
-
outlineWidth: 0,
|
|
64
|
-
borderWidth: 0,
|
|
65
|
-
backgroundColor: "transparent"
|
|
66
|
-
},
|
|
67
|
-
false: {
|
|
68
|
-
size: "$true",
|
|
69
|
-
justifyContent: "center",
|
|
70
|
-
alignItems: "center",
|
|
71
|
-
flexWrap: "nowrap",
|
|
72
|
-
flexDirection: "row",
|
|
73
|
-
backgroundColor: "$background",
|
|
74
|
-
borderWidth: 1,
|
|
75
|
-
borderColor: "transparent",
|
|
76
|
-
"$platform-web": {
|
|
77
|
-
cursor: "pointer"
|
|
78
|
-
},
|
|
79
|
-
hoverStyle: {
|
|
80
|
-
backgroundColor: "$backgroundHover",
|
|
81
|
-
borderColor: "$borderColorHover"
|
|
82
|
-
},
|
|
83
|
-
pressStyle: {
|
|
84
|
-
backgroundColor: "$backgroundPress",
|
|
85
|
-
borderColor: "$borderColorHover"
|
|
86
|
-
},
|
|
87
|
-
focusVisibleStyle: {
|
|
88
|
-
outlineColor: "$outlineColor",
|
|
89
|
-
outlineStyle: "solid",
|
|
90
|
-
outlineWidth: 2
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
variant: {
|
|
95
|
-
outlined: process.env.TAMAGUI_HEADLESS === "1" ? {} : {
|
|
96
|
-
backgroundColor: "transparent",
|
|
97
|
-
borderWidth: 1,
|
|
98
|
-
borderColor: "$borderColor",
|
|
99
|
-
hoverStyle: {
|
|
100
|
-
backgroundColor: "transparent",
|
|
101
|
-
borderColor: "$borderColorHover"
|
|
102
|
-
},
|
|
103
|
-
pressStyle: {
|
|
104
|
-
backgroundColor: "transparent",
|
|
105
|
-
borderColor: "$borderColorPress"
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
},
|
|
109
|
-
circular: import_stacks.themeableVariants.circular,
|
|
110
|
-
chromeless: import_stacks.themeableVariants.chromeless,
|
|
111
|
-
size: {
|
|
112
|
-
"...size": (val, extras) => {
|
|
113
|
-
const buttonStyle = (0, import_get_button_sized.getButtonSized)(val, extras);
|
|
114
|
-
const gap = (0, import_web.getTokenValue)(val);
|
|
115
|
-
return {
|
|
116
|
-
...buttonStyle,
|
|
117
|
-
gap
|
|
118
|
-
};
|
|
119
|
-
},
|
|
120
|
-
":number": (val, extras) => {
|
|
121
|
-
const buttonStyle = (0, import_get_button_sized.getButtonSized)(val, extras);
|
|
122
|
-
const gap = val * 0.4;
|
|
123
|
-
return {
|
|
124
|
-
...buttonStyle,
|
|
125
|
-
gap
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
},
|
|
129
|
-
elevation: {
|
|
130
|
-
"...size": import_stacks.getElevation,
|
|
131
|
-
":number": import_stacks.getElevation
|
|
132
|
-
},
|
|
133
|
-
disabled: {
|
|
134
|
-
true: {
|
|
135
|
-
pointerEvents: "none",
|
|
136
|
-
// @ts-ignore
|
|
137
|
-
"aria-disabled": true
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
},
|
|
141
|
-
defaultVariants: {
|
|
142
|
-
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
143
|
-
}
|
|
45
|
+
const ButtonText = (0, import_web.styled)(import_web.Text, {
|
|
46
|
+
flexGrow: 0,
|
|
47
|
+
flexShrink: 1
|
|
144
48
|
});
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
// flexGrow 1 leads to inconsistent native style where text pushes to start of view
|
|
152
|
-
flexGrow: 0,
|
|
153
|
-
flexShrink: 1,
|
|
154
|
-
ellipsis: true,
|
|
155
|
-
color: "$color",
|
|
156
|
-
"$platform-web": {
|
|
157
|
-
cursor: "pointer"
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
},
|
|
162
|
-
defaultVariants: {
|
|
163
|
-
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
const Icon = props => {
|
|
167
|
-
const {
|
|
168
|
-
children,
|
|
169
|
-
scaleIcon = 1,
|
|
170
|
-
size
|
|
171
|
-
} = props;
|
|
172
|
-
const styledContext = context.useStyledContext();
|
|
173
|
-
if (!styledContext) {
|
|
174
|
-
throw new Error("Button.Icon must be used within a Button");
|
|
175
|
-
}
|
|
176
|
-
const sizeToken = size ?? styledContext.size;
|
|
177
|
-
const iconColorProp = styledContext.color === "unset" || typeof styledContext.color === "number" ? void 0 : styledContext.color;
|
|
178
|
-
const iconColor = (0, import_helpers_tamagui.useCurrentColor)(iconColorProp);
|
|
179
|
-
const iconSize = (typeof sizeToken === "number" ? sizeToken * 0.5 : (0, import_font_size.getFontSize)(sizeToken)) * scaleIcon;
|
|
180
|
-
return (0, import_helpers_tamagui.getIcon)(children, {
|
|
181
|
-
size: iconSize,
|
|
182
|
-
color: iconColor
|
|
183
|
-
});
|
|
49
|
+
const ButtonIcon = ({ children, color, scaleIcon = 1, size }) => {
|
|
50
|
+
const getThemedIcon = (0, import_helpers_tamagui.useGetThemedIcon)({
|
|
51
|
+
color,
|
|
52
|
+
size: size === void 0 ? void 0 : size * scaleIcon
|
|
53
|
+
});
|
|
54
|
+
return getThemedIcon(children);
|
|
184
55
|
};
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
color: contextColor,
|
|
249
|
-
ellipsis: ellipsis ?? propsIn.ellipsis ?? styledContext?.ellipsis,
|
|
250
|
-
fontFamily: fontFamily ?? propsIn.fontFamily ?? styledContext?.fontFamily,
|
|
251
|
-
fontSize: fontSize ?? propsIn.fontSize ?? styledContext?.fontSize,
|
|
252
|
-
fontStyle: fontStyle ?? propsIn.fontStyle ?? styledContext?.fontStyle,
|
|
253
|
-
fontWeight: fontWeight ?? propsIn.fontWeight ?? styledContext?.fontWeight,
|
|
254
|
-
letterSpacing: letterSpacing ?? propsIn.letterSpacing ?? styledContext?.letterSpacing,
|
|
255
|
-
maxFontSizeMultiplier: maxFontSizeMultiplier ?? propsIn.maxFontSizeMultiplier ?? styledContext?.maxFontSizeMultiplier,
|
|
256
|
-
textAlign: textAlign ?? propsIn.textAlign ?? styledContext?.textAlign
|
|
257
|
-
};
|
|
258
|
-
const buttonContext = {
|
|
259
|
-
...styledContext,
|
|
260
|
-
...textContext,
|
|
261
|
-
size: props.size ?? propsIn.size ?? styledContext?.size,
|
|
262
|
-
variant: props.variant ?? propsIn.variant ?? styledContext?.variant,
|
|
263
|
-
elevation: props.elevation ?? propsIn.elevation ?? styledContext?.elevation
|
|
264
|
-
};
|
|
265
|
-
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_stacks.ButtonNestingContext.Provider, {
|
|
266
|
-
value: true,
|
|
267
|
-
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(context.Provider, {
|
|
268
|
-
...buttonContext,
|
|
269
|
-
children: /* @__PURE__ */(0, import_jsx_runtime.jsxs)(Frame, {
|
|
270
|
-
ref,
|
|
271
|
-
...props,
|
|
272
|
-
...(isNested && {
|
|
273
|
-
render: "span"
|
|
274
|
-
}),
|
|
275
|
-
...(props.circular && !propsIn.size && {
|
|
276
|
-
size
|
|
277
|
-
}),
|
|
278
|
-
tabIndex: 0,
|
|
279
|
-
children: [themedIcon, wrappedChildren, themedIconAfter]
|
|
280
|
-
})
|
|
281
|
-
})
|
|
282
|
-
});
|
|
283
|
-
});
|
|
284
|
-
const Button = (0, import_web.withStaticProperties)(ButtonComponent, {
|
|
285
|
-
Apply: context.Provider,
|
|
286
|
-
Frame,
|
|
287
|
-
Text,
|
|
288
|
-
Icon
|
|
289
|
-
});
|
|
56
|
+
function useButton(propsIn, { Text: Text2 = ButtonText, iconColor, iconSize: iconSizeOption, textProps: textPropsOption } = {}) {
|
|
57
|
+
const isNested = (0, import_react.useContext)(import_stacks.ButtonNestingContext);
|
|
58
|
+
const [wrappedTextProps, buttonProps] = (0, import_web.splitStyleProps)(propsIn, {
|
|
59
|
+
expandShorthands: true,
|
|
60
|
+
filter: import_text.textParentProps
|
|
61
|
+
});
|
|
62
|
+
const { children, disabled, icon, iconAfter, iconSize, render, scaleIcon = 1, ...frameProps } = buttonProps;
|
|
63
|
+
const { noTextWrap, textProps, ...textStyleProps } = wrappedTextProps;
|
|
64
|
+
const resolvedIconSize = iconSize ?? iconSizeOption;
|
|
65
|
+
const getThemedIcon = (0, import_helpers_tamagui.useGetThemedIcon)({
|
|
66
|
+
color: iconColor,
|
|
67
|
+
size: resolvedIconSize === void 0 ? void 0 : resolvedIconSize * scaleIcon
|
|
68
|
+
});
|
|
69
|
+
const [themedIcon, themedIconAfter] = [icon, iconAfter].map((item) => {
|
|
70
|
+
return item ? getThemedIcon(item) : null;
|
|
71
|
+
});
|
|
72
|
+
const wrappedChildren = (0, import_text.wrapChildrenInText)(Text2, {
|
|
73
|
+
children,
|
|
74
|
+
noTextWrap,
|
|
75
|
+
textProps
|
|
76
|
+
}, {
|
|
77
|
+
...textPropsOption,
|
|
78
|
+
...textStyleProps
|
|
79
|
+
});
|
|
80
|
+
const resolvedRender = render ?? (isNested ? "span" : disabled ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
|
|
81
|
+
type: "button",
|
|
82
|
+
disabled: true
|
|
83
|
+
}) : void 0);
|
|
84
|
+
const resolvedProps = {
|
|
85
|
+
...frameProps,
|
|
86
|
+
...disabled && {
|
|
87
|
+
"aria-disabled": true,
|
|
88
|
+
disabled: true,
|
|
89
|
+
tabIndex: -1
|
|
90
|
+
},
|
|
91
|
+
...resolvedRender === void 0 ? null : { render: resolvedRender },
|
|
92
|
+
...isNested && {
|
|
93
|
+
role: "none",
|
|
94
|
+
tabIndex: -1,
|
|
95
|
+
"aria-disabled": void 0,
|
|
96
|
+
disabled: void 0,
|
|
97
|
+
onPress: void 0,
|
|
98
|
+
onPressIn: void 0,
|
|
99
|
+
onPressOut: void 0,
|
|
100
|
+
onLongPress: void 0,
|
|
101
|
+
onClick: void 0,
|
|
102
|
+
onKeyDown: void 0,
|
|
103
|
+
onKeyUp: void 0
|
|
104
|
+
},
|
|
105
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_stacks.ButtonNestingContext.Provider, {
|
|
106
|
+
value: true,
|
|
107
|
+
children: [
|
|
108
|
+
themedIcon,
|
|
109
|
+
wrappedChildren,
|
|
110
|
+
themedIconAfter
|
|
111
|
+
]
|
|
112
|
+
})
|
|
113
|
+
};
|
|
114
|
+
return {
|
|
115
|
+
isNested,
|
|
116
|
+
props: resolvedProps
|
|
117
|
+
};
|
|
118
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
|
+
var Button_exports = {};
|
|
24
|
+
__export(Button_exports, {
|
|
25
|
+
ButtonFrame: () => ButtonFrame,
|
|
26
|
+
ButtonIcon: () => ButtonIcon,
|
|
27
|
+
ButtonText: () => ButtonText,
|
|
28
|
+
useButton: () => useButton
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(Button_exports);
|
|
31
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
32
|
+
var import_helpers_tamagui = require("@tamagui/helpers-tamagui");
|
|
33
|
+
var import_stacks = require("@tamagui/stacks");
|
|
34
|
+
var import_text = require("@tamagui/text");
|
|
35
|
+
var import_web = require("@tamagui/web");
|
|
36
|
+
var import_react = require("react");
|
|
37
|
+
var ButtonFrame = (0, import_web.styled)(import_web.View, {
|
|
38
|
+
role: "button",
|
|
39
|
+
render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button" }),
|
|
40
|
+
tabIndex: 0,
|
|
41
|
+
alignItems: "center",
|
|
42
|
+
flexDirection: "row",
|
|
43
|
+
flexWrap: "nowrap",
|
|
44
|
+
justifyContent: "center",
|
|
45
|
+
variants: { disabled: { true: { pointerEvents: "none" } } }
|
|
46
|
+
});
|
|
47
|
+
var ButtonText = (0, import_web.styled)(import_web.Text, {
|
|
48
|
+
flexGrow: 0,
|
|
49
|
+
flexShrink: 1
|
|
50
|
+
});
|
|
51
|
+
var ButtonIcon = function(param) {
|
|
52
|
+
var { children, color, scaleIcon = 1, size } = param;
|
|
53
|
+
var getThemedIcon = (0, import_helpers_tamagui.useGetThemedIcon)({
|
|
54
|
+
color,
|
|
55
|
+
size: size === void 0 ? void 0 : size * scaleIcon
|
|
56
|
+
});
|
|
57
|
+
return getThemedIcon(children);
|
|
58
|
+
};
|
|
59
|
+
function useButton(propsIn) {
|
|
60
|
+
var { Text: _$Text = ButtonText, iconColor, iconSize: iconSizeOption, textProps: textPropsOption } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
61
|
+
var isNested = (0, import_react.useContext)(import_stacks.ButtonNestingContext);
|
|
62
|
+
var [wrappedTextProps, buttonProps] = (0, import_web.splitStyleProps)(propsIn, {
|
|
63
|
+
expandShorthands: true,
|
|
64
|
+
filter: import_text.textParentProps
|
|
65
|
+
});
|
|
66
|
+
var { children, disabled, icon, iconAfter, iconSize, render, scaleIcon = 1, ...frameProps } = buttonProps;
|
|
67
|
+
var { noTextWrap, textProps, ...textStyleProps } = wrappedTextProps;
|
|
68
|
+
var resolvedIconSize = iconSize !== null && iconSize !== void 0 ? iconSize : iconSizeOption;
|
|
69
|
+
var getThemedIcon = (0, import_helpers_tamagui.useGetThemedIcon)({
|
|
70
|
+
color: iconColor,
|
|
71
|
+
size: resolvedIconSize === void 0 ? void 0 : resolvedIconSize * scaleIcon
|
|
72
|
+
});
|
|
73
|
+
var [themedIcon, themedIconAfter] = [icon, iconAfter].map(function(item) {
|
|
74
|
+
return item ? getThemedIcon(item) : null;
|
|
75
|
+
});
|
|
76
|
+
var wrappedChildren = (0, import_text.wrapChildrenInText)(_$Text, {
|
|
77
|
+
children,
|
|
78
|
+
noTextWrap,
|
|
79
|
+
textProps
|
|
80
|
+
}, {
|
|
81
|
+
...textPropsOption,
|
|
82
|
+
...textStyleProps
|
|
83
|
+
});
|
|
84
|
+
var resolvedRender = render !== null && render !== void 0 ? render : isNested ? "span" : disabled ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
|
|
85
|
+
type: "button",
|
|
86
|
+
disabled: true
|
|
87
|
+
}) : void 0;
|
|
88
|
+
var resolvedProps = {
|
|
89
|
+
...frameProps,
|
|
90
|
+
...disabled && {
|
|
91
|
+
"aria-disabled": true,
|
|
92
|
+
disabled: true,
|
|
93
|
+
tabIndex: -1
|
|
94
|
+
},
|
|
95
|
+
...resolvedRender === void 0 ? null : { render: resolvedRender },
|
|
96
|
+
...isNested && {
|
|
97
|
+
role: "none",
|
|
98
|
+
tabIndex: -1,
|
|
99
|
+
"aria-disabled": void 0,
|
|
100
|
+
disabled: void 0,
|
|
101
|
+
onPress: void 0,
|
|
102
|
+
onPressIn: void 0,
|
|
103
|
+
onPressOut: void 0,
|
|
104
|
+
onLongPress: void 0,
|
|
105
|
+
onClick: void 0,
|
|
106
|
+
onKeyDown: void 0,
|
|
107
|
+
onKeyUp: void 0
|
|
108
|
+
},
|
|
109
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_stacks.ButtonNestingContext.Provider, {
|
|
110
|
+
value: true,
|
|
111
|
+
children: [
|
|
112
|
+
themedIcon,
|
|
113
|
+
wrappedChildren,
|
|
114
|
+
themedIconAfter
|
|
115
|
+
]
|
|
116
|
+
})
|
|
117
|
+
};
|
|
118
|
+
return {
|
|
119
|
+
isNested,
|
|
120
|
+
props: resolvedProps
|
|
121
|
+
};
|
|
122
|
+
}
|