ehscan-react-components 0.1.5 → 0.1.6
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.ts +13 -0
- package/dist/Button.js +19 -0
- package/dist/Components.d.ts +1 -1
- package/dist/Components.js +3 -3
- package/package.json +1 -1
package/dist/Button.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
type Props = {
|
|
3
|
+
index?: string | number;
|
|
4
|
+
text?: string;
|
|
5
|
+
selected?: boolean;
|
|
6
|
+
addClass?: string;
|
|
7
|
+
notimeout?: boolean;
|
|
8
|
+
size?: 'sm' | 'md' | 'lg';
|
|
9
|
+
click?: (args?: any) => void;
|
|
10
|
+
children?: ReactNode;
|
|
11
|
+
};
|
|
12
|
+
declare const Button: React.FC<Props>;
|
|
13
|
+
export default Button;
|
package/dist/Button.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, useCallback } from "react";
|
|
3
|
+
import useRipple from "./tools/useRipple";
|
|
4
|
+
const Button = ({ index, text, selected, addClass, notimeout, size = 'md', click, children }) => {
|
|
5
|
+
const buttonRef = useRef(null);
|
|
6
|
+
const handleRipple = useRipple();
|
|
7
|
+
const handleButtonClick = useCallback((event) => {
|
|
8
|
+
handleRipple(event, buttonRef);
|
|
9
|
+
if (notimeout) {
|
|
10
|
+
click === null || click === void 0 ? void 0 : click(event);
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
setTimeout(() => {
|
|
14
|
+
click === null || click === void 0 ? void 0 : click(event);
|
|
15
|
+
}, 200);
|
|
16
|
+
}, [notimeout, click, handleRipple]);
|
|
17
|
+
return (_jsx(_Fragment, { children: _jsxs("button", { type: "button", ref: buttonRef, onClick: handleButtonClick, className: `ext-btn ext-btn--primary ext-btn--${size} _ripple ${addClass !== null && addClass !== void 0 ? addClass : ''}`, "aria-pressed": selected, children: [children, text && _jsx("div", { className: "ext-btn-label", children: text })] }, index) }));
|
|
18
|
+
};
|
|
19
|
+
export default Button;
|
package/dist/Components.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import './style/button.css';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const ExtButton: () => import("react/jsx-runtime").JSX.Element;
|
package/dist/Components.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import Button from './Button';
|
|
3
3
|
import './style/button.css';
|
|
4
|
-
export const
|
|
5
|
-
return _jsx(
|
|
4
|
+
export const ExtButton = () => {
|
|
5
|
+
return _jsx(Button, {});
|
|
6
6
|
};
|