@kopexa/button 8.0.10 → 10.0.0
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.d.mts +12 -1
- package/dist/button.d.ts +12 -1
- package/dist/button.js +60 -6
- package/dist/button.mjs +6 -3
- package/dist/{chunk-6W2OCYRO.mjs → chunk-AKZB54J4.mjs} +2 -6
- package/dist/{chunk-JU7NAIA6.mjs → chunk-IGA5FORT.mjs} +1 -1
- package/dist/{chunk-TWIY5JCA.mjs → chunk-SNQHD6JL.mjs} +60 -7
- package/dist/copy-button.js +57 -6
- package/dist/copy-button.mjs +2 -2
- package/dist/icon-button.js +57 -9
- package/dist/icon-button.mjs +3 -2
- package/dist/index.js +58 -11
- package/dist/index.mjs +3 -3
- package/package.json +8 -8
package/dist/button.d.mts
CHANGED
|
@@ -33,7 +33,18 @@ type ButtonProps = ComponentProps<"button"> & ButtonVariantProps & {
|
|
|
33
33
|
* @default false
|
|
34
34
|
*/
|
|
35
35
|
isLoading?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* You can provide shortcut keys
|
|
38
|
+
*/
|
|
39
|
+
shortcutKeys?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Allows to wrap a tooltip around the button
|
|
42
|
+
*/
|
|
43
|
+
tooltip?: string;
|
|
36
44
|
};
|
|
37
45
|
declare const Button: (props: ButtonProps) => react_jsx_runtime.JSX.Element;
|
|
46
|
+
declare const ShortcutDisplay: React.FC<{
|
|
47
|
+
shortcuts: string[];
|
|
48
|
+
}>;
|
|
38
49
|
|
|
39
|
-
export { Button, type ButtonProps };
|
|
50
|
+
export { Button, type ButtonProps, ShortcutDisplay };
|
package/dist/button.d.ts
CHANGED
|
@@ -33,7 +33,18 @@ type ButtonProps = ComponentProps<"button"> & ButtonVariantProps & {
|
|
|
33
33
|
* @default false
|
|
34
34
|
*/
|
|
35
35
|
isLoading?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* You can provide shortcut keys
|
|
38
|
+
*/
|
|
39
|
+
shortcutKeys?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Allows to wrap a tooltip around the button
|
|
42
|
+
*/
|
|
43
|
+
tooltip?: string;
|
|
36
44
|
};
|
|
37
45
|
declare const Button: (props: ButtonProps) => react_jsx_runtime.JSX.Element;
|
|
46
|
+
declare const ShortcutDisplay: React.FC<{
|
|
47
|
+
shortcuts: string[];
|
|
48
|
+
}>;
|
|
38
49
|
|
|
39
|
-
export { Button, type ButtonProps };
|
|
50
|
+
export { Button, type ButtonProps, ShortcutDisplay };
|
package/dist/button.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
"use strict";
|
|
3
|
+
"use client";
|
|
3
4
|
var __create = Object.create;
|
|
4
5
|
var __defProp = Object.defineProperty;
|
|
5
6
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -31,7 +32,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
32
|
// src/button.tsx
|
|
32
33
|
var button_exports = {};
|
|
33
34
|
__export(button_exports, {
|
|
34
|
-
Button: () => Button
|
|
35
|
+
Button: () => Button,
|
|
36
|
+
ShortcutDisplay: () => ShortcutDisplay
|
|
35
37
|
});
|
|
36
38
|
module.exports = __toCommonJS(button_exports);
|
|
37
39
|
var import_react_utils = require("@kopexa/react-utils");
|
|
@@ -39,6 +41,7 @@ var import_ripple = require("@kopexa/ripple");
|
|
|
39
41
|
var import_shared_utils = require("@kopexa/shared-utils");
|
|
40
42
|
var import_spinner = require("@kopexa/spinner");
|
|
41
43
|
var import_theme = require("@kopexa/theme");
|
|
44
|
+
var import_tooltip = require("@kopexa/tooltip");
|
|
42
45
|
var Slot = __toESM(require("@radix-ui/react-slot"));
|
|
43
46
|
var import_react = require("react");
|
|
44
47
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -53,7 +56,7 @@ var Button = (props) => {
|
|
|
53
56
|
ref,
|
|
54
57
|
isLoading,
|
|
55
58
|
variant,
|
|
56
|
-
size = "
|
|
59
|
+
size = "md",
|
|
57
60
|
className,
|
|
58
61
|
color,
|
|
59
62
|
radius,
|
|
@@ -62,9 +65,16 @@ var Button = (props) => {
|
|
|
62
65
|
endContent,
|
|
63
66
|
isIconOnly,
|
|
64
67
|
spinnerPlacement = "start",
|
|
68
|
+
shortcutKeys,
|
|
69
|
+
tooltip,
|
|
70
|
+
spacing,
|
|
65
71
|
...rest
|
|
66
72
|
} = props;
|
|
67
73
|
const Comp = asChild ? Slot.Root : "button";
|
|
74
|
+
const shortcuts = (0, import_react.useMemo)(
|
|
75
|
+
() => (0, import_shared_utils.parseShortcutKeys)({ shortcutKeys }),
|
|
76
|
+
[shortcutKeys]
|
|
77
|
+
);
|
|
68
78
|
const domRef = (0, import_react.useRef)(null);
|
|
69
79
|
const isDisabled = disabled || isLoading;
|
|
70
80
|
const {
|
|
@@ -80,9 +90,10 @@ var Button = (props) => {
|
|
|
80
90
|
radius,
|
|
81
91
|
fullWidth,
|
|
82
92
|
isIconOnly,
|
|
83
|
-
className
|
|
93
|
+
className,
|
|
94
|
+
spacing
|
|
84
95
|
});
|
|
85
|
-
}, [variant, size, color, radius, isIconOnly, fullWidth, className]);
|
|
96
|
+
}, [variant, size, color, radius, isIconOnly, fullWidth, className, spacing]);
|
|
86
97
|
const handleClick = (0, import_react.useCallback)(
|
|
87
98
|
(e) => {
|
|
88
99
|
if (disableRipple || isDisabled) return;
|
|
@@ -103,7 +114,7 @@ var Button = (props) => {
|
|
|
103
114
|
};
|
|
104
115
|
return buttonSpinnerSizeMap[size];
|
|
105
116
|
}, [size]);
|
|
106
|
-
|
|
117
|
+
const content = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
107
118
|
Comp,
|
|
108
119
|
{
|
|
109
120
|
type,
|
|
@@ -124,8 +135,51 @@ var Button = (props) => {
|
|
|
124
135
|
]
|
|
125
136
|
}
|
|
126
137
|
);
|
|
138
|
+
if (!tooltip) {
|
|
139
|
+
return content;
|
|
140
|
+
}
|
|
141
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
142
|
+
import_tooltip.Tooltip,
|
|
143
|
+
{
|
|
144
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
145
|
+
tooltip,
|
|
146
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ShortcutDisplay, { shortcuts })
|
|
147
|
+
] }),
|
|
148
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
149
|
+
Comp,
|
|
150
|
+
{
|
|
151
|
+
type,
|
|
152
|
+
className: styles,
|
|
153
|
+
onClick: handleClick,
|
|
154
|
+
ref: (0, import_react_utils.mergeRefs)(domRef, ref),
|
|
155
|
+
disabled: isDisabled,
|
|
156
|
+
"data-disabled": (0, import_shared_utils.dataAttr)(isDisabled),
|
|
157
|
+
"data-loading": (0, import_shared_utils.dataAttr)(isLoading),
|
|
158
|
+
"aria-disabled": isDisabled,
|
|
159
|
+
tabIndex: isDisabled ? -1 : void 0,
|
|
160
|
+
...rest,
|
|
161
|
+
children: [
|
|
162
|
+
isLoading && spinnerPlacement === "start" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_spinner.Spinner, { color: "current", size: spinnerSize }) : startContent,
|
|
163
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Slot.Slottable, { children }),
|
|
164
|
+
isLoading && spinnerPlacement === "end" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_spinner.Spinner, { color: "current", size: spinnerSize }) : endContent,
|
|
165
|
+
!disableRipple && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ripple.Ripple, { ...getRippleProps() })
|
|
166
|
+
]
|
|
167
|
+
}
|
|
168
|
+
)
|
|
169
|
+
}
|
|
170
|
+
);
|
|
171
|
+
};
|
|
172
|
+
var ShortcutDisplay = ({
|
|
173
|
+
shortcuts
|
|
174
|
+
}) => {
|
|
175
|
+
if (shortcuts.length === 0) return null;
|
|
176
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: shortcuts.map((key, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [
|
|
177
|
+
index > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("kbd", { children: "+" }),
|
|
178
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("kbd", { children: key })
|
|
179
|
+
] }, index.toString())) });
|
|
127
180
|
};
|
|
128
181
|
// Annotate the CommonJS export names for ESM import in node:
|
|
129
182
|
0 && (module.exports = {
|
|
130
|
-
Button
|
|
183
|
+
Button,
|
|
184
|
+
ShortcutDisplay
|
|
131
185
|
});
|
package/dist/button.mjs
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
Button
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-SNQHD6JL.mjs";
|
|
5
5
|
|
|
6
6
|
// src/icon-button.tsx
|
|
7
|
-
import { Tooltip } from "@kopexa/tooltip";
|
|
8
7
|
import { cloneElement, isValidElement, useMemo } from "react";
|
|
9
8
|
import { jsx } from "react/jsx-runtime";
|
|
10
9
|
var IconButton = (props) => {
|
|
@@ -20,10 +19,7 @@ var IconButton = (props) => {
|
|
|
20
19
|
// biome-ignore lint/suspicious/noExplicitAny: forcing type to any
|
|
21
20
|
cloneElement(children, { "aria-hidden": true })
|
|
22
21
|
) : children;
|
|
23
|
-
|
|
24
|
-
return /* @__PURE__ */ jsx(Tooltip, { content: toolip, children: /* @__PURE__ */ jsx(Button, { ...rest, "aria-label": ariaLabel, isIconOnly: true, children: clonedChildren }) });
|
|
25
|
-
}
|
|
26
|
-
return /* @__PURE__ */ jsx(Button, { ...rest, "aria-label": ariaLabel, isIconOnly: true, children: clonedChildren });
|
|
22
|
+
return /* @__PURE__ */ jsx(Button, { ...rest, tooltip: toolip, "aria-label": ariaLabel, isIconOnly: true, children: clonedChildren });
|
|
27
23
|
};
|
|
28
24
|
|
|
29
25
|
export {
|
|
@@ -3,16 +3,18 @@
|
|
|
3
3
|
// src/button.tsx
|
|
4
4
|
import { mergeRefs } from "@kopexa/react-utils";
|
|
5
5
|
import { Ripple, useRipple } from "@kopexa/ripple";
|
|
6
|
-
import { dataAttr } from "@kopexa/shared-utils";
|
|
6
|
+
import { dataAttr, parseShortcutKeys } from "@kopexa/shared-utils";
|
|
7
7
|
import { Spinner } from "@kopexa/spinner";
|
|
8
8
|
import { button } from "@kopexa/theme";
|
|
9
|
+
import { Tooltip } from "@kopexa/tooltip";
|
|
9
10
|
import * as Slot from "@radix-ui/react-slot";
|
|
10
11
|
import {
|
|
12
|
+
Fragment,
|
|
11
13
|
useCallback,
|
|
12
14
|
useMemo,
|
|
13
15
|
useRef
|
|
14
16
|
} from "react";
|
|
15
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
17
|
+
import { Fragment as Fragment2, jsx, jsxs } from "react/jsx-runtime";
|
|
16
18
|
var Button = (props) => {
|
|
17
19
|
const {
|
|
18
20
|
type = "button",
|
|
@@ -24,7 +26,7 @@ var Button = (props) => {
|
|
|
24
26
|
ref,
|
|
25
27
|
isLoading,
|
|
26
28
|
variant,
|
|
27
|
-
size = "
|
|
29
|
+
size = "md",
|
|
28
30
|
className,
|
|
29
31
|
color,
|
|
30
32
|
radius,
|
|
@@ -33,9 +35,16 @@ var Button = (props) => {
|
|
|
33
35
|
endContent,
|
|
34
36
|
isIconOnly,
|
|
35
37
|
spinnerPlacement = "start",
|
|
38
|
+
shortcutKeys,
|
|
39
|
+
tooltip,
|
|
40
|
+
spacing,
|
|
36
41
|
...rest
|
|
37
42
|
} = props;
|
|
38
43
|
const Comp = asChild ? Slot.Root : "button";
|
|
44
|
+
const shortcuts = useMemo(
|
|
45
|
+
() => parseShortcutKeys({ shortcutKeys }),
|
|
46
|
+
[shortcutKeys]
|
|
47
|
+
);
|
|
39
48
|
const domRef = useRef(null);
|
|
40
49
|
const isDisabled = disabled || isLoading;
|
|
41
50
|
const {
|
|
@@ -51,9 +60,10 @@ var Button = (props) => {
|
|
|
51
60
|
radius,
|
|
52
61
|
fullWidth,
|
|
53
62
|
isIconOnly,
|
|
54
|
-
className
|
|
63
|
+
className,
|
|
64
|
+
spacing
|
|
55
65
|
});
|
|
56
|
-
}, [variant, size, color, radius, isIconOnly, fullWidth, className]);
|
|
66
|
+
}, [variant, size, color, radius, isIconOnly, fullWidth, className, spacing]);
|
|
57
67
|
const handleClick = useCallback(
|
|
58
68
|
(e) => {
|
|
59
69
|
if (disableRipple || isDisabled) return;
|
|
@@ -74,7 +84,7 @@ var Button = (props) => {
|
|
|
74
84
|
};
|
|
75
85
|
return buttonSpinnerSizeMap[size];
|
|
76
86
|
}, [size]);
|
|
77
|
-
|
|
87
|
+
const content = /* @__PURE__ */ jsxs(
|
|
78
88
|
Comp,
|
|
79
89
|
{
|
|
80
90
|
type,
|
|
@@ -95,8 +105,51 @@ var Button = (props) => {
|
|
|
95
105
|
]
|
|
96
106
|
}
|
|
97
107
|
);
|
|
108
|
+
if (!tooltip) {
|
|
109
|
+
return content;
|
|
110
|
+
}
|
|
111
|
+
return /* @__PURE__ */ jsx(
|
|
112
|
+
Tooltip,
|
|
113
|
+
{
|
|
114
|
+
content: /* @__PURE__ */ jsxs(Fragment2, { children: [
|
|
115
|
+
tooltip,
|
|
116
|
+
/* @__PURE__ */ jsx(ShortcutDisplay, { shortcuts })
|
|
117
|
+
] }),
|
|
118
|
+
children: /* @__PURE__ */ jsxs(
|
|
119
|
+
Comp,
|
|
120
|
+
{
|
|
121
|
+
type,
|
|
122
|
+
className: styles,
|
|
123
|
+
onClick: handleClick,
|
|
124
|
+
ref: mergeRefs(domRef, ref),
|
|
125
|
+
disabled: isDisabled,
|
|
126
|
+
"data-disabled": dataAttr(isDisabled),
|
|
127
|
+
"data-loading": dataAttr(isLoading),
|
|
128
|
+
"aria-disabled": isDisabled,
|
|
129
|
+
tabIndex: isDisabled ? -1 : void 0,
|
|
130
|
+
...rest,
|
|
131
|
+
children: [
|
|
132
|
+
isLoading && spinnerPlacement === "start" ? /* @__PURE__ */ jsx(Spinner, { color: "current", size: spinnerSize }) : startContent,
|
|
133
|
+
/* @__PURE__ */ jsx(Slot.Slottable, { children }),
|
|
134
|
+
isLoading && spinnerPlacement === "end" ? /* @__PURE__ */ jsx(Spinner, { color: "current", size: spinnerSize }) : endContent,
|
|
135
|
+
!disableRipple && /* @__PURE__ */ jsx(Ripple, { ...getRippleProps() })
|
|
136
|
+
]
|
|
137
|
+
}
|
|
138
|
+
)
|
|
139
|
+
}
|
|
140
|
+
);
|
|
141
|
+
};
|
|
142
|
+
var ShortcutDisplay = ({
|
|
143
|
+
shortcuts
|
|
144
|
+
}) => {
|
|
145
|
+
if (shortcuts.length === 0) return null;
|
|
146
|
+
return /* @__PURE__ */ jsx("div", { children: shortcuts.map((key, index) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
147
|
+
index > 0 && /* @__PURE__ */ jsx("kbd", { children: "+" }),
|
|
148
|
+
/* @__PURE__ */ jsx("kbd", { children: key })
|
|
149
|
+
] }, index.toString())) });
|
|
98
150
|
};
|
|
99
151
|
|
|
100
152
|
export {
|
|
101
|
-
Button
|
|
153
|
+
Button,
|
|
154
|
+
ShortcutDisplay
|
|
102
155
|
};
|
package/dist/copy-button.js
CHANGED
|
@@ -36,7 +36,7 @@ __export(copy_button_exports, {
|
|
|
36
36
|
module.exports = __toCommonJS(copy_button_exports);
|
|
37
37
|
var import_icons = require("@kopexa/icons");
|
|
38
38
|
var import_shared_utils2 = require("@kopexa/shared-utils");
|
|
39
|
-
var
|
|
39
|
+
var import_tooltip2 = require("@kopexa/tooltip");
|
|
40
40
|
var import_react2 = require("react");
|
|
41
41
|
|
|
42
42
|
// src/button.tsx
|
|
@@ -45,6 +45,7 @@ var import_ripple = require("@kopexa/ripple");
|
|
|
45
45
|
var import_shared_utils = require("@kopexa/shared-utils");
|
|
46
46
|
var import_spinner = require("@kopexa/spinner");
|
|
47
47
|
var import_theme = require("@kopexa/theme");
|
|
48
|
+
var import_tooltip = require("@kopexa/tooltip");
|
|
48
49
|
var Slot = __toESM(require("@radix-ui/react-slot"));
|
|
49
50
|
var import_react = require("react");
|
|
50
51
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -59,7 +60,7 @@ var Button = (props) => {
|
|
|
59
60
|
ref,
|
|
60
61
|
isLoading,
|
|
61
62
|
variant,
|
|
62
|
-
size = "
|
|
63
|
+
size = "md",
|
|
63
64
|
className,
|
|
64
65
|
color,
|
|
65
66
|
radius,
|
|
@@ -68,9 +69,16 @@ var Button = (props) => {
|
|
|
68
69
|
endContent,
|
|
69
70
|
isIconOnly,
|
|
70
71
|
spinnerPlacement = "start",
|
|
72
|
+
shortcutKeys,
|
|
73
|
+
tooltip,
|
|
74
|
+
spacing,
|
|
71
75
|
...rest
|
|
72
76
|
} = props;
|
|
73
77
|
const Comp = asChild ? Slot.Root : "button";
|
|
78
|
+
const shortcuts = (0, import_react.useMemo)(
|
|
79
|
+
() => (0, import_shared_utils.parseShortcutKeys)({ shortcutKeys }),
|
|
80
|
+
[shortcutKeys]
|
|
81
|
+
);
|
|
74
82
|
const domRef = (0, import_react.useRef)(null);
|
|
75
83
|
const isDisabled = disabled || isLoading;
|
|
76
84
|
const {
|
|
@@ -86,9 +94,10 @@ var Button = (props) => {
|
|
|
86
94
|
radius,
|
|
87
95
|
fullWidth,
|
|
88
96
|
isIconOnly,
|
|
89
|
-
className
|
|
97
|
+
className,
|
|
98
|
+
spacing
|
|
90
99
|
});
|
|
91
|
-
}, [variant, size, color, radius, isIconOnly, fullWidth, className]);
|
|
100
|
+
}, [variant, size, color, radius, isIconOnly, fullWidth, className, spacing]);
|
|
92
101
|
const handleClick = (0, import_react.useCallback)(
|
|
93
102
|
(e) => {
|
|
94
103
|
if (disableRipple || isDisabled) return;
|
|
@@ -109,7 +118,7 @@ var Button = (props) => {
|
|
|
109
118
|
};
|
|
110
119
|
return buttonSpinnerSizeMap[size];
|
|
111
120
|
}, [size]);
|
|
112
|
-
|
|
121
|
+
const content = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
113
122
|
Comp,
|
|
114
123
|
{
|
|
115
124
|
type,
|
|
@@ -130,6 +139,48 @@ var Button = (props) => {
|
|
|
130
139
|
]
|
|
131
140
|
}
|
|
132
141
|
);
|
|
142
|
+
if (!tooltip) {
|
|
143
|
+
return content;
|
|
144
|
+
}
|
|
145
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
146
|
+
import_tooltip.Tooltip,
|
|
147
|
+
{
|
|
148
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
149
|
+
tooltip,
|
|
150
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ShortcutDisplay, { shortcuts })
|
|
151
|
+
] }),
|
|
152
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
153
|
+
Comp,
|
|
154
|
+
{
|
|
155
|
+
type,
|
|
156
|
+
className: styles,
|
|
157
|
+
onClick: handleClick,
|
|
158
|
+
ref: (0, import_react_utils.mergeRefs)(domRef, ref),
|
|
159
|
+
disabled: isDisabled,
|
|
160
|
+
"data-disabled": (0, import_shared_utils.dataAttr)(isDisabled),
|
|
161
|
+
"data-loading": (0, import_shared_utils.dataAttr)(isLoading),
|
|
162
|
+
"aria-disabled": isDisabled,
|
|
163
|
+
tabIndex: isDisabled ? -1 : void 0,
|
|
164
|
+
...rest,
|
|
165
|
+
children: [
|
|
166
|
+
isLoading && spinnerPlacement === "start" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_spinner.Spinner, { color: "current", size: spinnerSize }) : startContent,
|
|
167
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Slot.Slottable, { children }),
|
|
168
|
+
isLoading && spinnerPlacement === "end" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_spinner.Spinner, { color: "current", size: spinnerSize }) : endContent,
|
|
169
|
+
!disableRipple && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ripple.Ripple, { ...getRippleProps() })
|
|
170
|
+
]
|
|
171
|
+
}
|
|
172
|
+
)
|
|
173
|
+
}
|
|
174
|
+
);
|
|
175
|
+
};
|
|
176
|
+
var ShortcutDisplay = ({
|
|
177
|
+
shortcuts
|
|
178
|
+
}) => {
|
|
179
|
+
if (shortcuts.length === 0) return null;
|
|
180
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: shortcuts.map((key, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [
|
|
181
|
+
index > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("kbd", { children: "+" }),
|
|
182
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("kbd", { children: key })
|
|
183
|
+
] }, index.toString())) });
|
|
133
184
|
};
|
|
134
185
|
|
|
135
186
|
// src/copy-button.tsx
|
|
@@ -223,7 +274,7 @@ var CopyButton = ({
|
|
|
223
274
|
}
|
|
224
275
|
};
|
|
225
276
|
const isIconOnly = !children;
|
|
226
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
277
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_tooltip2.Tooltip, { content: tooltipContent, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
227
278
|
Button,
|
|
228
279
|
{
|
|
229
280
|
"aria-label": isIconOnly ? (_a = translations == null ? void 0 : translations.copy) != null ? _a : "Copy" : void 0,
|
package/dist/copy-button.mjs
CHANGED
package/dist/icon-button.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
"use strict";
|
|
3
|
+
"use client";
|
|
3
4
|
var __create = Object.create;
|
|
4
5
|
var __defProp = Object.defineProperty;
|
|
5
6
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -34,7 +35,6 @@ __export(icon_button_exports, {
|
|
|
34
35
|
IconButton: () => IconButton
|
|
35
36
|
});
|
|
36
37
|
module.exports = __toCommonJS(icon_button_exports);
|
|
37
|
-
var import_tooltip = require("@kopexa/tooltip");
|
|
38
38
|
var import_react2 = require("react");
|
|
39
39
|
|
|
40
40
|
// src/button.tsx
|
|
@@ -43,6 +43,7 @@ var import_ripple = require("@kopexa/ripple");
|
|
|
43
43
|
var import_shared_utils = require("@kopexa/shared-utils");
|
|
44
44
|
var import_spinner = require("@kopexa/spinner");
|
|
45
45
|
var import_theme = require("@kopexa/theme");
|
|
46
|
+
var import_tooltip = require("@kopexa/tooltip");
|
|
46
47
|
var Slot = __toESM(require("@radix-ui/react-slot"));
|
|
47
48
|
var import_react = require("react");
|
|
48
49
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -57,7 +58,7 @@ var Button = (props) => {
|
|
|
57
58
|
ref,
|
|
58
59
|
isLoading,
|
|
59
60
|
variant,
|
|
60
|
-
size = "
|
|
61
|
+
size = "md",
|
|
61
62
|
className,
|
|
62
63
|
color,
|
|
63
64
|
radius,
|
|
@@ -66,9 +67,16 @@ var Button = (props) => {
|
|
|
66
67
|
endContent,
|
|
67
68
|
isIconOnly,
|
|
68
69
|
spinnerPlacement = "start",
|
|
70
|
+
shortcutKeys,
|
|
71
|
+
tooltip,
|
|
72
|
+
spacing,
|
|
69
73
|
...rest
|
|
70
74
|
} = props;
|
|
71
75
|
const Comp = asChild ? Slot.Root : "button";
|
|
76
|
+
const shortcuts = (0, import_react.useMemo)(
|
|
77
|
+
() => (0, import_shared_utils.parseShortcutKeys)({ shortcutKeys }),
|
|
78
|
+
[shortcutKeys]
|
|
79
|
+
);
|
|
72
80
|
const domRef = (0, import_react.useRef)(null);
|
|
73
81
|
const isDisabled = disabled || isLoading;
|
|
74
82
|
const {
|
|
@@ -84,9 +92,10 @@ var Button = (props) => {
|
|
|
84
92
|
radius,
|
|
85
93
|
fullWidth,
|
|
86
94
|
isIconOnly,
|
|
87
|
-
className
|
|
95
|
+
className,
|
|
96
|
+
spacing
|
|
88
97
|
});
|
|
89
|
-
}, [variant, size, color, radius, isIconOnly, fullWidth, className]);
|
|
98
|
+
}, [variant, size, color, radius, isIconOnly, fullWidth, className, spacing]);
|
|
90
99
|
const handleClick = (0, import_react.useCallback)(
|
|
91
100
|
(e) => {
|
|
92
101
|
if (disableRipple || isDisabled) return;
|
|
@@ -107,7 +116,7 @@ var Button = (props) => {
|
|
|
107
116
|
};
|
|
108
117
|
return buttonSpinnerSizeMap[size];
|
|
109
118
|
}, [size]);
|
|
110
|
-
|
|
119
|
+
const content = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
111
120
|
Comp,
|
|
112
121
|
{
|
|
113
122
|
type,
|
|
@@ -128,6 +137,48 @@ var Button = (props) => {
|
|
|
128
137
|
]
|
|
129
138
|
}
|
|
130
139
|
);
|
|
140
|
+
if (!tooltip) {
|
|
141
|
+
return content;
|
|
142
|
+
}
|
|
143
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
144
|
+
import_tooltip.Tooltip,
|
|
145
|
+
{
|
|
146
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
147
|
+
tooltip,
|
|
148
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ShortcutDisplay, { shortcuts })
|
|
149
|
+
] }),
|
|
150
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
151
|
+
Comp,
|
|
152
|
+
{
|
|
153
|
+
type,
|
|
154
|
+
className: styles,
|
|
155
|
+
onClick: handleClick,
|
|
156
|
+
ref: (0, import_react_utils.mergeRefs)(domRef, ref),
|
|
157
|
+
disabled: isDisabled,
|
|
158
|
+
"data-disabled": (0, import_shared_utils.dataAttr)(isDisabled),
|
|
159
|
+
"data-loading": (0, import_shared_utils.dataAttr)(isLoading),
|
|
160
|
+
"aria-disabled": isDisabled,
|
|
161
|
+
tabIndex: isDisabled ? -1 : void 0,
|
|
162
|
+
...rest,
|
|
163
|
+
children: [
|
|
164
|
+
isLoading && spinnerPlacement === "start" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_spinner.Spinner, { color: "current", size: spinnerSize }) : startContent,
|
|
165
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Slot.Slottable, { children }),
|
|
166
|
+
isLoading && spinnerPlacement === "end" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_spinner.Spinner, { color: "current", size: spinnerSize }) : endContent,
|
|
167
|
+
!disableRipple && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ripple.Ripple, { ...getRippleProps() })
|
|
168
|
+
]
|
|
169
|
+
}
|
|
170
|
+
)
|
|
171
|
+
}
|
|
172
|
+
);
|
|
173
|
+
};
|
|
174
|
+
var ShortcutDisplay = ({
|
|
175
|
+
shortcuts
|
|
176
|
+
}) => {
|
|
177
|
+
if (shortcuts.length === 0) return null;
|
|
178
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: shortcuts.map((key, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [
|
|
179
|
+
index > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("kbd", { children: "+" }),
|
|
180
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("kbd", { children: key })
|
|
181
|
+
] }, index.toString())) });
|
|
131
182
|
};
|
|
132
183
|
|
|
133
184
|
// src/icon-button.tsx
|
|
@@ -145,10 +196,7 @@ var IconButton = (props) => {
|
|
|
145
196
|
// biome-ignore lint/suspicious/noExplicitAny: forcing type to any
|
|
146
197
|
(0, import_react2.cloneElement)(children, { "aria-hidden": true })
|
|
147
198
|
) : children;
|
|
148
|
-
|
|
149
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_tooltip.Tooltip, { content: toolip, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Button, { ...rest, "aria-label": ariaLabel, isIconOnly: true, children: clonedChildren }) });
|
|
150
|
-
}
|
|
151
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Button, { ...rest, "aria-label": ariaLabel, isIconOnly: true, children: clonedChildren });
|
|
199
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Button, { ...rest, tooltip: toolip, "aria-label": ariaLabel, isIconOnly: true, children: clonedChildren });
|
|
152
200
|
};
|
|
153
201
|
// Annotate the CommonJS export names for ESM import in node:
|
|
154
202
|
0 && (module.exports = {
|
package/dist/icon-button.mjs
CHANGED
package/dist/index.js
CHANGED
|
@@ -43,6 +43,7 @@ var import_ripple = require("@kopexa/ripple");
|
|
|
43
43
|
var import_shared_utils = require("@kopexa/shared-utils");
|
|
44
44
|
var import_spinner = require("@kopexa/spinner");
|
|
45
45
|
var import_theme = require("@kopexa/theme");
|
|
46
|
+
var import_tooltip = require("@kopexa/tooltip");
|
|
46
47
|
var Slot = __toESM(require("@radix-ui/react-slot"));
|
|
47
48
|
var import_react = require("react");
|
|
48
49
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -57,7 +58,7 @@ var Button = (props) => {
|
|
|
57
58
|
ref,
|
|
58
59
|
isLoading,
|
|
59
60
|
variant,
|
|
60
|
-
size = "
|
|
61
|
+
size = "md",
|
|
61
62
|
className,
|
|
62
63
|
color,
|
|
63
64
|
radius,
|
|
@@ -66,9 +67,16 @@ var Button = (props) => {
|
|
|
66
67
|
endContent,
|
|
67
68
|
isIconOnly,
|
|
68
69
|
spinnerPlacement = "start",
|
|
70
|
+
shortcutKeys,
|
|
71
|
+
tooltip,
|
|
72
|
+
spacing,
|
|
69
73
|
...rest
|
|
70
74
|
} = props;
|
|
71
75
|
const Comp = asChild ? Slot.Root : "button";
|
|
76
|
+
const shortcuts = (0, import_react.useMemo)(
|
|
77
|
+
() => (0, import_shared_utils.parseShortcutKeys)({ shortcutKeys }),
|
|
78
|
+
[shortcutKeys]
|
|
79
|
+
);
|
|
72
80
|
const domRef = (0, import_react.useRef)(null);
|
|
73
81
|
const isDisabled = disabled || isLoading;
|
|
74
82
|
const {
|
|
@@ -84,9 +92,10 @@ var Button = (props) => {
|
|
|
84
92
|
radius,
|
|
85
93
|
fullWidth,
|
|
86
94
|
isIconOnly,
|
|
87
|
-
className
|
|
95
|
+
className,
|
|
96
|
+
spacing
|
|
88
97
|
});
|
|
89
|
-
}, [variant, size, color, radius, isIconOnly, fullWidth, className]);
|
|
98
|
+
}, [variant, size, color, radius, isIconOnly, fullWidth, className, spacing]);
|
|
90
99
|
const handleClick = (0, import_react.useCallback)(
|
|
91
100
|
(e) => {
|
|
92
101
|
if (disableRipple || isDisabled) return;
|
|
@@ -107,7 +116,7 @@ var Button = (props) => {
|
|
|
107
116
|
};
|
|
108
117
|
return buttonSpinnerSizeMap[size];
|
|
109
118
|
}, [size]);
|
|
110
|
-
|
|
119
|
+
const content = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
111
120
|
Comp,
|
|
112
121
|
{
|
|
113
122
|
type,
|
|
@@ -128,12 +137,54 @@ var Button = (props) => {
|
|
|
128
137
|
]
|
|
129
138
|
}
|
|
130
139
|
);
|
|
140
|
+
if (!tooltip) {
|
|
141
|
+
return content;
|
|
142
|
+
}
|
|
143
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
144
|
+
import_tooltip.Tooltip,
|
|
145
|
+
{
|
|
146
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
147
|
+
tooltip,
|
|
148
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ShortcutDisplay, { shortcuts })
|
|
149
|
+
] }),
|
|
150
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
151
|
+
Comp,
|
|
152
|
+
{
|
|
153
|
+
type,
|
|
154
|
+
className: styles,
|
|
155
|
+
onClick: handleClick,
|
|
156
|
+
ref: (0, import_react_utils.mergeRefs)(domRef, ref),
|
|
157
|
+
disabled: isDisabled,
|
|
158
|
+
"data-disabled": (0, import_shared_utils.dataAttr)(isDisabled),
|
|
159
|
+
"data-loading": (0, import_shared_utils.dataAttr)(isLoading),
|
|
160
|
+
"aria-disabled": isDisabled,
|
|
161
|
+
tabIndex: isDisabled ? -1 : void 0,
|
|
162
|
+
...rest,
|
|
163
|
+
children: [
|
|
164
|
+
isLoading && spinnerPlacement === "start" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_spinner.Spinner, { color: "current", size: spinnerSize }) : startContent,
|
|
165
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Slot.Slottable, { children }),
|
|
166
|
+
isLoading && spinnerPlacement === "end" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_spinner.Spinner, { color: "current", size: spinnerSize }) : endContent,
|
|
167
|
+
!disableRipple && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ripple.Ripple, { ...getRippleProps() })
|
|
168
|
+
]
|
|
169
|
+
}
|
|
170
|
+
)
|
|
171
|
+
}
|
|
172
|
+
);
|
|
173
|
+
};
|
|
174
|
+
var ShortcutDisplay = ({
|
|
175
|
+
shortcuts
|
|
176
|
+
}) => {
|
|
177
|
+
if (shortcuts.length === 0) return null;
|
|
178
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: shortcuts.map((key, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [
|
|
179
|
+
index > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("kbd", { children: "+" }),
|
|
180
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("kbd", { children: key })
|
|
181
|
+
] }, index.toString())) });
|
|
131
182
|
};
|
|
132
183
|
|
|
133
184
|
// src/copy-button.tsx
|
|
134
185
|
var import_icons = require("@kopexa/icons");
|
|
135
186
|
var import_shared_utils2 = require("@kopexa/shared-utils");
|
|
136
|
-
var
|
|
187
|
+
var import_tooltip2 = require("@kopexa/tooltip");
|
|
137
188
|
var import_react2 = require("react");
|
|
138
189
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
139
190
|
var CopyButton = ({
|
|
@@ -225,7 +276,7 @@ var CopyButton = ({
|
|
|
225
276
|
}
|
|
226
277
|
};
|
|
227
278
|
const isIconOnly = !children;
|
|
228
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
279
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_tooltip2.Tooltip, { content: tooltipContent, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
229
280
|
Button,
|
|
230
281
|
{
|
|
231
282
|
"aria-label": isIconOnly ? (_a = translations == null ? void 0 : translations.copy) != null ? _a : "Copy" : void 0,
|
|
@@ -241,7 +292,6 @@ var CopyButton = ({
|
|
|
241
292
|
};
|
|
242
293
|
|
|
243
294
|
// src/icon-button.tsx
|
|
244
|
-
var import_tooltip2 = require("@kopexa/tooltip");
|
|
245
295
|
var import_react3 = require("react");
|
|
246
296
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
247
297
|
var IconButton = (props) => {
|
|
@@ -257,10 +307,7 @@ var IconButton = (props) => {
|
|
|
257
307
|
// biome-ignore lint/suspicious/noExplicitAny: forcing type to any
|
|
258
308
|
(0, import_react3.cloneElement)(children, { "aria-hidden": true })
|
|
259
309
|
) : children;
|
|
260
|
-
|
|
261
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_tooltip2.Tooltip, { content: toolip, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Button, { ...rest, "aria-label": ariaLabel, isIconOnly: true, children: clonedChildren }) });
|
|
262
|
-
}
|
|
263
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Button, { ...rest, "aria-label": ariaLabel, isIconOnly: true, children: clonedChildren });
|
|
310
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Button, { ...rest, tooltip: toolip, "aria-label": ariaLabel, isIconOnly: true, children: clonedChildren });
|
|
264
311
|
};
|
|
265
312
|
// Annotate the CommonJS export names for ESM import in node:
|
|
266
313
|
0 && (module.exports = {
|
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
CopyButton
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-IGA5FORT.mjs";
|
|
5
5
|
import {
|
|
6
6
|
IconButton
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-AKZB54J4.mjs";
|
|
8
8
|
import {
|
|
9
9
|
Button
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-SNQHD6JL.mjs";
|
|
11
11
|
export {
|
|
12
12
|
Button,
|
|
13
13
|
CopyButton,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kopexa/button",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.0",
|
|
4
4
|
"description": "Buttons allow users to perform actions and choose with a single tap.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"button"
|
|
@@ -28,16 +28,16 @@
|
|
|
28
28
|
"motion": ">=12.23.6",
|
|
29
29
|
"react": ">=19.0.0-rc.0",
|
|
30
30
|
"react-dom": ">=19.0.0-rc.0",
|
|
31
|
-
"@kopexa/theme": "1.
|
|
31
|
+
"@kopexa/theme": "2.1.0"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@radix-ui/react-slot": "^1.2.3",
|
|
35
|
-
"@kopexa/shared-utils": "
|
|
36
|
-
"@kopexa/react-utils": "
|
|
37
|
-
"@kopexa/spinner": "
|
|
38
|
-
"@kopexa/tooltip": "
|
|
39
|
-
"@kopexa/ripple": "
|
|
40
|
-
"@kopexa/icons": "
|
|
35
|
+
"@kopexa/shared-utils": "2.0.0",
|
|
36
|
+
"@kopexa/react-utils": "3.0.0",
|
|
37
|
+
"@kopexa/spinner": "8.0.0",
|
|
38
|
+
"@kopexa/tooltip": "8.0.0",
|
|
39
|
+
"@kopexa/ripple": "12.0.0",
|
|
40
|
+
"@kopexa/icons": "12.0.0"
|
|
41
41
|
},
|
|
42
42
|
"clean-package": "../../../clean-package.config.json",
|
|
43
43
|
"module": "dist/index.mjs",
|