@tamagui/button 2.7.7 → 3.0.0-beta.1091.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/cjs/Button.cjs +97 -268
  2. package/dist/cjs/Button.native.cjs +122 -0
  3. package/dist/cjs/Button.native.js +100 -273
  4. package/dist/cjs/Button.native.js.map +1 -1
  5. package/dist/cjs/index.cjs +9 -11
  6. package/dist/cjs/index.native.cjs +20 -0
  7. package/dist/cjs/index.native.js +9 -10
  8. package/dist/cjs/index.native.js.map +1 -1
  9. package/dist/esm/Button.mjs +88 -257
  10. package/dist/esm/Button.mjs.map +1 -1
  11. package/dist/esm/Button.native.js +91 -263
  12. package/dist/esm/Button.native.js.map +1 -1
  13. package/dist/esm/index.js +1 -2
  14. package/dist/esm/index.mjs +1 -2
  15. package/dist/esm/index.native.js +1 -2
  16. package/dist/jsx/Button.mjs +88 -257
  17. package/dist/jsx/Button.mjs.map +1 -1
  18. package/dist/jsx/Button.native.cjs +122 -0
  19. package/dist/jsx/Button.native.js +100 -273
  20. package/dist/jsx/Button.native.js.map +1 -1
  21. package/dist/jsx/index.js +1 -2
  22. package/dist/jsx/index.mjs +1 -2
  23. package/dist/jsx/index.native.cjs +20 -0
  24. package/dist/jsx/index.native.js +9 -10
  25. package/dist/jsx/index.native.js.map +1 -1
  26. package/package.json +14 -14
  27. package/src/Button.tsx +152 -309
  28. package/types/Button.d.ts +75 -208
  29. package/types/Button.d.ts.map +1 -1
  30. package/dist/cjs/Button.test.cjs +0 -37
  31. package/dist/cjs/Button.test.native.js +0 -40
  32. package/dist/cjs/Button.test.native.js.map +0 -1
  33. package/dist/esm/Button.test.mjs +0 -38
  34. package/dist/esm/Button.test.mjs.map +0 -1
  35. package/dist/esm/Button.test.native.js +0 -38
  36. package/dist/esm/Button.test.native.js.map +0 -1
  37. package/dist/esm/index.js.map +0 -1
  38. package/dist/esm/index.mjs.map +0 -1
  39. package/dist/esm/index.native.js.map +0 -1
  40. package/dist/jsx/Button.test.mjs +0 -38
  41. package/dist/jsx/Button.test.mjs.map +0 -1
  42. package/dist/jsx/Button.test.native.js +0 -40
  43. package/dist/jsx/Button.test.native.js.map +0 -1
  44. package/dist/jsx/index.js.map +0 -1
  45. package/dist/jsx/index.mjs.map +0 -1
  46. package/src/Button.test.tsx +0 -45
  47. package/types/Button.test.d.ts +0 -2
  48. package/types/Button.test.d.ts.map +0 -1
@@ -1,263 +1,94 @@
1
- import { getFontSize } from "@tamagui/font-size";
2
- import { getButtonSized } from "@tamagui/get-button-sized";
3
- import { getIcon, useCurrentColor } from "@tamagui/helpers-tamagui";
4
- import { ButtonNestingContext, getElevation, themeableVariants } from "@tamagui/stacks";
5
- import { SizableText, wrapChildrenInText } from "@tamagui/text";
6
- import { createStyledContext, getTokenValue, styled, useProps, View, withStaticProperties } from "@tamagui/web";
1
+ import { useGetThemedIcon } from "@tamagui/helpers-tamagui";
2
+ import { ButtonNestingContext } from "@tamagui/stacks";
3
+ import { textParentProps, wrapChildrenInText } from "@tamagui/text";
4
+ import { Text, View, splitStyleProps, styled } from "@tamagui/web";
7
5
  import { useContext } from "react";
8
6
  import { jsx, jsxs } from "react/jsx-runtime";
9
- const context = createStyledContext({
10
- size: void 0,
11
- variant: void 0,
12
- color: void 0,
13
- elevation: void 0,
14
- ellipsis: void 0,
15
- fontFamily: void 0,
16
- fontSize: void 0,
17
- fontStyle: void 0,
18
- fontWeight: void 0,
19
- letterSpacing: void 0,
20
- maxFontSizeMultiplier: void 0,
21
- textAlign: void 0
7
+
8
+ const ButtonFrame = styled(View, {
9
+ role: "button",
10
+ render: /* @__PURE__ */ jsx("button", { type: "button" }),
11
+ tabIndex: 0,
12
+ alignItems: "center",
13
+ flexDirection: "row",
14
+ flexWrap: "nowrap",
15
+ justifyContent: "center",
16
+ variants: { disabled: { true: { pointerEvents: "none" } } }
22
17
  });
23
- const Frame = styled(View, {
24
- context,
25
- name: "Button",
26
- role: "button",
27
- render: /* @__PURE__ */jsx("button", {
28
- type: "button"
29
- }),
30
- tabIndex: 0,
31
- variants: {
32
- unstyled: {
33
- true: {
34
- // reset browser <button> defaults
35
- outlineWidth: 0,
36
- borderWidth: 0,
37
- backgroundColor: "transparent"
38
- },
39
- false: {
40
- size: "$true",
41
- justifyContent: "center",
42
- alignItems: "center",
43
- flexWrap: "nowrap",
44
- flexDirection: "row",
45
- backgroundColor: "$background",
46
- borderWidth: 1,
47
- borderColor: "transparent",
48
- "$platform-web": {
49
- cursor: "pointer"
50
- },
51
- hoverStyle: {
52
- backgroundColor: "$backgroundHover",
53
- borderColor: "$borderColorHover"
54
- },
55
- pressStyle: {
56
- backgroundColor: "$backgroundPress",
57
- borderColor: "$borderColorHover"
58
- },
59
- focusVisibleStyle: {
60
- outlineColor: "$outlineColor",
61
- outlineStyle: "solid",
62
- outlineWidth: 2
63
- }
64
- }
65
- },
66
- variant: {
67
- outlined: process.env.TAMAGUI_HEADLESS === "1" ? {} : {
68
- backgroundColor: "transparent",
69
- borderWidth: 1,
70
- borderColor: "$borderColor",
71
- hoverStyle: {
72
- backgroundColor: "transparent",
73
- borderColor: "$borderColorHover"
74
- },
75
- pressStyle: {
76
- backgroundColor: "transparent",
77
- borderColor: "$borderColorPress"
78
- }
79
- }
80
- },
81
- circular: themeableVariants.circular,
82
- chromeless: themeableVariants.chromeless,
83
- size: {
84
- "...size": (val, extras) => {
85
- const buttonStyle = getButtonSized(val, extras);
86
- const gap = getTokenValue(val);
87
- return {
88
- ...buttonStyle,
89
- gap
90
- };
91
- },
92
- ":number": (val, extras) => {
93
- const buttonStyle = getButtonSized(val, extras);
94
- const gap = val * 0.4;
95
- return {
96
- ...buttonStyle,
97
- gap
98
- };
99
- }
100
- },
101
- elevation: {
102
- "...size": getElevation,
103
- ":number": getElevation
104
- },
105
- disabled: {
106
- true: {
107
- pointerEvents: "none",
108
- // @ts-ignore
109
- "aria-disabled": true
110
- }
111
- }
112
- },
113
- defaultVariants: {
114
- unstyled: process.env.TAMAGUI_HEADLESS === "1"
115
- }
18
+ const ButtonText = styled(Text, {
19
+ flexGrow: 0,
20
+ flexShrink: 1
116
21
  });
117
- const Text = styled(SizableText, {
118
- context,
119
- variants: {
120
- unstyled: {
121
- false: {
122
- userSelect: "none",
123
- // flexGrow 1 leads to inconsistent native style where text pushes to start of view
124
- flexGrow: 0,
125
- flexShrink: 1,
126
- ellipsis: true,
127
- color: "$color",
128
- "$platform-web": {
129
- cursor: "pointer"
130
- }
131
- }
132
- }
133
- },
134
- defaultVariants: {
135
- unstyled: process.env.TAMAGUI_HEADLESS === "1"
136
- }
137
- });
138
- const Icon = props => {
139
- const {
140
- children,
141
- scaleIcon = 1,
142
- size
143
- } = props;
144
- const styledContext = context.useStyledContext();
145
- if (!styledContext) {
146
- throw new Error("Button.Icon must be used within a Button");
147
- }
148
- const sizeToken = size ?? styledContext.size;
149
- const iconColorProp = styledContext.color === "unset" || typeof styledContext.color === "number" ? void 0 : styledContext.color;
150
- const iconColor = useCurrentColor(iconColorProp);
151
- const iconSize = (typeof sizeToken === "number" ? sizeToken * 0.5 : getFontSize(sizeToken)) * scaleIcon;
152
- return getIcon(children, {
153
- size: iconSize,
154
- color: iconColor
155
- });
22
+ const ButtonIcon = ({ children, color, scaleIcon = 1, size }) => {
23
+ const getThemedIcon = useGetThemedIcon({
24
+ color,
25
+ size: size === void 0 ? void 0 : size * scaleIcon
26
+ });
27
+ return getThemedIcon(children);
156
28
  };
157
- const ButtonContext = createStyledContext({
158
- size: void 0,
159
- variant: void 0,
160
- color: void 0
161
- });
162
- const ButtonComponent = Frame.styleable((propsIn, ref) => {
163
- const isNested = useContext(ButtonNestingContext);
164
- const processedProps = useProps(propsIn, {
165
- noNormalize: true,
166
- noExpand: true
167
- });
168
- const {
169
- children,
170
- iconSize,
171
- icon,
172
- iconAfter,
173
- scaleIcon = 1,
174
- noTextWrap,
175
- textProps,
176
- color,
177
- ellipsis,
178
- fontFamily,
179
- fontSize,
180
- fontStyle,
181
- fontWeight,
182
- letterSpacing,
183
- maxFontSizeMultiplier,
184
- textAlign,
185
- ...props
186
- } = processedProps;
187
- const size = propsIn.size || (propsIn.unstyled ? void 0 : "$true");
188
- const styledContext = context.useStyledContext();
189
- const contextColor = color ?? propsIn.color ?? styledContext?.color;
190
- const iconColorProp = contextColor === "unset" || typeof contextColor === "number" ? void 0 : contextColor;
191
- const iconColor = useCurrentColor(iconColorProp);
192
- const finalSize = iconSize ?? size ?? styledContext?.size;
193
- const iconSizeNumber = (typeof finalSize === "number" ? finalSize * 0.5 : getFontSize(finalSize)) * scaleIcon;
194
- const [themedIcon, themedIconAfter] = [icon, iconAfter].map(icon2 => {
195
- if (!icon2) return null;
196
- return getIcon(icon2, {
197
- size: iconSizeNumber,
198
- color: iconColor
199
- // No marginLeft or marginRight needed - spacing is handled by the gap property in Frame's size variants
200
- });
201
- });
202
- const wrappedChildren = wrapChildrenInText(Text, {
203
- children,
204
- color: contextColor,
205
- ellipsis: ellipsis ?? propsIn.ellipsis ?? styledContext?.ellipsis,
206
- fontFamily: fontFamily ?? propsIn.fontFamily ?? styledContext?.fontFamily,
207
- fontSize: fontSize ?? propsIn.fontSize ?? styledContext?.fontSize,
208
- fontStyle: fontStyle ?? propsIn.fontStyle ?? styledContext?.fontStyle,
209
- fontWeight: fontWeight ?? propsIn.fontWeight ?? styledContext?.fontWeight,
210
- letterSpacing: letterSpacing ?? propsIn.letterSpacing ?? styledContext?.letterSpacing,
211
- maxFontSizeMultiplier: maxFontSizeMultiplier ?? propsIn.maxFontSizeMultiplier ?? styledContext?.maxFontSizeMultiplier,
212
- noTextWrap: noTextWrap ?? propsIn.noTextWrap,
213
- textAlign: textAlign ?? propsIn.textAlign ?? styledContext?.textAlign,
214
- textProps: textProps ?? propsIn.textProps
215
- }, {
216
- unstyled: process.env.TAMAGUI_HEADLESS === "1",
217
- size: finalSize ?? styledContext?.size
218
- });
219
- const textContext = {
220
- color: contextColor,
221
- ellipsis: ellipsis ?? propsIn.ellipsis ?? styledContext?.ellipsis,
222
- fontFamily: fontFamily ?? propsIn.fontFamily ?? styledContext?.fontFamily,
223
- fontSize: fontSize ?? propsIn.fontSize ?? styledContext?.fontSize,
224
- fontStyle: fontStyle ?? propsIn.fontStyle ?? styledContext?.fontStyle,
225
- fontWeight: fontWeight ?? propsIn.fontWeight ?? styledContext?.fontWeight,
226
- letterSpacing: letterSpacing ?? propsIn.letterSpacing ?? styledContext?.letterSpacing,
227
- maxFontSizeMultiplier: maxFontSizeMultiplier ?? propsIn.maxFontSizeMultiplier ?? styledContext?.maxFontSizeMultiplier,
228
- textAlign: textAlign ?? propsIn.textAlign ?? styledContext?.textAlign
229
- };
230
- const buttonContext = {
231
- ...styledContext,
232
- ...textContext,
233
- size: props.size ?? propsIn.size ?? styledContext?.size,
234
- variant: props.variant ?? propsIn.variant ?? styledContext?.variant,
235
- elevation: props.elevation ?? propsIn.elevation ?? styledContext?.elevation
236
- };
237
- return /* @__PURE__ */jsx(ButtonNestingContext.Provider, {
238
- value: true,
239
- children: /* @__PURE__ */jsx(context.Provider, {
240
- ...buttonContext,
241
- children: /* @__PURE__ */jsxs(Frame, {
242
- ref,
243
- ...props,
244
- ...(isNested && {
245
- render: "span"
246
- }),
247
- ...(props.circular && !propsIn.size && {
248
- size
249
- }),
250
- tabIndex: 0,
251
- children: [themedIcon, wrappedChildren, themedIconAfter]
252
- })
253
- })
254
- });
255
- });
256
- const Button = withStaticProperties(ButtonComponent, {
257
- Apply: context.Provider,
258
- Frame,
259
- Text,
260
- Icon
261
- });
262
- export { Button, ButtonContext };
29
+ function useButton(propsIn, { Text: Text2 = ButtonText, iconColor, iconSize: iconSizeOption, textProps: textPropsOption } = {}) {
30
+ const isNested = useContext(ButtonNestingContext);
31
+ const [wrappedTextProps, buttonProps] = splitStyleProps(propsIn, {
32
+ expandShorthands: true,
33
+ filter: textParentProps
34
+ });
35
+ const { children, disabled, icon, iconAfter, iconSize, render, scaleIcon = 1, ...frameProps } = buttonProps;
36
+ const { noTextWrap, textProps, ...textStyleProps } = wrappedTextProps;
37
+ const resolvedIconSize = iconSize ?? iconSizeOption;
38
+ const getThemedIcon = useGetThemedIcon({
39
+ color: iconColor,
40
+ size: resolvedIconSize === void 0 ? void 0 : resolvedIconSize * scaleIcon
41
+ });
42
+ const [themedIcon, themedIconAfter] = [icon, iconAfter].map((item) => {
43
+ return item ? getThemedIcon(item) : null;
44
+ });
45
+ const wrappedChildren = wrapChildrenInText(Text2, {
46
+ children,
47
+ noTextWrap,
48
+ textProps
49
+ }, {
50
+ ...textPropsOption,
51
+ ...textStyleProps
52
+ });
53
+ const resolvedRender = render ?? (isNested ? "span" : disabled ? /* @__PURE__ */ jsx("button", {
54
+ type: "button",
55
+ disabled: true
56
+ }) : void 0);
57
+ const resolvedProps = {
58
+ ...frameProps,
59
+ ...disabled && {
60
+ "aria-disabled": true,
61
+ disabled: true,
62
+ tabIndex: -1
63
+ },
64
+ ...resolvedRender === void 0 ? null : { render: resolvedRender },
65
+ ...isNested && {
66
+ role: "none",
67
+ tabIndex: -1,
68
+ "aria-disabled": void 0,
69
+ disabled: void 0,
70
+ onPress: void 0,
71
+ onPressIn: void 0,
72
+ onPressOut: void 0,
73
+ onLongPress: void 0,
74
+ onClick: void 0,
75
+ onKeyDown: void 0,
76
+ onKeyUp: void 0
77
+ },
78
+ children: /* @__PURE__ */ jsxs(ButtonNestingContext.Provider, {
79
+ value: true,
80
+ children: [
81
+ themedIcon,
82
+ wrappedChildren,
83
+ themedIconAfter
84
+ ]
85
+ })
86
+ };
87
+ return {
88
+ isNested,
89
+ props: resolvedProps
90
+ };
91
+ }
92
+
93
+ export { ButtonFrame, ButtonIcon, ButtonText, useButton };
263
94
  //# sourceMappingURL=Button.mjs.map
@@ -1 +1 @@
1
- {"version":3,"names":["getFontSize","getButtonSized","getIcon","useCurrentColor","ButtonNestingContext","getElevation","themeableVariants","SizableText","wrapChildrenInText","createStyledContext","getTokenValue","styled","useProps","View","withStaticProperties","useContext","jsx","jsxs","context","size","variant","color","elevation","ellipsis","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","maxFontSizeMultiplier","textAlign","Frame","name","role","render","type","tabIndex","variants","unstyled","true","outlineWidth","borderWidth","backgroundColor","false","justifyContent","alignItems","flexWrap","flexDirection","borderColor","cursor","hoverStyle","pressStyle","focusVisibleStyle","outlineColor","outlineStyle","outlined","process","env","TAMAGUI_HEADLESS","circular","chromeless","...size","val","extras","buttonStyle","gap",":number","disabled","pointerEvents","defaultVariants","Text","userSelect","flexGrow","flexShrink","Icon","props","children","scaleIcon","styledContext","useStyledContext","Error","sizeToken","iconColorProp","iconColor","iconSize","ButtonContext","ButtonComponent","styleable","propsIn","ref","isNested","processedProps","noNormalize","noExpand","icon","iconAfter","noTextWrap","textProps","contextColor","finalSize","iconSizeNumber","themedIcon","themedIconAfter","map","wrappedChildren","textContext","buttonContext","Provider","value","Button","Apply"],"sources":["../../src/Button.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAASA,WAAA,QAAmB;AAC5B,SAASC,cAAA,QAAsB;AAC/B,SAASC,OAAA,EAASC,eAAA,QAAuB;AACzC,SAASC,oBAAA,EAAsBC,YAAA,EAAcC,iBAAA,QAAyB;AAEtE,SAASC,WAAA,EAAaC,kBAAA,QAA0B;AAEhD,SACEC,mBAAA,EACAC,aAAA,EACAC,MAAA,EACAC,QAAA,EACAC,IAAA,EACAC,oBAAA,QACK;AAEP,SAASC,UAAA,QAAkB;AA6BjB,SAAAC,GAAA,EAqSFC,IAAA,QArSE;AAnBV,MAAMC,OAAA,GAAUT,mBAAA,CAAyC;EACvDU,IAAA,EAAM;EACNC,OAAA,EAAS;EACTC,KAAA,EAAO;EACPC,SAAA,EAAW;EACXC,QAAA,EAAU;EACVC,UAAA,EAAY;EACZC,QAAA,EAAU;EACVC,SAAA,EAAW;EACXC,UAAA,EAAY;EACZC,aAAA,EAAe;EACfC,qBAAA,EAAuB;EACvBC,SAAA,EAAW;AACb,CAAC;AAED,MAAMC,KAAA,GA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AA,CAAQrE,IAAA,IAAQ2D,aAAA,EAAe3D,IAAA;IACnDC,OAAA,EAASuD,KAAA,CAAMvD,OAAA,IAAWoE,OAAA,CAAQpE,OAAA,IAAW0D,aAAA,EAAe1D,OAAA;IAC5DE,SAAA,EAAWqD,KAAA,CAAMrD,SAAA,IAAakE,OAAA,CAAQlE,SAAA,IAAawD,aAAA,EAAexD;EACpE;EAEA,OACE,eAAAN,GAAA,CAACZ,oBAAA,CAAqBuG,QAAA,EAArB;IAA8BC,KAAA,EAAO;IACpChC,QAAA,iBAAA5D,GAAA,CAACE,OAAA,CAAQyF,QAAA,EAAR;MAAkB,GAAGD,aAAA;MACpB9B,QAAA,iBAAA3D,IAAA,CAACc,KAAA;QACC0D,GAAA;QACC,GAAGd,KAAA;QACH,IAAIe,QAAA,IAAY;UAAExD,MAAA,EAAQ;QAAO;QAEjC,IAAIyC,KAAA,CAAMhB,QAAA,IAAY,CAAC6B,OAAA,CAAQrE,IAAA,IAAQ;UAAEA;QAAK;QAC/CiB,QAAA,EAAU;QAETwC,QAAA,GAAAyB,UAAA,EACAG,eAAA,EACAF,eAAA;MAAA,CACH;IAAA,CACF;EAAA,CACF;AAEJ,CAAC;AAEM,MAAMO,MAAA,GAAS/F,oBAAA,CAAqBwE,eAAA,EAAiB;EAC1DwB,KAAA,EAAO5F,OAAA,CAAQyF,QAAA;EACf5E,KAAA;EACAuC,IAAA;EACAI;AACF,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"Button.js","names":[],"sources":["esm/Button.js"],"sourcesContent":["import { useGetThemedIcon } from \"@tamagui/helpers-tamagui\";\nimport { ButtonNestingContext } from \"@tamagui/stacks\";\nimport { textParentProps, wrapChildrenInText } from \"@tamagui/text\";\nimport { splitStyleProps, styled, Text, View } from \"@tamagui/web\";\nimport { useContext } from \"react\";\nimport { jsx, jsxs } from \"react/jsx-runtime\";\nconst ButtonFrame = styled(View, {\n // role is the cross-platform one; render only lands on web\n role: \"button\",\n render: /* @__PURE__ */ jsx(\"button\", { type: \"button\" }),\n tabIndex: 0,\n alignItems: \"center\",\n flexDirection: \"row\",\n flexWrap: \"nowrap\",\n justifyContent: \"center\",\n variants: {\n disabled: {\n true: {\n pointerEvents: \"none\"\n }\n }\n }\n});\nconst ButtonText = styled(Text, {\n // flexGrow 1 pushes text to the start of its parent on native\n flexGrow: 0,\n flexShrink: 1\n});\nconst ButtonIcon = ({ children, color, scaleIcon = 1, size }) => {\n const getThemedIcon = useGetThemedIcon({\n color,\n size: size === void 0 ? void 0 : size * scaleIcon\n });\n return getThemedIcon(children);\n};\nfunction useButton(propsIn, {\n Text: Text2 = ButtonText,\n iconColor,\n iconSize: iconSizeOption,\n textProps: textPropsOption\n} = {}) {\n const isNested = useContext(ButtonNestingContext);\n const [wrappedTextProps, buttonProps] = splitStyleProps(propsIn, {\n expandShorthands: true,\n filter: textParentProps\n });\n const {\n children,\n disabled,\n icon,\n iconAfter,\n iconSize,\n render,\n scaleIcon = 1,\n ...frameProps\n } = buttonProps;\n const { noTextWrap, textProps, ...textStyleProps } = wrappedTextProps;\n const resolvedIconSize = iconSize ?? iconSizeOption;\n const getThemedIcon = useGetThemedIcon({\n color: iconColor,\n size: resolvedIconSize === void 0 ? void 0 : resolvedIconSize * scaleIcon\n });\n const [themedIcon, themedIconAfter] = [icon, iconAfter].map((item) => {\n return item ? getThemedIcon(item) : null;\n });\n const wrappedChildren = wrapChildrenInText(\n Text2,\n { children, noTextWrap, textProps },\n { ...textPropsOption, ...textStyleProps }\n );\n const resolvedRender = render ?? (isNested ? \"span\" : disabled ? /* @__PURE__ */ jsx(\"button\", { type: \"button\", disabled: true }) : void 0);\n const resolvedProps = {\n ...frameProps,\n ...disabled && {\n \"aria-disabled\": true,\n disabled: true,\n tabIndex: -1\n },\n ...resolvedRender === void 0 ? null : { render: resolvedRender },\n ...isNested && {\n // a nested Button is a presentation part, not a control: strip the\n // interactive semantics so we never place a focusable role=button (with\n // its own press/keyboard handlers) inside the outer native <button>. that\n // nesting is invalid html, adds an extra focus stop, and bubbles\n // activation to the outer control. resolvedRender already makes it a span.\n role: \"none\",\n tabIndex: -1,\n \"aria-disabled\": void 0,\n disabled: void 0,\n onPress: void 0,\n onPressIn: void 0,\n onPressOut: void 0,\n onLongPress: void 0,\n onClick: void 0,\n onKeyDown: void 0,\n onKeyUp: void 0\n },\n children: /* @__PURE__ */ jsxs(ButtonNestingContext.Provider, { value: true, children: [\n themedIcon,\n wrappedChildren,\n themedIconAfter\n ] })\n };\n return {\n isNested,\n props: resolvedProps\n };\n}\nexport {\n ButtonFrame,\n ButtonIcon,\n ButtonText,\n useButton\n};\n//# sourceMappingURL=Button.js.map\n"],"mappings":";;;;;;;;AAMA,MAAM,cAAc,OAAO,MAAM;CAE/B,MAAM;CACN,QAAwB,oBAAI,UAAU,EAAE,MAAM,SAAS,CAAC;CACxD,UAAU;CACV,YAAY;CACZ,eAAe;CACf,UAAU;CACV,gBAAgB;CAChB,UAAU,EACR,UAAU,EACR,MAAM,EACJ,eAAe,OACjB,EACF,EACF;AACF,CAAC;AACD,MAAM,aAAa,OAAO,MAAM;CAE9B,UAAU;CACV,YAAY;AACd,CAAC;AACD,MAAM,cAAc,EAAE,UAAU,OAAO,YAAY,GAAG,WAAW;CAC/D,MAAM,gBAAgB,iBAAiB;EACrC;EACA,MAAM,SAAS,KAAK,IAAI,KAAK,IAAI,OAAO;CAC1C,CAAC;CACD,OAAO,cAAc,QAAQ;AAC/B;AACA,SAAS,UAAU,SAAS,EAC1B,MAAM,QAAQ,YACd,WACA,UAAU,gBACV,WAAW,oBACT,CAAC,GAAG;CACN,MAAM,WAAW,WAAW,oBAAoB;CAChD,MAAM,CAAC,kBAAkB,eAAe,gBAAgB,SAAS;EAC/D,kBAAkB;EAClB,QAAQ;CACV,CAAC;CACD,MAAM,EACJ,UACA,UACA,MACA,WACA,UACA,QACA,YAAY,GACZ,GAAG,eACD;CACJ,MAAM,EAAE,YAAY,WAAW,GAAG,mBAAmB;CACrD,MAAM,mBAAmB,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