@tamagui/button 1.0.1-beta.100

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,194 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
+ var __spreadValues = (a, b) => {
13
+ for (var prop in b || (b = {}))
14
+ if (__hasOwnProp.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ if (__getOwnPropSymbols)
17
+ for (var prop of __getOwnPropSymbols(b)) {
18
+ if (__propIsEnum.call(b, prop))
19
+ __defNormalProp(a, prop, b[prop]);
20
+ }
21
+ return a;
22
+ };
23
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
+ var __objRest = (source, exclude) => {
25
+ var target = {};
26
+ for (var prop in source)
27
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
28
+ target[prop] = source[prop];
29
+ if (source != null && __getOwnPropSymbols)
30
+ for (var prop of __getOwnPropSymbols(source)) {
31
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
32
+ target[prop] = source[prop];
33
+ }
34
+ return target;
35
+ };
36
+ var __export = (target, all) => {
37
+ for (var name in all)
38
+ __defProp(target, name, { get: all[name], enumerable: true });
39
+ };
40
+ var __copyProps = (to, from, except, desc) => {
41
+ if (from && typeof from === "object" || typeof from === "function") {
42
+ for (let key of __getOwnPropNames(from))
43
+ if (!__hasOwnProp.call(to, key) && key !== except)
44
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
45
+ }
46
+ return to;
47
+ };
48
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
49
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
50
+ var Button_exports = {};
51
+ __export(Button_exports, {
52
+ Button: () => Button,
53
+ ButtonFrame: () => ButtonFrame,
54
+ ButtonText: () => ButtonText
55
+ });
56
+ module.exports = __toCommonJS(Button_exports);
57
+ var import_core = require("@tamagui/core");
58
+ var import_font_size = require("@tamagui/font-size");
59
+ var import_helpers_tamagui = require("@tamagui/helpers-tamagui");
60
+ var import_stacks = require("@tamagui/stacks");
61
+ var import_text = require("@tamagui/text");
62
+ var import_react = __toESM(require("react"));
63
+ import_react.default["createElement"];
64
+ const ButtonFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
65
+ name: "Button",
66
+ tag: "button",
67
+ focusable: true,
68
+ hoverTheme: true,
69
+ pressTheme: true,
70
+ backgrounded: true,
71
+ borderWidth: 1,
72
+ borderColor: "transparent",
73
+ justifyContent: "center",
74
+ alignItems: "center",
75
+ flexWrap: "nowrap",
76
+ flexDirection: "row",
77
+ cursor: "pointer",
78
+ pressStyle: {
79
+ borderColor: "transparent"
80
+ },
81
+ hoverStyle: {
82
+ borderColor: "transparent"
83
+ },
84
+ focusStyle: {
85
+ borderColor: "$borderColorFocus"
86
+ },
87
+ variants: {
88
+ size: {
89
+ "...size": import_core.getButtonSize
90
+ },
91
+ active: {
92
+ true: {
93
+ hoverStyle: {
94
+ backgroundColor: "$background"
95
+ }
96
+ }
97
+ },
98
+ disabled: {
99
+ true: {
100
+ opacity: 0.5,
101
+ pointerEvents: "none"
102
+ }
103
+ }
104
+ },
105
+ defaultVariants: {
106
+ size: "$4"
107
+ }
108
+ });
109
+ const ButtonText = (0, import_core.styled)(import_text.SizableText, {
110
+ color: "$color",
111
+ selectable: false,
112
+ cursor: "inherit",
113
+ flexGrow: 0,
114
+ flexShrink: 1,
115
+ ellipse: true
116
+ });
117
+ const ButtonComponent = (0, import_react.forwardRef)((props, ref) => {
118
+ const _a = props, {
119
+ children,
120
+ icon,
121
+ iconAfter,
122
+ noTextWrap,
123
+ theme: themeName,
124
+ space,
125
+ spaceFlex,
126
+ scaleIcon = 1,
127
+ scaleSpace = 0.66,
128
+ separator,
129
+ color,
130
+ fontWeight,
131
+ letterSpacing,
132
+ fontSize,
133
+ fontFamily,
134
+ textAlign,
135
+ textProps
136
+ } = _a, rest = __objRest(_a, [
137
+ "children",
138
+ "icon",
139
+ "iconAfter",
140
+ "noTextWrap",
141
+ "theme",
142
+ "space",
143
+ "spaceFlex",
144
+ "scaleIcon",
145
+ "scaleSpace",
146
+ "separator",
147
+ "color",
148
+ "fontWeight",
149
+ "letterSpacing",
150
+ "fontSize",
151
+ "fontFamily",
152
+ "textAlign",
153
+ "textProps"
154
+ ]);
155
+ const isInsideButton = (0, import_react.useContext)(import_core.ButtonInsideButtonContext);
156
+ const size = props.size || "$4";
157
+ const iconSize = (typeof size === "number" ? size * 0.5 : (0, import_font_size.getFontSize)(size)) * scaleIcon;
158
+ const getThemedIcon = (0, import_helpers_tamagui.useGetThemedIcon)({ size: iconSize, color });
159
+ const [themedIcon, themedIconAfter] = [icon, iconAfter].map(getThemedIcon);
160
+ const spaceSize = (0, import_core.getVariableValue)(iconSize) * scaleSpace;
161
+ const contents = (0, import_text.wrapChildrenInText)(ButtonText, props);
162
+ return /* @__PURE__ */ import_react.default.createElement(ButtonFrame, __spreadValues(__spreadProps(__spreadValues({
163
+ fontFamily
164
+ }, isInsideButton && {
165
+ tag: "span"
166
+ }), {
167
+ ref
168
+ }), rest), /* @__PURE__ */ import_react.default.createElement(import_core.ButtonInsideButtonContext.Provider, {
169
+ value: true
170
+ }, themedIcon || themedIconAfter ? (0, import_core.spacedChildren)({
171
+ space: spaceSize,
172
+ spaceFlex,
173
+ separator,
174
+ direction: props.flexDirection === "column" || props.flexDirection === "column-reverse" ? "vertical" : "horizontal",
175
+ children: [themedIcon, contents, themedIconAfter]
176
+ }) : contents));
177
+ });
178
+ const Button = ButtonFrame.extractable((0, import_core.themeable)(ButtonComponent), {
179
+ inlineProps: /* @__PURE__ */ new Set([
180
+ "color",
181
+ "fontWeight",
182
+ "fontSize",
183
+ "fontFamily",
184
+ "letterSpacing",
185
+ "textAlign"
186
+ ])
187
+ });
188
+ // Annotate the CommonJS export names for ESM import in node:
189
+ 0 && (module.exports = {
190
+ Button,
191
+ ButtonFrame,
192
+ ButtonText
193
+ });
194
+ //# sourceMappingURL=Button.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/Button.tsx"],
4
+ "sourcesContent": ["import {\n ButtonInsideButtonContext,\n GetProps,\n TamaguiComponent,\n ThemeableProps,\n getButtonSize,\n getVariableValue,\n spacedChildren,\n styled,\n themeable,\n} from '@tamagui/core'\nimport { getFontSize } from '@tamagui/font-size'\nimport { TextParentStyles, useGetThemedIcon } from '@tamagui/helpers-tamagui'\nimport { ThemeableStack } from '@tamagui/stacks'\nimport { SizableText, wrapChildrenInText } from '@tamagui/text'\nimport React, { FunctionComponent, forwardRef, useContext } from 'react'\nimport { View } from 'react-native'\n\n// bugfix esbuild strips react jsx: 'preserve'\nReact['createElement']\n\ntype ButtonIconProps = { color?: string; size?: number }\ntype IconProp = JSX.Element | FunctionComponent<ButtonIconProps> | null\n\nexport type ButtonProps = Omit<TextParentStyles, 'TextComponent'> &\n GetProps<typeof ButtonFrame> &\n ThemeableProps & {\n // add icon before, passes color and size automatically if Component\n icon?: IconProp\n // add icon after, passes color and size automatically if Component\n iconAfter?: IconProp\n // adjust icon relative to size\n // default: -1\n scaleIcon?: number\n // dont wrap inner contents in a text element\n noTextWrap?: boolean\n // make the spacing elements flex\n spaceFlex?: number | boolean\n // adjust internal space relative to icon size\n scaleSpace?: number\n }\n\nexport const ButtonFrame = styled(ThemeableStack, {\n name: 'Button',\n tag: 'button',\n focusable: true,\n hoverTheme: true,\n pressTheme: true,\n backgrounded: true,\n borderWidth: 1,\n borderColor: 'transparent',\n justifyContent: 'center',\n alignItems: 'center',\n flexWrap: 'nowrap',\n flexDirection: 'row',\n\n // if we wanted this only when pressable = true, we'd need to merge variants?\n cursor: 'pointer',\n\n pressStyle: {\n borderColor: 'transparent',\n },\n\n hoverStyle: {\n borderColor: 'transparent',\n },\n\n focusStyle: {\n borderColor: '$borderColorFocus',\n },\n\n variants: {\n size: {\n '...size': getButtonSize,\n },\n\n active: {\n true: {\n hoverStyle: {\n backgroundColor: '$background',\n },\n },\n },\n\n disabled: {\n true: {\n opacity: 0.5,\n pointerEvents: 'none',\n },\n },\n } as const,\n\n defaultVariants: {\n size: '$4',\n },\n})\n\n// see TODO breaking types\n// type x = GetProps<typeof ButtonFrame>\n// type y = x['size']\n\nexport const ButtonText = styled(SizableText, {\n color: '$color',\n selectable: false,\n cursor: 'inherit',\n // flexGrow 1 leads to inconsistent native style where text pushes to start of view\n flexGrow: 0,\n flexShrink: 1,\n ellipse: true,\n})\n\nconst ButtonComponent = forwardRef((props: ButtonProps, ref) => {\n // careful not to desctructure and re-order props, order is important\n const {\n children,\n icon,\n iconAfter,\n noTextWrap,\n theme: themeName,\n space,\n spaceFlex,\n scaleIcon = 1,\n scaleSpace = 0.66,\n separator,\n\n // text props\n color,\n fontWeight,\n letterSpacing,\n fontSize,\n fontFamily,\n textAlign,\n textProps,\n ...rest\n } = props as ButtonProps\n\n const isInsideButton = useContext(ButtonInsideButtonContext)\n const size = props.size || '$4'\n const iconSize = (typeof size === 'number' ? size * 0.5 : getFontSize(size)) * scaleIcon\n const getThemedIcon = useGetThemedIcon({ size: iconSize, color })\n const [themedIcon, themedIconAfter] = [icon, iconAfter].map(getThemedIcon)\n const spaceSize = getVariableValue(iconSize) * scaleSpace\n const contents = wrapChildrenInText(ButtonText, props)\n\n return (\n <ButtonFrame\n fontFamily={fontFamily}\n // fixes SSR issue + DOM nesting issue of not allowing button in button\n {...(isInsideButton && {\n tag: 'span',\n })}\n ref={ref as any}\n {...rest}\n >\n <ButtonInsideButtonContext.Provider value={true}>\n {themedIcon || themedIconAfter\n ? spacedChildren({\n // a bit arbitrary but scaling to font size is necessary so long as button does\n space: spaceSize,\n spaceFlex,\n separator,\n direction:\n props.flexDirection === 'column' || props.flexDirection === 'column-reverse'\n ? 'vertical'\n : 'horizontal',\n children: [themedIcon, contents, themedIconAfter],\n })\n : contents}\n </ButtonInsideButtonContext.Provider>\n </ButtonFrame>\n )\n})\n\nexport const Button: TamaguiComponent<ButtonProps, HTMLButtonElement | View> =\n ButtonFrame.extractable(themeable(ButtonComponent as any) as any, {\n inlineProps: new Set([\n // text props go here (can't really optimize them, but we never fully extract button anyway)\n 'color',\n 'fontWeight',\n 'fontSize',\n 'fontFamily',\n 'letterSpacing',\n 'textAlign',\n ]),\n })\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAUO;AACP,uBAA4B;AAC5B,6BAAmD;AACnD,oBAA+B;AAC/B,kBAAgD;AAChD,mBAAiE;AAIjE,qBAAM;AAuBC,MAAM,cAAc,wBAAO,8BAAgB;AAAA,EAChD,MAAM;AAAA,EACN,KAAK;AAAA,EACL,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,aAAa;AAAA,EACb,aAAa;AAAA,EACb,gBAAgB;AAAA,EAChB,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,eAAe;AAAA,EAGf,QAAQ;AAAA,EAER,YAAY;AAAA,IACV,aAAa;AAAA,EACf;AAAA,EA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M,UAAU,MAAM,CAAC;AAChE,QAAM,CAAC,YAAY,mBAAmB,CAAC,MAAM,SAAS,EAAE,IAAI,aAAa;AACzE,QAAM,YAAY,kCAAiB,QAAQ,IAAI;AAC/C,QAAM,WAAW,oCAAmB,YAAY,KAAK;AAErD,SACE,mDAAC;AAAA,IACC;AAAA,KAEK,kBAAkB;AAAA,IACrB,KAAK;AAAA,EACP,IALD;AAAA,IAMC;AAAA,MACI,OAEJ,mDAAC,sCAA0B,UAA1B;AAAA,IAAmC,OAAO;AAAA,KACxC,cAAc,kBACX,gCAAe;AAAA,IAEb,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA,WACE,MAAM,kBAAkB,YAAY,MAAM,kBAAkB,mBACxD,aACA;AAAA,IACN,UAAU,CAAC,YAAY,UAAU,eAAe;AAAA,EAClD,CAAC,IACD,QACN,CACF;AAEJ,CAAC;AAEM,MAAM,SACX,YAAY,YAAY,2BAAU,eAAsB,GAAU;AAAA,EAChE,aAAa,oBAAI,IAAI;AAAA,IAEnB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACH,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,18 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var src_exports = {};
16
+ module.exports = __toCommonJS(src_exports);
17
+ __reExport(src_exports, require("./Button"), module.exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "sourcesContent": ["export * from './Button'\n"],
5
+ "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,qBAAd;",
6
+ "names": []
7
+ }
@@ -0,0 +1,175 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __objRest = (source, exclude) => {
21
+ var target = {};
22
+ for (var prop in source)
23
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
+ target[prop] = source[prop];
25
+ if (source != null && __getOwnPropSymbols)
26
+ for (var prop of __getOwnPropSymbols(source)) {
27
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
+ target[prop] = source[prop];
29
+ }
30
+ return target;
31
+ };
32
+ import {
33
+ ButtonInsideButtonContext,
34
+ getButtonSize,
35
+ getVariableValue,
36
+ spacedChildren,
37
+ styled,
38
+ themeable
39
+ } from "@tamagui/core";
40
+ import { getFontSize } from "@tamagui/font-size";
41
+ import { useGetThemedIcon } from "@tamagui/helpers-tamagui";
42
+ import { ThemeableStack } from "@tamagui/stacks";
43
+ import { SizableText, wrapChildrenInText } from "@tamagui/text";
44
+ import React, { forwardRef, useContext } from "react";
45
+ React["createElement"];
46
+ const ButtonFrame = styled(ThemeableStack, {
47
+ name: "Button",
48
+ tag: "button",
49
+ focusable: true,
50
+ hoverTheme: true,
51
+ pressTheme: true,
52
+ backgrounded: true,
53
+ borderWidth: 1,
54
+ borderColor: "transparent",
55
+ justifyContent: "center",
56
+ alignItems: "center",
57
+ flexWrap: "nowrap",
58
+ flexDirection: "row",
59
+ cursor: "pointer",
60
+ pressStyle: {
61
+ borderColor: "transparent"
62
+ },
63
+ hoverStyle: {
64
+ borderColor: "transparent"
65
+ },
66
+ focusStyle: {
67
+ borderColor: "$borderColorFocus"
68
+ },
69
+ variants: {
70
+ size: {
71
+ "...size": getButtonSize
72
+ },
73
+ active: {
74
+ true: {
75
+ hoverStyle: {
76
+ backgroundColor: "$background"
77
+ }
78
+ }
79
+ },
80
+ disabled: {
81
+ true: {
82
+ opacity: 0.5,
83
+ pointerEvents: "none"
84
+ }
85
+ }
86
+ },
87
+ defaultVariants: {
88
+ size: "$4"
89
+ }
90
+ });
91
+ const ButtonText = styled(SizableText, {
92
+ color: "$color",
93
+ selectable: false,
94
+ cursor: "inherit",
95
+ flexGrow: 0,
96
+ flexShrink: 1,
97
+ ellipse: true
98
+ });
99
+ const ButtonComponent = forwardRef((props, ref) => {
100
+ const _a = props, {
101
+ children,
102
+ icon,
103
+ iconAfter,
104
+ noTextWrap,
105
+ theme: themeName,
106
+ space,
107
+ spaceFlex,
108
+ scaleIcon = 1,
109
+ scaleSpace = 0.66,
110
+ separator,
111
+ color,
112
+ fontWeight,
113
+ letterSpacing,
114
+ fontSize,
115
+ fontFamily,
116
+ textAlign,
117
+ textProps
118
+ } = _a, rest = __objRest(_a, [
119
+ "children",
120
+ "icon",
121
+ "iconAfter",
122
+ "noTextWrap",
123
+ "theme",
124
+ "space",
125
+ "spaceFlex",
126
+ "scaleIcon",
127
+ "scaleSpace",
128
+ "separator",
129
+ "color",
130
+ "fontWeight",
131
+ "letterSpacing",
132
+ "fontSize",
133
+ "fontFamily",
134
+ "textAlign",
135
+ "textProps"
136
+ ]);
137
+ const isInsideButton = useContext(ButtonInsideButtonContext);
138
+ const size = props.size || "$4";
139
+ const iconSize = (typeof size === "number" ? size * 0.5 : getFontSize(size)) * scaleIcon;
140
+ const getThemedIcon = useGetThemedIcon({ size: iconSize, color });
141
+ const [themedIcon, themedIconAfter] = [icon, iconAfter].map(getThemedIcon);
142
+ const spaceSize = getVariableValue(iconSize) * scaleSpace;
143
+ const contents = wrapChildrenInText(ButtonText, props);
144
+ return /* @__PURE__ */ React.createElement(ButtonFrame, __spreadValues(__spreadProps(__spreadValues({
145
+ fontFamily
146
+ }, isInsideButton && {
147
+ tag: "span"
148
+ }), {
149
+ ref
150
+ }), rest), /* @__PURE__ */ React.createElement(ButtonInsideButtonContext.Provider, {
151
+ value: true
152
+ }, themedIcon || themedIconAfter ? spacedChildren({
153
+ space: spaceSize,
154
+ spaceFlex,
155
+ separator,
156
+ direction: props.flexDirection === "column" || props.flexDirection === "column-reverse" ? "vertical" : "horizontal",
157
+ children: [themedIcon, contents, themedIconAfter]
158
+ }) : contents));
159
+ });
160
+ const Button = ButtonFrame.extractable(themeable(ButtonComponent), {
161
+ inlineProps: /* @__PURE__ */ new Set([
162
+ "color",
163
+ "fontWeight",
164
+ "fontSize",
165
+ "fontFamily",
166
+ "letterSpacing",
167
+ "textAlign"
168
+ ])
169
+ });
170
+ export {
171
+ Button,
172
+ ButtonFrame,
173
+ ButtonText
174
+ };
175
+ //# sourceMappingURL=Button.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/Button.tsx"],
4
+ "sourcesContent": ["import {\n ButtonInsideButtonContext,\n GetProps,\n TamaguiComponent,\n ThemeableProps,\n getButtonSize,\n getVariableValue,\n spacedChildren,\n styled,\n themeable,\n} from '@tamagui/core'\nimport { getFontSize } from '@tamagui/font-size'\nimport { TextParentStyles, useGetThemedIcon } from '@tamagui/helpers-tamagui'\nimport { ThemeableStack } from '@tamagui/stacks'\nimport { SizableText, wrapChildrenInText } from '@tamagui/text'\nimport React, { FunctionComponent, forwardRef, useContext } from 'react'\nimport { View } from 'react-native'\n\n// bugfix esbuild strips react jsx: 'preserve'\nReact['createElement']\n\ntype ButtonIconProps = { color?: string; size?: number }\ntype IconProp = JSX.Element | FunctionComponent<ButtonIconProps> | null\n\nexport type ButtonProps = Omit<TextParentStyles, 'TextComponent'> &\n GetProps<typeof ButtonFrame> &\n ThemeableProps & {\n // add icon before, passes color and size automatically if Component\n icon?: IconProp\n // add icon after, passes color and size automatically if Component\n iconAfter?: IconProp\n // adjust icon relative to size\n // default: -1\n scaleIcon?: number\n // dont wrap inner contents in a text element\n noTextWrap?: boolean\n // make the spacing elements flex\n spaceFlex?: number | boolean\n // adjust internal space relative to icon size\n scaleSpace?: number\n }\n\nexport const ButtonFrame = styled(ThemeableStack, {\n name: 'Button',\n tag: 'button',\n focusable: true,\n hoverTheme: true,\n pressTheme: true,\n backgrounded: true,\n borderWidth: 1,\n borderColor: 'transparent',\n justifyContent: 'center',\n alignItems: 'center',\n flexWrap: 'nowrap',\n flexDirection: 'row',\n\n // if we wanted this only when pressable = true, we'd need to merge variants?\n cursor: 'pointer',\n\n pressStyle: {\n borderColor: 'transparent',\n },\n\n hoverStyle: {\n borderColor: 'transparent',\n },\n\n focusStyle: {\n borderColor: '$borderColorFocus',\n },\n\n variants: {\n size: {\n '...size': getButtonSize,\n },\n\n active: {\n true: {\n hoverStyle: {\n backgroundColor: '$background',\n },\n },\n },\n\n disabled: {\n true: {\n opacity: 0.5,\n pointerEvents: 'none',\n },\n },\n } as const,\n\n defaultVariants: {\n size: '$4',\n },\n})\n\n// see TODO breaking types\n// type x = GetProps<typeof ButtonFrame>\n// type y = x['size']\n\nexport const ButtonText = styled(SizableText, {\n color: '$color',\n selectable: false,\n cursor: 'inherit',\n // flexGrow 1 leads to inconsistent native style where text pushes to start of view\n flexGrow: 0,\n flexShrink: 1,\n ellipse: true,\n})\n\nconst ButtonComponent = forwardRef((props: ButtonProps, ref) => {\n // careful not to desctructure and re-order props, order is important\n const {\n children,\n icon,\n iconAfter,\n noTextWrap,\n theme: themeName,\n space,\n spaceFlex,\n scaleIcon = 1,\n scaleSpace = 0.66,\n separator,\n\n // text props\n color,\n fontWeight,\n letterSpacing,\n fontSize,\n fontFamily,\n textAlign,\n textProps,\n ...rest\n } = props as ButtonProps\n\n const isInsideButton = useContext(ButtonInsideButtonContext)\n const size = props.size || '$4'\n const iconSize = (typeof size === 'number' ? size * 0.5 : getFontSize(size)) * scaleIcon\n const getThemedIcon = useGetThemedIcon({ size: iconSize, color })\n const [themedIcon, themedIconAfter] = [icon, iconAfter].map(getThemedIcon)\n const spaceSize = getVariableValue(iconSize) * scaleSpace\n const contents = wrapChildrenInText(ButtonText, props)\n\n return (\n <ButtonFrame\n fontFamily={fontFamily}\n // fixes SSR issue + DOM nesting issue of not allowing button in button\n {...(isInsideButton && {\n tag: 'span',\n })}\n ref={ref as any}\n {...rest}\n >\n <ButtonInsideButtonContext.Provider value={true}>\n {themedIcon || themedIconAfter\n ? spacedChildren({\n // a bit arbitrary but scaling to font size is necessary so long as button does\n space: spaceSize,\n spaceFlex,\n separator,\n direction:\n props.flexDirection === 'column' || props.flexDirection === 'column-reverse'\n ? 'vertical'\n : 'horizontal',\n children: [themedIcon, contents, themedIconAfter],\n })\n : contents}\n </ButtonInsideButtonContext.Provider>\n </ButtonFrame>\n )\n})\n\nexport const Button: TamaguiComponent<ButtonProps, HTMLButtonElement | View> =\n ButtonFrame.extractable(themeable(ButtonComponent as any) as any, {\n inlineProps: new Set([\n // text props go here (can't really optimize them, but we never fully extract button anyway)\n 'color',\n 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;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./Button";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "sourcesContent": ["export * from './Button'\n"],
5
+ "mappings": "AAAA;",
6
+ "names": []
7
+ }
@@ -0,0 +1,121 @@
1
+ import {
2
+ ButtonInsideButtonContext,
3
+ getButtonSize,
4
+ getVariableValue,
5
+ spacedChildren,
6
+ styled,
7
+ themeable
8
+ } from "@tamagui/core";
9
+ import { getFontSize } from "@tamagui/font-size";
10
+ import { useGetThemedIcon } from "@tamagui/helpers-tamagui";
11
+ import { ThemeableStack } from "@tamagui/stacks";
12
+ import { SizableText, wrapChildrenInText } from "@tamagui/text";
13
+ import React, { forwardRef, useContext } from "react";
14
+ React["createElement"];
15
+ const ButtonFrame = styled(ThemeableStack, {
16
+ name: "Button",
17
+ tag: "button",
18
+ focusable: true,
19
+ hoverTheme: true,
20
+ pressTheme: true,
21
+ backgrounded: true,
22
+ borderWidth: 1,
23
+ borderColor: "transparent",
24
+ justifyContent: "center",
25
+ alignItems: "center",
26
+ flexWrap: "nowrap",
27
+ flexDirection: "row",
28
+ cursor: "pointer",
29
+ pressStyle: {
30
+ borderColor: "transparent"
31
+ },
32
+ hoverStyle: {
33
+ borderColor: "transparent"
34
+ },
35
+ focusStyle: {
36
+ borderColor: "$borderColorFocus"
37
+ },
38
+ variants: {
39
+ size: {
40
+ "...size": getButtonSize
41
+ },
42
+ active: {
43
+ true: {
44
+ hoverStyle: {
45
+ backgroundColor: "$background"
46
+ }
47
+ }
48
+ },
49
+ disabled: {
50
+ true: {
51
+ opacity: 0.5,
52
+ pointerEvents: "none"
53
+ }
54
+ }
55
+ },
56
+ defaultVariants: {
57
+ size: "$4"
58
+ }
59
+ });
60
+ const ButtonText = styled(SizableText, {
61
+ color: "$color",
62
+ selectable: false,
63
+ cursor: "inherit",
64
+ flexGrow: 0,
65
+ flexShrink: 1,
66
+ ellipse: true
67
+ });
68
+ const ButtonComponent = forwardRef((props, ref) => {
69
+ const {
70
+ children,
71
+ icon,
72
+ iconAfter,
73
+ noTextWrap,
74
+ theme: themeName,
75
+ space,
76
+ spaceFlex,
77
+ scaleIcon = 1,
78
+ scaleSpace = 0.66,
79
+ separator,
80
+ color,
81
+ fontWeight,
82
+ letterSpacing,
83
+ fontSize,
84
+ fontFamily,
85
+ textAlign,
86
+ textProps,
87
+ ...rest
88
+ } = props;
89
+ const isInsideButton = useContext(ButtonInsideButtonContext);
90
+ const size = props.size || "$4";
91
+ const iconSize = (typeof size === "number" ? size * 0.5 : getFontSize(size)) * scaleIcon;
92
+ const getThemedIcon = useGetThemedIcon({ size: iconSize, color });
93
+ const [themedIcon, themedIconAfter] = [icon, iconAfter].map(getThemedIcon);
94
+ const spaceSize = getVariableValue(iconSize) * scaleSpace;
95
+ const contents = wrapChildrenInText(ButtonText, props);
96
+ return <ButtonFrame fontFamily={fontFamily} {...isInsideButton && {
97
+ tag: "span"
98
+ }} ref={ref} {...rest}><ButtonInsideButtonContext.Provider value={true}>{themedIcon || themedIconAfter ? spacedChildren({
99
+ space: spaceSize,
100
+ spaceFlex,
101
+ separator,
102
+ direction: props.flexDirection === "column" || props.flexDirection === "column-reverse" ? "vertical" : "horizontal",
103
+ children: [themedIcon, contents, themedIconAfter]
104
+ }) : contents}</ButtonInsideButtonContext.Provider></ButtonFrame>;
105
+ });
106
+ const Button = ButtonFrame.extractable(themeable(ButtonComponent), {
107
+ inlineProps: /* @__PURE__ */ new Set([
108
+ "color",
109
+ "fontWeight",
110
+ "fontSize",
111
+ "fontFamily",
112
+ "letterSpacing",
113
+ "textAlign"
114
+ ])
115
+ });
116
+ export {
117
+ Button,
118
+ ButtonFrame,
119
+ ButtonText
120
+ };
121
+ //# sourceMappingURL=Button.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/Button.tsx"],
4
+ "sourcesContent": ["import {\n ButtonInsideButtonContext,\n GetProps,\n TamaguiComponent,\n ThemeableProps,\n getButtonSize,\n getVariableValue,\n spacedChildren,\n styled,\n themeable,\n} from '@tamagui/core'\nimport { getFontSize } from '@tamagui/font-size'\nimport { TextParentStyles, useGetThemedIcon } from '@tamagui/helpers-tamagui'\nimport { ThemeableStack } from '@tamagui/stacks'\nimport { SizableText, wrapChildrenInText } from '@tamagui/text'\nimport React, { FunctionComponent, forwardRef, useContext } from 'react'\nimport { View } from 'react-native'\n\n// bugfix esbuild strips react jsx: 'preserve'\nReact['createElement']\n\ntype ButtonIconProps = { color?: string; size?: number }\ntype IconProp = JSX.Element | FunctionComponent<ButtonIconProps> | null\n\nexport type ButtonProps = Omit<TextParentStyles, 'TextComponent'> &\n GetProps<typeof ButtonFrame> &\n ThemeableProps & {\n // add icon before, passes color and size automatically if Component\n icon?: IconProp\n // add icon after, passes color and size automatically if Component\n iconAfter?: IconProp\n // adjust icon relative to size\n // default: -1\n scaleIcon?: number\n // dont wrap inner contents in a text element\n noTextWrap?: boolean\n // make the spacing elements flex\n spaceFlex?: number | boolean\n // adjust internal space relative to icon size\n scaleSpace?: number\n }\n\nexport const ButtonFrame = styled(ThemeableStack, {\n name: 'Button',\n tag: 'button',\n focusable: true,\n hoverTheme: true,\n pressTheme: true,\n backgrounded: true,\n borderWidth: 1,\n borderColor: 'transparent',\n justifyContent: 'center',\n alignItems: 'center',\n flexWrap: 'nowrap',\n flexDirection: 'row',\n\n // if we wanted this only when pressable = true, we'd need to merge variants?\n cursor: 'pointer',\n\n pressStyle: {\n borderColor: 'transparent',\n },\n\n hoverStyle: {\n borderColor: 'transparent',\n },\n\n focusStyle: {\n borderColor: '$borderColorFocus',\n },\n\n variants: {\n size: {\n '...size': getButtonSize,\n },\n\n active: {\n true: {\n hoverStyle: {\n backgroundColor: '$background',\n },\n },\n },\n\n disabled: {\n true: {\n opacity: 0.5,\n pointerEvents: 'none',\n },\n },\n } as const,\n\n defaultVariants: {\n size: '$4',\n },\n})\n\n// see TODO breaking types\n// type x = GetProps<typeof ButtonFrame>\n// type y = x['size']\n\nexport const ButtonText = styled(SizableText, {\n color: '$color',\n selectable: false,\n cursor: 'inherit',\n // flexGrow 1 leads to inconsistent native style where text pushes to start of view\n flexGrow: 0,\n flexShrink: 1,\n ellipse: true,\n})\n\nconst ButtonComponent = forwardRef((props: ButtonProps, ref) => {\n // careful not to desctructure and re-order props, order is important\n const {\n children,\n icon,\n iconAfter,\n noTextWrap,\n theme: themeName,\n space,\n spaceFlex,\n scaleIcon = 1,\n scaleSpace = 0.66,\n separator,\n\n // text props\n color,\n fontWeight,\n letterSpacing,\n fontSize,\n fontFamily,\n textAlign,\n textProps,\n ...rest\n } = props as ButtonProps\n\n const isInsideButton = useContext(ButtonInsideButtonContext)\n const size = props.size || '$4'\n const iconSize = (typeof size === 'number' ? size * 0.5 : getFontSize(size)) * scaleIcon\n const getThemedIcon = useGetThemedIcon({ size: iconSize, color })\n const [themedIcon, themedIconAfter] = [icon, iconAfter].map(getThemedIcon)\n const spaceSize = getVariableValue(iconSize) * scaleSpace\n const contents = wrapChildrenInText(ButtonText, props)\n\n return (\n <ButtonFrame\n fontFamily={fontFamily}\n // fixes SSR issue + DOM nesting issue of not allowing button in button\n {...(isInsideButton && {\n tag: 'span',\n })}\n ref={ref as any}\n {...rest}\n >\n <ButtonInsideButtonContext.Provider value={true}>\n {themedIcon || themedIconAfter\n ? spacedChildren({\n // a bit arbitrary but scaling to font size is necessary so long as button does\n space: spaceSize,\n spaceFlex,\n separator,\n direction:\n props.flexDirection === 'column' || props.flexDirection === 'column-reverse'\n ? 'vertical'\n : 'horizontal',\n children: [themedIcon, contents, themedIconAfter],\n })\n : contents}\n </ButtonInsideButtonContext.Provider>\n </ButtonFrame>\n )\n})\n\nexport const Button: TamaguiComponent<ButtonProps, HTMLButtonElement | View> =\n ButtonFrame.extractable(themeable(ButtonComponent as any) as any, {\n inlineProps: new Set([\n // text props go here (can't really optimize them, but we never fully extract button anyway)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AAa;AAAA,IACb;AAAA,IAGA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,OACG;AAAA,MACD;AAEJ,QAAM,iBAAiB,WAAW,yBAAyB;AAC3D,QAAM,OAAO,MAAM,QAAQ;AAC3B,QAAM,WAAY,QAAO,SAAS,WAAW,OAAO,MAAM,YAAY,IAAI,KAAK;AAC/E,QAAM,gBAAgB,iBAAiB,EAAE,MAAM,UAAU,MAAM,CAAC;AAChE,QAAM,CAAC,YAAY,mBAAmB,CAAC,MAAM,SAAS,EAAE,IAAI,aAAa;AACzE,QAAM,YAAY,iBAAiB,QAAQ,IAAI;AAC/C,QAAM,WAAW,mBAAmB,YAAY,KAAK;AAErD,SACE,CAAC,YACC,YAAY,gBAEP,kBAAkB;AAAA,IACrB,KAAK;AAAA,EACP,GACA,KAAK,SACD,MAEJ,CAAC,0BAA0B,SAAS,OAAO,OACxC,cAAc,kBACX,eAAe;AAAA,IAEb,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA,WACE,MAAM,kBAAkB,YAAY,MAAM,kBAAkB,mBACxD,aACA;AAAA,IACN,UAAU,CAAC,YAAY,UAAU,eAAe;AAAA,EAClD,CAAC,IACD,SACN,EAdC,0BAA0B,SAe7B,EAxBC;AA0BL,CAAC;AAEM,MAAM,SACX,YAAY,YAAY,UAAU,eAAsB,GAAU;AAAA,EAChE,aAAa,oBAAI,IAAI;AAAA,IAEnB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACH,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./Button";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "sourcesContent": ["export * from './Button'\n"],
5
+ "mappings": "AAAA;",
6
+ "names": []
7
+ }
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@tamagui/button",
3
+ "version": "1.0.1-beta.100",
4
+ "sideEffects": [
5
+ "*.css"
6
+ ],
7
+ "source": "src/index.ts",
8
+ "types": "./types/index.d.ts",
9
+ "main": "dist/cjs",
10
+ "module": "dist/esm",
11
+ "module:jsx": "dist/jsx",
12
+ "files": [
13
+ "src",
14
+ "types",
15
+ "dist"
16
+ ],
17
+ "scripts": {
18
+ "build": "tamagui-build",
19
+ "watch": "tamagui-build --watch"
20
+ },
21
+ "dependencies": {
22
+ "@tamagui/core": "^1.0.1-beta.100",
23
+ "@tamagui/font-size": "^1.0.1-beta.100",
24
+ "@tamagui/helpers-tamagui": "^1.0.1-beta.100"
25
+ },
26
+ "peerDependencies": {
27
+ "react": "*",
28
+ "react-dom": "*"
29
+ },
30
+ "devDependencies": {
31
+ "@tamagui/build": "^1.0.1-beta.100",
32
+ "react": "*",
33
+ "react-dom": "*"
34
+ },
35
+ "publishConfig": {
36
+ "access": "public"
37
+ },
38
+ "gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14"
39
+ }
package/src/Button.tsx ADDED
@@ -0,0 +1,185 @@
1
+ import {
2
+ ButtonInsideButtonContext,
3
+ GetProps,
4
+ TamaguiComponent,
5
+ ThemeableProps,
6
+ getButtonSize,
7
+ getVariableValue,
8
+ spacedChildren,
9
+ styled,
10
+ themeable,
11
+ } from '@tamagui/core'
12
+ import { getFontSize } from '@tamagui/font-size'
13
+ import { TextParentStyles, useGetThemedIcon } from '@tamagui/helpers-tamagui'
14
+ import { ThemeableStack } from '@tamagui/stacks'
15
+ import { SizableText, wrapChildrenInText } from '@tamagui/text'
16
+ import React, { FunctionComponent, forwardRef, useContext } from 'react'
17
+ import { View } from 'react-native'
18
+
19
+ // bugfix esbuild strips react jsx: 'preserve'
20
+ React['createElement']
21
+
22
+ type ButtonIconProps = { color?: string; size?: number }
23
+ type IconProp = JSX.Element | FunctionComponent<ButtonIconProps> | null
24
+
25
+ export type ButtonProps = Omit<TextParentStyles, 'TextComponent'> &
26
+ GetProps<typeof ButtonFrame> &
27
+ ThemeableProps & {
28
+ // add icon before, passes color and size automatically if Component
29
+ icon?: IconProp
30
+ // add icon after, passes color and size automatically if Component
31
+ iconAfter?: IconProp
32
+ // adjust icon relative to size
33
+ // default: -1
34
+ scaleIcon?: number
35
+ // dont wrap inner contents in a text element
36
+ noTextWrap?: boolean
37
+ // make the spacing elements flex
38
+ spaceFlex?: number | boolean
39
+ // adjust internal space relative to icon size
40
+ scaleSpace?: number
41
+ }
42
+
43
+ export const ButtonFrame = styled(ThemeableStack, {
44
+ name: 'Button',
45
+ tag: 'button',
46
+ focusable: true,
47
+ hoverTheme: true,
48
+ pressTheme: true,
49
+ backgrounded: true,
50
+ borderWidth: 1,
51
+ borderColor: 'transparent',
52
+ justifyContent: 'center',
53
+ alignItems: 'center',
54
+ flexWrap: 'nowrap',
55
+ flexDirection: 'row',
56
+
57
+ // if we wanted this only when pressable = true, we'd need to merge variants?
58
+ cursor: 'pointer',
59
+
60
+ pressStyle: {
61
+ borderColor: 'transparent',
62
+ },
63
+
64
+ hoverStyle: {
65
+ borderColor: 'transparent',
66
+ },
67
+
68
+ focusStyle: {
69
+ borderColor: '$borderColorFocus',
70
+ },
71
+
72
+ variants: {
73
+ size: {
74
+ '...size': getButtonSize,
75
+ },
76
+
77
+ active: {
78
+ true: {
79
+ hoverStyle: {
80
+ backgroundColor: '$background',
81
+ },
82
+ },
83
+ },
84
+
85
+ disabled: {
86
+ true: {
87
+ opacity: 0.5,
88
+ pointerEvents: 'none',
89
+ },
90
+ },
91
+ } as const,
92
+
93
+ defaultVariants: {
94
+ size: '$4',
95
+ },
96
+ })
97
+
98
+ // see TODO breaking types
99
+ // type x = GetProps<typeof ButtonFrame>
100
+ // type y = x['size']
101
+
102
+ export const ButtonText = styled(SizableText, {
103
+ color: '$color',
104
+ selectable: false,
105
+ cursor: 'inherit',
106
+ // flexGrow 1 leads to inconsistent native style where text pushes to start of view
107
+ flexGrow: 0,
108
+ flexShrink: 1,
109
+ ellipse: true,
110
+ })
111
+
112
+ const ButtonComponent = forwardRef((props: ButtonProps, ref) => {
113
+ // careful not to desctructure and re-order props, order is important
114
+ const {
115
+ children,
116
+ icon,
117
+ iconAfter,
118
+ noTextWrap,
119
+ theme: themeName,
120
+ space,
121
+ spaceFlex,
122
+ scaleIcon = 1,
123
+ scaleSpace = 0.66,
124
+ separator,
125
+
126
+ // text props
127
+ color,
128
+ fontWeight,
129
+ letterSpacing,
130
+ fontSize,
131
+ fontFamily,
132
+ textAlign,
133
+ textProps,
134
+ ...rest
135
+ } = props as ButtonProps
136
+
137
+ const isInsideButton = useContext(ButtonInsideButtonContext)
138
+ const size = props.size || '$4'
139
+ const iconSize = (typeof size === 'number' ? size * 0.5 : getFontSize(size)) * scaleIcon
140
+ const getThemedIcon = useGetThemedIcon({ size: iconSize, color })
141
+ const [themedIcon, themedIconAfter] = [icon, iconAfter].map(getThemedIcon)
142
+ const spaceSize = getVariableValue(iconSize) * scaleSpace
143
+ const contents = wrapChildrenInText(ButtonText, props)
144
+
145
+ return (
146
+ <ButtonFrame
147
+ fontFamily={fontFamily}
148
+ // fixes SSR issue + DOM nesting issue of not allowing button in button
149
+ {...(isInsideButton && {
150
+ tag: 'span',
151
+ })}
152
+ ref={ref as any}
153
+ {...rest}
154
+ >
155
+ <ButtonInsideButtonContext.Provider value={true}>
156
+ {themedIcon || themedIconAfter
157
+ ? spacedChildren({
158
+ // a bit arbitrary but scaling to font size is necessary so long as button does
159
+ space: spaceSize,
160
+ spaceFlex,
161
+ separator,
162
+ direction:
163
+ props.flexDirection === 'column' || props.flexDirection === 'column-reverse'
164
+ ? 'vertical'
165
+ : 'horizontal',
166
+ children: [themedIcon, contents, themedIconAfter],
167
+ })
168
+ : contents}
169
+ </ButtonInsideButtonContext.Provider>
170
+ </ButtonFrame>
171
+ )
172
+ })
173
+
174
+ export const Button: TamaguiComponent<ButtonProps, HTMLButtonElement | View> =
175
+ ButtonFrame.extractable(themeable(ButtonComponent as any) as any, {
176
+ inlineProps: new Set([
177
+ // text props go here (can't really optimize them, but we never fully extract button anyway)
178
+ 'color',
179
+ 'fontWeight',
180
+ 'fontSize',
181
+ 'fontFamily',
182
+ 'letterSpacing',
183
+ 'textAlign',
184
+ ]),
185
+ })
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './Button'
@@ -0,0 +1,124 @@
1
+ import { GetProps, TamaguiComponent, ThemeableProps } from '@tamagui/core';
2
+ import { TextParentStyles } from '@tamagui/helpers-tamagui';
3
+ import { FunctionComponent } from 'react';
4
+ import { View } from 'react-native';
5
+ declare type ButtonIconProps = {
6
+ color?: string;
7
+ size?: number;
8
+ };
9
+ declare type IconProp = JSX.Element | FunctionComponent<ButtonIconProps> | null;
10
+ export declare type ButtonProps = Omit<TextParentStyles, 'TextComponent'> & GetProps<typeof ButtonFrame> & ThemeableProps & {
11
+ icon?: IconProp;
12
+ iconAfter?: IconProp;
13
+ scaleIcon?: number;
14
+ noTextWrap?: boolean;
15
+ spaceFlex?: number | boolean;
16
+ scaleSpace?: number;
17
+ };
18
+ export declare const ButtonFrame: TamaguiComponent<Omit<import("react-native").ViewProps, "display" | "children"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{
19
+ readonly fullscreen?: boolean | undefined;
20
+ readonly elevation?: import("@tamagui/core").SizeTokens | undefined;
21
+ } & {
22
+ fontFamily?: unknown;
23
+ backgrounded?: boolean | undefined;
24
+ radiused?: boolean | undefined;
25
+ hoverTheme?: boolean | undefined;
26
+ pressTheme?: boolean | undefined;
27
+ focusTheme?: boolean | undefined;
28
+ circular?: boolean | undefined;
29
+ padded?: boolean | undefined;
30
+ elevate?: boolean | undefined;
31
+ bordered?: number | boolean | undefined;
32
+ transparent?: boolean | undefined;
33
+ chromeless?: boolean | undefined;
34
+ }, "disabled" | "size" | "active"> & {
35
+ readonly size?: import("@tamagui/core").SizeTokens | undefined;
36
+ readonly active?: boolean | undefined;
37
+ readonly disabled?: boolean | undefined;
38
+ } & import("@tamagui/core").MediaProps<Partial<Omit<import("react-native").ViewProps, "display" | "children"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{
39
+ readonly fullscreen?: boolean | undefined;
40
+ readonly elevation?: import("@tamagui/core").SizeTokens | undefined;
41
+ } & {
42
+ fontFamily?: unknown;
43
+ backgrounded?: boolean | undefined;
44
+ radiused?: boolean | undefined;
45
+ hoverTheme?: boolean | undefined;
46
+ pressTheme?: boolean | undefined;
47
+ focusTheme?: boolean | undefined;
48
+ circular?: boolean | undefined;
49
+ padded?: boolean | undefined;
50
+ elevate?: boolean | undefined;
51
+ bordered?: number | boolean | undefined;
52
+ transparent?: boolean | undefined;
53
+ chromeless?: boolean | undefined;
54
+ }, "disabled" | "size" | "active"> & {
55
+ readonly size?: import("@tamagui/core").SizeTokens | undefined;
56
+ readonly active?: boolean | undefined;
57
+ readonly disabled?: boolean | undefined;
58
+ }>> & import("@tamagui/core").PseudoProps<Partial<Omit<import("react-native").ViewProps, "display" | "children"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{
59
+ readonly fullscreen?: boolean | undefined;
60
+ readonly elevation?: import("@tamagui/core").SizeTokens | undefined;
61
+ } & {
62
+ fontFamily?: unknown;
63
+ backgrounded?: boolean | undefined;
64
+ radiused?: boolean | undefined;
65
+ hoverTheme?: boolean | undefined;
66
+ pressTheme?: boolean | undefined;
67
+ focusTheme?: boolean | undefined;
68
+ circular?: boolean | undefined;
69
+ padded?: boolean | undefined;
70
+ elevate?: boolean | undefined;
71
+ bordered?: number | boolean | undefined;
72
+ transparent?: boolean | undefined;
73
+ chromeless?: boolean | undefined;
74
+ }, "disabled" | "size" | "active"> & {
75
+ readonly size?: import("@tamagui/core").SizeTokens | undefined;
76
+ readonly active?: boolean | undefined;
77
+ readonly disabled?: boolean | undefined;
78
+ }>>, any, import("@tamagui/core").StackPropsBase, {
79
+ readonly fullscreen?: boolean | undefined;
80
+ readonly elevation?: import("@tamagui/core").SizeTokens | undefined;
81
+ } & {
82
+ fontFamily?: unknown;
83
+ backgrounded?: boolean | undefined;
84
+ radiused?: boolean | undefined;
85
+ hoverTheme?: boolean | undefined;
86
+ pressTheme?: boolean | undefined;
87
+ focusTheme?: boolean | undefined;
88
+ circular?: boolean | undefined;
89
+ padded?: boolean | undefined;
90
+ elevate?: boolean | undefined;
91
+ bordered?: number | boolean | undefined;
92
+ transparent?: boolean | undefined;
93
+ chromeless?: boolean | undefined;
94
+ } & {
95
+ readonly size?: import("@tamagui/core").SizeTokens | undefined;
96
+ readonly active?: boolean | undefined;
97
+ readonly disabled?: boolean | undefined;
98
+ }>;
99
+ export declare const ButtonText: TamaguiComponent<(Omit<import("react-native").TextProps, "children"> & import("@tamagui/core").RNWTextProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").TextStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").TextStylePropsBase>> & Omit<{}, "size"> & {
100
+ size?: import("@tamagui/core").FontSizeTokens | undefined;
101
+ } & import("@tamagui/core").MediaProps<Partial<Omit<import("react-native").TextProps, "children"> & import("@tamagui/core").RNWTextProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").TextStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").TextStylePropsBase>> & Omit<{}, "size"> & {
102
+ size?: import("@tamagui/core").FontSizeTokens | undefined;
103
+ }>> & import("@tamagui/core").PseudoProps<Partial<Omit<import("react-native").TextProps, "children"> & import("@tamagui/core").RNWTextProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").TextStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").TextStylePropsBase>> & Omit<{}, "size"> & {
104
+ size?: import("@tamagui/core").FontSizeTokens | undefined;
105
+ }>>) | (Omit<import("react-native").TextProps, "children"> & import("@tamagui/core").RNWTextProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").TextStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").TextStylePropsBase>> & Omit<{
106
+ size?: import("@tamagui/core").FontSizeTokens | undefined;
107
+ }, string | number> & {
108
+ [x: string]: undefined;
109
+ } & import("@tamagui/core").MediaProps<Partial<Omit<import("react-native").TextProps, "children"> & import("@tamagui/core").RNWTextProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").TextStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").TextStylePropsBase>> & Omit<{
110
+ size?: import("@tamagui/core").FontSizeTokens | undefined;
111
+ }, string | number> & {
112
+ [x: string]: undefined;
113
+ }>> & import("@tamagui/core").PseudoProps<Partial<Omit<import("react-native").TextProps, "children"> & import("@tamagui/core").RNWTextProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").TextStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").TextStylePropsBase>> & Omit<{
114
+ size?: import("@tamagui/core").FontSizeTokens | undefined;
115
+ }, string | number> & {
116
+ [x: string]: undefined;
117
+ }>>), any, import("@tamagui/core").TextPropsBase, {
118
+ size?: import("@tamagui/core").FontSizeTokens | undefined;
119
+ } & ({} | {
120
+ [x: string]: undefined;
121
+ })>;
122
+ export declare const Button: TamaguiComponent<ButtonProps, HTMLButtonElement | View>;
123
+ export {};
124
+ //# sourceMappingURL=Button.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../src/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EACR,gBAAgB,EAChB,cAAc,EAMf,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,gBAAgB,EAAoB,MAAM,0BAA0B,CAAA;AAG7E,OAAc,EAAE,iBAAiB,EAA0B,MAAM,OAAO,CAAA;AACxE,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAKnC,aAAK,eAAe,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AACxD,aAAK,QAAQ,GAAG,GAAG,CAAC,OAAO,GAAG,iBAAiB,CAAC,eAAe,CAAC,GAAG,IAAI,CAAA;AAEvE,oBAAY,WAAW,GAAG,IAAI,CAAC,gBAAgB,EAAE,eAAe,CAAC,GAC/D,QAAQ,CAAC,OAAO,WAAW,CAAC,GAC5B,cAAc,GAAG;IAEf,IAAI,CAAC,EAAE,QAAQ,CAAA;IAEf,SAAS,CAAC,EAAE,QAAQ,CAAA;IAGpB,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB,UAAU,CAAC,EAAE,OAAO,CAAA;IAEpB,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IAE5B,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,CAAA;AAEH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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