@tamagui/button 2.7.7 → 3.0.0-beta.643.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 +180 -266
- package/dist/cjs/Button.native.cjs +224 -0
- package/dist/cjs/Button.native.js +200 -271
- package/dist/cjs/Button.native.js.map +1 -1
- package/dist/cjs/index.cjs +10 -11
- package/dist/cjs/index.native.cjs +21 -0
- package/dist/cjs/index.native.js +10 -10
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/esm/Button.mjs +168 -255
- package/dist/esm/Button.mjs.map +1 -1
- package/dist/esm/Button.native.js +188 -261
- 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 +168 -255
- package/dist/jsx/Button.mjs.map +1 -1
- package/dist/jsx/Button.native.cjs +224 -0
- package/dist/jsx/Button.native.js +200 -271
- 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 +21 -0
- package/dist/jsx/index.native.js +10 -10
- package/dist/jsx/index.native.js.map +1 -1
- package/package.json +11 -12
- package/src/Button.tsx +222 -280
- package/types/Button.d.ts +218 -114
- 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
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all) __defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
|
+
get: () => from[key],
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var Button_exports = {};
|
|
25
|
+
__export(Button_exports, {
|
|
26
|
+
Button: () => Button2,
|
|
27
|
+
ButtonContext: () => ButtonContext,
|
|
28
|
+
ButtonFrame: () => ButtonFrame,
|
|
29
|
+
ButtonIcon: () => ButtonIcon,
|
|
30
|
+
ButtonText: () => ButtonText,
|
|
31
|
+
useButton: () => useButton
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(Button_exports);
|
|
34
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
35
|
+
var import_helpers_tamagui = require("@tamagui/helpers-tamagui");
|
|
36
|
+
var import_stacks = require("@tamagui/stacks");
|
|
37
|
+
var import_text = require("@tamagui/text");
|
|
38
|
+
var import_web = require("@tamagui/web");
|
|
39
|
+
var import_react = require("react");
|
|
40
|
+
var buttonContextKeys = [
|
|
41
|
+
"color",
|
|
42
|
+
"ellipsis",
|
|
43
|
+
"fontFamily",
|
|
44
|
+
"fontSize",
|
|
45
|
+
"fontStyle",
|
|
46
|
+
"fontWeight",
|
|
47
|
+
"letterSpacing",
|
|
48
|
+
"maxFontSizeMultiplier",
|
|
49
|
+
"textAlign"
|
|
50
|
+
];
|
|
51
|
+
var ButtonContext = (0, import_web.createStyledContext)({
|
|
52
|
+
color: void 0,
|
|
53
|
+
ellipsis: void 0,
|
|
54
|
+
fontFamily: void 0,
|
|
55
|
+
fontSize: void 0,
|
|
56
|
+
fontStyle: void 0,
|
|
57
|
+
fontWeight: void 0,
|
|
58
|
+
letterSpacing: void 0,
|
|
59
|
+
maxFontSizeMultiplier: void 0,
|
|
60
|
+
textAlign: void 0
|
|
61
|
+
}, { keys: buttonContextKeys });
|
|
62
|
+
var ButtonFrame = (0, import_web.styled)(import_web.View, {
|
|
63
|
+
context: ButtonContext,
|
|
64
|
+
displayName: "ButtonFrame",
|
|
65
|
+
role: "button",
|
|
66
|
+
render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button" }),
|
|
67
|
+
tabIndex: 0,
|
|
68
|
+
alignItems: "center",
|
|
69
|
+
flexDirection: "row",
|
|
70
|
+
flexWrap: "nowrap",
|
|
71
|
+
justifyContent: "center",
|
|
72
|
+
variants: { disabled: { true: { pointerEvents: "none" } } }
|
|
73
|
+
});
|
|
74
|
+
var ButtonText = (0, import_web.styled)(import_web.Text, {
|
|
75
|
+
context: ButtonContext,
|
|
76
|
+
displayName: "ButtonText",
|
|
77
|
+
flexGrow: 0,
|
|
78
|
+
flexShrink: 1
|
|
79
|
+
});
|
|
80
|
+
var ButtonIcon = function(param) {
|
|
81
|
+
var { children, color, scaleIcon = 1, size } = param;
|
|
82
|
+
var styledContext = ButtonContext.useStyledContext();
|
|
83
|
+
var iconColor = color !== null && color !== void 0 ? color : styledContext === null || styledContext === void 0 ? void 0 : styledContext.color;
|
|
84
|
+
var getThemedIcon = (0, import_helpers_tamagui.useGetThemedIcon)({
|
|
85
|
+
color: iconColor === "unset" || typeof iconColor === "number" ? void 0 : iconColor,
|
|
86
|
+
size: size === void 0 ? void 0 : size * scaleIcon
|
|
87
|
+
});
|
|
88
|
+
return getThemedIcon(children);
|
|
89
|
+
};
|
|
90
|
+
var buttonInternalPropNames = [
|
|
91
|
+
"children",
|
|
92
|
+
"color",
|
|
93
|
+
"disabled",
|
|
94
|
+
"ellipsis",
|
|
95
|
+
"fontFamily",
|
|
96
|
+
"fontSize",
|
|
97
|
+
"fontStyle",
|
|
98
|
+
"fontWeight",
|
|
99
|
+
"icon",
|
|
100
|
+
"iconAfter",
|
|
101
|
+
"iconSize",
|
|
102
|
+
"letterSpacing",
|
|
103
|
+
"maxFontSizeMultiplier",
|
|
104
|
+
"noTextWrap",
|
|
105
|
+
"render",
|
|
106
|
+
"scaleIcon",
|
|
107
|
+
"textAlign",
|
|
108
|
+
"textProps"
|
|
109
|
+
];
|
|
110
|
+
function useButton(propsIn) {
|
|
111
|
+
var { Text: _$Text = ButtonText, iconColor: iconColorOption, iconSize: iconSizeOption, textProps: textPropsOption } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
112
|
+
var isNested = (0, import_react.useContext)(import_stacks.ButtonNestingContext);
|
|
113
|
+
var styledContext = ButtonContext.useStyledContext();
|
|
114
|
+
var processedProps = (0, import_web.useProps)(propsIn, {
|
|
115
|
+
noNormalize: true,
|
|
116
|
+
noExpand: true
|
|
117
|
+
});
|
|
118
|
+
var { children, color, disabled, ellipsis, fontFamily, fontSize, fontStyle, fontWeight, icon, iconAfter, iconSize, letterSpacing, maxFontSizeMultiplier, noTextWrap, render, scaleIcon = 1, textAlign, textProps } = processedProps;
|
|
119
|
+
var frameProps = { ...propsIn };
|
|
120
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
121
|
+
try {
|
|
122
|
+
for (var _iterator = buttonInternalPropNames[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
123
|
+
var key = _step.value;
|
|
124
|
+
delete frameProps[key];
|
|
125
|
+
}
|
|
126
|
+
} catch (err) {
|
|
127
|
+
_didIteratorError = true;
|
|
128
|
+
_iteratorError = err;
|
|
129
|
+
} finally {
|
|
130
|
+
try {
|
|
131
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
132
|
+
_iterator.return();
|
|
133
|
+
}
|
|
134
|
+
} finally {
|
|
135
|
+
if (_didIteratorError) {
|
|
136
|
+
throw _iteratorError;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
var contextColor = color !== null && color !== void 0 ? color : styledContext === null || styledContext === void 0 ? void 0 : styledContext.color;
|
|
141
|
+
var iconColor = iconColorOption !== null && iconColorOption !== void 0 ? iconColorOption : contextColor;
|
|
142
|
+
var resolvedIconSize = iconSize !== null && iconSize !== void 0 ? iconSize : iconSizeOption;
|
|
143
|
+
var getThemedIcon = (0, import_helpers_tamagui.useGetThemedIcon)({
|
|
144
|
+
color: iconColor === "unset" || typeof iconColor === "number" ? void 0 : iconColor,
|
|
145
|
+
size: resolvedIconSize === void 0 ? void 0 : resolvedIconSize * scaleIcon
|
|
146
|
+
});
|
|
147
|
+
var [themedIcon, themedIconAfter] = [icon, iconAfter].map(function(item) {
|
|
148
|
+
return item ? getThemedIcon(item) : null;
|
|
149
|
+
});
|
|
150
|
+
var textContext = {
|
|
151
|
+
color: contextColor,
|
|
152
|
+
ellipsis: ellipsis !== null && ellipsis !== void 0 ? ellipsis : styledContext === null || styledContext === void 0 ? void 0 : styledContext.ellipsis,
|
|
153
|
+
fontFamily: fontFamily !== null && fontFamily !== void 0 ? fontFamily : styledContext === null || styledContext === void 0 ? void 0 : styledContext.fontFamily,
|
|
154
|
+
fontSize: fontSize !== null && fontSize !== void 0 ? fontSize : styledContext === null || styledContext === void 0 ? void 0 : styledContext.fontSize,
|
|
155
|
+
fontStyle: fontStyle !== null && fontStyle !== void 0 ? fontStyle : styledContext === null || styledContext === void 0 ? void 0 : styledContext.fontStyle,
|
|
156
|
+
fontWeight: fontWeight !== null && fontWeight !== void 0 ? fontWeight : styledContext === null || styledContext === void 0 ? void 0 : styledContext.fontWeight,
|
|
157
|
+
letterSpacing: letterSpacing !== null && letterSpacing !== void 0 ? letterSpacing : styledContext === null || styledContext === void 0 ? void 0 : styledContext.letterSpacing,
|
|
158
|
+
maxFontSizeMultiplier: maxFontSizeMultiplier !== null && maxFontSizeMultiplier !== void 0 ? maxFontSizeMultiplier : styledContext === null || styledContext === void 0 ? void 0 : styledContext.maxFontSizeMultiplier,
|
|
159
|
+
textAlign: textAlign !== null && textAlign !== void 0 ? textAlign : styledContext === null || styledContext === void 0 ? void 0 : styledContext.textAlign
|
|
160
|
+
};
|
|
161
|
+
var wrappedChildren = (0, import_text.wrapChildrenInText)(_$Text, {
|
|
162
|
+
children,
|
|
163
|
+
...textContext,
|
|
164
|
+
noTextWrap,
|
|
165
|
+
textProps
|
|
166
|
+
}, {
|
|
167
|
+
...textPropsOption,
|
|
168
|
+
...processedProps.size === void 0 ? null : { size: processedProps.size }
|
|
169
|
+
});
|
|
170
|
+
var resolvedRender = render !== null && render !== void 0 ? render : isNested ? "span" : processedProps.accessibilityRole === "link" || processedProps.role === "link" ? "a" : disabled ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
|
|
171
|
+
type: "button",
|
|
172
|
+
disabled: true
|
|
173
|
+
}) : void 0;
|
|
174
|
+
var props = {
|
|
175
|
+
...frameProps,
|
|
176
|
+
...disabled && {
|
|
177
|
+
"aria-disabled": true,
|
|
178
|
+
disabled: true,
|
|
179
|
+
tabIndex: -1
|
|
180
|
+
},
|
|
181
|
+
...resolvedRender === void 0 ? null : { render: resolvedRender },
|
|
182
|
+
...isNested && {
|
|
183
|
+
role: "none",
|
|
184
|
+
tabIndex: -1,
|
|
185
|
+
"aria-disabled": void 0,
|
|
186
|
+
disabled: void 0,
|
|
187
|
+
onPress: void 0,
|
|
188
|
+
onPressIn: void 0,
|
|
189
|
+
onPressOut: void 0,
|
|
190
|
+
onLongPress: void 0,
|
|
191
|
+
onClick: void 0,
|
|
192
|
+
onKeyDown: void 0,
|
|
193
|
+
onKeyUp: void 0
|
|
194
|
+
},
|
|
195
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stacks.ButtonNestingContext.Provider, {
|
|
196
|
+
value: true,
|
|
197
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(ButtonContext.Provider, {
|
|
198
|
+
...textContext,
|
|
199
|
+
children: [
|
|
200
|
+
themedIcon,
|
|
201
|
+
wrappedChildren,
|
|
202
|
+
themedIconAfter
|
|
203
|
+
]
|
|
204
|
+
})
|
|
205
|
+
})
|
|
206
|
+
};
|
|
207
|
+
return {
|
|
208
|
+
isNested,
|
|
209
|
+
props
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
var ButtonComponent = (0, import_web.createStyledHOC)(ButtonFrame, function Button(props, ref) {
|
|
213
|
+
var { props: buttonProps } = useButton(props);
|
|
214
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ButtonFrame, {
|
|
215
|
+
ref,
|
|
216
|
+
...buttonProps
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
var Button2 = (0, import_web.withStaticProperties)(ButtonComponent, {
|
|
220
|
+
Apply: ButtonContext.Provider,
|
|
221
|
+
Frame: ButtonFrame,
|
|
222
|
+
Icon: ButtonIcon,
|
|
223
|
+
Text: ButtonText
|
|
224
|
+
});
|