@tamagui/button 1.79.7 → 1.79.8

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.
@@ -0,0 +1,29 @@
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 base_exports = {};
20
+ __export(base_exports, {
21
+ Button: () => import_Button.Button
22
+ });
23
+ module.exports = __toCommonJS(base_exports);
24
+ var import_Button = require("./Button");
25
+ // Annotate the CommonJS export names for ESM import in node:
26
+ 0 && (module.exports = {
27
+ Button
28
+ });
29
+ //# sourceMappingURL=base.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/base.ts"],
4
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAAuB;",
5
+ "names": []
6
+ }
@@ -0,0 +1,252 @@
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 themed_exports = {};
20
+ __export(themed_exports, {
21
+ Button: () => Button,
22
+ ButtonFrame: () => ButtonFrame,
23
+ ButtonText: () => ButtonTextFrame,
24
+ buttonStaticConfig: () => buttonStaticConfig,
25
+ createButtonScope: () => createButtonScope,
26
+ useButton: () => useButton
27
+ });
28
+ module.exports = __toCommonJS(themed_exports);
29
+ var import_jsx_runtime = require("react/jsx-runtime");
30
+ var import_create_context = require("@tamagui/create-context");
31
+ var import_font_size = require("@tamagui/font-size");
32
+ var import_get_button_sized = require("@tamagui/get-button-sized");
33
+ var import_helpers_tamagui = require("@tamagui/helpers-tamagui");
34
+ var import_text = require("@tamagui/text");
35
+ var import_web = require("@tamagui/web");
36
+ var import_react = require("react");
37
+ var import_Button = require("./Button");
38
+ const ButtonFrame = (0, import_web.styled)(import_Button.Button, {
39
+ name: import_Button.BUTTON_NAME,
40
+ variants: {
41
+ unstyled: {
42
+ false: {
43
+ size: "$true",
44
+ justifyContent: "center",
45
+ alignItems: "center",
46
+ flexWrap: "nowrap",
47
+ flexDirection: "row",
48
+ cursor: "pointer",
49
+ hoverTheme: true,
50
+ pressTheme: true,
51
+ backgrounded: true,
52
+ borderWidth: 1,
53
+ borderColor: "$borderColor",
54
+ pressStyle: {
55
+ borderColor: "$borderColorPress"
56
+ },
57
+ focusStyle: {
58
+ outlineColor: "$borderColorFocus",
59
+ outlineStyle: "solid",
60
+ outlineWidth: 2
61
+ }
62
+ }
63
+ },
64
+ size: {
65
+ "...size": import_get_button_sized.getButtonSized
66
+ },
67
+ active: {
68
+ true: {
69
+ hoverStyle: {
70
+ backgroundColor: "$background"
71
+ }
72
+ }
73
+ },
74
+ disabled: {
75
+ true: {
76
+ pointerEvents: "none"
77
+ }
78
+ }
79
+ },
80
+ defaultVariants: {
81
+ unstyled: false
82
+ }
83
+ });
84
+ const [createButtonContext, createButtonScope] = (0, import_create_context.createContextScope)(import_Button.BUTTON_NAME);
85
+ const [ButtonProvider, useButtonContext] = createButtonContext("Button");
86
+ const ButtonTextFrame = (0, import_web.styled)(import_Button.Button.Text, {
87
+ name: import_Button.BUTTON_TEXT_NAME,
88
+ variants: {
89
+ unstyled: {
90
+ false: {
91
+ userSelect: "none",
92
+ cursor: "pointer",
93
+ // flexGrow 1 leads to inconsistent native style where text pushes to start of view
94
+ flexGrow: 0,
95
+ flexShrink: 1,
96
+ ellipse: true,
97
+ color: "$color"
98
+ }
99
+ }
100
+ },
101
+ defaultVariants: {
102
+ unstyled: false
103
+ }
104
+ });
105
+ const ButtonText = ButtonTextFrame.styleable(
106
+ (props, ref) => {
107
+ const context = useButtonContext(import_Button.BUTTON_TEXT_NAME, props.__scopeButton);
108
+ (0, import_react.useEffect)(() => {
109
+ const unregister = context.registerButtonText();
110
+ return () => unregister();
111
+ }, [context.registerButtonText]);
112
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ButtonTextFrame, { ref, color: context.color, size: context.size, ...props, children: props.children });
113
+ }
114
+ );
115
+ const ButtonIcon = (props) => {
116
+ const { children, scaleIcon = 1 } = props;
117
+ const context = useButtonContext(import_Button.BUTTON_ICON_NAME, props.__scopeButton);
118
+ const size = context.size;
119
+ const color = context.color;
120
+ const iconSize = (typeof size === "number" ? size * 0.5 : (0, import_font_size.getFontSize)(size)) * scaleIcon;
121
+ const getThemedIcon = (0, import_helpers_tamagui.useGetThemedIcon)({ size: iconSize, color });
122
+ return getThemedIcon(children);
123
+ };
124
+ const ButtonComponent = ButtonFrame.styleable(
125
+ (props, ref) => {
126
+ const buttonApi = props.forceButtonApi ?? (0, import_web.getConfig)().buttonApi ?? "mixed";
127
+ const { props: buttonProps } = useButton(props);
128
+ const [buttonTextCount, setButtonTextCount] = (0, import_react.useState)(0);
129
+ const registerButtonText = (0, import_react.useCallback)(() => {
130
+ if (buttonApi === "simple") {
131
+ console.warn(
132
+ "You are using Button.Text with simple button API. Either remove Button.Text or use either `buttonApi: composable` or `mixed` in your tamagui config."
133
+ );
134
+ }
135
+ if (buttonApi === "composable")
136
+ return () => {
137
+ };
138
+ setButtonTextCount((prev) => prev + 1);
139
+ return () => setButtonTextCount((prev) => prev - 1);
140
+ }, [setButtonTextCount]);
141
+ const usesComposableApi = buttonApi === "composable" || buttonApi === "mixed" && buttonTextCount > 0;
142
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
143
+ ButtonProvider,
144
+ {
145
+ scope: props.__scopeButton,
146
+ size: props.size ?? "$true",
147
+ color: props.color,
148
+ usesComposableApi,
149
+ registerButtonText,
150
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ButtonFrame, { unstyled: props.unstyled ?? false, ref, ...buttonProps })
151
+ }
152
+ );
153
+ }
154
+ );
155
+ const Button = (0, import_web.withStaticProperties)(ButtonComponent, {
156
+ Text: ButtonText,
157
+ Icon: ButtonIcon
158
+ });
159
+ function useButton(propsIn, { Text = ButtonTextFrame } = { Text: ButtonTextFrame }) {
160
+ const {
161
+ children,
162
+ icon,
163
+ iconAfter,
164
+ noTextWrap,
165
+ theme: themeName,
166
+ space,
167
+ spaceFlex,
168
+ scaleIcon = 1,
169
+ scaleSpace = 0.66,
170
+ separator,
171
+ // text props
172
+ color,
173
+ fontWeight,
174
+ letterSpacing,
175
+ fontSize,
176
+ fontFamily,
177
+ fontStyle,
178
+ textAlign,
179
+ unstyled = false,
180
+ textProps,
181
+ ...rest
182
+ } = propsIn;
183
+ const isNested = import_web.isRSC ? false : (0, import_react.useContext)(import_web.ButtonNestingContext);
184
+ const propsActive = (0, import_web.useMediaPropsActive)(propsIn);
185
+ const size = propsActive.size || "$true";
186
+ const iconSize = (typeof size === "number" ? size * 0.5 : (0, import_font_size.getFontSize)(size)) * scaleIcon;
187
+ const getThemedIcon = (0, import_helpers_tamagui.useGetThemedIcon)({ size: iconSize, color });
188
+ const [themedIcon, themedIconAfter] = [icon, iconAfter].map(getThemedIcon);
189
+ const spaceSize = propsActive.space ?? (0, import_web.getVariableValue)(iconSize) * scaleSpace;
190
+ const contents = (0, import_text.wrapChildrenInText)(
191
+ Text,
192
+ propsActive,
193
+ Text === ButtonTextFrame ? {
194
+ unstyled
195
+ } : void 0
196
+ );
197
+ const inner = (0, import_web.spacedChildren)({
198
+ // a bit arbitrary but scaling to font size is necessary so long as button does
199
+ space: spaceSize,
200
+ spaceFlex,
201
+ separator,
202
+ direction: propsActive.flexDirection === "column" || propsActive.flexDirection === "column-reverse" ? "vertical" : "horizontal",
203
+ children: [themedIcon, ...contents, themedIconAfter]
204
+ });
205
+ const tag = isNested ? "span" : (
206
+ // defaults to <a /> when accessibilityRole = link
207
+ // see https://github.com/tamagui/tamagui/issues/505
208
+ propsIn.accessibilityRole === "link" ? "a" : void 0
209
+ );
210
+ const props = {
211
+ ...propsActive.disabled && {
212
+ // in rnw - false still has keyboard tabIndex, undefined = not actually focusable
213
+ focusable: void 0,
214
+ // even with tabIndex unset, it will keep focusStyle on web so disable it here
215
+ focusStyle: {
216
+ borderColor: "$background"
217
+ }
218
+ },
219
+ tag,
220
+ ...rest,
221
+ children: import_web.isRSC ? inner : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_web.ButtonNestingContext.Provider, { value: true, children: inner })
222
+ };
223
+ return {
224
+ spaceSize,
225
+ isNested,
226
+ props
227
+ };
228
+ }
229
+ const buttonStaticConfig = {
230
+ inlineProps: /* @__PURE__ */ new Set([
231
+ // text props go here (can't really optimize them, but we never fully extract button anyway)
232
+ // may be able to remove this entirely, as the compiler / runtime have gotten better
233
+ "color",
234
+ "fontWeight",
235
+ "fontSize",
236
+ "fontFamily",
237
+ "fontStyle",
238
+ "letterSpacing",
239
+ "textAlign",
240
+ "unstyled"
241
+ ])
242
+ };
243
+ // Annotate the CommonJS export names for ESM import in node:
244
+ 0 && (module.exports = {
245
+ Button,
246
+ ButtonFrame,
247
+ ButtonText,
248
+ buttonStaticConfig,
249
+ createButtonScope,
250
+ useButton
251
+ });
252
+ //# sourceMappingURL=themed.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/themed.tsx"],
4
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA8KM;AA7KN,4BAAmC;AACnC,uBAA4B;AAC5B,8BAA+B;AAC/B,6BAA4C;AAC5C,kBAAqD;AACrD,iBAaO;AACP,mBAAgF;AAEhF,oBAKO;AAEP,MAAM,kBAAc,mBAAO,cAAAA,QAAY;AAAA,EACrC,MAAM;AAAA,EACN,UAAU;AAAA,IACR,UAAU;AAAA,MACR,OAAO;AAAA,QACL,MAAM;AAAA,QACN,gBAAgB;AAAA,QAChB,YAAY;AAAA,QACZ,UAAU;AAAA,QACV,eAAe;AAAA,QACf,QAAQ;AAAA,QACR,YAAY;AAAA,QACZ,YAAY;AAAA,QACZ,cAAc;AAAA,QACd,aAAa;AAAA,QACb,aAAa;AAAA,QAEb,YAAY;AAAA,UACV,aAAa;AAAA,QACf;AAAA,QAEA,YAAY;AAAA,UACV,cAAc;AAAA,UACd,cAAc;AAAA,UACd,cAAc;AAAA,QAChB;AAAA,MACF;AAAA,IACF;AAAA,IAEA,MAAM;AAAA,MACJ,WAAW;AAAA,IACb;AAAA,IAEA,QAAQ;AAAA,MACN,MAAM;AAAA,QACJ,YAAY;AAAA,UACV,iBAAiB;AAAA,QACnB;AAAA,MACF;AAAA,IACF;AAAA,IAEA,UAAU;AAAA,MACR,MAAM;AAAA,QACJ,eAAe;AAAA,MACjB;AAAA,IACF;AAAA,EACF;AAAA,EAEA,iBAAiB;AAAA,IACf,U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+ import { getButtonSized } from "@tamagui/get-button-sized";
3
+ import { useGetThemedIcon } from "@tamagui/helpers-tamagui";
4
+ import { ThemeableStack } from "@tamagui/stacks";
5
+ import {
6
+ SizableText,
7
+ wrapChildrenInText
8
+ } from "@tamagui/text";
9
+ import {
10
+ createStyledContext,
11
+ getVariableValue,
12
+ spacedChildren,
13
+ styled,
14
+ useProps,
15
+ withStaticProperties
16
+ } from "@tamagui/web";
17
+ import { createContext, useContext } from "react";
18
+ import { jsx } from "react/jsx-runtime";
19
+ const ButtonContext = createStyledContext({}), BUTTON_NAME = "Button", ButtonFrame = styled(ThemeableStack, {
20
+ name: BUTTON_NAME,
21
+ tag: "button",
22
+ context: ButtonContext,
23
+ focusable: !0,
24
+ role: "button",
25
+ variants: {
26
+ unstyled: {
27
+ false: {
28
+ size: "$true",
29
+ justifyContent: "center",
30
+ alignItems: "center",
31
+ flexWrap: "nowrap",
32
+ flexDirection: "row",
33
+ cursor: "pointer",
34
+ hoverTheme: !0,
35
+ pressTheme: !0,
36
+ backgrounded: !0,
37
+ borderWidth: 1,
38
+ borderColor: "transparent",
39
+ focusStyle: {
40
+ outlineColor: "$borderColorFocus",
41
+ outlineStyle: "solid",
42
+ outlineWidth: 2
43
+ }
44
+ }
45
+ },
46
+ variant: {
47
+ outlined: {
48
+ backgroundColor: "transparent",
49
+ borderWidth: 2,
50
+ borderColor: "$borderColor",
51
+ hoverStyle: {
52
+ backgroundColor: "transparent",
53
+ borderColor: "$borderColorHover"
54
+ },
55
+ pressStyle: {
56
+ backgroundColor: "transparent",
57
+ borderColor: "$borderColorPress"
58
+ },
59
+ focusStyle: {
60
+ backgroundColor: "transparent",
61
+ borderColor: "$borderColorFocus"
62
+ }
63
+ }
64
+ },
65
+ size: {
66
+ "...size": getButtonSized
67
+ },
68
+ disabled: {
69
+ true: {
70
+ pointerEvents: "none"
71
+ }
72
+ }
73
+ },
74
+ defaultVariants: {
75
+ unstyled: !1
76
+ }
77
+ }), ButtonText = styled(SizableText, {
78
+ name: "Button",
79
+ // same name as the frame so they can share a single theme
80
+ context: ButtonContext,
81
+ variants: {
82
+ unstyled: {
83
+ false: {
84
+ userSelect: "none",
85
+ cursor: "pointer",
86
+ // flexGrow 1 leads to inconsistent native style where text pushes to start of view
87
+ flexGrow: 0,
88
+ flexShrink: 1,
89
+ ellipse: !0,
90
+ color: "$color"
91
+ }
92
+ }
93
+ },
94
+ defaultVariants: {
95
+ unstyled: !1
96
+ }
97
+ }), ButtonIcon = (props) => {
98
+ const { children, scaleIcon = 1 } = props, { size, color } = useContext(ButtonContext), iconSize = (typeof size == "number" ? size * 0.5 : getFontSize(size)) * scaleIcon;
99
+ return useGetThemedIcon({ size: iconSize, color })(children);
100
+ }, ButtonComponent = ButtonFrame.styleable(function(props, ref) {
101
+ const { props: buttonProps } = useButton(props);
102
+ return /* @__PURE__ */ jsx(ButtonFrame, { ...buttonProps, ref });
103
+ }), buttonStaticConfig = {
104
+ inlineProps: /* @__PURE__ */ new Set([
105
+ // text props go here (can't really optimize them, but we never fully extract button anyway)
106
+ // may be able to remove this entirely, as the compiler / runtime have gotten better
107
+ "color",
108
+ "fontWeight",
109
+ "fontSize",
110
+ "fontFamily",
111
+ "fontStyle",
112
+ "letterSpacing",
113
+ "textAlign",
114
+ "unstyled"
115
+ ])
116
+ }, Button2 = withStaticProperties(ButtonComponent, {
117
+ Text: ButtonText,
118
+ Icon: ButtonIcon
119
+ }), ButtonNestingContext = createContext(!1);
120
+ function useButton(propsIn, { Text = Button2.Text } = { Text: Button2.Text }) {
121
+ const {
122
+ children,
123
+ icon,
124
+ iconAfter,
125
+ noTextWrap,
126
+ theme: themeName,
127
+ space,
128
+ spaceFlex,
129
+ scaleIcon = 1,
130
+ scaleSpace = 0.66,
131
+ separator,
132
+ // text props
133
+ color,
134
+ fontWeight,
135
+ letterSpacing,
136
+ fontSize,
137
+ fontFamily,
138
+ fontStyle,
139
+ textAlign,
140
+ textProps,
141
+ ...rest
142
+ } = propsIn, isNested = useContext(ButtonNestingContext), propsActive = useProps(propsIn), size = propsActive.size || (propsActive.unstyled ? void 0 : "$true"), iconSize = (typeof size == "number" ? size * 0.5 : getFontSize(size)) * scaleIcon, getThemedIcon = useGetThemedIcon({ size: iconSize, color }), [themedIcon, themedIconAfter] = [icon, iconAfter].map(getThemedIcon), spaceSize = propsActive.space ?? getVariableValue(iconSize) * scaleSpace, contents = wrapChildrenInText(
143
+ Text,
144
+ propsActive,
145
+ Text === ButtonText && propsIn.unstyled !== !0 ? {
146
+ unstyled: !1,
147
+ size
148
+ } : void 0
149
+ ), inner = spacedChildren({
150
+ // a bit arbitrary but scaling to font size is necessary so long as button does
151
+ space: spaceSize,
152
+ spaceFlex,
153
+ separator,
154
+ direction: propsActive.flexDirection === "column" || propsActive.flexDirection === "column-reverse" ? "vertical" : "horizontal",
155
+ children: [themedIcon, ...contents, themedIconAfter]
156
+ }), tag = isNested ? "span" : (
157
+ // defaults to <a /> when accessibilityRole = link
158
+ // see https://github.com/tamagui/tamagui/issues/505
159
+ propsIn.accessibilityRole === "link" ? "a" : void 0
160
+ ), props = {
161
+ ...propsActive.disabled && {
162
+ // in rnw - false still has keyboard tabIndex, undefined = not actually focusable
163
+ focusable: void 0,
164
+ // even with tabIndex unset, it will keep focusStyle on web so disable it here
165
+ focusStyle: {
166
+ borderColor: "$background"
167
+ }
168
+ },
169
+ ...tag && {
170
+ tag
171
+ },
172
+ ...rest,
173
+ children: /* @__PURE__ */ jsx(ButtonNestingContext.Provider, { value: !0, children: inner })
174
+ };
175
+ return {
176
+ spaceSize,
177
+ isNested,
178
+ props
179
+ };
180
+ }
181
+ export {
182
+ Button2 as Button,
183
+ ButtonContext,
184
+ ButtonFrame,
185
+ ButtonIcon,
186
+ ButtonNestingContext,
187
+ ButtonText,
188
+ buttonStaticConfig,
189
+ useButton
190
+ };
191
+ //# sourceMappingURL=Button.mjs.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/Button.tsx"],
4
+ "m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0,0 +1,10 @@
1
+ import { getDefaultTamaguiConfig } from "@tamagui/config-default";
2
+ import { createTamagui } from "@tamagui/core";
3
+ import { describe, expect, test } from "vitest";
4
+ const conf = createTamagui(getDefaultTamaguiConfig());
5
+ describe("Button", () => {
6
+ test("123", () => {
7
+ expect(!0).toBeTruthy();
8
+ });
9
+ });
10
+ //# sourceMappingURL=Button.test.mjs.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/Button.test.tsx"],
4
+ "mappings": "AAAA,SAAS,+BAA+B;AACxC,SAAS,qBAAqB;AAC9B,SAAS,UAAU,QAAQ,YAAY;AAEvC,MAAM,OAAO,cAAc,wBAAwB,CAAC;AAEpD,SAAS,UAAU,MAAM;AACvB,OAAK,OAAO,MAAM;AAChB,WAAO,EAAI,EAAE,WAAW;AAAA,EAC1B,CAAC;AAWH,CAAC;",
5
+ "names": []
6
+ }
@@ -0,0 +1,5 @@
1
+ import { Button } from "./Button";
2
+ export {
3
+ Button
4
+ };
5
+ //# sourceMappingURL=base.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/base.ts"],
4
+ "mappings": "AACA,SAAS,cAAc;",
5
+ "names": []
6
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./Button";
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "mappings": "AAAA,cAAc;",
5
+ "names": []
6
+ }