@kopexa/button 0.0.0-canary-20250718183330
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 +20 -0
- package/dist/button.d.ts +20 -0
- package/dist/button.js +102 -0
- package/dist/button.mjs +7 -0
- package/dist/chunk-JCUHIKMH.mjs +69 -0
- package/dist/index.d.mts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +104 -0
- package/dist/index.mjs +7 -0
- package/package.json +57 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ButtonVariantProps } from '@kopexa/theme';
|
|
3
|
+
import { ComponentProps } from 'react';
|
|
4
|
+
|
|
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
|
+
};
|
|
18
|
+
declare const Button: (props: ButtonProps) => react_jsx_runtime.JSX.Element;
|
|
19
|
+
|
|
20
|
+
export { Button, type ButtonProps };
|
package/dist/button.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ButtonVariantProps } from '@kopexa/theme';
|
|
3
|
+
import { ComponentProps } from 'react';
|
|
4
|
+
|
|
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
|
+
};
|
|
18
|
+
declare const Button: (props: ButtonProps) => react_jsx_runtime.JSX.Element;
|
|
19
|
+
|
|
20
|
+
export { Button, type ButtonProps };
|
package/dist/button.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
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
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
|
|
31
|
+
// src/button.tsx
|
|
32
|
+
var button_exports = {};
|
|
33
|
+
__export(button_exports, {
|
|
34
|
+
Button: () => Button
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(button_exports);
|
|
37
|
+
var import_react_utils = require("@kopexa/react-utils");
|
|
38
|
+
var import_ripple = require("@kopexa/ripple");
|
|
39
|
+
var import_theme = require("@kopexa/theme");
|
|
40
|
+
var Slot = __toESM(require("@radix-ui/react-slot"));
|
|
41
|
+
var import_react = require("react");
|
|
42
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
43
|
+
var Button = (props) => {
|
|
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
|
+
);
|
|
98
|
+
};
|
|
99
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
100
|
+
0 && (module.exports = {
|
|
101
|
+
Button
|
|
102
|
+
});
|
package/dist/button.mjs
ADDED
|
@@ -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
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
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
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
|
|
31
|
+
// src/index.ts
|
|
32
|
+
var index_exports = {};
|
|
33
|
+
__export(index_exports, {
|
|
34
|
+
Button: () => Button
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(index_exports);
|
|
37
|
+
|
|
38
|
+
// src/button.tsx
|
|
39
|
+
var import_react_utils = require("@kopexa/react-utils");
|
|
40
|
+
var import_ripple = require("@kopexa/ripple");
|
|
41
|
+
var import_theme = require("@kopexa/theme");
|
|
42
|
+
var Slot = __toESM(require("@radix-ui/react-slot"));
|
|
43
|
+
var import_react = require("react");
|
|
44
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
45
|
+
var Button = (props) => {
|
|
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
|
+
);
|
|
100
|
+
};
|
|
101
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
102
|
+
0 && (module.exports = {
|
|
103
|
+
Button
|
|
104
|
+
});
|
package/dist/index.mjs
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kopexa/button",
|
|
3
|
+
"version": "0.0.0-canary-20250718183330",
|
|
4
|
+
"description": "Buttons allow users to perform actions and choose with a single tap.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"button"
|
|
7
|
+
],
|
|
8
|
+
"author": "Kopexa <hello@kopexa.com>",
|
|
9
|
+
"homepage": "https://kopexa.com",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"main": "dist/index.js",
|
|
12
|
+
"sideEffects": false,
|
|
13
|
+
"files": [
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/kopexa-grc/sight.git",
|
|
22
|
+
"directory": "packages/components/button"
|
|
23
|
+
},
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/kopexa-grc/sight/issues"
|
|
26
|
+
},
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"motion": ">=12.23.6",
|
|
29
|
+
"react": ">=19.0.0-rc.0",
|
|
30
|
+
"react-dom": ">=19.0.0-rc.0",
|
|
31
|
+
"@kopexa/theme": "0.0.0-canary-20250718183330"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@radix-ui/react-slot": "^1.2.3",
|
|
35
|
+
"@kopexa/shared-utils": "0.0.0-canary-20250718183330",
|
|
36
|
+
"@kopexa/react-utils": "0.0.0-canary-20250718183330",
|
|
37
|
+
"@kopexa/ripple": "0.0.0-canary-20250718183330"
|
|
38
|
+
},
|
|
39
|
+
"clean-package": "../../../clean-package.config.json",
|
|
40
|
+
"module": "dist/index.mjs",
|
|
41
|
+
"types": "dist/index.d.ts",
|
|
42
|
+
"exports": {
|
|
43
|
+
".": {
|
|
44
|
+
"types": "./dist/index.d.ts",
|
|
45
|
+
"import": "./dist/index.mjs",
|
|
46
|
+
"require": "./dist/index.js"
|
|
47
|
+
},
|
|
48
|
+
"./package.json": "./package.json"
|
|
49
|
+
},
|
|
50
|
+
"scripts": {
|
|
51
|
+
"build": "tsup src --dts",
|
|
52
|
+
"dev": "pnpm build:fast --watch",
|
|
53
|
+
"clean": "rimraf dist .turbo",
|
|
54
|
+
"typecheck": "tsc --noEmit",
|
|
55
|
+
"build:fast": "tsup src"
|
|
56
|
+
}
|
|
57
|
+
}
|