@yamada-ui/button 0.2.5 → 0.2.7
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.
- package/dist/button-group.js +6 -4
- package/dist/button-group.mjs +1 -1
- package/dist/button.js +79 -76
- package/dist/button.mjs +2 -2
- package/dist/{chunk-ZJ6VNE3P.mjs → chunk-EGXUSOSB.mjs} +10 -5
- package/dist/chunk-PJFZNNJZ.mjs +151 -0
- package/dist/{chunk-UNYNUYOU.mjs → chunk-WAZQVSDT.mjs} +11 -2
- package/dist/icon-button.js +89 -77
- package/dist/icon-button.mjs +3 -3
- package/dist/index.js +89 -77
- package/dist/index.mjs +3 -3
- package/package.json +4 -4
- package/dist/chunk-2U57OXHK.mjs +0 -146
package/dist/button-group.js
CHANGED
|
@@ -28,10 +28,12 @@ var import_core = require("@yamada-ui/core");
|
|
|
28
28
|
var import_utils = require("@yamada-ui/utils");
|
|
29
29
|
var import_react = require("react");
|
|
30
30
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
31
|
-
var [ButtonGroupProvider, useButtonGroup] = (0, import_utils.createContext)(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
var [ButtonGroupProvider, useButtonGroup] = (0, import_utils.createContext)(
|
|
32
|
+
{
|
|
33
|
+
strict: false,
|
|
34
|
+
name: "ButtonGroupContext"
|
|
35
|
+
}
|
|
36
|
+
);
|
|
35
37
|
var ButtonGroup = (0, import_core.forwardRef)(
|
|
36
38
|
({
|
|
37
39
|
className,
|
package/dist/button-group.mjs
CHANGED
package/dist/button.js
CHANGED
|
@@ -34,10 +34,12 @@ var import_core = require("@yamada-ui/core");
|
|
|
34
34
|
var import_utils = require("@yamada-ui/utils");
|
|
35
35
|
var import_react = require("react");
|
|
36
36
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
37
|
-
var [ButtonGroupProvider, useButtonGroup] = (0, import_utils.createContext)(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
var [ButtonGroupProvider, useButtonGroup] = (0, import_utils.createContext)(
|
|
38
|
+
{
|
|
39
|
+
strict: false,
|
|
40
|
+
name: "ButtonGroupContext"
|
|
41
|
+
}
|
|
42
|
+
);
|
|
41
43
|
var ButtonGroup = (0, import_core.forwardRef)(
|
|
42
44
|
({
|
|
43
45
|
className,
|
|
@@ -89,79 +91,80 @@ var ButtonGroup = (0, import_core.forwardRef)(
|
|
|
89
91
|
|
|
90
92
|
// src/button.tsx
|
|
91
93
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
92
|
-
var Button = (0, import_core2.forwardRef)(
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
isDisabled = group == null ? void 0 : group.isDisabled,
|
|
102
|
-
leftIcon,
|
|
103
|
-
rightIcon,
|
|
104
|
-
loadingIcon,
|
|
105
|
-
loadingText,
|
|
106
|
-
loadingPlacement = "start",
|
|
107
|
-
__css,
|
|
108
|
-
...rest
|
|
109
|
-
} = (0, import_core2.omitThemeProps)(mergedProps);
|
|
110
|
-
const { ref: buttonRef, type: defaultType } = useButtonType(as);
|
|
111
|
-
const ref = (0, import_utils2.useMergeRefs)(customRef, buttonRef);
|
|
112
|
-
const css = (0, import_react2.useMemo)(() => {
|
|
113
|
-
var _a;
|
|
114
|
-
const _focus = "_focus" in styles ? (0, import_utils2.merge)((_a = styles._focus) != null ? _a : {}, { zIndex: 1 }) : {};
|
|
115
|
-
return {
|
|
116
|
-
display: "inline-flex",
|
|
117
|
-
alignItems: "center",
|
|
118
|
-
justifyContent: "center",
|
|
119
|
-
gap: "2",
|
|
120
|
-
appearance: "none",
|
|
121
|
-
userSelect: "none",
|
|
122
|
-
position: "relative",
|
|
123
|
-
whiteSpace: "nowrap",
|
|
124
|
-
verticalAlign: "middle",
|
|
125
|
-
outline: "none",
|
|
126
|
-
...styles,
|
|
127
|
-
...__css,
|
|
128
|
-
...!!group ? { _focus } : {}
|
|
129
|
-
};
|
|
130
|
-
}, [styles, __css, group]);
|
|
131
|
-
const contentProps = {
|
|
132
|
-
leftIcon,
|
|
133
|
-
rightIcon,
|
|
134
|
-
children
|
|
135
|
-
};
|
|
136
|
-
const loadingProps = {
|
|
137
|
-
loadingIcon,
|
|
138
|
-
loadingText
|
|
139
|
-
};
|
|
140
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
141
|
-
import_core2.ui.button,
|
|
142
|
-
{
|
|
143
|
-
ref,
|
|
94
|
+
var Button = (0, import_core2.forwardRef)(
|
|
95
|
+
({ children, ...props }, customRef) => {
|
|
96
|
+
const group = useButtonGroup();
|
|
97
|
+
const [styles, mergedProps] = (0, import_core2.useComponentStyle)("Button", {
|
|
98
|
+
...group,
|
|
99
|
+
...props
|
|
100
|
+
});
|
|
101
|
+
const {
|
|
102
|
+
className,
|
|
144
103
|
as,
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
var
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
104
|
+
type,
|
|
105
|
+
isLoading,
|
|
106
|
+
isActive,
|
|
107
|
+
isDisabled = group == null ? void 0 : group.isDisabled,
|
|
108
|
+
leftIcon,
|
|
109
|
+
rightIcon,
|
|
110
|
+
loadingIcon,
|
|
111
|
+
loadingText,
|
|
112
|
+
loadingPlacement = "start",
|
|
113
|
+
__css,
|
|
114
|
+
...rest
|
|
115
|
+
} = (0, import_core2.omitThemeProps)(mergedProps);
|
|
116
|
+
const { ref: buttonRef, type: defaultType } = useButtonType(as);
|
|
117
|
+
const ref = (0, import_utils2.useMergeRefs)(customRef, buttonRef);
|
|
118
|
+
const css = (0, import_react2.useMemo)(() => {
|
|
119
|
+
var _a;
|
|
120
|
+
const _focus = "_focus" in styles ? (0, import_utils2.merge)((_a = styles._focus) != null ? _a : {}, { zIndex: 1 }) : {};
|
|
121
|
+
return {
|
|
122
|
+
display: "inline-flex",
|
|
123
|
+
alignItems: "center",
|
|
124
|
+
justifyContent: "center",
|
|
125
|
+
gap: "2",
|
|
126
|
+
appearance: "none",
|
|
127
|
+
userSelect: "none",
|
|
128
|
+
position: "relative",
|
|
129
|
+
whiteSpace: "nowrap",
|
|
130
|
+
verticalAlign: "middle",
|
|
131
|
+
outline: "none",
|
|
132
|
+
...styles,
|
|
133
|
+
...__css,
|
|
134
|
+
...!!group ? { _focus } : {}
|
|
135
|
+
};
|
|
136
|
+
}, [styles, __css, group]);
|
|
137
|
+
const contentProps = {
|
|
138
|
+
leftIcon,
|
|
139
|
+
rightIcon,
|
|
140
|
+
children
|
|
141
|
+
};
|
|
142
|
+
const loadingProps = {
|
|
143
|
+
loadingIcon,
|
|
144
|
+
loadingText
|
|
145
|
+
};
|
|
146
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
147
|
+
import_core2.ui.button,
|
|
148
|
+
{
|
|
149
|
+
ref,
|
|
150
|
+
as,
|
|
151
|
+
className: (0, import_utils2.cx)("ui-button", className),
|
|
152
|
+
type: type != null ? type : defaultType,
|
|
153
|
+
disabled: isDisabled || isLoading,
|
|
154
|
+
"data-active": (0, import_utils2.dataAttr)(isActive),
|
|
155
|
+
"data-loading": (0, import_utils2.dataAttr)(isLoading),
|
|
156
|
+
__css: css,
|
|
157
|
+
...rest,
|
|
158
|
+
children: [
|
|
159
|
+
isLoading && loadingPlacement === "start" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Loading, { className: "ui-button-loading--start", ...loadingProps }) : null,
|
|
160
|
+
isLoading ? loadingText || /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.ui.span, { opacity: 0, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Content, { ...contentProps }) }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Content, { ...contentProps }),
|
|
161
|
+
isLoading && loadingPlacement === "end" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Loading, { className: "ui-button-loading--end", ...loadingProps }) : null
|
|
162
|
+
]
|
|
163
|
+
}
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
);
|
|
167
|
+
var Loading = ({ className, loadingIcon, loadingText }) => {
|
|
165
168
|
const css = (0, import_react2.useMemo)(
|
|
166
169
|
() => ({
|
|
167
170
|
display: "flex",
|
package/dist/button.mjs
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
// src/button-group.tsx
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
ui,
|
|
4
|
+
forwardRef
|
|
5
|
+
} from "@yamada-ui/core";
|
|
3
6
|
import { createContext, cx, dataAttr } from "@yamada-ui/utils";
|
|
4
7
|
import { useMemo } from "react";
|
|
5
8
|
import { jsx } from "react/jsx-runtime";
|
|
6
|
-
var [ButtonGroupProvider, useButtonGroup] = createContext(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
var [ButtonGroupProvider, useButtonGroup] = createContext(
|
|
10
|
+
{
|
|
11
|
+
strict: false,
|
|
12
|
+
name: "ButtonGroupContext"
|
|
13
|
+
}
|
|
14
|
+
);
|
|
10
15
|
var ButtonGroup = forwardRef(
|
|
11
16
|
({
|
|
12
17
|
className,
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useButtonGroup
|
|
3
|
+
} from "./chunk-EGXUSOSB.mjs";
|
|
4
|
+
|
|
5
|
+
// src/button.tsx
|
|
6
|
+
import {
|
|
7
|
+
ui,
|
|
8
|
+
forwardRef,
|
|
9
|
+
useComponentStyle,
|
|
10
|
+
omitThemeProps
|
|
11
|
+
} from "@yamada-ui/core";
|
|
12
|
+
import { Loading as LoadingIcon } from "@yamada-ui/loading";
|
|
13
|
+
import { cx, useMergeRefs, merge, dataAttr } from "@yamada-ui/utils";
|
|
14
|
+
import {
|
|
15
|
+
useCallback,
|
|
16
|
+
useMemo,
|
|
17
|
+
useState
|
|
18
|
+
} from "react";
|
|
19
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
20
|
+
var Button = forwardRef(
|
|
21
|
+
({ children, ...props }, customRef) => {
|
|
22
|
+
const group = useButtonGroup();
|
|
23
|
+
const [styles, mergedProps] = useComponentStyle("Button", {
|
|
24
|
+
...group,
|
|
25
|
+
...props
|
|
26
|
+
});
|
|
27
|
+
const {
|
|
28
|
+
className,
|
|
29
|
+
as,
|
|
30
|
+
type,
|
|
31
|
+
isLoading,
|
|
32
|
+
isActive,
|
|
33
|
+
isDisabled = group == null ? void 0 : group.isDisabled,
|
|
34
|
+
leftIcon,
|
|
35
|
+
rightIcon,
|
|
36
|
+
loadingIcon,
|
|
37
|
+
loadingText,
|
|
38
|
+
loadingPlacement = "start",
|
|
39
|
+
__css,
|
|
40
|
+
...rest
|
|
41
|
+
} = omitThemeProps(mergedProps);
|
|
42
|
+
const { ref: buttonRef, type: defaultType } = useButtonType(as);
|
|
43
|
+
const ref = useMergeRefs(customRef, buttonRef);
|
|
44
|
+
const css = useMemo(() => {
|
|
45
|
+
var _a;
|
|
46
|
+
const _focus = "_focus" in styles ? merge((_a = styles._focus) != null ? _a : {}, { zIndex: 1 }) : {};
|
|
47
|
+
return {
|
|
48
|
+
display: "inline-flex",
|
|
49
|
+
alignItems: "center",
|
|
50
|
+
justifyContent: "center",
|
|
51
|
+
gap: "2",
|
|
52
|
+
appearance: "none",
|
|
53
|
+
userSelect: "none",
|
|
54
|
+
position: "relative",
|
|
55
|
+
whiteSpace: "nowrap",
|
|
56
|
+
verticalAlign: "middle",
|
|
57
|
+
outline: "none",
|
|
58
|
+
...styles,
|
|
59
|
+
...__css,
|
|
60
|
+
...!!group ? { _focus } : {}
|
|
61
|
+
};
|
|
62
|
+
}, [styles, __css, group]);
|
|
63
|
+
const contentProps = {
|
|
64
|
+
leftIcon,
|
|
65
|
+
rightIcon,
|
|
66
|
+
children
|
|
67
|
+
};
|
|
68
|
+
const loadingProps = {
|
|
69
|
+
loadingIcon,
|
|
70
|
+
loadingText
|
|
71
|
+
};
|
|
72
|
+
return /* @__PURE__ */ jsxs(
|
|
73
|
+
ui.button,
|
|
74
|
+
{
|
|
75
|
+
ref,
|
|
76
|
+
as,
|
|
77
|
+
className: cx("ui-button", className),
|
|
78
|
+
type: type != null ? type : defaultType,
|
|
79
|
+
disabled: isDisabled || isLoading,
|
|
80
|
+
"data-active": dataAttr(isActive),
|
|
81
|
+
"data-loading": dataAttr(isLoading),
|
|
82
|
+
__css: css,
|
|
83
|
+
...rest,
|
|
84
|
+
children: [
|
|
85
|
+
isLoading && loadingPlacement === "start" ? /* @__PURE__ */ jsx(Loading, { className: "ui-button-loading--start", ...loadingProps }) : null,
|
|
86
|
+
isLoading ? loadingText || /* @__PURE__ */ jsx(ui.span, { opacity: 0, children: /* @__PURE__ */ jsx(Content, { ...contentProps }) }) : /* @__PURE__ */ jsx(Content, { ...contentProps }),
|
|
87
|
+
isLoading && loadingPlacement === "end" ? /* @__PURE__ */ jsx(Loading, { className: "ui-button-loading--end", ...loadingProps }) : null
|
|
88
|
+
]
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
);
|
|
93
|
+
var Loading = ({ className, loadingIcon, loadingText }) => {
|
|
94
|
+
const css = useMemo(
|
|
95
|
+
() => ({
|
|
96
|
+
display: "flex",
|
|
97
|
+
alignItems: "center",
|
|
98
|
+
position: loadingText ? "relative" : "absolute",
|
|
99
|
+
fontSize: "1em",
|
|
100
|
+
lineHeight: "normal"
|
|
101
|
+
}),
|
|
102
|
+
[loadingText]
|
|
103
|
+
);
|
|
104
|
+
const element = useMemo(() => {
|
|
105
|
+
if (typeof loadingIcon === "string") {
|
|
106
|
+
return /* @__PURE__ */ jsx(LoadingIcon, { color: "current", variant: loadingIcon });
|
|
107
|
+
} else {
|
|
108
|
+
return loadingIcon || /* @__PURE__ */ jsx(LoadingIcon, { color: "current" });
|
|
109
|
+
}
|
|
110
|
+
}, [loadingIcon]);
|
|
111
|
+
return /* @__PURE__ */ jsx(ui.div, { className: cx("ui-button-loading", className), __css: css, children: element });
|
|
112
|
+
};
|
|
113
|
+
var Content = ({
|
|
114
|
+
leftIcon,
|
|
115
|
+
rightIcon,
|
|
116
|
+
children
|
|
117
|
+
}) => {
|
|
118
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
119
|
+
leftIcon ? /* @__PURE__ */ jsx(Icon, { children: leftIcon }) : null,
|
|
120
|
+
children,
|
|
121
|
+
rightIcon ? /* @__PURE__ */ jsx(Icon, { children: rightIcon }) : null
|
|
122
|
+
] });
|
|
123
|
+
};
|
|
124
|
+
var Icon = ({ children, className, ...rest }) => {
|
|
125
|
+
return /* @__PURE__ */ jsx(
|
|
126
|
+
ui.span,
|
|
127
|
+
{
|
|
128
|
+
className: cx("ui-button-icon", className),
|
|
129
|
+
display: "inline-flex",
|
|
130
|
+
alignSelf: "center",
|
|
131
|
+
flexShrink: 0,
|
|
132
|
+
"aria-hidden": true,
|
|
133
|
+
...rest,
|
|
134
|
+
children
|
|
135
|
+
}
|
|
136
|
+
);
|
|
137
|
+
};
|
|
138
|
+
var useButtonType = (value) => {
|
|
139
|
+
const [isButton, setIsButton] = useState(!value);
|
|
140
|
+
const ref = useCallback((node) => {
|
|
141
|
+
if (node)
|
|
142
|
+
setIsButton(node.tagName === "BUTTON");
|
|
143
|
+
}, []);
|
|
144
|
+
const type = isButton ? "button" : void 0;
|
|
145
|
+
return { ref, type };
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
export {
|
|
149
|
+
Button,
|
|
150
|
+
useButtonType
|
|
151
|
+
};
|
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Button
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-PJFZNNJZ.mjs";
|
|
4
4
|
|
|
5
5
|
// src/icon-button.tsx
|
|
6
6
|
import { forwardRef } from "@yamada-ui/core";
|
|
7
7
|
import { jsx } from "react/jsx-runtime";
|
|
8
8
|
var IconButton = forwardRef(
|
|
9
9
|
({ icon, isRounded, children, ...rest }, ref) => {
|
|
10
|
-
return /* @__PURE__ */ jsx(
|
|
10
|
+
return /* @__PURE__ */ jsx(
|
|
11
|
+
Button,
|
|
12
|
+
{
|
|
13
|
+
ref,
|
|
14
|
+
p: 0,
|
|
15
|
+
...isRounded ? { rounded: "full" } : {},
|
|
16
|
+
...rest,
|
|
17
|
+
children: icon || children
|
|
18
|
+
}
|
|
19
|
+
);
|
|
11
20
|
}
|
|
12
21
|
);
|
|
13
22
|
|
package/dist/icon-button.js
CHANGED
|
@@ -36,10 +36,12 @@ var import_core = require("@yamada-ui/core");
|
|
|
36
36
|
var import_utils = require("@yamada-ui/utils");
|
|
37
37
|
var import_react = require("react");
|
|
38
38
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
39
|
-
var [ButtonGroupProvider, useButtonGroup] = (0, import_utils.createContext)(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
var [ButtonGroupProvider, useButtonGroup] = (0, import_utils.createContext)(
|
|
40
|
+
{
|
|
41
|
+
strict: false,
|
|
42
|
+
name: "ButtonGroupContext"
|
|
43
|
+
}
|
|
44
|
+
);
|
|
43
45
|
var ButtonGroup = (0, import_core.forwardRef)(
|
|
44
46
|
({
|
|
45
47
|
className,
|
|
@@ -91,79 +93,80 @@ var ButtonGroup = (0, import_core.forwardRef)(
|
|
|
91
93
|
|
|
92
94
|
// src/button.tsx
|
|
93
95
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
94
|
-
var Button = (0, import_core2.forwardRef)(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
isDisabled = group == null ? void 0 : group.isDisabled,
|
|
104
|
-
leftIcon,
|
|
105
|
-
rightIcon,
|
|
106
|
-
loadingIcon,
|
|
107
|
-
loadingText,
|
|
108
|
-
loadingPlacement = "start",
|
|
109
|
-
__css,
|
|
110
|
-
...rest
|
|
111
|
-
} = (0, import_core2.omitThemeProps)(mergedProps);
|
|
112
|
-
const { ref: buttonRef, type: defaultType } = useButtonType(as);
|
|
113
|
-
const ref = (0, import_utils2.useMergeRefs)(customRef, buttonRef);
|
|
114
|
-
const css = (0, import_react2.useMemo)(() => {
|
|
115
|
-
var _a;
|
|
116
|
-
const _focus = "_focus" in styles ? (0, import_utils2.merge)((_a = styles._focus) != null ? _a : {}, { zIndex: 1 }) : {};
|
|
117
|
-
return {
|
|
118
|
-
display: "inline-flex",
|
|
119
|
-
alignItems: "center",
|
|
120
|
-
justifyContent: "center",
|
|
121
|
-
gap: "2",
|
|
122
|
-
appearance: "none",
|
|
123
|
-
userSelect: "none",
|
|
124
|
-
position: "relative",
|
|
125
|
-
whiteSpace: "nowrap",
|
|
126
|
-
verticalAlign: "middle",
|
|
127
|
-
outline: "none",
|
|
128
|
-
...styles,
|
|
129
|
-
...__css,
|
|
130
|
-
...!!group ? { _focus } : {}
|
|
131
|
-
};
|
|
132
|
-
}, [styles, __css, group]);
|
|
133
|
-
const contentProps = {
|
|
134
|
-
leftIcon,
|
|
135
|
-
rightIcon,
|
|
136
|
-
children
|
|
137
|
-
};
|
|
138
|
-
const loadingProps = {
|
|
139
|
-
loadingIcon,
|
|
140
|
-
loadingText
|
|
141
|
-
};
|
|
142
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
143
|
-
import_core2.ui.button,
|
|
144
|
-
{
|
|
145
|
-
ref,
|
|
96
|
+
var Button = (0, import_core2.forwardRef)(
|
|
97
|
+
({ children, ...props }, customRef) => {
|
|
98
|
+
const group = useButtonGroup();
|
|
99
|
+
const [styles, mergedProps] = (0, import_core2.useComponentStyle)("Button", {
|
|
100
|
+
...group,
|
|
101
|
+
...props
|
|
102
|
+
});
|
|
103
|
+
const {
|
|
104
|
+
className,
|
|
146
105
|
as,
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
var
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
106
|
+
type,
|
|
107
|
+
isLoading,
|
|
108
|
+
isActive,
|
|
109
|
+
isDisabled = group == null ? void 0 : group.isDisabled,
|
|
110
|
+
leftIcon,
|
|
111
|
+
rightIcon,
|
|
112
|
+
loadingIcon,
|
|
113
|
+
loadingText,
|
|
114
|
+
loadingPlacement = "start",
|
|
115
|
+
__css,
|
|
116
|
+
...rest
|
|
117
|
+
} = (0, import_core2.omitThemeProps)(mergedProps);
|
|
118
|
+
const { ref: buttonRef, type: defaultType } = useButtonType(as);
|
|
119
|
+
const ref = (0, import_utils2.useMergeRefs)(customRef, buttonRef);
|
|
120
|
+
const css = (0, import_react2.useMemo)(() => {
|
|
121
|
+
var _a;
|
|
122
|
+
const _focus = "_focus" in styles ? (0, import_utils2.merge)((_a = styles._focus) != null ? _a : {}, { zIndex: 1 }) : {};
|
|
123
|
+
return {
|
|
124
|
+
display: "inline-flex",
|
|
125
|
+
alignItems: "center",
|
|
126
|
+
justifyContent: "center",
|
|
127
|
+
gap: "2",
|
|
128
|
+
appearance: "none",
|
|
129
|
+
userSelect: "none",
|
|
130
|
+
position: "relative",
|
|
131
|
+
whiteSpace: "nowrap",
|
|
132
|
+
verticalAlign: "middle",
|
|
133
|
+
outline: "none",
|
|
134
|
+
...styles,
|
|
135
|
+
...__css,
|
|
136
|
+
...!!group ? { _focus } : {}
|
|
137
|
+
};
|
|
138
|
+
}, [styles, __css, group]);
|
|
139
|
+
const contentProps = {
|
|
140
|
+
leftIcon,
|
|
141
|
+
rightIcon,
|
|
142
|
+
children
|
|
143
|
+
};
|
|
144
|
+
const loadingProps = {
|
|
145
|
+
loadingIcon,
|
|
146
|
+
loadingText
|
|
147
|
+
};
|
|
148
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
149
|
+
import_core2.ui.button,
|
|
150
|
+
{
|
|
151
|
+
ref,
|
|
152
|
+
as,
|
|
153
|
+
className: (0, import_utils2.cx)("ui-button", className),
|
|
154
|
+
type: type != null ? type : defaultType,
|
|
155
|
+
disabled: isDisabled || isLoading,
|
|
156
|
+
"data-active": (0, import_utils2.dataAttr)(isActive),
|
|
157
|
+
"data-loading": (0, import_utils2.dataAttr)(isLoading),
|
|
158
|
+
__css: css,
|
|
159
|
+
...rest,
|
|
160
|
+
children: [
|
|
161
|
+
isLoading && loadingPlacement === "start" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Loading, { className: "ui-button-loading--start", ...loadingProps }) : null,
|
|
162
|
+
isLoading ? loadingText || /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.ui.span, { opacity: 0, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Content, { ...contentProps }) }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Content, { ...contentProps }),
|
|
163
|
+
isLoading && loadingPlacement === "end" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Loading, { className: "ui-button-loading--end", ...loadingProps }) : null
|
|
164
|
+
]
|
|
165
|
+
}
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
);
|
|
169
|
+
var Loading = ({ className, loadingIcon, loadingText }) => {
|
|
167
170
|
const css = (0, import_react2.useMemo)(
|
|
168
171
|
() => ({
|
|
169
172
|
display: "flex",
|
|
@@ -222,7 +225,16 @@ var useButtonType = (value) => {
|
|
|
222
225
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
223
226
|
var IconButton = (0, import_core3.forwardRef)(
|
|
224
227
|
({ icon, isRounded, children, ...rest }, ref) => {
|
|
225
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
228
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
229
|
+
Button,
|
|
230
|
+
{
|
|
231
|
+
ref,
|
|
232
|
+
p: 0,
|
|
233
|
+
...isRounded ? { rounded: "full" } : {},
|
|
234
|
+
...rest,
|
|
235
|
+
children: icon || children
|
|
236
|
+
}
|
|
237
|
+
);
|
|
226
238
|
}
|
|
227
239
|
);
|
|
228
240
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/icon-button.mjs
CHANGED
package/dist/index.js
CHANGED
|
@@ -37,10 +37,12 @@ var import_core = require("@yamada-ui/core");
|
|
|
37
37
|
var import_utils = require("@yamada-ui/utils");
|
|
38
38
|
var import_react = require("react");
|
|
39
39
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
40
|
-
var [ButtonGroupProvider, useButtonGroup] = (0, import_utils.createContext)(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
var [ButtonGroupProvider, useButtonGroup] = (0, import_utils.createContext)(
|
|
41
|
+
{
|
|
42
|
+
strict: false,
|
|
43
|
+
name: "ButtonGroupContext"
|
|
44
|
+
}
|
|
45
|
+
);
|
|
44
46
|
var ButtonGroup = (0, import_core.forwardRef)(
|
|
45
47
|
({
|
|
46
48
|
className,
|
|
@@ -92,79 +94,80 @@ var ButtonGroup = (0, import_core.forwardRef)(
|
|
|
92
94
|
|
|
93
95
|
// src/button.tsx
|
|
94
96
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
95
|
-
var Button = (0, import_core2.forwardRef)(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
isDisabled = group == null ? void 0 : group.isDisabled,
|
|
105
|
-
leftIcon,
|
|
106
|
-
rightIcon,
|
|
107
|
-
loadingIcon,
|
|
108
|
-
loadingText,
|
|
109
|
-
loadingPlacement = "start",
|
|
110
|
-
__css,
|
|
111
|
-
...rest
|
|
112
|
-
} = (0, import_core2.omitThemeProps)(mergedProps);
|
|
113
|
-
const { ref: buttonRef, type: defaultType } = useButtonType(as);
|
|
114
|
-
const ref = (0, import_utils2.useMergeRefs)(customRef, buttonRef);
|
|
115
|
-
const css = (0, import_react2.useMemo)(() => {
|
|
116
|
-
var _a;
|
|
117
|
-
const _focus = "_focus" in styles ? (0, import_utils2.merge)((_a = styles._focus) != null ? _a : {}, { zIndex: 1 }) : {};
|
|
118
|
-
return {
|
|
119
|
-
display: "inline-flex",
|
|
120
|
-
alignItems: "center",
|
|
121
|
-
justifyContent: "center",
|
|
122
|
-
gap: "2",
|
|
123
|
-
appearance: "none",
|
|
124
|
-
userSelect: "none",
|
|
125
|
-
position: "relative",
|
|
126
|
-
whiteSpace: "nowrap",
|
|
127
|
-
verticalAlign: "middle",
|
|
128
|
-
outline: "none",
|
|
129
|
-
...styles,
|
|
130
|
-
...__css,
|
|
131
|
-
...!!group ? { _focus } : {}
|
|
132
|
-
};
|
|
133
|
-
}, [styles, __css, group]);
|
|
134
|
-
const contentProps = {
|
|
135
|
-
leftIcon,
|
|
136
|
-
rightIcon,
|
|
137
|
-
children
|
|
138
|
-
};
|
|
139
|
-
const loadingProps = {
|
|
140
|
-
loadingIcon,
|
|
141
|
-
loadingText
|
|
142
|
-
};
|
|
143
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
144
|
-
import_core2.ui.button,
|
|
145
|
-
{
|
|
146
|
-
ref,
|
|
97
|
+
var Button = (0, import_core2.forwardRef)(
|
|
98
|
+
({ children, ...props }, customRef) => {
|
|
99
|
+
const group = useButtonGroup();
|
|
100
|
+
const [styles, mergedProps] = (0, import_core2.useComponentStyle)("Button", {
|
|
101
|
+
...group,
|
|
102
|
+
...props
|
|
103
|
+
});
|
|
104
|
+
const {
|
|
105
|
+
className,
|
|
147
106
|
as,
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
var
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
107
|
+
type,
|
|
108
|
+
isLoading,
|
|
109
|
+
isActive,
|
|
110
|
+
isDisabled = group == null ? void 0 : group.isDisabled,
|
|
111
|
+
leftIcon,
|
|
112
|
+
rightIcon,
|
|
113
|
+
loadingIcon,
|
|
114
|
+
loadingText,
|
|
115
|
+
loadingPlacement = "start",
|
|
116
|
+
__css,
|
|
117
|
+
...rest
|
|
118
|
+
} = (0, import_core2.omitThemeProps)(mergedProps);
|
|
119
|
+
const { ref: buttonRef, type: defaultType } = useButtonType(as);
|
|
120
|
+
const ref = (0, import_utils2.useMergeRefs)(customRef, buttonRef);
|
|
121
|
+
const css = (0, import_react2.useMemo)(() => {
|
|
122
|
+
var _a;
|
|
123
|
+
const _focus = "_focus" in styles ? (0, import_utils2.merge)((_a = styles._focus) != null ? _a : {}, { zIndex: 1 }) : {};
|
|
124
|
+
return {
|
|
125
|
+
display: "inline-flex",
|
|
126
|
+
alignItems: "center",
|
|
127
|
+
justifyContent: "center",
|
|
128
|
+
gap: "2",
|
|
129
|
+
appearance: "none",
|
|
130
|
+
userSelect: "none",
|
|
131
|
+
position: "relative",
|
|
132
|
+
whiteSpace: "nowrap",
|
|
133
|
+
verticalAlign: "middle",
|
|
134
|
+
outline: "none",
|
|
135
|
+
...styles,
|
|
136
|
+
...__css,
|
|
137
|
+
...!!group ? { _focus } : {}
|
|
138
|
+
};
|
|
139
|
+
}, [styles, __css, group]);
|
|
140
|
+
const contentProps = {
|
|
141
|
+
leftIcon,
|
|
142
|
+
rightIcon,
|
|
143
|
+
children
|
|
144
|
+
};
|
|
145
|
+
const loadingProps = {
|
|
146
|
+
loadingIcon,
|
|
147
|
+
loadingText
|
|
148
|
+
};
|
|
149
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
150
|
+
import_core2.ui.button,
|
|
151
|
+
{
|
|
152
|
+
ref,
|
|
153
|
+
as,
|
|
154
|
+
className: (0, import_utils2.cx)("ui-button", className),
|
|
155
|
+
type: type != null ? type : defaultType,
|
|
156
|
+
disabled: isDisabled || isLoading,
|
|
157
|
+
"data-active": (0, import_utils2.dataAttr)(isActive),
|
|
158
|
+
"data-loading": (0, import_utils2.dataAttr)(isLoading),
|
|
159
|
+
__css: css,
|
|
160
|
+
...rest,
|
|
161
|
+
children: [
|
|
162
|
+
isLoading && loadingPlacement === "start" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Loading, { className: "ui-button-loading--start", ...loadingProps }) : null,
|
|
163
|
+
isLoading ? loadingText || /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.ui.span, { opacity: 0, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Content, { ...contentProps }) }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Content, { ...contentProps }),
|
|
164
|
+
isLoading && loadingPlacement === "end" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Loading, { className: "ui-button-loading--end", ...loadingProps }) : null
|
|
165
|
+
]
|
|
166
|
+
}
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
);
|
|
170
|
+
var Loading = ({ className, loadingIcon, loadingText }) => {
|
|
168
171
|
const css = (0, import_react2.useMemo)(
|
|
169
172
|
() => ({
|
|
170
173
|
display: "flex",
|
|
@@ -224,7 +227,16 @@ var import_core3 = require("@yamada-ui/core");
|
|
|
224
227
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
225
228
|
var IconButton = (0, import_core3.forwardRef)(
|
|
226
229
|
({ icon, isRounded, children, ...rest }, ref) => {
|
|
227
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
230
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
231
|
+
Button,
|
|
232
|
+
{
|
|
233
|
+
ref,
|
|
234
|
+
p: 0,
|
|
235
|
+
...isRounded ? { rounded: "full" } : {},
|
|
236
|
+
...rest,
|
|
237
|
+
children: icon || children
|
|
238
|
+
}
|
|
239
|
+
);
|
|
228
240
|
}
|
|
229
241
|
);
|
|
230
242
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
IconButton
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-WAZQVSDT.mjs";
|
|
4
4
|
import {
|
|
5
5
|
Button
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-PJFZNNJZ.mjs";
|
|
7
7
|
import {
|
|
8
8
|
ButtonGroup
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-EGXUSOSB.mjs";
|
|
10
10
|
export {
|
|
11
11
|
Button,
|
|
12
12
|
ButtonGroup,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yamada-ui/button",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.7",
|
|
4
4
|
"description": "Yamada UI button components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"yamada",
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
"url": "https://github.com/hirotomoyamada/yamada-ui/issues"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@yamada-ui/core": "0.5.
|
|
41
|
-
"@yamada-ui/utils": "0.1.
|
|
42
|
-
"@yamada-ui/loading": "0.3.
|
|
40
|
+
"@yamada-ui/core": "0.5.2",
|
|
41
|
+
"@yamada-ui/utils": "0.1.4",
|
|
42
|
+
"@yamada-ui/loading": "0.3.7"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"react": "^18.0.0",
|
package/dist/chunk-2U57OXHK.mjs
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useButtonGroup
|
|
3
|
-
} from "./chunk-ZJ6VNE3P.mjs";
|
|
4
|
-
|
|
5
|
-
// src/button.tsx
|
|
6
|
-
import {
|
|
7
|
-
ui,
|
|
8
|
-
forwardRef,
|
|
9
|
-
useComponentStyle,
|
|
10
|
-
omitThemeProps
|
|
11
|
-
} from "@yamada-ui/core";
|
|
12
|
-
import { Loading as LoadingIcon } from "@yamada-ui/loading";
|
|
13
|
-
import { cx, useMergeRefs, merge, dataAttr } from "@yamada-ui/utils";
|
|
14
|
-
import { useCallback, useMemo, useState } from "react";
|
|
15
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
16
|
-
var Button = forwardRef(({ children, ...props }, customRef) => {
|
|
17
|
-
const group = useButtonGroup();
|
|
18
|
-
const [styles, mergedProps] = useComponentStyle("Button", { ...group, ...props });
|
|
19
|
-
const {
|
|
20
|
-
className,
|
|
21
|
-
as,
|
|
22
|
-
type,
|
|
23
|
-
isLoading,
|
|
24
|
-
isActive,
|
|
25
|
-
isDisabled = group == null ? void 0 : group.isDisabled,
|
|
26
|
-
leftIcon,
|
|
27
|
-
rightIcon,
|
|
28
|
-
loadingIcon,
|
|
29
|
-
loadingText,
|
|
30
|
-
loadingPlacement = "start",
|
|
31
|
-
__css,
|
|
32
|
-
...rest
|
|
33
|
-
} = omitThemeProps(mergedProps);
|
|
34
|
-
const { ref: buttonRef, type: defaultType } = useButtonType(as);
|
|
35
|
-
const ref = useMergeRefs(customRef, buttonRef);
|
|
36
|
-
const css = useMemo(() => {
|
|
37
|
-
var _a;
|
|
38
|
-
const _focus = "_focus" in styles ? merge((_a = styles._focus) != null ? _a : {}, { zIndex: 1 }) : {};
|
|
39
|
-
return {
|
|
40
|
-
display: "inline-flex",
|
|
41
|
-
alignItems: "center",
|
|
42
|
-
justifyContent: "center",
|
|
43
|
-
gap: "2",
|
|
44
|
-
appearance: "none",
|
|
45
|
-
userSelect: "none",
|
|
46
|
-
position: "relative",
|
|
47
|
-
whiteSpace: "nowrap",
|
|
48
|
-
verticalAlign: "middle",
|
|
49
|
-
outline: "none",
|
|
50
|
-
...styles,
|
|
51
|
-
...__css,
|
|
52
|
-
...!!group ? { _focus } : {}
|
|
53
|
-
};
|
|
54
|
-
}, [styles, __css, group]);
|
|
55
|
-
const contentProps = {
|
|
56
|
-
leftIcon,
|
|
57
|
-
rightIcon,
|
|
58
|
-
children
|
|
59
|
-
};
|
|
60
|
-
const loadingProps = {
|
|
61
|
-
loadingIcon,
|
|
62
|
-
loadingText
|
|
63
|
-
};
|
|
64
|
-
return /* @__PURE__ */ jsxs(
|
|
65
|
-
ui.button,
|
|
66
|
-
{
|
|
67
|
-
ref,
|
|
68
|
-
as,
|
|
69
|
-
className: cx("ui-button", className),
|
|
70
|
-
type: type != null ? type : defaultType,
|
|
71
|
-
disabled: isDisabled || isLoading,
|
|
72
|
-
"data-active": dataAttr(isActive),
|
|
73
|
-
"data-loading": dataAttr(isLoading),
|
|
74
|
-
__css: css,
|
|
75
|
-
...rest,
|
|
76
|
-
children: [
|
|
77
|
-
isLoading && loadingPlacement === "start" ? /* @__PURE__ */ jsx(Loading, { className: "ui-button-loading--start", ...loadingProps }) : null,
|
|
78
|
-
isLoading ? loadingText || /* @__PURE__ */ jsx(ui.span, { opacity: 0, children: /* @__PURE__ */ jsx(Content, { ...contentProps }) }) : /* @__PURE__ */ jsx(Content, { ...contentProps }),
|
|
79
|
-
isLoading && loadingPlacement === "end" ? /* @__PURE__ */ jsx(Loading, { className: "ui-button-loading--end", ...loadingProps }) : null
|
|
80
|
-
]
|
|
81
|
-
}
|
|
82
|
-
);
|
|
83
|
-
});
|
|
84
|
-
var Loading = ({
|
|
85
|
-
className,
|
|
86
|
-
loadingIcon,
|
|
87
|
-
loadingText
|
|
88
|
-
}) => {
|
|
89
|
-
const css = useMemo(
|
|
90
|
-
() => ({
|
|
91
|
-
display: "flex",
|
|
92
|
-
alignItems: "center",
|
|
93
|
-
position: loadingText ? "relative" : "absolute",
|
|
94
|
-
fontSize: "1em",
|
|
95
|
-
lineHeight: "normal"
|
|
96
|
-
}),
|
|
97
|
-
[loadingText]
|
|
98
|
-
);
|
|
99
|
-
const element = useMemo(() => {
|
|
100
|
-
if (typeof loadingIcon === "string") {
|
|
101
|
-
return /* @__PURE__ */ jsx(LoadingIcon, { color: "current", variant: loadingIcon });
|
|
102
|
-
} else {
|
|
103
|
-
return loadingIcon || /* @__PURE__ */ jsx(LoadingIcon, { color: "current" });
|
|
104
|
-
}
|
|
105
|
-
}, [loadingIcon]);
|
|
106
|
-
return /* @__PURE__ */ jsx(ui.div, { className: cx("ui-button-loading", className), __css: css, children: element });
|
|
107
|
-
};
|
|
108
|
-
var Content = ({
|
|
109
|
-
leftIcon,
|
|
110
|
-
rightIcon,
|
|
111
|
-
children
|
|
112
|
-
}) => {
|
|
113
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
114
|
-
leftIcon ? /* @__PURE__ */ jsx(Icon, { children: leftIcon }) : null,
|
|
115
|
-
children,
|
|
116
|
-
rightIcon ? /* @__PURE__ */ jsx(Icon, { children: rightIcon }) : null
|
|
117
|
-
] });
|
|
118
|
-
};
|
|
119
|
-
var Icon = ({ children, className, ...rest }) => {
|
|
120
|
-
return /* @__PURE__ */ jsx(
|
|
121
|
-
ui.span,
|
|
122
|
-
{
|
|
123
|
-
className: cx("ui-button-icon", className),
|
|
124
|
-
display: "inline-flex",
|
|
125
|
-
alignSelf: "center",
|
|
126
|
-
flexShrink: 0,
|
|
127
|
-
"aria-hidden": true,
|
|
128
|
-
...rest,
|
|
129
|
-
children
|
|
130
|
-
}
|
|
131
|
-
);
|
|
132
|
-
};
|
|
133
|
-
var useButtonType = (value) => {
|
|
134
|
-
const [isButton, setIsButton] = useState(!value);
|
|
135
|
-
const ref = useCallback((node) => {
|
|
136
|
-
if (node)
|
|
137
|
-
setIsButton(node.tagName === "BUTTON");
|
|
138
|
-
}, []);
|
|
139
|
-
const type = isButton ? "button" : void 0;
|
|
140
|
-
return { ref, type };
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
export {
|
|
144
|
-
Button,
|
|
145
|
-
useButtonType
|
|
146
|
-
};
|