@sb1/ffe-buttons-react 24.0.46 → 24.1.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/es/BaseButton.js +2 -2
- package/es/ExpandButton.js +6 -4
- package/lib/BaseButton.js +2 -2
- package/lib/ExpandButton.js +6 -4
- package/package.json +4 -4
- package/types/BaseButton.d.ts +4 -0
- package/types/ExpandButton.d.ts +2 -0
package/es/BaseButton.js
CHANGED
|
@@ -28,9 +28,9 @@ import classNames from 'classnames';
|
|
|
28
28
|
* @ignore
|
|
29
29
|
*/
|
|
30
30
|
function BaseButtonWithForwardRef(props, ref) {
|
|
31
|
-
var _a = props.as, Comp = _a === void 0 ? 'button' : _a, buttonType = props.buttonType, isLoading = props.isLoading, isDisabled = props.isDisabled, className = props.className, onClick = props.onClick, leftIcon = props.leftIcon, rightIcon = props.rightIcon, ariaLoadingMessage = props.ariaLoadingMessage, children = props.children, rest = __rest(props, ["as", "buttonType", "isLoading", "isDisabled", "className", "onClick", "leftIcon", "rightIcon", "ariaLoadingMessage", "children"]);
|
|
31
|
+
var _a = props.as, Comp = _a === void 0 ? 'button' : _a, buttonType = props.buttonType, isLoading = props.isLoading, isDisabled = props.isDisabled, className = props.className, onClick = props.onClick, leftIcon = props.leftIcon, rightIcon = props.rightIcon, _b = props.size, size = _b === void 0 ? 'md' : _b, ariaLoadingMessage = props.ariaLoadingMessage, children = props.children, rest = __rest(props, ["as", "buttonType", "isLoading", "isDisabled", "className", "onClick", "leftIcon", "rightIcon", "size", "ariaLoadingMessage", "children"]);
|
|
32
32
|
var supportsSpinner = ['action', 'primary', 'secondary'].includes(buttonType);
|
|
33
|
-
return (React.createElement(Comp, __assign({ "aria-busy": isLoading && supportsSpinner, "aria-disabled": isDisabled || (isLoading && supportsSpinner), className: classNames('ffe-button', "ffe-button--".concat(buttonType), { 'ffe-button--loading': isLoading && supportsSpinner }, className), onClick: function (event) {
|
|
33
|
+
return (React.createElement(Comp, __assign({ "aria-busy": isLoading && supportsSpinner, "aria-disabled": isDisabled || (isLoading && supportsSpinner), className: classNames('ffe-button', "ffe-button--".concat(buttonType), "ffe-button--".concat(size), { 'ffe-button--loading': isLoading && supportsSpinner }, className), onClick: function (event) {
|
|
34
34
|
if (isLoading && supportsSpinner) {
|
|
35
35
|
event.preventDefault();
|
|
36
36
|
event.stopPropagation();
|
package/es/ExpandButton.js
CHANGED
|
@@ -25,10 +25,12 @@ import classNames from 'classnames';
|
|
|
25
25
|
import { Icon } from '@sb1/ffe-icons-react';
|
|
26
26
|
import { fixedForwardRef } from './fixedForwardRef';
|
|
27
27
|
function ExpandButtonWithForwardRef(props, ref) {
|
|
28
|
-
var children = props.children, className = props.className, _a = props.closeLabel, closeLabel = _a === void 0 ? 'Lukk' : _a, _b = props.as, Comp = _b === void 0 ? 'button' : _b, isExpanded = props.isExpanded, rest = __rest(props, ["children", "className", "closeLabel", "as", "isExpanded"]);
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
var children = props.children, className = props.className, _a = props.closeLabel, closeLabel = _a === void 0 ? 'Lukk' : _a, _b = props.as, Comp = _b === void 0 ? 'button' : _b, isExpanded = props.isExpanded, _c = props.size, size = _c === void 0 ? 'md' : _c, rest = __rest(props, ["children", "className", "closeLabel", "as", "isExpanded", "size"]);
|
|
29
|
+
var closeIconMd = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgLTk2MCA5NjAgOTYwIiB3aWR0aD0iMjQiPjxwYXRoIGQ9Ik00ODAtNDM3Ljg0NyAyNzcuMDc2LTIzNC45MjRxLTguMzA3IDguMzA4LTIwLjg4NCA4LjUtMTIuNTc2LjE5My0yMS4yNjgtOC41LTguNjkzLTguNjkyLTguNjkzLTIxLjA3NnQ4LjY5My0yMS4wNzZMNDM3Ljg0Ny00ODAgMjM0LjkyNC02ODIuOTI0c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4yNy04LjcgOC42OS0xOC41OCA4LjY5LTkuODggMC0xOC41OC04LjY5TDQ4MC00NDIuODVaIi8+PC9zdmc+';
|
|
31
|
+
var closeIcon = size === 'sm' ? closeIconSm : closeIconMd;
|
|
32
|
+
return (React.createElement(Comp, __assign({ "aria-expanded": isExpanded, "aria-label": isExpanded ? closeLabel : undefined, className: classNames('ffe-button', 'ffe-button--secondary', 'ffe-button--expand', "ffe-button--".concat(size), { 'ffe-button--expanded': isExpanded }, className) }, rest, { ref: ref }),
|
|
33
|
+
isExpanded && (React.createElement(Icon, { className: "ffe-button__icon", fileUrl: closeIcon, size: size === 'sm' ? 'sm' : 'md' })),
|
|
32
34
|
!isExpanded && React.createElement("span", null, children)));
|
|
33
35
|
}
|
|
34
36
|
export var ExpandButton = fixedForwardRef(ExpandButtonWithForwardRef);
|
package/lib/BaseButton.js
CHANGED
|
@@ -34,9 +34,9 @@ var classnames_1 = __importDefault(require("classnames"));
|
|
|
34
34
|
* @ignore
|
|
35
35
|
*/
|
|
36
36
|
function BaseButtonWithForwardRef(props, ref) {
|
|
37
|
-
var _a = props.as, Comp = _a === void 0 ? 'button' : _a, buttonType = props.buttonType, isLoading = props.isLoading, isDisabled = props.isDisabled, className = props.className, onClick = props.onClick, leftIcon = props.leftIcon, rightIcon = props.rightIcon, ariaLoadingMessage = props.ariaLoadingMessage, children = props.children, rest = __rest(props, ["as", "buttonType", "isLoading", "isDisabled", "className", "onClick", "leftIcon", "rightIcon", "ariaLoadingMessage", "children"]);
|
|
37
|
+
var _a = props.as, Comp = _a === void 0 ? 'button' : _a, buttonType = props.buttonType, isLoading = props.isLoading, isDisabled = props.isDisabled, className = props.className, onClick = props.onClick, leftIcon = props.leftIcon, rightIcon = props.rightIcon, _b = props.size, size = _b === void 0 ? 'md' : _b, ariaLoadingMessage = props.ariaLoadingMessage, children = props.children, rest = __rest(props, ["as", "buttonType", "isLoading", "isDisabled", "className", "onClick", "leftIcon", "rightIcon", "size", "ariaLoadingMessage", "children"]);
|
|
38
38
|
var supportsSpinner = ['action', 'primary', 'secondary'].includes(buttonType);
|
|
39
|
-
return (react_1.default.createElement(Comp, __assign({ "aria-busy": isLoading && supportsSpinner, "aria-disabled": isDisabled || (isLoading && supportsSpinner), className: (0, classnames_1.default)('ffe-button', "ffe-button--".concat(buttonType), { 'ffe-button--loading': isLoading && supportsSpinner }, className), onClick: function (event) {
|
|
39
|
+
return (react_1.default.createElement(Comp, __assign({ "aria-busy": isLoading && supportsSpinner, "aria-disabled": isDisabled || (isLoading && supportsSpinner), className: (0, classnames_1.default)('ffe-button', "ffe-button--".concat(buttonType), "ffe-button--".concat(size), { 'ffe-button--loading': isLoading && supportsSpinner }, className), onClick: function (event) {
|
|
40
40
|
if (isLoading && supportsSpinner) {
|
|
41
41
|
event.preventDefault();
|
|
42
42
|
event.stopPropagation();
|
package/lib/ExpandButton.js
CHANGED
|
@@ -31,10 +31,12 @@ var classnames_1 = __importDefault(require("classnames"));
|
|
|
31
31
|
var ffe_icons_react_1 = require("@sb1/ffe-icons-react");
|
|
32
32
|
var fixedForwardRef_1 = require("./fixedForwardRef");
|
|
33
33
|
function ExpandButtonWithForwardRef(props, ref) {
|
|
34
|
-
var children = props.children, className = props.className, _a = props.closeLabel, closeLabel = _a === void 0 ? 'Lukk' : _a, _b = props.as, Comp = _b === void 0 ? 'button' : _b, isExpanded = props.isExpanded, rest = __rest(props, ["children", "className", "closeLabel", "as", "isExpanded"]);
|
|
35
|
-
var
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
var children = props.children, className = props.className, _a = props.closeLabel, closeLabel = _a === void 0 ? 'Lukk' : _a, _b = props.as, Comp = _b === void 0 ? 'button' : _b, isExpanded = props.isExpanded, _c = props.size, size = _c === void 0 ? 'md' : _c, rest = __rest(props, ["children", "className", "closeLabel", "as", "isExpanded", "size"]);
|
|
35
|
+
var closeIconMd = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciI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yA5LTE4Ljc3IDguNy04LjY5IDE4LjU4LTguNjkgOS44OCAwIDE4LjU4IDguNjlMNDgwLTUxNy4xNWwxNzAuOTItMTcwLjkzcTguMzEtOC4zIDE4LjM5LTguNSAxMC4wNy0uMTkgMTguNzcgOC41IDguNjkgOC43IDguNjkgMTguNTggMCA5Ljg4LTguNjkgMTguNThMNTE3LjE1LTQ4MGwxNzAuOTMgMTcwLjkycTguMyA4LjMxIDguNSAxNy44OS4xOSA5LjU3LTguNSAxOC4yNy04LjcgOC42OS0xOC41OCA4LjY5LTkuODggMC0xOC41OC04LjY5TDQ4MC00NDIuODVaIi8+PC9zdmc+';
|
|
37
|
+
var closeIcon = size === 'sm' ? closeIconSm : closeIconMd;
|
|
38
|
+
return (react_1.default.createElement(Comp, __assign({ "aria-expanded": isExpanded, "aria-label": isExpanded ? closeLabel : undefined, className: (0, classnames_1.default)('ffe-button', 'ffe-button--secondary', 'ffe-button--expand', "ffe-button--".concat(size), { 'ffe-button--expanded': isExpanded }, className) }, rest, { ref: ref }),
|
|
39
|
+
isExpanded && (react_1.default.createElement(ffe_icons_react_1.Icon, { className: "ffe-button__icon", fileUrl: closeIcon, size: size === 'sm' ? 'sm' : 'md' })),
|
|
38
40
|
!isExpanded && react_1.default.createElement("span", null, children)));
|
|
39
41
|
}
|
|
40
42
|
exports.ExpandButton = (0, fixedForwardRef_1.fixedForwardRef)(ExpandButtonWithForwardRef);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sb1/ffe-buttons-react",
|
|
3
|
-
"version": "24.0
|
|
3
|
+
"version": "24.1.0",
|
|
4
4
|
"description": "React implementation of ffe-buttons",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ffe"
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"test:watch": "ffe-buildtool jest --watch"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@sb1/ffe-buttons": "^21.0
|
|
33
|
-
"@sb1/ffe-icons-react": "^11.0.
|
|
32
|
+
"@sb1/ffe-buttons": "^21.1.0",
|
|
33
|
+
"@sb1/ffe-icons-react": "^11.0.20",
|
|
34
34
|
"classnames": "^2.3.1"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"access": "public"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "06ff61e99e6eda9597ca92a309b37bd5b7fbcb01"
|
|
49
49
|
}
|
package/types/BaseButton.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ export type BaseButtonProps<As extends ElementType = 'button'> = ComponentAsProp
|
|
|
7
7
|
isLoading?: boolean;
|
|
8
8
|
leftIcon?: ReactElement;
|
|
9
9
|
rightIcon?: ReactElement;
|
|
10
|
+
/** Default md. */
|
|
11
|
+
size?: 'sm' | 'md' | 'lg';
|
|
10
12
|
};
|
|
11
13
|
export declare const BaseButton: <As extends ElementType>(props: {
|
|
12
14
|
as?: As | undefined;
|
|
@@ -19,4 +21,6 @@ export declare const BaseButton: <As extends ElementType>(props: {
|
|
|
19
21
|
isLoading?: boolean;
|
|
20
22
|
leftIcon?: ReactElement;
|
|
21
23
|
rightIcon?: ReactElement;
|
|
24
|
+
/** Default md. */
|
|
25
|
+
size?: "sm" | "md" | "lg";
|
|
22
26
|
} & React.RefAttributes<any>) => React.JSX.Element;
|
package/types/ExpandButton.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export type ExpandButtonProps<As extends ElementType = 'button'> = ComponentAsPr
|
|
|
5
5
|
closeLabel?: string;
|
|
6
6
|
/** When true the component will render a circle with an X indicating whatever is controlled is in an expanded state. */
|
|
7
7
|
isExpanded: boolean;
|
|
8
|
+
size?: 'sm' | 'md' | 'lg';
|
|
8
9
|
};
|
|
9
10
|
export declare const ExpandButton: <As extends ElementType>(props: {
|
|
10
11
|
as?: As | undefined;
|
|
@@ -15,4 +16,5 @@ export declare const ExpandButton: <As extends ElementType>(props: {
|
|
|
15
16
|
closeLabel?: string;
|
|
16
17
|
/** When true the component will render a circle with an X indicating whatever is controlled is in an expanded state. */
|
|
17
18
|
isExpanded: boolean;
|
|
19
|
+
size?: "sm" | "md" | "lg";
|
|
18
20
|
} & React.RefAttributes<any>) => React.JSX.Element;
|