@speakapbv/dough-component-library 10.2.0 → 10.3.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.
|
@@ -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;
|
|
@@ -113,7 +113,8 @@ export interface BoxProps {
|
|
|
113
113
|
/** Event properties */
|
|
114
114
|
onScrollReachedBottom?(e?: UIEvent): void;
|
|
115
115
|
onMouseEnter?: MouseEventHandler<HTMLDivElement>;
|
|
116
|
+
onMouseMove?: MouseEventHandler<HTMLDivElement>;
|
|
116
117
|
onMouseLeave?: MouseEventHandler<HTMLDivElement>;
|
|
117
118
|
onClick?: MouseEventHandler<HTMLDivElement>;
|
|
118
119
|
}
|
|
119
|
-
export declare const Box: React.ForwardRefExoticComponent<Pick<BoxProps, "className" | "children" | "dataAttributes" | "width" | "height" | "minWidth" | "minHeight" | "maxWidth" | "maxHeight" | "absolute" | "zIndex" | "color" | "border" | "borderRadius" | "rounded" | "shadow" | "padding" | "transform" | "overflow" | "display" | "direction" | "flex" | "basis" | "grow" | "shrink" | "order" | "wrap" | "justifyContent" | "alignItems" | "alignContent" | "alignSelf" | "onScrollReachedBottom" | "onMouseEnter" | "onMouseLeave" | "onClick"> & React.RefAttributes<HTMLDivElement>>;
|
|
120
|
+
export declare const Box: React.ForwardRefExoticComponent<Pick<BoxProps, "className" | "children" | "dataAttributes" | "width" | "height" | "minWidth" | "minHeight" | "maxWidth" | "maxHeight" | "absolute" | "zIndex" | "color" | "border" | "borderRadius" | "rounded" | "shadow" | "padding" | "transform" | "overflow" | "display" | "direction" | "flex" | "basis" | "grow" | "shrink" | "order" | "wrap" | "justifyContent" | "alignItems" | "alignContent" | "alignSelf" | "onScrollReachedBottom" | "onMouseEnter" | "onMouseMove" | "onMouseLeave" | "onClick"> & React.RefAttributes<HTMLDivElement>>;
|
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 &&
|
|
@@ -1177,7 +1193,7 @@ var Box = forwardRef(function (props, ref) {
|
|
|
1177
1193
|
_a["dough-flex-align-content-" + props.alignContent] = props.alignContent,
|
|
1178
1194
|
_a["dough-flex-align-self-" + props.alignSelf] = props.alignSelf,
|
|
1179
1195
|
_a)), style: __assign({ width: props.width, height: props.height, minWidth: props.minWidth, minHeight: props.minHeight, maxWidth: props.maxWidth, maxHeight: props.maxHeight, flexBasis: props.basis, flexGrow: props.grow, flexShrink: props.shrink, order: props.order, flex: props.flex, zIndex: props.zIndex, transform: props.transform }, (isTypeObject(props.absolute) &&
|
|
1180
|
-
props.absolute)) }, props.dataAttributes, { onScroll: props.onScrollReachedBottom ? handleScroll : undefined, onMouseEnter: props.onMouseEnter, onMouseLeave: props.onMouseLeave, onClick: props.onClick }), props.children));
|
|
1196
|
+
props.absolute)) }, props.dataAttributes, { onScroll: props.onScrollReachedBottom ? handleScroll : undefined, onMouseEnter: props.onMouseEnter, onMouseLeave: props.onMouseLeave, onMouseMove: props.onMouseMove, onClick: props.onClick }), props.children));
|
|
1181
1197
|
});
|
|
1182
1198
|
Box.displayName = "Box";
|
|
1183
1199
|
|
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 &&
|
|
@@ -1162,7 +1178,7 @@ var Box = React.forwardRef(function (props, ref) {
|
|
|
1162
1178
|
_a["dough-flex-align-content-" + props.alignContent] = props.alignContent,
|
|
1163
1179
|
_a["dough-flex-align-self-" + props.alignSelf] = props.alignSelf,
|
|
1164
1180
|
_a)), style: __assign({ width: props.width, height: props.height, minWidth: props.minWidth, minHeight: props.minHeight, maxWidth: props.maxWidth, maxHeight: props.maxHeight, flexBasis: props.basis, flexGrow: props.grow, flexShrink: props.shrink, order: props.order, flex: props.flex, zIndex: props.zIndex, transform: props.transform }, (isTypeObject(props.absolute) &&
|
|
1165
|
-
props.absolute)) }, props.dataAttributes, { onScroll: props.onScrollReachedBottom ? handleScroll : undefined, onMouseEnter: props.onMouseEnter, onMouseLeave: props.onMouseLeave, onClick: props.onClick }), props.children));
|
|
1181
|
+
props.absolute)) }, props.dataAttributes, { onScroll: props.onScrollReachedBottom ? handleScroll : undefined, onMouseEnter: props.onMouseEnter, onMouseLeave: props.onMouseLeave, onMouseMove: props.onMouseMove, onClick: props.onClick }), props.children));
|
|
1166
1182
|
});
|
|
1167
1183
|
Box.displayName = "Box";
|
|
1168
1184
|
|
|
@@ -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
|
}>;
|