@hanzogui/button 7.0.0 → 7.3.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 (84) hide show
  1. package/LICENSE +40 -19
  2. package/dist/cjs/Button.cjs +225 -0
  3. package/dist/cjs/Button.native.js +229 -0
  4. package/dist/cjs/Button.native.js.map +1 -0
  5. package/dist/cjs/Button.test.cjs +37 -0
  6. package/dist/cjs/Button.test.native.js +40 -0
  7. package/dist/cjs/Button.test.native.js.map +1 -0
  8. package/dist/cjs/index.cjs +20 -0
  9. package/dist/cjs/index.native.js +23 -0
  10. package/dist/cjs/index.native.js.map +1 -0
  11. package/dist/cjs/v1/Button.cjs +262 -0
  12. package/dist/cjs/v1/Button.native.js +267 -0
  13. package/dist/cjs/v1/Button.native.js.map +1 -0
  14. package/dist/cjs/v1/Button.test.cjs +9 -0
  15. package/dist/cjs/v1/Button.test.native.js +12 -0
  16. package/dist/cjs/v1/Button.test.native.js.map +1 -0
  17. package/dist/cjs/v1/index.cjs +20 -0
  18. package/dist/cjs/v1/index.native.js +23 -0
  19. package/dist/cjs/v1/index.native.js.map +1 -0
  20. package/dist/esm/Button.mjs +199 -0
  21. package/dist/esm/Button.mjs.map +1 -0
  22. package/dist/esm/Button.native.js +200 -0
  23. package/dist/esm/Button.native.js.map +1 -0
  24. package/dist/esm/Button.test.mjs +38 -0
  25. package/dist/esm/Button.test.mjs.map +1 -0
  26. package/dist/esm/Button.test.native.js +38 -0
  27. package/dist/esm/Button.test.native.js.map +1 -0
  28. package/dist/esm/index.js +2 -0
  29. package/dist/esm/index.js.map +1 -0
  30. package/dist/esm/index.mjs +2 -0
  31. package/dist/esm/index.mjs.map +1 -0
  32. package/dist/esm/index.native.js +2 -0
  33. package/dist/esm/index.native.js.map +1 -0
  34. package/dist/esm/v1/Button.mjs +232 -0
  35. package/dist/esm/v1/Button.mjs.map +1 -0
  36. package/dist/esm/v1/Button.native.js +234 -0
  37. package/dist/esm/v1/Button.native.js.map +1 -0
  38. package/dist/esm/v1/Button.test.mjs +10 -0
  39. package/dist/esm/v1/Button.test.mjs.map +1 -0
  40. package/dist/esm/v1/Button.test.native.js +10 -0
  41. package/dist/esm/v1/Button.test.native.js.map +1 -0
  42. package/dist/esm/v1/index.mjs +2 -0
  43. package/dist/esm/v1/index.mjs.map +1 -0
  44. package/dist/esm/v1/index.native.js +2 -0
  45. package/dist/esm/v1/index.native.js.map +1 -0
  46. package/dist/jsx/Button.mjs +199 -0
  47. package/dist/jsx/Button.mjs.map +1 -0
  48. package/dist/jsx/Button.native.js +229 -0
  49. package/dist/jsx/Button.native.js.map +1 -0
  50. package/dist/jsx/Button.test.mjs +38 -0
  51. package/dist/jsx/Button.test.mjs.map +1 -0
  52. package/dist/jsx/Button.test.native.js +40 -0
  53. package/dist/jsx/Button.test.native.js.map +1 -0
  54. package/dist/jsx/index.js +2 -0
  55. package/dist/jsx/index.js.map +1 -0
  56. package/dist/jsx/index.mjs +2 -0
  57. package/dist/jsx/index.mjs.map +1 -0
  58. package/dist/jsx/index.native.js +23 -0
  59. package/dist/jsx/index.native.js.map +1 -0
  60. package/dist/jsx/v1/Button.mjs +232 -0
  61. package/dist/jsx/v1/Button.mjs.map +1 -0
  62. package/dist/jsx/v1/Button.native.js +267 -0
  63. package/dist/jsx/v1/Button.native.js.map +1 -0
  64. package/dist/jsx/v1/Button.test.mjs +10 -0
  65. package/dist/jsx/v1/Button.test.mjs.map +1 -0
  66. package/dist/jsx/v1/Button.test.native.js +12 -0
  67. package/dist/jsx/v1/Button.test.native.js.map +1 -0
  68. package/dist/jsx/v1/index.mjs +2 -0
  69. package/dist/jsx/v1/index.mjs.map +1 -0
  70. package/dist/jsx/v1/index.native.js +23 -0
  71. package/dist/jsx/v1/index.native.js.map +1 -0
  72. package/package.json +20 -18
  73. package/src/Button.test.tsx +5 -5
  74. package/src/Button.tsx +4 -4
  75. package/src/v1/Button.test.tsx +5 -5
  76. package/src/v1/Button.tsx +5 -5
  77. package/types/Button.d.ts +7 -7
  78. package/types/Button.d.ts.map +1 -0
  79. package/types/Button.test.d.ts.map +1 -0
  80. package/types/index.d.ts.map +1 -0
  81. package/types/v1/Button.d.ts +10 -10
  82. package/types/v1/Button.d.ts.map +1 -0
  83. package/types/v1/Button.test.d.ts.map +1 -0
  84. package/types/v1/index.d.ts.map +1 -0
@@ -0,0 +1,262 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
14
+ get: () => from[key],
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ return to;
19
+ };
20
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
+ value: true
22
+ }), mod);
23
+ var Button_exports = {};
24
+ __export(Button_exports, {
25
+ Button: () => Button2,
26
+ ButtonContext: () => ButtonContext,
27
+ ButtonFrame: () => ButtonFrame,
28
+ ButtonIcon: () => ButtonIcon,
29
+ ButtonText: () => ButtonText,
30
+ useButton: () => useButton
31
+ });
32
+ module.exports = __toCommonJS(Button_exports);
33
+ var import_font_size = require("@hanzogui/font-size");
34
+ var import_get_button_sized = require("@hanzogui/get-button-sized");
35
+ var import_helpers = require("@hanzogui/helpers");
36
+ var import_component_helpers = require("@hanzogui/component-helpers");
37
+ var import_stacks = require("@hanzogui/stacks");
38
+ var import_text = require("@hanzogui/text");
39
+ var import_web = require("@hanzogui/web");
40
+ var import_react = require("react");
41
+ var import_spacer = require("@hanzogui/spacer");
42
+ var import_jsx_runtime = require("react/jsx-runtime");
43
+ const ButtonContext = (0, import_web.createStyledContext)({
44
+ // keeping these here means they work with styled() passing down color to text
45
+ color: void 0,
46
+ ellipsis: void 0,
47
+ fontFamily: void 0,
48
+ fontSize: void 0,
49
+ fontStyle: void 0,
50
+ fontWeight: void 0,
51
+ letterSpacing: void 0,
52
+ maxFontSizeMultiplier: void 0,
53
+ size: void 0,
54
+ textAlign: void 0,
55
+ variant: void 0
56
+ });
57
+ const BUTTON_NAME = "Button";
58
+ const ButtonFrame = (0, import_web.styled)(import_stacks.ThemeableStack, {
59
+ name: BUTTON_NAME,
60
+ render: "button",
61
+ context: ButtonContext,
62
+ role: "button",
63
+ focusable: true,
64
+ variants: {
65
+ unstyled: {
66
+ false: {
67
+ size: "$true",
68
+ justifyContent: "center",
69
+ alignItems: "center",
70
+ flexWrap: "nowrap",
71
+ flexDirection: "row",
72
+ cursor: "pointer",
73
+ hoverTheme: true,
74
+ pressTheme: true,
75
+ backgroundColor: "$background",
76
+ borderWidth: 1,
77
+ borderColor: "transparent",
78
+ focusVisibleStyle: {
79
+ outlineColor: "$outlineColor",
80
+ outlineStyle: "solid",
81
+ outlineWidth: 2
82
+ }
83
+ }
84
+ },
85
+ variant: {
86
+ outlined: {
87
+ backgroundColor: "transparent",
88
+ borderWidth: 2,
89
+ borderColor: "$borderColor",
90
+ hoverStyle: {
91
+ backgroundColor: "transparent",
92
+ borderColor: "$borderColorHover"
93
+ },
94
+ pressStyle: {
95
+ backgroundColor: "transparent",
96
+ borderColor: "$borderColorPress"
97
+ },
98
+ focusVisibleStyle: {
99
+ backgroundColor: "transparent",
100
+ borderColor: "$borderColorFocus"
101
+ }
102
+ }
103
+ },
104
+ size: {
105
+ "...size": import_get_button_sized.getButtonSized,
106
+ ":number": import_get_button_sized.getButtonSized
107
+ },
108
+ disabled: {
109
+ true: {
110
+ pointerEvents: "none"
111
+ }
112
+ }
113
+ },
114
+ defaultVariants: {
115
+ unstyled: process.env.GUI_HEADLESS === "1"
116
+ }
117
+ });
118
+ const ButtonText = (0, import_web.styled)(import_text.SizableText, {
119
+ name: "Button",
120
+ context: ButtonContext,
121
+ variants: {
122
+ unstyled: {
123
+ false: {
124
+ userSelect: "none",
125
+ cursor: "pointer",
126
+ // flexGrow 1 leads to inconsistent native style where text pushes to start of view
127
+ flexGrow: 0,
128
+ flexShrink: 1,
129
+ ellipsis: true,
130
+ color: "$color"
131
+ }
132
+ }
133
+ },
134
+ defaultVariants: {
135
+ unstyled: process.env.GUI_HEADLESS === "1"
136
+ }
137
+ });
138
+ const ButtonIcon = props => {
139
+ const {
140
+ children,
141
+ scaleIcon = 1
142
+ } = props;
143
+ const {
144
+ size,
145
+ color
146
+ } = (0, import_react.useContext)(ButtonContext);
147
+ const iconSize = (typeof size === "number" ? size * 0.5 : (0, import_font_size.getFontSize)(size)) * scaleIcon;
148
+ const getThemedIcon = (0, import_component_helpers.useGetThemedIcon)({
149
+ size: iconSize,
150
+ color
151
+ });
152
+ return getThemedIcon(children);
153
+ };
154
+ const ButtonComponent = ButtonFrame.styleable(function Button(props, ref) {
155
+ const {
156
+ props: buttonProps
157
+ } = useButton(props);
158
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(ButtonFrame, {
159
+ "data-disable-theme": true,
160
+ ...buttonProps,
161
+ ref
162
+ });
163
+ });
164
+ const Button2 = (0, import_helpers.withStaticProperties)(ButtonComponent, {
165
+ Text: ButtonText,
166
+ Icon: ButtonIcon
167
+ });
168
+ function useButton({
169
+ textProps,
170
+ ...propsIn
171
+ }, {
172
+ Text = Button2.Text
173
+ } = {
174
+ Text: Button2.Text
175
+ }) {
176
+ const isNested = (0, import_react.useContext)(import_stacks.ButtonNestingContext);
177
+ const propsActive = (0, import_web.useProps)(propsIn, {
178
+ noNormalize: true,
179
+ noExpand: true
180
+ });
181
+ const {
182
+ icon,
183
+ iconAfter,
184
+ gap,
185
+ spaceFlex,
186
+ scaleIcon = 1,
187
+ scaleSpace = 0.66,
188
+ noTextWrap,
189
+ fontFamily,
190
+ fontSize,
191
+ fontWeight,
192
+ fontStyle,
193
+ letterSpacing,
194
+ render,
195
+ ellipsis,
196
+ maxFontSizeMultiplier,
197
+ ...restProps
198
+ } = propsActive;
199
+ const size = propsActive.size || (propsActive.unstyled ? void 0 : "$true");
200
+ const color = propsActive.color;
201
+ const iconSize = (typeof size === "number" ? size * 0.5 : (0, import_font_size.getFontSize)(size, {
202
+ font: fontFamily?.[0] === "$" ? fontFamily : void 0
203
+ })) * scaleIcon;
204
+ const getThemedIcon = (0, import_component_helpers.useGetThemedIcon)({
205
+ size: iconSize,
206
+ color
207
+ });
208
+ const [themedIcon, themedIconAfter] = [icon, iconAfter].map(getThemedIcon);
209
+ const spaceSize = gap ?? (0, import_web.getVariableValue)(iconSize) * scaleSpace;
210
+ const contents = noTextWrap ? [propsIn.children] : (0, import_text.wrapChildrenInText)(Text, {
211
+ children: propsIn.children,
212
+ fontFamily,
213
+ fontSize,
214
+ textProps,
215
+ fontWeight,
216
+ fontStyle,
217
+ letterSpacing,
218
+ ellipsis,
219
+ maxFontSizeMultiplier
220
+ }, Text === ButtonText && propsActive.unstyled !== true ? {
221
+ unstyled: process.env.GUI_HEADLESS === "1",
222
+ size
223
+ } : void 0);
224
+ const inner = (0, import_spacer.spacedChildren)({
225
+ // a bit arbitrary but scaling to font size is necessary so long as button does
226
+ space: spaceSize,
227
+ spaceFlex,
228
+ ensureKeys: true,
229
+ direction: propsActive.flexDirection === "column" || propsActive.flexDirection === "column-reverse" ? "vertical" : "horizontal",
230
+ // for keys to stay the same we keep indices as similar a possible
231
+ // so even if icons are undefined we still pass them
232
+ children: [themedIcon, ...contents, themedIconAfter]
233
+ });
234
+ const props = {
235
+ size,
236
+ ...(propsIn.disabled && {
237
+ // in rnw - false still has keyboard tabIndex, undefined = not actually focusable
238
+ focusable: void 0,
239
+ // even with tabIndex unset, it will keep focusVisibleStyle on web so disable it here
240
+ focusVisibleStyle: {
241
+ borderColor: "$background"
242
+ }
243
+ }),
244
+ // fixes SSR issue + DOM nesting issue of not allowing button in button
245
+ render: render ?? (isNested ? "span" :
246
+ // defaults to <a /> when accessibilityRole = link
247
+ // see https://github.com/hanzoai/gui/issues/505
248
+ propsActive.accessibilityRole === "link" || propsActive.role === "link" ? "a" : "button"),
249
+ ...restProps,
250
+ children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_stacks.ButtonNestingContext.Provider, {
251
+ value: true,
252
+ children: inner
253
+ }),
254
+ // forces it to be a runtime pressStyle so it passes through context text colors
255
+ disableClassName: true
256
+ };
257
+ return {
258
+ spaceSize,
259
+ isNested,
260
+ props
261
+ };
262
+ }
@@ -0,0 +1,267 @@
1
+ "use strict";
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true
11
+ });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
+ get: () => from[key],
17
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
+ });
19
+ }
20
+ return to;
21
+ };
22
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
23
+ value: true
24
+ }), mod);
25
+ var Button_exports = {};
26
+ __export(Button_exports, {
27
+ Button: () => Button2,
28
+ ButtonContext: () => ButtonContext,
29
+ ButtonFrame: () => ButtonFrame,
30
+ ButtonIcon: () => ButtonIcon,
31
+ ButtonText: () => ButtonText,
32
+ useButton: () => useButton
33
+ });
34
+ module.exports = __toCommonJS(Button_exports);
35
+ var import_jsx_runtime = require("react/jsx-runtime");
36
+ var import_font_size = require("@hanzogui/font-size");
37
+ var import_get_button_sized = require("@hanzogui/get-button-sized");
38
+ var import_helpers = require("@hanzogui/helpers");
39
+ var import_component_helpers = require("@hanzogui/component-helpers");
40
+ var import_stacks = require("@hanzogui/stacks");
41
+ var import_text = require("@hanzogui/text");
42
+ var import_web = require("@hanzogui/web");
43
+ var import_react = require("react");
44
+ var import_spacer = require("@hanzogui/spacer");
45
+ var ButtonContext = (0, import_web.createStyledContext)({
46
+ // keeping these here means they work with styled() passing down color to text
47
+ color: void 0,
48
+ ellipsis: void 0,
49
+ fontFamily: void 0,
50
+ fontSize: void 0,
51
+ fontStyle: void 0,
52
+ fontWeight: void 0,
53
+ letterSpacing: void 0,
54
+ maxFontSizeMultiplier: void 0,
55
+ size: void 0,
56
+ textAlign: void 0,
57
+ variant: void 0
58
+ });
59
+ var BUTTON_NAME = "Button";
60
+ var ButtonFrame = (0, import_web.styled)(import_stacks.ThemeableStack, {
61
+ name: BUTTON_NAME,
62
+ render: "button",
63
+ context: ButtonContext,
64
+ role: "button",
65
+ focusable: true,
66
+ variants: {
67
+ unstyled: {
68
+ false: {
69
+ size: "$true",
70
+ justifyContent: "center",
71
+ alignItems: "center",
72
+ flexWrap: "nowrap",
73
+ flexDirection: "row",
74
+ cursor: "pointer",
75
+ hoverTheme: true,
76
+ pressTheme: true,
77
+ backgroundColor: "$background",
78
+ borderWidth: 1,
79
+ borderColor: "transparent",
80
+ focusVisibleStyle: {
81
+ outlineColor: "$outlineColor",
82
+ outlineStyle: "solid",
83
+ outlineWidth: 2
84
+ }
85
+ }
86
+ },
87
+ variant: {
88
+ outlined: {
89
+ backgroundColor: "transparent",
90
+ borderWidth: 2,
91
+ borderColor: "$borderColor",
92
+ hoverStyle: {
93
+ backgroundColor: "transparent",
94
+ borderColor: "$borderColorHover"
95
+ },
96
+ pressStyle: {
97
+ backgroundColor: "transparent",
98
+ borderColor: "$borderColorPress"
99
+ },
100
+ focusVisibleStyle: {
101
+ backgroundColor: "transparent",
102
+ borderColor: "$borderColorFocus"
103
+ }
104
+ }
105
+ },
106
+ size: {
107
+ "...size": import_get_button_sized.getButtonSized,
108
+ ":number": import_get_button_sized.getButtonSized
109
+ },
110
+ disabled: {
111
+ true: {
112
+ pointerEvents: "none"
113
+ }
114
+ }
115
+ },
116
+ defaultVariants: {
117
+ unstyled: process.env.GUI_HEADLESS === "1"
118
+ }
119
+ });
120
+ var ButtonText = (0, import_web.styled)(import_text.SizableText, {
121
+ name: "Button",
122
+ context: ButtonContext,
123
+ variants: {
124
+ unstyled: {
125
+ false: {
126
+ userSelect: "none",
127
+ cursor: "pointer",
128
+ // flexGrow 1 leads to inconsistent native style where text pushes to start of view
129
+ flexGrow: 0,
130
+ flexShrink: 1,
131
+ ellipsis: true,
132
+ color: "$color"
133
+ }
134
+ }
135
+ },
136
+ defaultVariants: {
137
+ unstyled: process.env.GUI_HEADLESS === "1"
138
+ }
139
+ });
140
+ var ButtonIcon = function (props) {
141
+ var {
142
+ children,
143
+ scaleIcon = 1
144
+ } = props;
145
+ var {
146
+ size,
147
+ color
148
+ } = (0, import_react.useContext)(ButtonContext);
149
+ var iconSize = (typeof size === "number" ? size * 0.5 : (0, import_font_size.getFontSize)(size)) * scaleIcon;
150
+ var getThemedIcon = (0, import_component_helpers.useGetThemedIcon)({
151
+ size: iconSize,
152
+ color
153
+ });
154
+ return getThemedIcon(children);
155
+ };
156
+ var ButtonComponent = ButtonFrame.styleable(function Button(props, ref) {
157
+ var {
158
+ props: buttonProps
159
+ } = useButton(props);
160
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(ButtonFrame, {
161
+ "data-disable-theme": true,
162
+ ...buttonProps,
163
+ ref
164
+ });
165
+ });
166
+ var Button2 = (0, import_helpers.withStaticProperties)(ButtonComponent, {
167
+ Text: ButtonText,
168
+ Icon: ButtonIcon
169
+ });
170
+ function useButton(param) {
171
+ var {
172
+ textProps,
173
+ ...propsIn
174
+ } = param,
175
+ {
176
+ Text = Button2.Text
177
+ } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
178
+ Text: Button2.Text
179
+ };
180
+ var isNested = (0, import_react.useContext)(import_stacks.ButtonNestingContext);
181
+ var propsActive = (0, import_web.useProps)(propsIn, {
182
+ noNormalize: true,
183
+ noExpand: true
184
+ });
185
+ var {
186
+ icon,
187
+ iconAfter,
188
+ gap,
189
+ spaceFlex,
190
+ scaleIcon = 1,
191
+ scaleSpace = 0.66,
192
+ noTextWrap,
193
+ fontFamily,
194
+ fontSize,
195
+ fontWeight,
196
+ fontStyle,
197
+ letterSpacing,
198
+ render,
199
+ ellipsis,
200
+ maxFontSizeMultiplier,
201
+ ...restProps
202
+ } = propsActive;
203
+ var size = propsActive.size || (propsActive.unstyled ? void 0 : "$true");
204
+ var color = propsActive.color;
205
+ var iconSize = (typeof size === "number" ? size * 0.5 : (0, import_font_size.getFontSize)(size, {
206
+ font: (fontFamily === null || fontFamily === void 0 ? void 0 : fontFamily[0]) === "$" ? fontFamily : void 0
207
+ })) * scaleIcon;
208
+ var getThemedIcon = (0, import_component_helpers.useGetThemedIcon)({
209
+ size: iconSize,
210
+ color
211
+ });
212
+ var [themedIcon, themedIconAfter] = [icon, iconAfter].map(getThemedIcon);
213
+ var spaceSize = gap !== null && gap !== void 0 ? gap : (0, import_web.getVariableValue)(iconSize) * scaleSpace;
214
+ var contents = noTextWrap ? [propsIn.children] : (0, import_text.wrapChildrenInText)(Text, {
215
+ children: propsIn.children,
216
+ fontFamily,
217
+ fontSize,
218
+ textProps,
219
+ fontWeight,
220
+ fontStyle,
221
+ letterSpacing,
222
+ ellipsis,
223
+ maxFontSizeMultiplier
224
+ }, Text === ButtonText && propsActive.unstyled !== true ? {
225
+ unstyled: process.env.GUI_HEADLESS === "1",
226
+ size
227
+ } : void 0);
228
+ var inner = (0, import_spacer.spacedChildren)({
229
+ // a bit arbitrary but scaling to font size is necessary so long as button does
230
+ space: spaceSize,
231
+ spaceFlex,
232
+ ensureKeys: true,
233
+ direction: propsActive.flexDirection === "column" || propsActive.flexDirection === "column-reverse" ? "vertical" : "horizontal",
234
+ // for keys to stay the same we keep indices as similar a possible
235
+ // so even if icons are undefined we still pass them
236
+ children: [themedIcon, ...contents, themedIconAfter]
237
+ });
238
+ var props = {
239
+ size,
240
+ ...(propsIn.disabled && {
241
+ // in rnw - false still has keyboard tabIndex, undefined = not actually focusable
242
+ focusable: void 0,
243
+ // even with tabIndex unset, it will keep focusVisibleStyle on web so disable it here
244
+ focusVisibleStyle: {
245
+ borderColor: "$background"
246
+ }
247
+ }),
248
+ // fixes SSR issue + DOM nesting issue of not allowing button in button
249
+ render: render !== null && render !== void 0 ? render : isNested ? "span" :
250
+ // defaults to <a /> when accessibilityRole = link
251
+ // see https://github.com/hanzoai/gui/issues/505
252
+ propsActive.accessibilityRole === "link" || propsActive.role === "link" ? "a" : "button",
253
+ ...restProps,
254
+ children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_stacks.ButtonNestingContext.Provider, {
255
+ value: true,
256
+ children: inner
257
+ }),
258
+ // forces it to be a runtime pressStyle so it passes through context text colors
259
+ disableClassName: true
260
+ };
261
+ return {
262
+ spaceSize,
263
+ isNested,
264
+ props
265
+ };
266
+ }
267
+ //# sourceMappingURL=Button.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","Button_exports","__export","Button","Button2","ButtonContext","ButtonFrame","ButtonIcon","ButtonText","useButton","module","exports","import_jsx_runtime","require","import_font_size","import_get_button_sized","import_helpers","import_component_helpers","import_stacks","import_text","import_web","import_react","import_spacer","createStyledContext","color","ellipsis","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","maxFontSizeMultiplier","size","textAlign","variant","BUTTON_NAME","styled","ThemeableStack","name","render","context","role","focusable","variants","unstyled","false","justifyContent","alignItems","flexWrap","flexDirection","cursor","hoverTheme","pressTheme","backgroundColor","borderWidth","borderColor","focusVisibleStyle","outlineColor","outlineStyle","outlineWidth","outlined","hoverStyle","pressStyle","getButtonSized","disabled","true","pointerEvents","defaultVariants","process","env","GUI_HEADLESS","SizableText","userSelect","flexGrow","flexShrink","props","children","scaleIcon","useContext","iconSize","getFontSize","getThemedIcon","useGetThemedIcon","ButtonComponent","styleable","ref","buttonProps","jsx","withStaticProperties","Text","Icon","param","textProps","propsIn","arguments","length","isNested","ButtonNestingContext","propsActive","useProps","noNormalize","noExpand","icon","iconAfter","gap","spaceFlex","scaleSpace","noTextWrap","restProps","font","themedIcon","themedIconAfter","map","spaceSize","getVariableValue","contents","wrapChildrenInText","inner","spacedChildren","space","ensureKeys","direction","accessibilityRole","Provider","disableClassName"],"sources":["../../../src/v1/Button.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,cAAA;AAAAC,QAAA,CAAAD,cAAA;EAAAE,MAAA,EAAAA,CAAA,KAAAC,OAAA;EAAAC,aAAA,EAAAA,CAAA,KAAAA,aAAA;EAAAC,WAAA,EAAAA,CAAA,KAAAA,WAAA;EAAAC,UAAA,EAAAA,CAAA,KAAAA,UAAA;EAAAC,UAAA,EAAAA,CAAA,KAAAA,UAAA;EAAAC,SAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAf,YAA4B,CAAAK,cAAA;AAC5B,IAAAW,kBAAA,GAAAC,OAA+B;AAC/B,IAAAC,gBAAA,GAAqCD,OAAA;AACrC,IAAAE,uBAAA,GAAAF,OAAiC;AACjC,IAAAG,cAAA,GAAqDH,OAAA;AAErD,IAAAI,wBAAgD,GAAAJ,OAAA;AAEhD,IAAAK,aAAwE,GAAAL,OAAA;AAExE,IAAAM,WAAA,GAAAN,OAA2B;AAC3B,IAAAO,UAAA,GAAAP,OAA+B;AAiLpB,IAAAQ,YAAA,GAAAR,OAAA;AA7KJ,IAAAS,aAAM,GAAAT,OAAgB;AAO3B,IAAAR,aAAA,OA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Db,QAAO,EAAAiB,OAAY,CAAAjB,QAAA;IACnBlD,UAAM;IACNC,QAAM;IAGAiE,SAAA;IACA/D,UAAA;IAAAD,SACE;IAAkBE,aAClB;IAAAL,QACA;IAAAM;EACA,GAAA0D,IACA,KAAAjF,UAAA,IAAA0F,WAAA,CAAAtD,QAAA;IAAAA,QACA,EAAAwB,OAAA,CAAAC,GAAA,CAAAC,YAAA;IAAAtC;EACA,IACA;EAAA,IACAqF,KAAA,OAAA/F,aAAA,CAAAgG,cAAA;IACF;IACAC,KAAA,EAAAN,SAAS;IACLR,SACE;IAAuCe,UACvC;IACFC,SACA,EAAAvB,WAAA,CAAAjD,aAAA,iBAAAiD,WAAA,CAAAjD,aAAA;IACN;IAEJ;IAA6B2B,QAAA,GAE3BkC,UAAO,EACP,GAAAK,QAAA,EACAJ,eAAY;EAKN;EAAA,IAAApC,KAAA;IAGN3C,IAAA;IACD,IAAA6D,OAAA,CAAA7B,QAAA;MAED;MACEtB,SAAA;MACA;MAAwBc,iBAAA;QAEtBD,WAAW;MAAA;IAAA;IAEQ;IACJhB,MACf,EAAAA,MAAA,aAAAA,MAAA,cAAAA,MAAA,GAAAyD,QAAA;IACF;IAAA;IAEAE,WACE,CAAAwB,iBAEI,eAAAxB,WAAA,CAAAzD,IAAA;IAAA,GAAAmE,SAAA;IAAAhC,QAGA,iBAAY,IAAAhE,kBAAgC,CAAA2E,GAAA,EAAArE,aAAqB,CAAA+E,oBAE/D,CAAA0B,QAAA;MAAA3H,KAAA;MAER4E,QAAG,EAAAyC;IAEH;IACqD;IAGrDO,gBAAA,EAAkB;EACpB;EAEA,OAAO;IACLX,SAAA;IACAjB,QAAA;IACArB;EACF;AACF","ignoreList":[]}
@@ -0,0 +1,9 @@
1
+ var import_config_default = require("@hanzogui/config-default");
2
+ var import_core = require("@hanzogui/core");
3
+ var import_vitest = require("vitest");
4
+ const conf = (0, import_core.createGui)((0, import_config_default.getDefaultGuiConfig)());
5
+ (0, import_vitest.describe)("Button", () => {
6
+ (0, import_vitest.test)(`123`, () => {
7
+ (0, import_vitest.expect)(true).toBeTruthy();
8
+ });
9
+ });
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ var import_config_default = require("@hanzogui/config-default");
4
+ var import_core = require("@hanzogui/core");
5
+ var import_vitest = require("vitest");
6
+ var conf = (0, import_core.createGui)((0, import_config_default.getDefaultGuiConfig)());
7
+ (0, import_vitest.describe)("Button", function () {
8
+ (0, import_vitest.test)(`123`, function () {
9
+ (0, import_vitest.expect)(true).toBeTruthy();
10
+ });
11
+ });
12
+ //# sourceMappingURL=Button.test.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["import_config_default","require","import_core","import_vitest","conf","createGui","getDefaultGuiConfig","describe","test","expect","toBeTruthy"],"sources":["../../../src/v1/Button.test.tsx"],"sourcesContent":[null],"mappings":"AAAA;;AACA,IAAAA,qBAA0B,GAAAC,OAAA;AAC1B,IAAAC,WAAA,GAAAD,OAAuC;AAEvC,IAAAE,aAAa,GAAAF,OAAA;AAA+B,IAE5CG,IAAA,OAAAF,WAAA,CAAAG,SAAS,EAAU,IAAAL,qBAAM,CAAAM,mBAAA;AACvB,IAAAH,aAAA,CAAAI,QAAK,UAAO,cAAM;EAChB,IAAAJ,aAAA,CAAAK,IAAA,OAAO,cAAM;IACd,IAAAL,aAAA,CAAAM,MAAA,QAAAC,UAAA;EAWF","ignoreList":[]}
@@ -0,0 +1,20 @@
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)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
8
+ get: () => from[key],
9
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
10
+ });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
16
+ value: true
17
+ }), mod);
18
+ var v1_exports = {};
19
+ module.exports = __toCommonJS(v1_exports);
20
+ __reExport(v1_exports, require("./Button.cjs"), module.exports);
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __copyProps = (to, from, except, desc) => {
8
+ if (from && typeof from === "object" || typeof from === "function") {
9
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
10
+ get: () => from[key],
11
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
12
+ });
13
+ }
14
+ return to;
15
+ };
16
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
17
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
18
+ value: true
19
+ }), mod);
20
+ var v1_exports = {};
21
+ module.exports = __toCommonJS(v1_exports);
22
+ __reExport(v1_exports, require("./Button.native.js"), module.exports);
23
+ //# sourceMappingURL=index.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","v1_exports","module","exports"],"sources":["../../../src/v1/index.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,UAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAP,YAAc,CAAAK,UAAA","ignoreList":[]}