@tamagui/button 2.0.0-rc.36 → 2.0.0-rc.36-1775258360494

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.
Files changed (53) hide show
  1. package/dist/cjs/Button.cjs +194 -187
  2. package/dist/cjs/Button.native.js +194 -189
  3. package/dist/cjs/Button.native.js.map +1 -1
  4. package/dist/cjs/Button.test.cjs +32 -31
  5. package/dist/cjs/Button.test.native.js +33 -32
  6. package/dist/cjs/Button.test.native.js.map +1 -1
  7. package/dist/cjs/index.cjs +7 -5
  8. package/dist/cjs/index.native.js +7 -5
  9. package/dist/cjs/index.native.js.map +1 -1
  10. package/dist/cjs/v1/Button.cjs +215 -212
  11. package/dist/cjs/v1/Button.native.js +217 -215
  12. package/dist/cjs/v1/Button.native.js.map +1 -1
  13. package/dist/cjs/v1/Button.test.cjs +5 -5
  14. package/dist/cjs/v1/Button.test.native.js +6 -6
  15. package/dist/cjs/v1/Button.test.native.js.map +1 -1
  16. package/dist/cjs/v1/index.cjs +7 -5
  17. package/dist/cjs/v1/index.native.js +7 -5
  18. package/dist/cjs/v1/index.native.js.map +1 -1
  19. package/dist/esm/Button.mjs +173 -168
  20. package/dist/esm/Button.mjs.map +1 -1
  21. package/dist/esm/Button.native.js +173 -170
  22. package/dist/esm/Button.native.js.map +1 -1
  23. package/dist/esm/Button.test.mjs +27 -26
  24. package/dist/esm/Button.test.mjs.map +1 -1
  25. package/dist/esm/Button.test.native.js +27 -26
  26. package/dist/esm/Button.test.native.js.map +1 -1
  27. package/dist/esm/v1/Button.mjs +193 -192
  28. package/dist/esm/v1/Button.mjs.map +1 -1
  29. package/dist/esm/v1/Button.native.js +194 -194
  30. package/dist/esm/v1/Button.native.js.map +1 -1
  31. package/dist/esm/v1/Button.test.mjs +2 -2
  32. package/dist/esm/v1/Button.test.mjs.map +1 -1
  33. package/dist/esm/v1/Button.test.native.js +2 -2
  34. package/dist/esm/v1/Button.test.native.js.map +1 -1
  35. package/dist/jsx/Button.mjs +173 -168
  36. package/dist/jsx/Button.mjs.map +1 -1
  37. package/dist/jsx/Button.native.js +194 -189
  38. package/dist/jsx/Button.native.js.map +1 -1
  39. package/dist/jsx/Button.test.mjs +27 -26
  40. package/dist/jsx/Button.test.mjs.map +1 -1
  41. package/dist/jsx/Button.test.native.js +33 -32
  42. package/dist/jsx/Button.test.native.js.map +1 -1
  43. package/dist/jsx/index.native.js +7 -5
  44. package/dist/jsx/v1/Button.mjs +193 -192
  45. package/dist/jsx/v1/Button.mjs.map +1 -1
  46. package/dist/jsx/v1/Button.native.js +217 -215
  47. package/dist/jsx/v1/Button.native.js.map +1 -1
  48. package/dist/jsx/v1/Button.test.mjs +2 -2
  49. package/dist/jsx/v1/Button.test.mjs.map +1 -1
  50. package/dist/jsx/v1/Button.test.native.js +6 -6
  51. package/dist/jsx/v1/Button.test.native.js.map +1 -1
  52. package/dist/jsx/v1/index.native.js +7 -5
  53. package/package.json +12 -12
@@ -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
- for (var name in all) __defProp(target, name, {
7
- get: all[name],
8
- enumerable: !0
9
- });
10
- },
11
- __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
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
- return to;
17
- };
17
+ }
18
+ return to;
19
+ };
18
20
  var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
- value: !0
21
+ value: true
20
22
  }), mod);
21
23
  var Button_exports = {};
22
24
  __export(Button_exports, {
@@ -24,195 +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
- import_get_button_sized = require("@tamagui/get-button-sized"),
29
- import_helpers_tamagui = require("@tamagui/helpers-tamagui"),
30
- import_stacks = require("@tamagui/stacks"),
31
- import_text = require("@tamagui/text"),
32
- import_web = require("@tamagui/web"),
33
- import_react = require("react"),
34
- import_jsx_runtime = require("react/jsx-runtime");
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
- size: void 0,
37
- variant: void 0,
38
- color: void 0,
39
- elevation: void 0
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
- Frame = (0, import_web.styled)(import_web.View, {
42
- context,
43
- name: "Button",
44
- role: "button",
45
- render: /* @__PURE__ */(0, import_jsx_runtime.jsx)("button", {
46
- type: "button"
47
- }),
48
- tabIndex: 0,
49
- variants: {
50
- unstyled: {
51
- false: {
52
- size: "$true",
53
- justifyContent: "center",
54
- alignItems: "center",
55
- flexWrap: "nowrap",
56
- flexDirection: "row",
57
- cursor: "pointer",
58
- backgroundColor: "$background",
59
- borderWidth: 1,
60
- borderColor: "transparent",
61
- hoverStyle: {
62
- backgroundColor: "$backgroundHover",
63
- borderColor: "$borderColorHover"
64
- },
65
- pressStyle: {
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
- variant: {
77
- outlined: process.env.TAMAGUI_HEADLESS === "1" ? {} : {
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
- borderWidth: 1,
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
- ":number": (val, extras) => {
103
- const buttonStyle = (0, import_get_button_sized.getButtonSized)(val, extras),
104
- gap = val * 0.4;
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
- elevation: {
112
- "...size": import_stacks.getElevation,
113
- ":number": import_stacks.getElevation
114
- },
115
- disabled: {
116
- true: {
117
- pointerEvents: "none",
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
- defaultVariants: {
124
- unstyled: process.env.TAMAGUI_HEADLESS === "1"
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
- Text = (0, import_web.styled)(import_text.SizableText, {
128
- context,
129
- variants: {
130
- unstyled: {
131
- false: {
132
- userSelect: "none",
133
- cursor: "pointer",
134
- // flexGrow 1 leads to inconsistent native style where text pushes to start of view
135
- flexGrow: 0,
136
- flexShrink: 1,
137
- ellipsis: !0,
138
- color: "$color"
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
- iconColor = (0, import_helpers_tamagui.useCurrentColor)(styledContext.color),
156
- iconSize = (typeof sizeToken == "number" ? sizeToken * 0.5 : (0, import_font_size.getFontSize)(sizeToken)) * scaleIcon;
157
- return (0, import_helpers_tamagui.getIcon)(children, {
158
- size: iconSize,
143
+ },
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,
159
194
  color: iconColor
195
+ // No marginLeft or marginRight needed - spacing is handled by the gap property in Frame's size variants
160
196
  });
161
- },
162
- ButtonContext = (0, import_web.createStyledContext)({
163
- size: void 0,
164
- variant: void 0,
165
- color: void 0
166
- }),
167
- ButtonComponent = Frame.styleable((propsIn, ref) => {
168
- const isNested = (0, import_react.useContext)(import_stacks.ButtonNestingContext),
169
- processedProps = (0, import_web.useProps)(propsIn, {
170
- noNormalize: !0,
171
- noExpand: !0
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"
172
211
  }),
173
- {
174
- children,
175
- iconSize,
176
- icon,
177
- iconAfter,
178
- scaleIcon = 1,
179
- ...props
180
- } = processedProps,
181
- size = propsIn.size || (propsIn.unstyled ? void 0 : "$true"),
182
- styledContext = context.useStyledContext(),
183
- iconColor = (0, import_helpers_tamagui.useCurrentColor)(styledContext?.color),
184
- finalSize = iconSize ?? size ?? styledContext?.size,
185
- iconSizeNumber = (typeof finalSize == "number" ? finalSize * 0.5 : (0, import_font_size.getFontSize)(finalSize)) * scaleIcon,
186
- [themedIcon, themedIconAfter] = [icon, iconAfter].map(icon2 => icon2 ? (0, import_helpers_tamagui.getIcon)(icon2, {
187
- size: iconSizeNumber,
188
- color: iconColor
189
- // No marginLeft or marginRight needed - spacing is handled by the gap property in Frame's size variants
190
- }) : null),
191
- wrappedChildren = (0, import_text.wrapChildrenInText)(Text, {
192
- children
193
- }, {
194
- unstyled: process.env.TAMAGUI_HEADLESS === "1",
195
- size: finalSize ?? styledContext?.size
196
- });
197
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_stacks.ButtonNestingContext.Provider, {
198
- value: !0,
199
- children: /* @__PURE__ */(0, import_jsx_runtime.jsxs)(Frame, {
200
- ref,
201
- ...props,
202
- ...(isNested && {
203
- render: "span"
204
- }),
205
- ...(props.circular && !propsIn.size && {
206
- size
207
- }),
208
- tabIndex: 0,
209
- children: [themedIcon, wrappedChildren, themedIconAfter]
210
- })
211
- });
212
- }),
213
- Button = (0, import_web.withStaticProperties)(ButtonComponent, {
214
- Apply: context.Provider,
215
- Frame,
216
- Text,
217
- Icon
218
- });
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
+ });