@speakapbv/dough-component-library 10.2.0 → 10.2.1
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { ReactNode, MouseEvent } from "react";
|
|
1
|
+
import React, { ReactNode, MouseEvent, MouseEventHandler } from "react";
|
|
2
2
|
import { Colors, Sizes, DoughDataAttributes, ColorsText } from "../../utils/constants";
|
|
3
3
|
import "./button.scss";
|
|
4
4
|
export declare enum ButtonInputType {
|
|
@@ -31,6 +31,9 @@ export interface ButtonProps {
|
|
|
31
31
|
padding?: boolean;
|
|
32
32
|
onClick?(e?: MouseEvent): void;
|
|
33
33
|
onDoubleClick?(e?: MouseEvent): void;
|
|
34
|
+
onMouseDown?: MouseEventHandler<HTMLButtonElement>;
|
|
35
|
+
onPointerDown?: MouseEventHandler<HTMLButtonElement>;
|
|
36
|
+
allEvents?: boolean;
|
|
34
37
|
rounded?: boolean;
|
|
35
38
|
flat?: boolean;
|
|
36
39
|
size?: Sizes.LARGE | Sizes.NORMAL | Sizes.SMALL | Sizes.XS;
|
package/dist/index.es.js
CHANGED
|
@@ -623,8 +623,8 @@ var Button = forwardRef(function (props, externalRef) {
|
|
|
623
623
|
var doubleClickPrevent = false;
|
|
624
624
|
var clickTime = 0;
|
|
625
625
|
var doubleClickDuration = 250;
|
|
626
|
-
var _a = props.alignIconRight, alignIconRight = _a === void 0 ? false : _a, _b = props.shadow, shadow = _b === void 0 ? true : _b, _c = props.padding, padding = _c === void 0 ? true : _c, _d = props.size, size = _d === void 0 ? Sizes.SMALL : _d, _e = props.type, type = _e === void 0 ? ButtonInputType.BUTTON : _e, _f = props.linkProps, linkProps = _f === void 0 ? {} : _f, withoutBackground = props.withoutBackground;
|
|
627
|
-
var
|
|
626
|
+
var _a = props.alignIconRight, alignIconRight = _a === void 0 ? false : _a, _b = props.shadow, shadow = _b === void 0 ? true : _b, _c = props.padding, padding = _c === void 0 ? true : _c, _d = props.size, size = _d === void 0 ? Sizes.SMALL : _d, _e = props.type, type = _e === void 0 ? ButtonInputType.BUTTON : _e, _f = props.linkProps, linkProps = _f === void 0 ? {} : _f, withoutBackground = props.withoutBackground, _g = props.allEvents, allEvents = _g === void 0 ? false : _g, onMouseDown = props.onMouseDown, onPointerDown = props.onPointerDown;
|
|
627
|
+
var _h = useState(props.color || Colors.BUTTON), colorVal = _h[0], setColorVal = _h[1];
|
|
628
628
|
var initColorVal = useState(props.color || Colors.BUTTON)[0];
|
|
629
629
|
var buttonRef = useRef();
|
|
630
630
|
var clickAndDoubleClickHandler = function (eNative, e, handler) {
|
|
@@ -764,12 +764,28 @@ var Button = forwardRef(function (props, externalRef) {
|
|
|
764
764
|
}
|
|
765
765
|
};
|
|
766
766
|
}
|
|
767
|
+
function handleMouseDown(event) {
|
|
768
|
+
if (onMouseDown) {
|
|
769
|
+
onMouseDown(event);
|
|
770
|
+
}
|
|
771
|
+
else if (!allEvents) {
|
|
772
|
+
cancelEvent(event);
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
function handlePointerDown(event) {
|
|
776
|
+
if (onPointerDown) {
|
|
777
|
+
onPointerDown(event);
|
|
778
|
+
}
|
|
779
|
+
else if (!allEvents) {
|
|
780
|
+
cancelEvent(event);
|
|
781
|
+
}
|
|
782
|
+
}
|
|
767
783
|
return (React.createElement(React.Fragment, null,
|
|
768
784
|
type === ButtonInputType.LINK && (React.createElement(Link, __assign({ ref: getRef(), className: cn("dough-button-wrapper", props.className, {
|
|
769
785
|
"dough-button-full-width": props.fullWidth,
|
|
770
786
|
"dough-link-no-underline": type === ButtonInputType.LINK,
|
|
771
787
|
}), disabled: props.disabled, onClick: clickHandler, dataAttributes: props.dataAttributes }, linkProps), getButtonContent())),
|
|
772
|
-
type !== ButtonInputType.LINK && (React.createElement("button", __assign({ ref: getRef(), type: type, autoFocus: props.autoFocus, name: props.name, tabIndex: props.tabIndex === undefined ? 0 : props.tabIndex, className: cn("dough-button-wrapper", props.className, {
|
|
788
|
+
type !== ButtonInputType.LINK && (React.createElement("button", __assign({ ref: getRef(), type: type, autoFocus: props.autoFocus, name: props.name, onMouseDown: handleMouseDown, onPointerDown: handlePointerDown, tabIndex: props.tabIndex === undefined ? 0 : props.tabIndex, className: cn("dough-button-wrapper", props.className, {
|
|
773
789
|
"dough-button-full-width": props.fullWidth,
|
|
774
790
|
"dough-button-not-clickable": !props.onClick &&
|
|
775
791
|
!props.onDoubleClick &&
|
package/dist/index.js
CHANGED
|
@@ -617,8 +617,8 @@ var Button = React.forwardRef(function (props, externalRef) {
|
|
|
617
617
|
var doubleClickPrevent = false;
|
|
618
618
|
var clickTime = 0;
|
|
619
619
|
var doubleClickDuration = 250;
|
|
620
|
-
var _a = props.alignIconRight, alignIconRight = _a === void 0 ? false : _a, _b = props.shadow, shadow = _b === void 0 ? true : _b, _c = props.padding, padding = _c === void 0 ? true : _c, _d = props.size, size = _d === void 0 ? exports.Sizes.SMALL : _d, _e = props.type, type = _e === void 0 ? exports.ButtonInputType.BUTTON : _e, _f = props.linkProps, linkProps = _f === void 0 ? {} : _f, withoutBackground = props.withoutBackground;
|
|
621
|
-
var
|
|
620
|
+
var _a = props.alignIconRight, alignIconRight = _a === void 0 ? false : _a, _b = props.shadow, shadow = _b === void 0 ? true : _b, _c = props.padding, padding = _c === void 0 ? true : _c, _d = props.size, size = _d === void 0 ? exports.Sizes.SMALL : _d, _e = props.type, type = _e === void 0 ? exports.ButtonInputType.BUTTON : _e, _f = props.linkProps, linkProps = _f === void 0 ? {} : _f, withoutBackground = props.withoutBackground, _g = props.allEvents, allEvents = _g === void 0 ? false : _g, onMouseDown = props.onMouseDown, onPointerDown = props.onPointerDown;
|
|
621
|
+
var _h = React.useState(props.color || exports.Colors.BUTTON), colorVal = _h[0], setColorVal = _h[1];
|
|
622
622
|
var initColorVal = React.useState(props.color || exports.Colors.BUTTON)[0];
|
|
623
623
|
var buttonRef = React.useRef();
|
|
624
624
|
var clickAndDoubleClickHandler = function (eNative, e, handler) {
|
|
@@ -758,12 +758,28 @@ var Button = React.forwardRef(function (props, externalRef) {
|
|
|
758
758
|
}
|
|
759
759
|
};
|
|
760
760
|
}
|
|
761
|
+
function handleMouseDown(event) {
|
|
762
|
+
if (onMouseDown) {
|
|
763
|
+
onMouseDown(event);
|
|
764
|
+
}
|
|
765
|
+
else if (!allEvents) {
|
|
766
|
+
cancelEvent(event);
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
function handlePointerDown(event) {
|
|
770
|
+
if (onPointerDown) {
|
|
771
|
+
onPointerDown(event);
|
|
772
|
+
}
|
|
773
|
+
else if (!allEvents) {
|
|
774
|
+
cancelEvent(event);
|
|
775
|
+
}
|
|
776
|
+
}
|
|
761
777
|
return (React__default.createElement(React__default.Fragment, null,
|
|
762
778
|
type === exports.ButtonInputType.LINK && (React__default.createElement(Link, __assign({ ref: getRef(), className: cn("dough-button-wrapper", props.className, {
|
|
763
779
|
"dough-button-full-width": props.fullWidth,
|
|
764
780
|
"dough-link-no-underline": type === exports.ButtonInputType.LINK,
|
|
765
781
|
}), disabled: props.disabled, onClick: clickHandler, dataAttributes: props.dataAttributes }, linkProps), getButtonContent())),
|
|
766
|
-
type !== exports.ButtonInputType.LINK && (React__default.createElement("button", __assign({ ref: getRef(), type: type, autoFocus: props.autoFocus, name: props.name, tabIndex: props.tabIndex === undefined ? 0 : props.tabIndex, className: cn("dough-button-wrapper", props.className, {
|
|
782
|
+
type !== exports.ButtonInputType.LINK && (React__default.createElement("button", __assign({ ref: getRef(), type: type, autoFocus: props.autoFocus, name: props.name, onMouseDown: handleMouseDown, onPointerDown: handlePointerDown, tabIndex: props.tabIndex === undefined ? 0 : props.tabIndex, className: cn("dough-button-wrapper", props.className, {
|
|
767
783
|
"dough-button-full-width": props.fullWidth,
|
|
768
784
|
"dough-button-not-clickable": !props.onClick &&
|
|
769
785
|
!props.onDoubleClick &&
|
|
@@ -14,6 +14,6 @@ export declare const ColorButton: import("@storybook/csf").AnnotatedStoryFn<impo
|
|
|
14
14
|
export declare const ColorButtonWithoutBorder: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, ButtonProps & {
|
|
15
15
|
width: string;
|
|
16
16
|
}>;
|
|
17
|
-
export declare const ConstrainedButton: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, Pick<ButtonProps, "className" | "children" | "dataAttributes" | "type" | "size" | "color" | "border" | "rounded" | "shadow" | "padding" | "onClick" | "fullWidth" | "disabled" | "alignIconRight" | "linkProps" | "tabIndex" | "name" | "autoFocus" | "icon" | "onDoubleClick" | "flat" | "busy" | "withoutBackground" | "colorPicker"> & {
|
|
17
|
+
export declare const ConstrainedButton: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, Pick<ButtonProps, "className" | "children" | "dataAttributes" | "type" | "size" | "color" | "border" | "rounded" | "shadow" | "padding" | "onClick" | "fullWidth" | "disabled" | "alignIconRight" | "linkProps" | "tabIndex" | "name" | "autoFocus" | "icon" | "onDoubleClick" | "onMouseDown" | "onPointerDown" | "allEvents" | "flat" | "busy" | "withoutBackground" | "colorPicker"> & {
|
|
18
18
|
singleLabel: boolean;
|
|
19
19
|
}>;
|
package/package.json
CHANGED
|
File without changes
|