@tamagui/button 1.0.1-beta.219 → 1.0.1-beta.221

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.
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,10 +15,6 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
- mod
23
- ));
24
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
19
  var Button_exports = {};
26
20
  __export(Button_exports, {
@@ -38,10 +32,10 @@ var import_get_button_sized = require("@tamagui/get-button-sized");
38
32
  var import_helpers_tamagui = require("@tamagui/helpers-tamagui");
39
33
  var import_stacks = require("@tamagui/stacks");
40
34
  var import_text = require("@tamagui/text");
41
- var import_react = __toESM(require("react"));
42
- import_react.default["createElement"];
35
+ var import_react = require("react");
36
+ const NAME = "Button";
43
37
  const ButtonFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
44
- name: "Button",
38
+ name: NAME,
45
39
  tag: "button",
46
40
  focusable: true,
47
41
  hoverTheme: true,
@@ -76,7 +70,6 @@ const ButtonFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
76
70
  },
77
71
  disabled: {
78
72
  true: {
79
- opacity: 0.375,
80
73
  pointerEvents: "none"
81
74
  }
82
75
  }
@@ -114,7 +107,7 @@ function useButton(props, { Text = ButtonText } = { Text: ButtonText }) {
114
107
  textProps,
115
108
  ...rest
116
109
  } = props;
117
- const isInsideButton = import_core.isRSC ? false : (0, import_react.useContext)(import_core.ButtonInsideButtonContext);
110
+ const isNested = import_core.isRSC ? false : (0, import_react.useContext)(import_core.ButtonNestingContext);
118
111
  const mediaActiveProps = (0, import_core.useMediaPropsActive)(props);
119
112
  const size = mediaActiveProps.size || "$4";
120
113
  const iconSize = (typeof size === "number" ? size * 0.5 : (0, import_font_size.getFontSize)(size)) * scaleIcon;
@@ -131,7 +124,7 @@ function useButton(props, { Text = ButtonText } = { Text: ButtonText }) {
131
124
  }) : contents;
132
125
  return {
133
126
  spaceSize,
134
- isInsideButton,
127
+ isNested,
135
128
  props: {
136
129
  ...props.disabled && {
137
130
  focusable: void 0,
@@ -139,11 +132,11 @@ function useButton(props, { Text = ButtonText } = { Text: ButtonText }) {
139
132
  borderColor: "$background"
140
133
  }
141
134
  },
142
- ...isInsideButton && {
135
+ ...isNested ? {
143
136
  tag: "span"
144
- },
137
+ } : {},
145
138
  ...rest,
146
- children: import_core.isRSC ? inner : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.ButtonInsideButtonContext.Provider, {
139
+ children: import_core.isRSC ? inner : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.ButtonNestingContext.Provider, {
147
140
  value: true,
148
141
  children: inner
149
142
  })
@@ -167,7 +160,10 @@ const buttonStaticConfig = {
167
160
  "textAlign"
168
161
  ])
169
162
  };
170
- const Button2 = ButtonFrame.extractable((0, import_core.themeable)(ButtonComponent), buttonStaticConfig);
163
+ const Button2 = ButtonFrame.extractable(
164
+ (0, import_core.themeable)(ButtonComponent, ButtonFrame.staticConfig),
165
+ buttonStaticConfig
166
+ );
171
167
  // Annotate the CommonJS export names for ESM import in node:
172
168
  0 && (module.exports = {
173
169
  Button,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/Button.tsx"],
4
- "sourcesContent": ["import {\n ButtonInsideButtonContext,\n GetProps,\n TamaguiElement,\n ThemeableProps,\n getVariableValue,\n isRSC,\n spacedChildren,\n styled,\n themeable,\n useMediaPropsActive,\n} from '@tamagui/core'\nimport { getFontSize } from '@tamagui/font-size'\nimport { getButtonSized } from '@tamagui/get-button-sized'\nimport { useGetThemedIcon } from '@tamagui/helpers-tamagui'\nimport { ThemeableStack } from '@tamagui/stacks'\nimport { SizableText, TextParentStyles, wrapChildrenInText } from '@tamagui/text'\nimport React, { FunctionComponent, forwardRef, useContext } from 'react'\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 /**\n * add icon before, passes color and size automatically if Component\n */\n icon?: IconProp\n /**\n * add icon after, passes color and size automatically if Component\n */\n iconAfter?: IconProp\n /**\n * adjust icon relative to size\n */\n /**\n * default: -1\n */\n scaleIcon?: number\n /**\n * make the spacing elements flex\n */\n spaceFlex?: number | boolean\n /**\n * adjust internal space relative to icon size\n */\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': getButtonSized,\n },\n\n active: {\n true: {\n hoverStyle: {\n backgroundColor: '$background',\n },\n },\n },\n\n disabled: {\n true: {\n opacity: 0.375,\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 userSelect: 'none',\n cursor: 'pointer',\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\nexport function useButton(\n props: ButtonProps,\n { Text = ButtonText }: { Text: any } = { Text: ButtonText }\n) {\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\n\n const isInsideButton = isRSC ? false : useContext(ButtonInsideButtonContext)\n const mediaActiveProps = useMediaPropsActive(props)\n const size = mediaActiveProps.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(Text, mediaActiveProps)\n const inner =\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\n return {\n spaceSize,\n isInsideButton,\n props: {\n ...(props.disabled && {\n // in rnw - false still has keyboard tabIndex, undefined = not actually focusable\n focusable: undefined,\n // even with tabIndex unset, it will keep focusStyle on web so disable it here\n focusStyle: {\n borderColor: '$background',\n },\n }),\n // fixes SSR issue + DOM nesting issue of not allowing button in button\n ...(isInsideButton && {\n tag: 'span',\n }),\n ...rest,\n children: isRSC ? (\n inner\n ) : (\n <ButtonInsideButtonContext.Provider value={true}>\n {inner}\n </ButtonInsideButtonContext.Provider>\n ),\n },\n }\n}\n\nconst ButtonComponent = forwardRef<TamaguiElement, ButtonProps>(function Button(props, ref) {\n const { props: buttonProps } = useButton(props)\n return <ButtonFrame {...buttonProps} ref={ref} />\n})\n\nexport const buttonStaticConfig = {\n inlineProps: new Set([\n // text props go here (can't really optimize them, but we never fully extract button anyway)\n // may be able to remove this entirely, as the compiler / runtime have gotten better\n 'color',\n 'fontWeight',\n 'fontSize',\n 'fontFamily',\n 'letterSpacing',\n 'textAlign',\n ]),\n}\n\nexport const Button = ButtonFrame.extractable(themeable(ButtonComponent), buttonStaticConfig)\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,gBAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiMQ;AAjMR,kBAWO;AACP,uBAA4B;AAC5B,8BAA+B;AAC/B,6BAAiC;AACjC,oBAA+B;AAC/B,kBAAkE;AAClE,mBAAiE;AAGjE,aAAAC,QAAM;AAiCC,MAAM,kBAAc,oBAAO,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,EAEA,YAAY;AAAA,IACV,aAAa;AAAA,EACf;AAAA,EAEA,YAAY;AAAA,IACV,aAAa;AAAA,EACf;AAAA,EAEA,UAAU;AAAA,IACR,MAAM;AAAA,MACJ,WAAW;AAAA,IACb;AAAA,IAEA,QAAQ;AAAA,MACN,MAAM;AAAA,QACJ,YAAY;AAAA,UAC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,UAAU,CAAC,YAAY,UAAU,eAAe;AAAA,EAClD,CAAC,IACD;AAEN,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,OAAO;AAAA,MACL,GAAI,MAAM,YAAY;AAAA,QAEpB,WAAW;AAAA,QAEX,YAAY;AAAA,UACV,aAAa;AAAA,QACf;AAAA,MACF;AAAA,MAEA,GAAI,kBAAkB;AAAA,QACpB,KAAK;AAAA,MACP;AAAA,MACA,GAAG;AAAA,MACH,UAAU,oBACR,QAEA,4CAAC,sCAA0B,UAA1B;AAAA,QAAmC,OAAO;AAAA,QACxC;AAAA,OACH;AAAA,IAEJ;AAAA,EACF;AACF;AAEA,MAAM,sBAAkB,yBAAwC,SAAS,OAAO,OAAO,KAAK;AAC1F,QAAM,EAAE,OAAO,YAAY,IAAI,UAAU,KAAK;AAC9C,SAAO,4CAAC;AAAA,IAAa,GAAG;AAAA,IAAa;AAAA,GAAU;AACjD,CAAC;AAEM,MAAM,qBAAqB;AAAA,EAChC,aAAa,oBAAI,IAAI;AAAA,IAGnB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACH;AAEO,MAAMD,UAAS,YAAY,gBAAY,uBAAU,eAAe,GAAG,kBAAkB;",
6
- "names": ["Button", "React"]
4
+ "sourcesContent": ["import {\n ButtonNestingContext,\n GetProps,\n TamaguiElement,\n ThemeableProps,\n getVariableValue,\n isRSC,\n spacedChildren,\n styled,\n themeable,\n useMediaPropsActive,\n} from '@tamagui/core'\nimport { getFontSize } from '@tamagui/font-size'\nimport { getButtonSized } from '@tamagui/get-button-sized'\nimport { useGetThemedIcon } from '@tamagui/helpers-tamagui'\nimport { ThemeableStack } from '@tamagui/stacks'\nimport { SizableText, TextParentStyles, wrapChildrenInText } from '@tamagui/text'\nimport { FunctionComponent, forwardRef, useContext } from 'react'\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 /**\n * add icon before, passes color and size automatically if Component\n */\n icon?: IconProp\n /**\n * add icon after, passes color and size automatically if Component\n */\n iconAfter?: IconProp\n /**\n * adjust icon relative to size\n */\n /**\n * default: -1\n */\n scaleIcon?: number\n /**\n * make the spacing elements flex\n */\n spaceFlex?: number | boolean\n /**\n * adjust internal space relative to icon size\n */\n scaleSpace?: number\n }\n\nconst NAME = 'Button'\n\nexport const ButtonFrame = styled(ThemeableStack, {\n name: NAME,\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': getButtonSized,\n },\n\n active: {\n true: {\n hoverStyle: {\n backgroundColor: '$background',\n },\n },\n },\n\n disabled: {\n true: {\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 userSelect: 'none',\n cursor: 'pointer',\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\nexport function useButton(\n props: ButtonProps,\n { Text = ButtonText }: { Text: any } = { Text: ButtonText }\n) {\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\n\n const isNested = isRSC ? false : useContext(ButtonNestingContext)\n const mediaActiveProps = useMediaPropsActive(props)\n const size = mediaActiveProps.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(Text, mediaActiveProps)\n const inner =\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\n return {\n spaceSize,\n isNested,\n props: {\n ...(props.disabled && {\n // in rnw - false still has keyboard tabIndex, undefined = not actually focusable\n focusable: undefined,\n // even with tabIndex unset, it will keep focusStyle on web so disable it here\n focusStyle: {\n borderColor: '$background',\n },\n }),\n // fixes SSR issue + DOM nesting issue of not allowing button in button\n ...(isNested\n ? {\n tag: 'span',\n }\n : {}),\n ...rest,\n children: isRSC ? (\n inner\n ) : (\n <ButtonNestingContext.Provider value={true}>{inner}</ButtonNestingContext.Provider>\n ),\n },\n }\n}\n\nconst ButtonComponent = forwardRef<TamaguiElement, ButtonProps>(function Button(props, ref) {\n const { props: buttonProps } = useButton(props)\n return <ButtonFrame {...buttonProps} ref={ref} />\n})\n\nexport const buttonStaticConfig = {\n inlineProps: new Set([\n // text props go here (can't really optimize them, but we never fully extract button anyway)\n // may be able to remove this entirely, as the compiler / runtime have gotten better\n 'color',\n 'fontWeight',\n 'fontSize',\n 'fontFamily',\n 'letterSpacing',\n 'textAlign',\n ]),\n}\n\nexport const Button = ButtonFrame.extractable(\n themeable(ButtonComponent, ButtonFrame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AK;AAC1F,QAAM,EAAE,OAAO,YAAY,IAAI,UAAU,KAAK;AAC9C,SAAO,4CAAC;AAAA,IAAa,GAAG;AAAA,IAAa;AAAA,GAAU;AACjD,CAAC;AAEM,MAAM,qBAAqB;AAAA,EAChC,aAAa,oBAAI,IAAI;AAAA,IAGnB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACH;AAEO,MAAMA,UAAS,YAAY;AAAA,MAChC,uBAAU,iBAAiB,YAAY,YAAY;AAAA,EACnD;AACF;",
6
+ "names": ["Button"]
7
7
  }
@@ -1,6 +1,6 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import {
3
- ButtonInsideButtonContext,
3
+ ButtonNestingContext,
4
4
  getVariableValue,
5
5
  isRSC,
6
6
  spacedChildren,
@@ -13,10 +13,10 @@ import { getButtonSized } from "@tamagui/get-button-sized";
13
13
  import { useGetThemedIcon } from "@tamagui/helpers-tamagui";
14
14
  import { ThemeableStack } from "@tamagui/stacks";
15
15
  import { SizableText, wrapChildrenInText } from "@tamagui/text";
16
- import React, { forwardRef, useContext } from "react";
17
- React["createElement"];
16
+ import { forwardRef, useContext } from "react";
17
+ const NAME = "Button";
18
18
  const ButtonFrame = styled(ThemeableStack, {
19
- name: "Button",
19
+ name: NAME,
20
20
  tag: "button",
21
21
  focusable: true,
22
22
  hoverTheme: true,
@@ -51,7 +51,6 @@ const ButtonFrame = styled(ThemeableStack, {
51
51
  },
52
52
  disabled: {
53
53
  true: {
54
- opacity: 0.375,
55
54
  pointerEvents: "none"
56
55
  }
57
56
  }
@@ -89,7 +88,7 @@ function useButton(props, { Text = ButtonText } = { Text: ButtonText }) {
89
88
  textProps,
90
89
  ...rest
91
90
  } = props;
92
- const isInsideButton = isRSC ? false : useContext(ButtonInsideButtonContext);
91
+ const isNested = isRSC ? false : useContext(ButtonNestingContext);
93
92
  const mediaActiveProps = useMediaPropsActive(props);
94
93
  const size = mediaActiveProps.size || "$4";
95
94
  const iconSize = (typeof size === "number" ? size * 0.5 : getFontSize(size)) * scaleIcon;
@@ -106,7 +105,7 @@ function useButton(props, { Text = ButtonText } = { Text: ButtonText }) {
106
105
  }) : contents;
107
106
  return {
108
107
  spaceSize,
109
- isInsideButton,
108
+ isNested,
110
109
  props: {
111
110
  ...props.disabled && {
112
111
  focusable: void 0,
@@ -114,11 +113,11 @@ function useButton(props, { Text = ButtonText } = { Text: ButtonText }) {
114
113
  borderColor: "$background"
115
114
  }
116
115
  },
117
- ...isInsideButton && {
116
+ ...isNested ? {
118
117
  tag: "span"
119
- },
118
+ } : {},
120
119
  ...rest,
121
- children: isRSC ? inner : /* @__PURE__ */ jsx(ButtonInsideButtonContext.Provider, {
120
+ children: isRSC ? inner : /* @__PURE__ */ jsx(ButtonNestingContext.Provider, {
122
121
  value: true,
123
122
  children: inner
124
123
  })
@@ -142,7 +141,10 @@ const buttonStaticConfig = {
142
141
  "textAlign"
143
142
  ])
144
143
  };
145
- const Button2 = ButtonFrame.extractable(themeable(ButtonComponent), buttonStaticConfig);
144
+ const Button2 = ButtonFrame.extractable(
145
+ themeable(ButtonComponent, ButtonFrame.staticConfig),
146
+ buttonStaticConfig
147
+ );
146
148
  export {
147
149
  Button2 as Button,
148
150
  ButtonFrame,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/Button.tsx"],
4
- "sourcesContent": ["import {\n ButtonInsideButtonContext,\n GetProps,\n TamaguiElement,\n ThemeableProps,\n getVariableValue,\n isRSC,\n spacedChildren,\n styled,\n themeable,\n useMediaPropsActive,\n} from '@tamagui/core'\nimport { getFontSize } from '@tamagui/font-size'\nimport { getButtonSized } from '@tamagui/get-button-sized'\nimport { useGetThemedIcon } from '@tamagui/helpers-tamagui'\nimport { ThemeableStack } from '@tamagui/stacks'\nimport { SizableText, TextParentStyles, wrapChildrenInText } from '@tamagui/text'\nimport React, { FunctionComponent, forwardRef, useContext } from 'react'\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 /**\n * add icon before, passes color and size automatically if Component\n */\n icon?: IconProp\n /**\n * add icon after, passes color and size automatically if Component\n */\n iconAfter?: IconProp\n /**\n * adjust icon relative to size\n */\n /**\n * default: -1\n */\n scaleIcon?: number\n /**\n * make the spacing elements flex\n */\n spaceFlex?: number | boolean\n /**\n * adjust internal space relative to icon size\n */\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': getButtonSized,\n },\n\n active: {\n true: {\n hoverStyle: {\n backgroundColor: '$background',\n },\n },\n },\n\n disabled: {\n true: {\n opacity: 0.375,\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 userSelect: 'none',\n cursor: 'pointer',\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\nexport function useButton(\n props: ButtonProps,\n { Text = ButtonText }: { Text: any } = { Text: ButtonText }\n) {\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\n\n const isInsideButton = isRSC ? false : useContext(ButtonInsideButtonContext)\n const mediaActiveProps = useMediaPropsActive(props)\n const size = mediaActiveProps.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(Text, mediaActiveProps)\n const inner =\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\n return {\n spaceSize,\n isInsideButton,\n props: {\n ...(props.disabled && {\n // in rnw - false still has keyboard tabIndex, undefined = not actually focusable\n focusable: undefined,\n // even with tabIndex unset, it will keep focusStyle on web so disable it here\n focusStyle: {\n borderColor: '$background',\n },\n }),\n // fixes SSR issue + DOM nesting issue of not allowing button in button\n ...(isInsideButton && {\n tag: 'span',\n }),\n ...rest,\n children: isRSC ? (\n inner\n ) : (\n <ButtonInsideButtonContext.Provider value={true}>\n {inner}\n </ButtonInsideButtonContext.Provider>\n ),\n },\n }\n}\n\nconst ButtonComponent = forwardRef<TamaguiElement, ButtonProps>(function Button(props, ref) {\n const { props: buttonProps } = useButton(props)\n return <ButtonFrame {...buttonProps} ref={ref} />\n})\n\nexport const buttonStaticConfig = {\n inlineProps: new Set([\n // text props go here (can't really optimize them, but we never fully extract button anyway)\n // may be able to remove this entirely, as the compiler / runtime have gotten better\n 'color',\n 'fontWeight',\n 'fontSize',\n 'fontFamily',\n 'letterSpacing',\n 'textAlign',\n ]),\n}\n\nexport const Button = ButtonFrame.extractable(themeable(ButtonComponent), buttonStaticConfig)\n"],
5
- "mappings": "AAiMQ;AAjMR;AAAA,EACE;AAAA,EAIA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,mBAAmB;AAC5B,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,sBAAsB;AAC/B,SAAS,aAA+B,0BAA0B;AAClE,OAAO,SAA4B,YAAY,kBAAkB;AAGjE,MAAM;AAiCC,MAAM,cAAc,OAAO,gBAAgB;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,EAEA,YAAY;AAAA,IACV,aAAa;AAAA,EACf;AAAA,EAEA,YAAY;AAAA,IACV,aAAa;AAAA,EACf;AAAA,EAEA,UAAU;AAAA,IACR,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,SAAS;AAAA,QACT,eAAe;AAAA,MACjB;AAAA,IACF;AAAA,EACF;AAAA,EAEA,iBAAiB;AAAA,IACf,MAAM;AAAA,EACR;AACF,CAAC;AAMM,MAAM,aAAa,OAAO,aAAa;AAAA,EAC5C,OAAO;AAAA,EACP,YAAY;AAAA,EACZ,QAAQ;AAAA,EAER,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AC,0BAA0B,UAA1B;AAAA,QAAmC,OAAO;AAAA,QACxC;AAAA,OACH;AAAA,IAEJ;AAAA,EACF;AACF;AAEA,MAAM,kBAAkB,WAAwC,SAAS,OAAO,OAAO,KAAK;AAC1F,QAAM,EAAE,OAAO,YAAY,IAAI,UAAU,KAAK;AAC9C,SAAO,oBAAC;AAAA,IAAa,GAAG;AAAA,IAAa;AAAA,GAAU;AACjD,CAAC;AAEM,MAAM,qBAAqB;AAAA,EAChC,aAAa,oBAAI,IAAI;AAAA,IAGnB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACH;AAEO,MAAMA,UAAS,YAAY,YAAY,UAAU,eAAe,GAAG,kBAAkB;",
4
+ "sourcesContent": ["import {\n ButtonNestingContext,\n GetProps,\n TamaguiElement,\n ThemeableProps,\n getVariableValue,\n isRSC,\n spacedChildren,\n styled,\n themeable,\n useMediaPropsActive,\n} from '@tamagui/core'\nimport { getFontSize } from '@tamagui/font-size'\nimport { getButtonSized } from '@tamagui/get-button-sized'\nimport { useGetThemedIcon } from '@tamagui/helpers-tamagui'\nimport { ThemeableStack } from '@tamagui/stacks'\nimport { SizableText, TextParentStyles, wrapChildrenInText } from '@tamagui/text'\nimport { FunctionComponent, forwardRef, useContext } from 'react'\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 /**\n * add icon before, passes color and size automatically if Component\n */\n icon?: IconProp\n /**\n * add icon after, passes color and size automatically if Component\n */\n iconAfter?: IconProp\n /**\n * adjust icon relative to size\n */\n /**\n * default: -1\n */\n scaleIcon?: number\n /**\n * make the spacing elements flex\n */\n spaceFlex?: number | boolean\n /**\n * adjust internal space relative to icon size\n */\n scaleSpace?: number\n }\n\nconst NAME = 'Button'\n\nexport const ButtonFrame = styled(ThemeableStack, {\n name: NAME,\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': getButtonSized,\n },\n\n active: {\n true: {\n hoverStyle: {\n backgroundColor: '$background',\n },\n },\n },\n\n disabled: {\n true: {\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 userSelect: 'none',\n cursor: 'pointer',\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\nexport function useButton(\n props: ButtonProps,\n { Text = ButtonText }: { Text: any } = { Text: ButtonText }\n) {\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\n\n const isNested = isRSC ? false : useContext(ButtonNestingContext)\n const mediaActiveProps = useMediaPropsActive(props)\n const size = mediaActiveProps.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(Text, mediaActiveProps)\n const inner =\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\n return {\n spaceSize,\n isNested,\n props: {\n ...(props.disabled && {\n // in rnw - false still has keyboard tabIndex, undefined = not actually focusable\n focusable: undefined,\n // even with tabIndex unset, it will keep focusStyle on web so disable it here\n focusStyle: {\n borderColor: '$background',\n },\n }),\n // fixes SSR issue + DOM nesting issue of not allowing button in button\n ...(isNested\n ? {\n tag: 'span',\n }\n : {}),\n ...rest,\n children: isRSC ? (\n inner\n ) : (\n <ButtonNestingContext.Provider value={true}>{inner}</ButtonNestingContext.Provider>\n ),\n },\n }\n}\n\nconst ButtonComponent = forwardRef<TamaguiElement, ButtonProps>(function Button(props, ref) {\n const { props: buttonProps } = useButton(props)\n return <ButtonFrame {...buttonProps} ref={ref} />\n})\n\nexport const buttonStaticConfig = {\n inlineProps: new Set([\n // text props go here (can't really optimize them, but we never fully extract button anyway)\n // may be able to remove this entirely, as the compiler / runtime have gotten better\n 'color',\n 'fontWeight',\n 'fontSize',\n 'fontFamily',\n 'letterSpacing',\n 'textAlign',\n ]),\n}\n\nexport const Button = ButtonFrame.extractable(\n themeable(ButtonComponent, ButtonFrame.staticConfig),\n buttonStaticConfig\n)\n"],
5
+ "mappings": "AAiMQ;AAjMR;AAAA,EACE;AAAA,EAIA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,mBAAmB;AAC5B,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,sBAAsB;AAC/B,SAAS,aAA+B,0BAA0B;AAClE,SAA4B,YAAY,kBAAkB;AAiC1D,MAAM,OAAO;AAEN,MAAM,cAAc,OAAO,gBAAg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,iBAAiB,YAAY,YAAY;AAAA,EACnD;AACF;",
6
6
  "names": ["Button"]
7
7
  }
@@ -1,5 +1,5 @@
1
1
  import {
2
- ButtonInsideButtonContext,
2
+ ButtonNestingContext,
3
3
  getVariableValue,
4
4
  isRSC,
5
5
  spacedChildren,
@@ -12,10 +12,10 @@ import { getButtonSized } from "@tamagui/get-button-sized";
12
12
  import { useGetThemedIcon } from "@tamagui/helpers-tamagui";
13
13
  import { ThemeableStack } from "@tamagui/stacks";
14
14
  import { SizableText, wrapChildrenInText } from "@tamagui/text";
15
- import React, { forwardRef, useContext } from "react";
16
- React["createElement"];
15
+ import { forwardRef, useContext } from "react";
16
+ const NAME = "Button";
17
17
  const ButtonFrame = styled(ThemeableStack, {
18
- name: "Button",
18
+ name: NAME,
19
19
  tag: "button",
20
20
  focusable: true,
21
21
  hoverTheme: true,
@@ -50,7 +50,6 @@ const ButtonFrame = styled(ThemeableStack, {
50
50
  },
51
51
  disabled: {
52
52
  true: {
53
- opacity: 0.375,
54
53
  pointerEvents: "none"
55
54
  }
56
55
  }
@@ -88,7 +87,7 @@ function useButton(props, { Text = ButtonText } = { Text: ButtonText }) {
88
87
  textProps,
89
88
  ...rest
90
89
  } = props;
91
- const isInsideButton = isRSC ? false : useContext(ButtonInsideButtonContext);
90
+ const isNested = isRSC ? false : useContext(ButtonNestingContext);
92
91
  const mediaActiveProps = useMediaPropsActive(props);
93
92
  const size = mediaActiveProps.size || "$4";
94
93
  const iconSize = (typeof size === "number" ? size * 0.5 : getFontSize(size)) * scaleIcon;
@@ -105,7 +104,7 @@ function useButton(props, { Text = ButtonText } = { Text: ButtonText }) {
105
104
  }) : contents;
106
105
  return {
107
106
  spaceSize,
108
- isInsideButton,
107
+ isNested,
109
108
  props: {
110
109
  ...props.disabled && {
111
110
  focusable: void 0,
@@ -113,11 +112,11 @@ function useButton(props, { Text = ButtonText } = { Text: ButtonText }) {
113
112
  borderColor: "$background"
114
113
  }
115
114
  },
116
- ...isInsideButton && {
115
+ ...isNested ? {
117
116
  tag: "span"
118
- },
117
+ } : {},
119
118
  ...rest,
120
- children: isRSC ? inner : <ButtonInsideButtonContext.Provider value={true}>{inner}</ButtonInsideButtonContext.Provider>
119
+ children: isRSC ? inner : <ButtonNestingContext.Provider value={true}>{inner}</ButtonNestingContext.Provider>
121
120
  }
122
121
  };
123
122
  }
@@ -135,7 +134,10 @@ const buttonStaticConfig = {
135
134
  "textAlign"
136
135
  ])
137
136
  };
138
- const Button2 = ButtonFrame.extractable(themeable(ButtonComponent), buttonStaticConfig);
137
+ const Button2 = ButtonFrame.extractable(
138
+ themeable(ButtonComponent, ButtonFrame.staticConfig),
139
+ buttonStaticConfig
140
+ );
139
141
  export {
140
142
  Button2 as Button,
141
143
  ButtonFrame,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/Button.tsx"],
4
- "sourcesContent": ["import {\n ButtonInsideButtonContext,\n GetProps,\n TamaguiElement,\n ThemeableProps,\n getVariableValue,\n isRSC,\n spacedChildren,\n styled,\n themeable,\n useMediaPropsActive,\n} from '@tamagui/core'\nimport { getFontSize } from '@tamagui/font-size'\nimport { getButtonSized } from '@tamagui/get-button-sized'\nimport { useGetThemedIcon } from '@tamagui/helpers-tamagui'\nimport { ThemeableStack } from '@tamagui/stacks'\nimport { SizableText, TextParentStyles, wrapChildrenInText } from '@tamagui/text'\nimport React, { FunctionComponent, forwardRef, useContext } from 'react'\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 /**\n * add icon before, passes color and size automatically if Component\n */\n icon?: IconProp\n /**\n * add icon after, passes color and size automatically if Component\n */\n iconAfter?: IconProp\n /**\n * adjust icon relative to size\n */\n /**\n * default: -1\n */\n scaleIcon?: number\n /**\n * make the spacing elements flex\n */\n spaceFlex?: number | boolean\n /**\n * adjust internal space relative to icon size\n */\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': getButtonSized,\n },\n\n active: {\n true: {\n hoverStyle: {\n backgroundColor: '$background',\n },\n },\n },\n\n disabled: {\n true: {\n opacity: 0.375,\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 userSelect: 'none',\n cursor: 'pointer',\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\nexport function useButton(\n props: ButtonProps,\n { Text = ButtonText }: { Text: any } = { Text: ButtonText }\n) {\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\n\n const isInsideButton = isRSC ? false : useContext(ButtonInsideButtonContext)\n const mediaActiveProps = useMediaPropsActive(props)\n const size = mediaActiveProps.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(Text, mediaActiveProps)\n const inner =\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\n return {\n spaceSize,\n isInsideButton,\n props: {\n ...(props.disabled && {\n // in rnw - false still has keyboard tabIndex, undefined = not actually focusable\n focusable: undefined,\n // even with tabIndex unset, it will keep focusStyle on web so disable it here\n focusStyle: {\n borderColor: '$background',\n },\n }),\n // fixes SSR issue + DOM nesting issue of not allowing button in button\n ...(isInsideButton && {\n tag: 'span',\n }),\n ...rest,\n children: isRSC ? (\n inner\n ) : (\n <ButtonInsideButtonContext.Provider value={true}>\n {inner}\n </ButtonInsideButtonContext.Provider>\n ),\n },\n }\n}\n\nconst ButtonComponent = forwardRef<TamaguiElement, ButtonProps>(function Button(props, ref) {\n const { props: buttonProps } = useButton(props)\n return <ButtonFrame {...buttonProps} ref={ref} />\n})\n\nexport const buttonStaticConfig = {\n inlineProps: new Set([\n // text props go here (can't really optimize them, but we never fully extract button anyway)\n // may be able to remove this entirely, as the compiler / runtime have gotten better\n 'color',\n 'fontWeight',\n 'fontSize',\n 'fontFamily',\n 'letterSpacing',\n 'textAlign',\n ]),\n}\n\nexport const Button = ButtonFrame.extractable(themeable(ButtonComponent), buttonStaticConfig)\n"],
5
- "mappings": "AAAA;AAAA,EACE;AAAA,EAIA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,mBAAmB;AAC5B,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,sBAAsB;AAC/B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AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACH;AAEO,MAAMA,UAAS,YAAY,YAAY,UAAU,eAAe,GAAG,kBAAkB;",
4
+ "sourcesContent": ["import {\n ButtonNestingContext,\n GetProps,\n TamaguiElement,\n ThemeableProps,\n getVariableValue,\n isRSC,\n spacedChildren,\n styled,\n themeable,\n useMediaPropsActive,\n} from '@tamagui/core'\nimport { getFontSize } from '@tamagui/font-size'\nimport { getButtonSized } from '@tamagui/get-button-sized'\nimport { useGetThemedIcon } from '@tamagui/helpers-tamagui'\nimport { ThemeableStack } from '@tamagui/stacks'\nimport { SizableText, TextParentStyles, wrapChildrenInText } from '@tamagui/text'\nimport { FunctionComponent, forwardRef, useContext } from 'react'\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 /**\n * add icon before, passes color and size automatically if Component\n */\n icon?: IconProp\n /**\n * add icon after, passes color and size automatically if Component\n */\n iconAfter?: IconProp\n /**\n * adjust icon relative to size\n */\n /**\n * default: -1\n */\n scaleIcon?: number\n /**\n * make the spacing elements flex\n */\n spaceFlex?: number | boolean\n /**\n * adjust internal space relative to icon size\n */\n scaleSpace?: number\n }\n\nconst NAME = 'Button'\n\nexport const ButtonFrame = styled(ThemeableStack, {\n name: NAME,\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': getButtonSized,\n },\n\n active: {\n true: {\n hoverStyle: {\n backgroundColor: '$background',\n },\n },\n },\n\n disabled: {\n true: {\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 userSelect: 'none',\n cursor: 'pointer',\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\nexport function useButton(\n props: ButtonProps,\n { Text = ButtonText }: { Text: any } = { Text: ButtonText }\n) {\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\n\n const isNested = isRSC ? false : useContext(ButtonNestingContext)\n const mediaActiveProps = useMediaPropsActive(props)\n const size = mediaActiveProps.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(Text, mediaActiveProps)\n const inner =\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\n return {\n spaceSize,\n isNested,\n props: {\n ...(props.disabled && {\n // in rnw - false still has keyboard tabIndex, undefined = not actually focusable\n focusable: undefined,\n // even with tabIndex unset, it will keep focusStyle on web so disable it here\n focusStyle: {\n borderColor: '$background',\n },\n }),\n // fixes SSR issue + DOM nesting issue of not allowing button in button\n ...(isNested\n ? {\n tag: 'span',\n }\n : {}),\n ...rest,\n children: isRSC ? (\n inner\n ) : (\n <ButtonNestingContext.Provider value={true}>{inner}</ButtonNestingContext.Provider>\n ),\n },\n }\n}\n\nconst ButtonComponent = forwardRef<TamaguiElement, ButtonProps>(function Button(props, ref) {\n const { props: buttonProps } = useButton(props)\n return <ButtonFrame {...buttonProps} ref={ref} />\n})\n\nexport const buttonStaticConfig = {\n inlineProps: new Set([\n // text props go here (can't really optimize them, but we never fully extract button anyway)\n // may be able to remove this entirely, as the compiler / runtime have gotten better\n 'color',\n 'fontWeight',\n 'fontSize',\n 'fontFamily',\n 'letterSpacing',\n 'textAlign',\n ]),\n}\n\nexport const Button = ButtonFrame.extractable(\n themeable(ButtonComponent, ButtonFrame.staticConfig),\n buttonStaticConfig\n)\n"],
5
+ "mappings": "AAAA;AAAA,EACE;AAAA,EAIA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,mBAAmB;AAC5B,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,sBAAsB;AAC/B,SAAS,aAA+B,0BAA0B;AAClE,SAA4B,YAAY,kBAAkB;AAiC1D,MAAM,OAAO;AAEN,MAAM,cAAc,OAAO,gBAAgB;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,EAEA,YAAY;AAAA,IACV,aAAa;AAAA,EACf;AAAA,EAEA,YAAY;AAAA,IACV,aAAa;AAAA,EACf;AAAA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AA,IACP;AAAA,IACA;AAAA,IACA,WACE,MAAM,kBAAkB,YAAY,MAAM,kBAAkB,mBACxD,aACA;AAAA,IACN,UAAU,CAAC,YAAY,UAAU,eAAe;AAAA,EAClD,CAAC,IACD;AAEN,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,OAAO;AAAA,MACL,GAAI,MAAM,YAAY;AAAA,QAEpB,WAAW;AAAA,QAEX,YAAY;AAAA,UACV,aAAa;AAAA,QACf;AAAA,MACF;AAAA,MAEA,GAAI,WACA;AAAA,QACE,KAAK;AAAA,MACP,IACA,CAAC;AAAA,MACL,GAAG;AAAA,MACH,UAAU,QACR,QAEA,CAAC,qBAAqB,SAAS,OAAO,OAAO,MAAM,EAAlD,qBAAqB;AAAA,IAE1B;AAAA,EACF;AACF;AAEA,MAAM,kBAAkB,WAAwC,SAAS,OAAO,OAAO,KAAK;AAC1F,QAAM,EAAE,OAAO,YAAY,IAAI,UAAU,KAAK;AAC9C,SAAO,CAAC,gBAAgB,aAAa,KAAK,KAAK;AACjD,CAAC;AAEM,MAAM,qBAAqB;AAAA,EAChC,aAAa,oBAAI,IAAI;AAAA,IAGnB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACH;AAEO,MAAMA,UAAS,YAAY;AAAA,EAChC,UAAU,iBAAiB,YAAY,YAAY;AAAA,EACnD;AACF;",
6
6
  "names": ["Button"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/button",
3
- "version": "1.0.1-beta.219",
3
+ "version": "1.0.1-beta.221",
4
4
  "sideEffects": [
5
5
  "*.css"
6
6
  ],
@@ -17,7 +17,7 @@
17
17
  "scripts": {
18
18
  "build": "tamagui-build",
19
19
  "watch": "tamagui-build --watch",
20
- "lint": "eslint",
20
+ "lint": "eslint src",
21
21
  "lint:fix": "yarn lint --fix"
22
22
  },
23
23
  "exports": {
@@ -28,17 +28,17 @@
28
28
  }
29
29
  },
30
30
  "dependencies": {
31
- "@tamagui/core": "^1.0.1-beta.219",
32
- "@tamagui/font-size": "^1.0.1-beta.219",
33
- "@tamagui/get-button-sized": "^1.0.1-beta.219",
34
- "@tamagui/helpers-tamagui": "^1.0.1-beta.219"
31
+ "@tamagui/core": "^1.0.1-beta.221",
32
+ "@tamagui/font-size": "^1.0.1-beta.221",
33
+ "@tamagui/get-button-sized": "^1.0.1-beta.221",
34
+ "@tamagui/helpers-tamagui": "^1.0.1-beta.221"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "react": ">=18",
38
38
  "react-dom": ">=18"
39
39
  },
40
40
  "devDependencies": {
41
- "@tamagui/build": "^1.0.1-beta.219",
41
+ "@tamagui/build": "^1.0.1-beta.221",
42
42
  "react": ">=18",
43
43
  "react-dom": ">=18"
44
44
  },
package/src/Button.tsx CHANGED
@@ -1,5 +1,5 @@
1
1
  import {
2
- ButtonInsideButtonContext,
2
+ ButtonNestingContext,
3
3
  GetProps,
4
4
  TamaguiElement,
5
5
  ThemeableProps,
@@ -15,10 +15,7 @@ import { getButtonSized } from '@tamagui/get-button-sized'
15
15
  import { useGetThemedIcon } from '@tamagui/helpers-tamagui'
16
16
  import { ThemeableStack } from '@tamagui/stacks'
17
17
  import { SizableText, TextParentStyles, wrapChildrenInText } from '@tamagui/text'
18
- import React, { FunctionComponent, forwardRef, useContext } from 'react'
19
-
20
- // bugfix esbuild strips react jsx: 'preserve'
21
- React['createElement']
18
+ import { FunctionComponent, forwardRef, useContext } from 'react'
22
19
 
23
20
  type ButtonIconProps = { color?: string; size?: number }
24
21
  type IconProp = JSX.Element | FunctionComponent<ButtonIconProps> | null
@@ -51,8 +48,10 @@ export type ButtonProps = Omit<TextParentStyles, 'TextComponent'> &
51
48
  scaleSpace?: number
52
49
  }
53
50
 
51
+ const NAME = 'Button'
52
+
54
53
  export const ButtonFrame = styled(ThemeableStack, {
55
- name: 'Button',
54
+ name: NAME,
56
55
  tag: 'button',
57
56
  focusable: true,
58
57
  hoverTheme: true,
@@ -95,7 +94,6 @@ export const ButtonFrame = styled(ThemeableStack, {
95
94
 
96
95
  disabled: {
97
96
  true: {
98
- opacity: 0.375,
99
97
  pointerEvents: 'none',
100
98
  },
101
99
  },
@@ -148,7 +146,7 @@ export function useButton(
148
146
  ...rest
149
147
  } = props
150
148
 
151
- const isInsideButton = isRSC ? false : useContext(ButtonInsideButtonContext)
149
+ const isNested = isRSC ? false : useContext(ButtonNestingContext)
152
150
  const mediaActiveProps = useMediaPropsActive(props)
153
151
  const size = mediaActiveProps.size || '$4'
154
152
  const iconSize = (typeof size === 'number' ? size * 0.5 : getFontSize(size)) * scaleIcon
@@ -173,7 +171,7 @@ export function useButton(
173
171
 
174
172
  return {
175
173
  spaceSize,
176
- isInsideButton,
174
+ isNested,
177
175
  props: {
178
176
  ...(props.disabled && {
179
177
  // in rnw - false still has keyboard tabIndex, undefined = not actually focusable
@@ -184,16 +182,16 @@ export function useButton(
184
182
  },
185
183
  }),
186
184
  // fixes SSR issue + DOM nesting issue of not allowing button in button
187
- ...(isInsideButton && {
188
- tag: 'span',
189
- }),
185
+ ...(isNested
186
+ ? {
187
+ tag: 'span',
188
+ }
189
+ : {}),
190
190
  ...rest,
191
191
  children: isRSC ? (
192
192
  inner
193
193
  ) : (
194
- <ButtonInsideButtonContext.Provider value={true}>
195
- {inner}
196
- </ButtonInsideButtonContext.Provider>
194
+ <ButtonNestingContext.Provider value={true}>{inner}</ButtonNestingContext.Provider>
197
195
  ),
198
196
  },
199
197
  }
@@ -217,4 +215,7 @@ export const buttonStaticConfig = {
217
215
  ]),
218
216
  }
219
217
 
220
- export const Button = ButtonFrame.extractable(themeable(ButtonComponent), buttonStaticConfig)
218
+ export const Button = ButtonFrame.extractable(
219
+ themeable(ButtonComponent, ButtonFrame.staticConfig),
220
+ buttonStaticConfig
221
+ )
package/types/Button.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { GetProps, TamaguiElement, ThemeableProps } from '@tamagui/core';
2
2
  import { TextParentStyles } from '@tamagui/text';
3
- import React, { FunctionComponent } from 'react';
3
+ import { FunctionComponent } from 'react';
4
4
  declare type ButtonIconProps = {
5
5
  color?: string;
6
6
  size?: number;
@@ -115,7 +115,9 @@ export declare const ButtonFrame: import("@tamagui/core").TamaguiComponent<Omit<
115
115
  export declare const ButtonText: import("@tamagui/core").TamaguiComponent<(Omit<import("@tamagui/types-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"> & {
116
116
  readonly size?: import("@tamagui/core").FontSizeTokens | undefined;
117
117
  } & import("@tamagui/core").MediaProps<Partial<Omit<import("@tamagui/types-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"> & {
118
- readonly size?: import("@tamagui/core").FontSizeTokens | undefined;
118
+ readonly size?: import("@tamagui/core").FontSizeTokens | undefined; /**
119
+ * default: -1
120
+ */
119
121
  }>> & import("@tamagui/core").PseudoProps<Partial<Omit<import("@tamagui/types-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"> & {
120
122
  readonly size?: import("@tamagui/core").FontSizeTokens | undefined;
121
123
  }>>) | (Omit<import("@tamagui/types-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<{
@@ -141,9 +143,9 @@ export declare function useButton(props: ButtonProps, { Text }?: {
141
143
  Text: any;
142
144
  }): {
143
145
  spaceSize: number;
144
- isInsideButton: boolean;
146
+ isNested: boolean;
145
147
  props: {
146
- children: string | number | boolean | any[] | JSX.Element | React.ReactFragment | null | undefined;
148
+ children: string | number | boolean | any[] | JSX.Element | import("react").ReactFragment | null | undefined;
147
149
  hitSlop?: import("@tamagui/types-react-native").Insets | (import("@tamagui/types-react-native").Insets & number) | undefined;
148
150
  onLayout?: ((event: import("@tamagui/types-react-native").LayoutChangeEvent) => void) | undefined;
149
151
  pointerEvents?: "box-none" | "none" | "box-only" | "auto" | undefined;
@@ -198,9 +200,6 @@ export declare function useButton(props: ButtonProps, { Text }?: {
198
200
  label?: string | undefined;
199
201
  }>[] | undefined;
200
202
  accessibilityLabel?: string | undefined;
201
- /**
202
- * add icon after, passes color and size automatically if Component
203
- */
204
203
  accessibilityRole?: "none" | "button" | "link" | "search" | "image" | "keyboardkey" | "text" | "adjustable" | "imagebutton" | "header" | "summary" | "list" | undefined;
205
204
  accessibilityState?: import("@tamagui/types-react-native").AccessibilityState | undefined;
206
205
  accessibilityHint?: string | undefined;
@@ -226,30 +225,25 @@ export declare function useButton(props: ButtonProps, { Text }?: {
226
225
  rel?: string | undefined;
227
226
  download?: boolean | undefined;
228
227
  } | undefined;
229
- onMouseDown?: (((event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void) & ((e: MouseEvent) => any)) | undefined;
230
- onMouseUp?: ((event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void) | undefined;
231
- onMouseEnter?: (((event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void) & ((e: MouseEvent) => any)) | undefined;
232
- onMouseLeave?: (((event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void) & ((e: MouseEvent) => any)) | undefined;
233
- onFocus?: ((event: React.FocusEvent<HTMLDivElement, Element>) => void) | undefined;
234
- onScroll?: ((event: React.UIEvent<HTMLDivElement, UIEvent>) => void) | undefined;
228
+ onMouseDown?: (((event: import("react").MouseEvent<HTMLDivElement, MouseEvent>) => void) & ((e: MouseEvent) => any)) | undefined;
229
+ onMouseUp?: ((event: import("react").MouseEvent<HTMLDivElement, MouseEvent>) => void) | undefined;
230
+ onMouseEnter?: (((event: import("react").MouseEvent<HTMLDivElement, MouseEvent>) => void) & ((e: MouseEvent) => any)) | undefined;
231
+ onMouseLeave?: (((event: import("react").MouseEvent<HTMLDivElement, MouseEvent>) => void) & ((e: MouseEvent) => any)) | undefined;
232
+ onFocus?: ((event: import("react").FocusEvent<HTMLDivElement, Element>) => void) | undefined;
233
+ onScroll?: ((event: import("react").UIEvent<HTMLDivElement, UIEvent>) => void) | undefined;
235
234
  onScrollShouldSetResponder?: unknown;
236
235
  onScrollShouldSetResponderCapture?: unknown;
237
236
  onSelectionChangeShouldSetResponder?: unknown;
238
237
  onSelectionChangeShouldSetResponderCapture?: unknown;
239
238
  asChild?: boolean | undefined;
240
239
  spaceDirection?: import("@tamagui/core").SpaceDirection | undefined;
241
- /**
242
- * default: -1
243
- */
244
240
  dangerouslySetInnerHTML?: {
245
241
  __html: string;
246
242
  } | undefined;
247
243
  animation?: import("@tamagui/core").AnimationProp | undefined;
248
244
  animateOnly?: string[] | undefined;
249
- debug?: import("@tamagui/core").DebugProp | undefined;
250
- disabled?: boolean | undefined; /**
251
- * adjust internal space relative to icon size
252
- */
245
+ debug?: boolean | "verbose" | undefined;
246
+ disabled?: boolean | undefined;
253
247
  className?: string | undefined;
254
248
  themeShallow?: boolean | undefined;
255
249
  id?: string | undefined;
@@ -485,6 +479,7 @@ export declare function useButton(props: ButtonProps, { Text }?: {
485
479
  readonly disabled?: boolean | undefined;
486
480
  }> | null | undefined;
487
481
  themeInverse?: boolean | undefined;
482
+ reset?: boolean | undefined;
488
483
  };
489
484
  };
490
485
  export declare const buttonStaticConfig: {
@@ -574,6 +569,6 @@ export declare const Button: (props: Omit<Omit<TextParentStyles, "TextComponent"
574
569
  * adjust internal space relative to icon size
575
570
  */
576
571
  scaleSpace?: number | undefined;
577
- } & React.RefAttributes<TamaguiElement>, "theme" | "themeInverse"> & ThemeableProps) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
572
+ } & import("react").RefAttributes<TamaguiElement>, "theme" | "themeInverse"> & ThemeableProps) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | null;
578
573
  export {};
579
574
  //# sourceMappingURL=Button.d.ts.map