@kopexa/button 0.0.0 → 2.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 CHANGED
@@ -1,7 +1,20 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ButtonVariantProps } from '@kopexa/theme';
2
3
  import { ComponentProps } from 'react';
3
4
 
4
- type ButtonProps = ComponentProps<"button">;
5
+ type ButtonProps = ComponentProps<"button"> & ButtonVariantProps & {
6
+ asChild?: boolean;
7
+ /**
8
+ * Whether the button should display a ripple effect on press.
9
+ * @default false
10
+ */
11
+ disableRipple?: boolean;
12
+ /**
13
+ * Whether the button should display a loading spinner.
14
+ * @default false
15
+ */
16
+ isLoading?: boolean;
17
+ };
5
18
  declare const Button: (props: ButtonProps) => react_jsx_runtime.JSX.Element;
6
19
 
7
20
  export { Button, type ButtonProps };
package/dist/button.d.ts CHANGED
@@ -1,7 +1,20 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ButtonVariantProps } from '@kopexa/theme';
2
3
  import { ComponentProps } from 'react';
3
4
 
4
- type ButtonProps = ComponentProps<"button">;
5
+ type ButtonProps = ComponentProps<"button"> & ButtonVariantProps & {
6
+ asChild?: boolean;
7
+ /**
8
+ * Whether the button should display a ripple effect on press.
9
+ * @default false
10
+ */
11
+ disableRipple?: boolean;
12
+ /**
13
+ * Whether the button should display a loading spinner.
14
+ * @default false
15
+ */
16
+ isLoading?: boolean;
17
+ };
5
18
  declare const Button: (props: ButtonProps) => react_jsx_runtime.JSX.Element;
6
19
 
7
20
  export { Button, type ButtonProps };
package/dist/button.js CHANGED
@@ -1,8 +1,10 @@
1
1
  "use client";
2
2
  "use strict";
3
+ var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
6
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
9
  var __export = (target, all) => {
8
10
  for (var name in all)
@@ -16,6 +18,14 @@ var __copyProps = (to, from, except, desc) => {
16
18
  }
17
19
  return to;
18
20
  };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
19
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
30
 
21
31
  // src/button.tsx
@@ -24,12 +34,67 @@ __export(button_exports, {
24
34
  Button: () => Button
25
35
  });
26
36
  module.exports = __toCommonJS(button_exports);
37
+ var import_react_utils = require("@kopexa/react-utils");
38
+ var import_ripple = require("@kopexa/ripple");
27
39
  var import_theme = require("@kopexa/theme");
40
+ var Slot = __toESM(require("@radix-ui/react-slot"));
41
+ var import_react = require("react");
28
42
  var import_jsx_runtime = require("react/jsx-runtime");
29
43
  var Button = (props) => {
30
- const { type = "button", ...rest } = props;
31
- const styles = (0, import_theme.button)();
32
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type, className: styles, ...rest });
44
+ const {
45
+ type = "button",
46
+ asChild,
47
+ children,
48
+ onClick,
49
+ disabled,
50
+ disableRipple,
51
+ ref,
52
+ isLoading,
53
+ variant,
54
+ size,
55
+ className,
56
+ ...rest
57
+ } = props;
58
+ const Comp = asChild ? Slot.Root : "button";
59
+ const domRef = (0, import_react.useRef)(null);
60
+ const isDisabled = disabled || isLoading;
61
+ const {
62
+ onClick: onRippleClickHandler,
63
+ onClear: onClearRipple,
64
+ ripples
65
+ } = (0, import_ripple.useRipple)();
66
+ const styles = (0, import_theme.button)({
67
+ variant,
68
+ size,
69
+ className
70
+ });
71
+ const handleClick = (0, import_react.useCallback)(
72
+ (e) => {
73
+ if (disableRipple || isDisabled) return;
74
+ domRef.current && onRippleClickHandler(e);
75
+ onClick == null ? void 0 : onClick(e);
76
+ },
77
+ [onClick, disableRipple, isDisabled, onRippleClickHandler]
78
+ );
79
+ const getRippleProps = (0, import_react.useCallback)(
80
+ () => ({ ripples, onClear: onClearRipple }),
81
+ [ripples, onClearRipple]
82
+ );
83
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
84
+ Comp,
85
+ {
86
+ type,
87
+ className: styles,
88
+ onClick: handleClick,
89
+ ref: (0, import_react_utils.mergeRefs)(domRef, ref),
90
+ disabled: isDisabled,
91
+ ...rest,
92
+ children: [
93
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Slot.Slottable, { children }),
94
+ !disableRipple && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ripple.Ripple, { ...getRippleProps() })
95
+ ]
96
+ }
97
+ );
33
98
  };
34
99
  // Annotate the CommonJS export names for ESM import in node:
35
100
  0 && (module.exports = {
package/dist/button.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  Button
4
- } from "./chunk-JVF4QGRI.mjs";
4
+ } from "./chunk-JCUHIKMH.mjs";
5
5
  export {
6
6
  Button
7
7
  };
@@ -0,0 +1,69 @@
1
+ "use client";
2
+
3
+ // src/button.tsx
4
+ import { mergeRefs } from "@kopexa/react-utils";
5
+ import { Ripple, useRipple } from "@kopexa/ripple";
6
+ import { button } from "@kopexa/theme";
7
+ import * as Slot from "@radix-ui/react-slot";
8
+ import { useCallback, useRef } from "react";
9
+ import { jsx, jsxs } from "react/jsx-runtime";
10
+ var Button = (props) => {
11
+ const {
12
+ type = "button",
13
+ asChild,
14
+ children,
15
+ onClick,
16
+ disabled,
17
+ disableRipple,
18
+ ref,
19
+ isLoading,
20
+ variant,
21
+ size,
22
+ className,
23
+ ...rest
24
+ } = props;
25
+ const Comp = asChild ? Slot.Root : "button";
26
+ const domRef = useRef(null);
27
+ const isDisabled = disabled || isLoading;
28
+ const {
29
+ onClick: onRippleClickHandler,
30
+ onClear: onClearRipple,
31
+ ripples
32
+ } = useRipple();
33
+ const styles = button({
34
+ variant,
35
+ size,
36
+ className
37
+ });
38
+ const handleClick = useCallback(
39
+ (e) => {
40
+ if (disableRipple || isDisabled) return;
41
+ domRef.current && onRippleClickHandler(e);
42
+ onClick == null ? void 0 : onClick(e);
43
+ },
44
+ [onClick, disableRipple, isDisabled, onRippleClickHandler]
45
+ );
46
+ const getRippleProps = useCallback(
47
+ () => ({ ripples, onClear: onClearRipple }),
48
+ [ripples, onClearRipple]
49
+ );
50
+ return /* @__PURE__ */ jsxs(
51
+ Comp,
52
+ {
53
+ type,
54
+ className: styles,
55
+ onClick: handleClick,
56
+ ref: mergeRefs(domRef, ref),
57
+ disabled: isDisabled,
58
+ ...rest,
59
+ children: [
60
+ /* @__PURE__ */ jsx(Slot.Slottable, { children }),
61
+ !disableRipple && /* @__PURE__ */ jsx(Ripple, { ...getRippleProps() })
62
+ ]
63
+ }
64
+ );
65
+ };
66
+
67
+ export {
68
+ Button
69
+ };
package/dist/index.d.mts CHANGED
@@ -1,3 +1,4 @@
1
1
  export { Button, ButtonProps } from './button.mjs';
2
2
  import 'react/jsx-runtime';
3
+ import '@kopexa/theme';
3
4
  import 'react';
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export { Button, ButtonProps } from './button.js';
2
2
  import 'react/jsx-runtime';
3
+ import '@kopexa/theme';
3
4
  import 'react';
package/dist/index.js CHANGED
@@ -1,8 +1,10 @@
1
1
  "use client";
2
2
  "use strict";
3
+ var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
6
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
9
  var __export = (target, all) => {
8
10
  for (var name in all)
@@ -16,6 +18,14 @@ var __copyProps = (to, from, except, desc) => {
16
18
  }
17
19
  return to;
18
20
  };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
19
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
30
 
21
31
  // src/index.ts
@@ -26,12 +36,67 @@ __export(index_exports, {
26
36
  module.exports = __toCommonJS(index_exports);
27
37
 
28
38
  // src/button.tsx
39
+ var import_react_utils = require("@kopexa/react-utils");
40
+ var import_ripple = require("@kopexa/ripple");
29
41
  var import_theme = require("@kopexa/theme");
42
+ var Slot = __toESM(require("@radix-ui/react-slot"));
43
+ var import_react = require("react");
30
44
  var import_jsx_runtime = require("react/jsx-runtime");
31
45
  var Button = (props) => {
32
- const { type = "button", ...rest } = props;
33
- const styles = (0, import_theme.button)();
34
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type, className: styles, ...rest });
46
+ const {
47
+ type = "button",
48
+ asChild,
49
+ children,
50
+ onClick,
51
+ disabled,
52
+ disableRipple,
53
+ ref,
54
+ isLoading,
55
+ variant,
56
+ size,
57
+ className,
58
+ ...rest
59
+ } = props;
60
+ const Comp = asChild ? Slot.Root : "button";
61
+ const domRef = (0, import_react.useRef)(null);
62
+ const isDisabled = disabled || isLoading;
63
+ const {
64
+ onClick: onRippleClickHandler,
65
+ onClear: onClearRipple,
66
+ ripples
67
+ } = (0, import_ripple.useRipple)();
68
+ const styles = (0, import_theme.button)({
69
+ variant,
70
+ size,
71
+ className
72
+ });
73
+ const handleClick = (0, import_react.useCallback)(
74
+ (e) => {
75
+ if (disableRipple || isDisabled) return;
76
+ domRef.current && onRippleClickHandler(e);
77
+ onClick == null ? void 0 : onClick(e);
78
+ },
79
+ [onClick, disableRipple, isDisabled, onRippleClickHandler]
80
+ );
81
+ const getRippleProps = (0, import_react.useCallback)(
82
+ () => ({ ripples, onClear: onClearRipple }),
83
+ [ripples, onClearRipple]
84
+ );
85
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
86
+ Comp,
87
+ {
88
+ type,
89
+ className: styles,
90
+ onClick: handleClick,
91
+ ref: (0, import_react_utils.mergeRefs)(domRef, ref),
92
+ disabled: isDisabled,
93
+ ...rest,
94
+ children: [
95
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Slot.Slottable, { children }),
96
+ !disableRipple && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ripple.Ripple, { ...getRippleProps() })
97
+ ]
98
+ }
99
+ );
35
100
  };
36
101
  // Annotate the CommonJS export names for ESM import in node:
37
102
  0 && (module.exports = {
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  Button
4
- } from "./chunk-JVF4QGRI.mjs";
4
+ } from "./chunk-JCUHIKMH.mjs";
5
5
  export {
6
6
  Button
7
7
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kopexa/button",
3
- "version": "0.0.0",
3
+ "version": "2.0.0",
4
4
  "description": "Buttons allow users to perform actions and choose with a single tap.",
5
5
  "keywords": [
6
6
  "button"
@@ -25,12 +25,17 @@
25
25
  "url": "https://github.com/kopexa-grc/sight/issues"
26
26
  },
27
27
  "peerDependencies": {
28
- "react": ">=18 || >=19.0.0-rc.0",
29
- "react-dom": ">=18 || >=19.0.0-rc.0",
30
- "framer-motion": ">=11.5.6 || >=12.0.0-alpha.1",
31
- "@kopexa/theme": "0.0.0"
28
+ "motion": ">=12.23.6",
29
+ "react": ">=19.0.0-rc.0",
30
+ "react-dom": ">=19.0.0-rc.0",
31
+ "@kopexa/theme": "1.1.0"
32
+ },
33
+ "dependencies": {
34
+ "@radix-ui/react-slot": "^1.2.3",
35
+ "@kopexa/shared-utils": "1.1.0",
36
+ "@kopexa/react-utils": "1.1.0",
37
+ "@kopexa/ripple": "4.0.0"
32
38
  },
33
- "dependencies": {},
34
39
  "clean-package": "../../../clean-package.config.json",
35
40
  "module": "dist/index.mjs",
36
41
  "types": "dist/index.d.ts",
@@ -1,14 +0,0 @@
1
- "use client";
2
-
3
- // src/button.tsx
4
- import { button } from "@kopexa/theme";
5
- import { jsx } from "react/jsx-runtime";
6
- var Button = (props) => {
7
- const { type = "button", ...rest } = props;
8
- const styles = button();
9
- return /* @__PURE__ */ jsx("button", { type, className: styles, ...rest });
10
- };
11
-
12
- export {
13
- Button
14
- };