@tamagui/button 2.0.0-rc.4 → 2.0.0-rc.40
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 +195 -186
- package/dist/cjs/Button.native.js +195 -188
- package/dist/cjs/Button.native.js.map +1 -1
- package/dist/cjs/Button.test.cjs +33 -5
- package/dist/cjs/Button.test.native.js +34 -6
- package/dist/cjs/Button.test.native.js.map +1 -1
- package/dist/cjs/index.cjs +7 -5
- package/dist/cjs/index.native.js +7 -5
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/v1/Button.cjs +215 -212
- package/dist/cjs/v1/Button.native.js +217 -215
- package/dist/cjs/v1/Button.native.js.map +1 -1
- package/dist/cjs/v1/Button.test.cjs +5 -5
- package/dist/cjs/v1/Button.test.native.js +6 -6
- package/dist/cjs/v1/Button.test.native.js.map +1 -1
- package/dist/cjs/v1/index.cjs +7 -5
- package/dist/cjs/v1/index.native.js +7 -5
- package/dist/cjs/v1/index.native.js.map +1 -1
- package/dist/esm/Button.mjs +175 -168
- package/dist/esm/Button.mjs.map +1 -1
- package/dist/esm/Button.native.js +175 -170
- package/dist/esm/Button.native.js.map +1 -1
- package/dist/esm/Button.test.mjs +30 -2
- package/dist/esm/Button.test.mjs.map +1 -1
- package/dist/esm/Button.test.native.js +30 -2
- package/dist/esm/Button.test.native.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -6
- package/dist/esm/v1/Button.mjs +193 -192
- package/dist/esm/v1/Button.mjs.map +1 -1
- package/dist/esm/v1/Button.native.js +194 -194
- package/dist/esm/v1/Button.native.js.map +1 -1
- package/dist/esm/v1/Button.test.mjs +2 -2
- package/dist/esm/v1/Button.test.mjs.map +1 -1
- package/dist/esm/v1/Button.test.native.js +2 -2
- package/dist/esm/v1/Button.test.native.js.map +1 -1
- package/dist/jsx/Button.mjs +175 -168
- package/dist/jsx/Button.mjs.map +1 -1
- package/dist/jsx/Button.native.js +195 -188
- package/dist/jsx/Button.native.js.map +1 -1
- package/dist/jsx/Button.test.mjs +30 -2
- package/dist/jsx/Button.test.mjs.map +1 -1
- package/dist/jsx/Button.test.native.js +34 -6
- package/dist/jsx/Button.test.native.js.map +1 -1
- package/dist/jsx/index.js +1 -1
- package/dist/jsx/index.js.map +1 -6
- package/dist/jsx/index.native.js +7 -5
- package/dist/jsx/v1/Button.mjs +193 -192
- package/dist/jsx/v1/Button.mjs.map +1 -1
- package/dist/jsx/v1/Button.native.js +217 -215
- package/dist/jsx/v1/Button.native.js.map +1 -1
- package/dist/jsx/v1/Button.test.mjs +2 -2
- package/dist/jsx/v1/Button.test.mjs.map +1 -1
- package/dist/jsx/v1/Button.test.native.js +6 -6
- package/dist/jsx/v1/Button.test.native.js.map +1 -1
- package/dist/jsx/v1/index.native.js +7 -5
- package/package.json +15 -18
- package/src/Button.test.tsx +24 -0
- package/src/Button.tsx +16 -3
- package/types/Button.d.ts +9 -0
- package/types/Button.d.ts.map +1 -1
- package/dist/cjs/Button.js +0 -176
- package/dist/cjs/Button.js.map +0 -6
- package/dist/cjs/Button.test.js +0 -8
- package/dist/cjs/Button.test.js.map +0 -6
- package/dist/cjs/index.js +0 -15
- package/dist/cjs/index.js.map +0 -6
- package/dist/cjs/v1/Button.js +0 -208
- package/dist/cjs/v1/Button.js.map +0 -6
- package/dist/cjs/v1/Button.test.js +0 -8
- package/dist/cjs/v1/Button.test.js.map +0 -6
- package/dist/cjs/v1/index.js +0 -15
- package/dist/cjs/v1/index.js.map +0 -6
- package/dist/esm/Button.js +0 -174
- package/dist/esm/Button.js.map +0 -6
- package/dist/esm/Button.test.js +0 -10
- package/dist/esm/Button.test.js.map +0 -6
- package/dist/esm/v1/Button.js +0 -201
- package/dist/esm/v1/Button.js.map +0 -6
- package/dist/esm/v1/Button.test.js +0 -10
- package/dist/esm/v1/Button.test.js.map +0 -6
- package/dist/esm/v1/index.js +0 -2
- package/dist/esm/v1/index.js.map +0 -6
- package/dist/jsx/Button.js +0 -174
- package/dist/jsx/Button.js.map +0 -6
- package/dist/jsx/Button.test.js +0 -10
- package/dist/jsx/Button.test.js.map +0 -6
- package/dist/jsx/v1/Button.js +0 -201
- package/dist/jsx/v1/Button.js.map +0 -6
- package/dist/jsx/v1/Button.test.js +0 -10
- package/dist/jsx/v1/Button.test.js.map +0 -6
- package/dist/jsx/v1/index.js +0 -2
- package/dist/jsx/v1/index.js.map +0 -6
package/dist/cjs/Button.cjs
CHANGED
|
@@ -3,20 +3,22 @@ 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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
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, {
|
|
13
14
|
get: () => from[key],
|
|
14
15
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
16
|
});
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
18
20
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
-
value:
|
|
21
|
+
value: true
|
|
20
22
|
}), mod);
|
|
21
23
|
var Button_exports = {};
|
|
22
24
|
__export(Button_exports, {
|
|
@@ -24,193 +26,200 @@ __export(Button_exports, {
|
|
|
24
26
|
ButtonContext: () => ButtonContext
|
|
25
27
|
});
|
|
26
28
|
module.exports = __toCommonJS(Button_exports);
|
|
27
|
-
var import_font_size = require("@tamagui/font-size")
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
35
37
|
const context = (0, import_web.createStyledContext)({
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
size: void 0,
|
|
39
|
+
variant: void 0,
|
|
40
|
+
color: void 0,
|
|
41
|
+
elevation: void 0
|
|
42
|
+
});
|
|
43
|
+
const Frame = (0, import_web.styled)(import_web.View, {
|
|
44
|
+
context,
|
|
45
|
+
name: "Button",
|
|
46
|
+
role: "button",
|
|
47
|
+
render: /* @__PURE__ */(0, import_jsx_runtime.jsx)("button", {
|
|
48
|
+
type: "button"
|
|
40
49
|
}),
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
borderColor: "
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
backgroundColor: "$backgroundPress",
|
|
67
|
-
borderColor: "$borderColorHover"
|
|
68
|
-
},
|
|
69
|
-
focusVisibleStyle: {
|
|
70
|
-
outlineColor: "$outlineColor",
|
|
71
|
-
outlineStyle: "solid",
|
|
72
|
-
outlineWidth: 2
|
|
73
|
-
}
|
|
50
|
+
tabIndex: 0,
|
|
51
|
+
variants: {
|
|
52
|
+
unstyled: {
|
|
53
|
+
false: {
|
|
54
|
+
size: "$true",
|
|
55
|
+
justifyContent: "center",
|
|
56
|
+
alignItems: "center",
|
|
57
|
+
flexWrap: "nowrap",
|
|
58
|
+
flexDirection: "row",
|
|
59
|
+
cursor: "pointer",
|
|
60
|
+
backgroundColor: "$background",
|
|
61
|
+
borderWidth: 1,
|
|
62
|
+
borderColor: "transparent",
|
|
63
|
+
hoverStyle: {
|
|
64
|
+
backgroundColor: "$backgroundHover",
|
|
65
|
+
borderColor: "$borderColorHover"
|
|
66
|
+
},
|
|
67
|
+
pressStyle: {
|
|
68
|
+
backgroundColor: "$backgroundPress",
|
|
69
|
+
borderColor: "$borderColorHover"
|
|
70
|
+
},
|
|
71
|
+
focusVisibleStyle: {
|
|
72
|
+
outlineColor: "$outlineColor",
|
|
73
|
+
outlineStyle: "solid",
|
|
74
|
+
outlineWidth: 2
|
|
74
75
|
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
variant: {
|
|
79
|
+
outlined: process.env.TAMAGUI_HEADLESS === "1" ? {} : {
|
|
80
|
+
backgroundColor: "transparent",
|
|
81
|
+
borderWidth: 1,
|
|
82
|
+
borderColor: "$borderColor",
|
|
83
|
+
hoverStyle: {
|
|
78
84
|
backgroundColor: "transparent",
|
|
79
|
-
|
|
80
|
-
borderColor: "$borderColor",
|
|
81
|
-
hoverStyle: {
|
|
82
|
-
backgroundColor: "transparent",
|
|
83
|
-
borderColor: "$borderColorHover"
|
|
84
|
-
},
|
|
85
|
-
pressStyle: {
|
|
86
|
-
backgroundColor: "transparent",
|
|
87
|
-
borderColor: "$borderColorPress"
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
|
-
circular: import_stacks.themeableVariants.circular,
|
|
92
|
-
chromeless: import_stacks.themeableVariants.chromeless,
|
|
93
|
-
size: {
|
|
94
|
-
"...size": (val, extras) => {
|
|
95
|
-
const buttonStyle = (0, import_get_button_sized.getButtonSized)(val, extras),
|
|
96
|
-
gap = (0, import_web.getTokenValue)(val);
|
|
97
|
-
return {
|
|
98
|
-
...buttonStyle,
|
|
99
|
-
gap
|
|
100
|
-
};
|
|
85
|
+
borderColor: "$borderColorHover"
|
|
101
86
|
},
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
return {
|
|
106
|
-
...buttonStyle,
|
|
107
|
-
gap
|
|
108
|
-
};
|
|
87
|
+
pressStyle: {
|
|
88
|
+
backgroundColor: "transparent",
|
|
89
|
+
borderColor: "$borderColorPress"
|
|
109
90
|
}
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
circular: import_stacks.themeableVariants.circular,
|
|
94
|
+
chromeless: import_stacks.themeableVariants.chromeless,
|
|
95
|
+
size: {
|
|
96
|
+
"...size": (val, extras) => {
|
|
97
|
+
const buttonStyle = (0, import_get_button_sized.getButtonSized)(val, extras);
|
|
98
|
+
const gap = (0, import_web.getTokenValue)(val);
|
|
99
|
+
return {
|
|
100
|
+
...buttonStyle,
|
|
101
|
+
gap
|
|
102
|
+
};
|
|
110
103
|
},
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
// @ts-ignore
|
|
119
|
-
"aria-disabled": !0
|
|
120
|
-
}
|
|
104
|
+
":number": (val, extras) => {
|
|
105
|
+
const buttonStyle = (0, import_get_button_sized.getButtonSized)(val, extras);
|
|
106
|
+
const gap = val * 0.4;
|
|
107
|
+
return {
|
|
108
|
+
...buttonStyle,
|
|
109
|
+
gap
|
|
110
|
+
};
|
|
121
111
|
}
|
|
122
112
|
},
|
|
123
|
-
|
|
124
|
-
|
|
113
|
+
elevation: {
|
|
114
|
+
"...size": import_stacks.getElevation,
|
|
115
|
+
":number": import_stacks.getElevation
|
|
116
|
+
},
|
|
117
|
+
disabled: {
|
|
118
|
+
true: {
|
|
119
|
+
pointerEvents: "none",
|
|
120
|
+
// @ts-ignore
|
|
121
|
+
"aria-disabled": true
|
|
122
|
+
}
|
|
125
123
|
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
124
|
+
},
|
|
125
|
+
defaultVariants: {
|
|
126
|
+
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
const Text = (0, import_web.styled)(import_text.SizableText, {
|
|
130
|
+
context,
|
|
131
|
+
variants: {
|
|
132
|
+
unstyled: {
|
|
133
|
+
false: {
|
|
134
|
+
userSelect: "none",
|
|
135
|
+
cursor: "pointer",
|
|
136
|
+
// flexGrow 1 leads to inconsistent native style where text pushes to start of view
|
|
137
|
+
flexGrow: 0,
|
|
138
|
+
flexShrink: 1,
|
|
139
|
+
ellipsis: true,
|
|
140
|
+
color: "$color"
|
|
140
141
|
}
|
|
141
|
-
},
|
|
142
|
-
defaultVariants: {
|
|
143
|
-
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
144
142
|
}
|
|
145
|
-
}),
|
|
146
|
-
Icon = props => {
|
|
147
|
-
const {
|
|
148
|
-
children,
|
|
149
|
-
scaleIcon = 1,
|
|
150
|
-
size
|
|
151
|
-
} = props,
|
|
152
|
-
styledContext = context.useStyledContext();
|
|
153
|
-
if (!styledContext) throw new Error("Button.Icon must be used within a Button");
|
|
154
|
-
const sizeToken = size ?? styledContext.size,
|
|
155
|
-
iconSize = (typeof sizeToken == "number" ? sizeToken * 0.5 : (0, import_font_size.getFontSize)(sizeToken)) * scaleIcon;
|
|
156
|
-
return (0, import_helpers_tamagui.getIcon)(children, {
|
|
157
|
-
size: iconSize,
|
|
158
|
-
color: styledContext.color
|
|
159
|
-
});
|
|
160
143
|
},
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
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
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
144
|
+
defaultVariants: {
|
|
145
|
+
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
const Icon = props => {
|
|
149
|
+
const {
|
|
150
|
+
children,
|
|
151
|
+
scaleIcon = 1,
|
|
152
|
+
size
|
|
153
|
+
} = props;
|
|
154
|
+
const styledContext = context.useStyledContext();
|
|
155
|
+
if (!styledContext) {
|
|
156
|
+
throw new Error("Button.Icon must be used within a Button");
|
|
157
|
+
}
|
|
158
|
+
const sizeToken = size ?? styledContext.size;
|
|
159
|
+
const iconColor = (0, import_helpers_tamagui.useCurrentColor)(styledContext.color);
|
|
160
|
+
const iconSize = (typeof sizeToken === "number" ? sizeToken * 0.5 : (0, import_font_size.getFontSize)(sizeToken)) * scaleIcon;
|
|
161
|
+
return (0, import_helpers_tamagui.getIcon)(children, {
|
|
162
|
+
size: iconSize,
|
|
163
|
+
color: iconColor
|
|
164
|
+
});
|
|
165
|
+
};
|
|
166
|
+
const ButtonContext = (0, import_web.createStyledContext)({
|
|
167
|
+
size: void 0,
|
|
168
|
+
variant: void 0,
|
|
169
|
+
color: void 0
|
|
170
|
+
});
|
|
171
|
+
const ButtonComponent = Frame.styleable((propsIn, ref) => {
|
|
172
|
+
const isNested = (0, import_react.useContext)(import_stacks.ButtonNestingContext);
|
|
173
|
+
const processedProps = (0, import_web.useProps)(propsIn, {
|
|
174
|
+
noNormalize: true,
|
|
175
|
+
noExpand: true
|
|
176
|
+
});
|
|
177
|
+
const {
|
|
178
|
+
children,
|
|
179
|
+
iconSize,
|
|
180
|
+
icon,
|
|
181
|
+
iconAfter,
|
|
182
|
+
scaleIcon = 1,
|
|
183
|
+
...props
|
|
184
|
+
} = processedProps;
|
|
185
|
+
const size = propsIn.size || (propsIn.unstyled ? void 0 : "$true");
|
|
186
|
+
const styledContext = context.useStyledContext();
|
|
187
|
+
const iconColor = (0, import_helpers_tamagui.useCurrentColor)(styledContext?.color);
|
|
188
|
+
const finalSize = iconSize ?? size ?? styledContext?.size;
|
|
189
|
+
const iconSizeNumber = (typeof finalSize === "number" ? finalSize * 0.5 : (0, import_font_size.getFontSize)(finalSize)) * scaleIcon;
|
|
190
|
+
const [themedIcon, themedIconAfter] = [icon, iconAfter].map(icon2 => {
|
|
191
|
+
if (!icon2) return null;
|
|
192
|
+
return (0, import_helpers_tamagui.getIcon)(icon2, {
|
|
193
|
+
size: iconSizeNumber,
|
|
194
|
+
color: iconColor
|
|
195
|
+
// No marginLeft or marginRight needed - spacing is handled by the gap property in Frame's size variants
|
|
209
196
|
});
|
|
210
|
-
})
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
});
|
|
197
|
+
});
|
|
198
|
+
const wrappedChildren = (0, import_text.wrapChildrenInText)(Text, {
|
|
199
|
+
children
|
|
200
|
+
}, {
|
|
201
|
+
unstyled: process.env.TAMAGUI_HEADLESS === "1",
|
|
202
|
+
size: finalSize ?? styledContext?.size
|
|
203
|
+
});
|
|
204
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_stacks.ButtonNestingContext.Provider, {
|
|
205
|
+
value: true,
|
|
206
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsxs)(Frame, {
|
|
207
|
+
ref,
|
|
208
|
+
...props,
|
|
209
|
+
...(isNested && {
|
|
210
|
+
render: "span"
|
|
211
|
+
}),
|
|
212
|
+
...(props.circular && !propsIn.size && {
|
|
213
|
+
size
|
|
214
|
+
}),
|
|
215
|
+
tabIndex: 0,
|
|
216
|
+
children: [themedIcon, wrappedChildren, themedIconAfter]
|
|
217
|
+
})
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
const Button = (0, import_web.withStaticProperties)(ButtonComponent, {
|
|
221
|
+
Apply: context.Provider,
|
|
222
|
+
Frame,
|
|
223
|
+
Text,
|
|
224
|
+
Icon
|
|
225
|
+
});
|