@tamagui/button 1.74.2 → 1.74.4

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,201 @@
1
+ import { getFontSize } from "@tamagui/font-size";
2
+ 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({
20
+ // keeping these here means they work with styled() passing down color to text
21
+ color: void 0,
22
+ ellipse: void 0,
23
+ fontFamily: void 0,
24
+ fontSize: void 0,
25
+ fontStyle: void 0,
26
+ fontWeight: void 0,
27
+ letterSpacing: void 0,
28
+ maxFontSizeMultiplier: void 0,
29
+ size: void 0,
30
+ textAlign: void 0
31
+ }), BUTTON_NAME = "Button", ButtonFrame = styled(ThemeableStack, {
32
+ name: BUTTON_NAME,
33
+ tag: "button",
34
+ context: ButtonContext,
35
+ focusable: !0,
36
+ role: "button",
37
+ variants: {
38
+ unstyled: {
39
+ false: {
40
+ size: "$true",
41
+ justifyContent: "center",
42
+ alignItems: "center",
43
+ flexWrap: "nowrap",
44
+ flexDirection: "row",
45
+ cursor: "pointer",
46
+ hoverTheme: !0,
47
+ pressTheme: !0,
48
+ backgrounded: !0,
49
+ borderWidth: 1,
50
+ borderColor: "transparent",
51
+ focusStyle: {
52
+ outlineColor: "$borderColorFocus",
53
+ outlineStyle: "solid",
54
+ outlineWidth: 2
55
+ }
56
+ }
57
+ },
58
+ variant: {
59
+ outlined: {
60
+ backgroundColor: "transparent",
61
+ borderWidth: 2,
62
+ borderColor: "$borderColor",
63
+ hoverStyle: {
64
+ backgroundColor: "transparent",
65
+ borderColor: "$borderColorHover"
66
+ },
67
+ pressStyle: {
68
+ backgroundColor: "transparent",
69
+ borderColor: "$borderColorPress"
70
+ },
71
+ focusStyle: {
72
+ backgroundColor: "transparent",
73
+ borderColor: "$borderColorFocus"
74
+ }
75
+ }
76
+ },
77
+ size: {
78
+ "...size": getButtonSized
79
+ },
80
+ disabled: {
81
+ true: {
82
+ pointerEvents: "none"
83
+ }
84
+ }
85
+ },
86
+ defaultVariants: {
87
+ unstyled: !1
88
+ }
89
+ }), ButtonText = styled(SizableText, {
90
+ name: "Button",
91
+ // same name as the frame so they can share a single theme
92
+ context: ButtonContext,
93
+ variants: {
94
+ unstyled: {
95
+ false: {
96
+ userSelect: "none",
97
+ cursor: "pointer",
98
+ // flexGrow 1 leads to inconsistent native style where text pushes to start of view
99
+ flexGrow: 0,
100
+ flexShrink: 1,
101
+ ellipse: !0,
102
+ color: "$color"
103
+ }
104
+ }
105
+ },
106
+ defaultVariants: {
107
+ unstyled: !1
108
+ }
109
+ }), ButtonIcon = (props) => {
110
+ const { children, scaleIcon = 1 } = props, { size, color } = useContext(ButtonContext), iconSize = (typeof size == "number" ? size * 0.5 : getFontSize(size)) * scaleIcon;
111
+ return useGetThemedIcon({ size: iconSize, color })(children);
112
+ }, ButtonComponent = ButtonFrame.styleable(function(props, ref) {
113
+ const { props: buttonProps } = useButton(props);
114
+ return /* @__PURE__ */ jsx(ButtonFrame, { ...buttonProps, ref });
115
+ }), buttonStaticConfig = {
116
+ inlineProps: /* @__PURE__ */ new Set([
117
+ // text props go here (can't really optimize them, but we never fully extract button anyway)
118
+ // may be able to remove this entirely, as the compiler / runtime have gotten better
119
+ "color",
120
+ "fontWeight",
121
+ "fontSize",
122
+ "fontFamily",
123
+ "fontStyle",
124
+ "letterSpacing",
125
+ "textAlign",
126
+ "unstyled"
127
+ ])
128
+ }, Button2 = withStaticProperties(ButtonComponent, {
129
+ Text: ButtonText,
130
+ Icon: ButtonIcon
131
+ }), ButtonNestingContext = createContext(!1);
132
+ function useButton(propsIn, { Text = Button2.Text } = { Text: Button2.Text }) {
133
+ const isNested = useContext(ButtonNestingContext), propsActive = useProps(propsIn), {
134
+ children,
135
+ icon,
136
+ iconAfter,
137
+ space,
138
+ spaceFlex,
139
+ scaleIcon = 1,
140
+ scaleSpace = 0.66,
141
+ separator,
142
+ noTextWrap,
143
+ fontFamily,
144
+ fontSize,
145
+ ...rest
146
+ } = propsActive, size = propsActive.size || (propsActive.unstyled ? void 0 : "$true"), iconSize = (typeof size == "number" ? size * 0.5 : getFontSize(size)) * scaleIcon, getThemedIcon = useGetThemedIcon({
147
+ size: iconSize,
148
+ color: propsActive.color
149
+ }), [themedIcon, themedIconAfter] = [icon, iconAfter].map(getThemedIcon), spaceSize = propsActive.space ?? getVariableValue(iconSize) * scaleSpace, contents = noTextWrap ? [children] : wrapChildrenInText(
150
+ Text,
151
+ { children, fontFamily, fontSize },
152
+ Text === ButtonText && propsIn.unstyled !== !0 ? {
153
+ unstyled: !1,
154
+ size
155
+ } : void 0
156
+ ), inner = spacedChildren({
157
+ // a bit arbitrary but scaling to font size is necessary so long as button does
158
+ space: spaceSize,
159
+ spaceFlex,
160
+ separator,
161
+ direction: propsActive.flexDirection === "column" || propsActive.flexDirection === "column-reverse" ? "vertical" : "horizontal",
162
+ children: [themedIcon, ...contents, themedIconAfter]
163
+ }), tag = isNested ? "span" : (
164
+ // defaults to <a /> when accessibilityRole = link
165
+ // see https://github.com/tamagui/tamagui/issues/505
166
+ propsIn.accessibilityRole === "link" ? "a" : void 0
167
+ ), props = {
168
+ size,
169
+ ...propsActive.disabled && {
170
+ // in rnw - false still has keyboard tabIndex, undefined = not actually focusable
171
+ focusable: void 0,
172
+ // even with tabIndex unset, it will keep focusStyle on web so disable it here
173
+ focusStyle: {
174
+ borderColor: "$background"
175
+ }
176
+ },
177
+ ...tag && {
178
+ tag
179
+ },
180
+ ...rest,
181
+ children: /* @__PURE__ */ jsx(ButtonNestingContext.Provider, { value: !0, children: inner }),
182
+ // forces it to be a runtime pressStyle so it passes through context text colors
183
+ disableClassName: !0
184
+ };
185
+ return {
186
+ spaceSize,
187
+ isNested,
188
+ props
189
+ };
190
+ }
191
+ export {
192
+ Button2 as Button,
193
+ ButtonContext,
194
+ ButtonFrame,
195
+ ButtonIcon,
196
+ ButtonNestingContext,
197
+ ButtonText,
198
+ buttonStaticConfig,
199
+ useButton
200
+ };
201
+ //# sourceMappingURL=Button.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/Button.tsx"],
4
+ "mappings": "AAAA,SAAS,mBAAmB;AAC5B,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,sBAAsB;AAC/B;AAAA,EACE;AAAA,EAGA;AAAA,OACK;AACP;AAAA,EAKE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAA4B,eAAe,kBAAkB;AAoKpD;AAlKF,MAAM,gBAAgB,oBAM3B;AAAA;AAAA,EAEA,OAAO;AAAA,EACP,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,eAAe;AAAA,EACf,uBAAuB;AAAA,EACvB,MAAM;AAAA,EACN,WAAW;AACb,CAAC,GAoCK,cAAc,UAEd,cAAc,OAAO,gBAAgB;AAAA,EACzC,MAAM;AAAA,EACN,KAAK;AAAA,EACL,SAAS;AAAA,EACT,WAAW;AAAA,EACX,MAAM;AAAA,EAEN,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,QA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AAY,kBAAkB,YAC9B,YAAY,kBAAkB,mBAC1B,aACA;AAAA,IACN,UAAU,CAAC,YAAY,GAAG,UAAU,eAAe;AAAA,EACrD,CAAC,GAGK,MAAM,WACR;AAAA;AAAA;AAAA,IAGF,QAAQ,sBAAsB,SAC5B,MACA;AAAA,KAEE,QAAQ;AAAA,IACZ;AAAA,IACA,GAAI,YAAY,YAAY;AAAA;AAAA,MAE1B,WAAW;AAAA;AAAA,MAEX,YAAY;AAAA,QACV,aAAa;AAAA,MACf;AAAA,IACF;AAAA,IACA,GAAI,OAAO;AAAA,MACT;AAAA,IACF;AAAA,IACA,GAAG;AAAA,IACH,UACE,oBAAC,qBAAqB,UAArB,EAA8B,OAAO,IAAO,iBAAM;AAAA;AAAA,IAGrD,kBAAkB;AAAA,EACpB;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
5
+ "names": ["Button"]
6
+ }
@@ -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.js.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,2 @@
1
+ export * from "./Button";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "mappings": "AAAA,cAAc;",
5
+ "names": []
6
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/button",
3
- "version": "1.74.2",
3
+ "version": "1.74.4",
4
4
  "sideEffects": [
5
5
  "*.css"
6
6
  ],
@@ -29,17 +29,17 @@
29
29
  }
30
30
  },
31
31
  "dependencies": {
32
- "@tamagui/font-size": "1.74.2",
33
- "@tamagui/get-button-sized": "1.74.2",
34
- "@tamagui/helpers-tamagui": "1.74.2",
35
- "@tamagui/text": "1.74.2",
36
- "@tamagui/web": "1.74.2"
32
+ "@tamagui/font-size": "1.74.4",
33
+ "@tamagui/get-button-sized": "1.74.4",
34
+ "@tamagui/helpers-tamagui": "1.74.4",
35
+ "@tamagui/text": "1.74.4",
36
+ "@tamagui/web": "1.74.4"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "react": "*"
40
40
  },
41
41
  "devDependencies": {
42
- "@tamagui/build": "1.74.2",
42
+ "@tamagui/build": "1.74.4",
43
43
  "react": "^18.2.0",
44
44
  "vitest": "^0.34.3"
45
45
  },