@rescui/button 0.22.3 → 0.22.4-RUI-262-Migrate-to-GH-Actions-Release-dummy-8695a904.3
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/package.json +8 -8
- package/lib/_virtual/index.css.js +0 -15
- package/lib/_virtual/loading.js +0 -122
- package/lib/button.d.ts +0 -81
- package/lib/button.js +0 -232
- package/lib/button.p.module.css.js +0 -34
- package/lib/index.css +0 -664
- package/lib/index.d.ts +0 -54
- package/lib/index.js +0 -9
- package/lib/public-api.p.css +0 -359
- package/lib/public-api.pcss +0 -359
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rescui/button",
|
|
3
|
-
"version": "0.22.3",
|
|
3
|
+
"version": "0.22.4-RUI-262-Migrate-to-GH-Actions-Release-dummy-8695a904.3+8695a904",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "JetBrains",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@babel/runtime-corejs3": "^7.26.0",
|
|
19
|
-
"@rescui/use-resize-observer": "
|
|
19
|
+
"@rescui/use-resize-observer": "0.3.1-RUI-262-Migrate-to-GH-Actions-Release-dummy-8695a904.19+8695a904",
|
|
20
20
|
"classnames": "^2.2.6"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
@@ -25,11 +25,11 @@
|
|
|
25
25
|
"react": ">=16.8.0 <20"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@rescui/colors": "
|
|
29
|
-
"@rescui/icons": "
|
|
30
|
-
"@rescui/scripts": "
|
|
31
|
-
"@rescui/typography": "
|
|
32
|
-
"@rescui/visual-regression": "
|
|
28
|
+
"@rescui/colors": "0.2.11-RUI-262-Migrate-to-GH-Actions-Release-dummy-8695a904.19+8695a904",
|
|
29
|
+
"@rescui/icons": "1.6.1-RUI-262-Migrate-to-GH-Actions-Release-dummy-8695a904.3+8695a904",
|
|
30
|
+
"@rescui/scripts": "0.5.1",
|
|
31
|
+
"@rescui/typography": "0.24.1-RUI-262-Migrate-to-GH-Actions-Release-dummy-8695a904.19+8695a904",
|
|
32
|
+
"@rescui/visual-regression": "0.1.2",
|
|
33
33
|
"@types/classnames": "^2.2.11"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"build-pcss-api": "rescui-scripts build-pcss-api --file public-api.p.css"
|
|
38
38
|
},
|
|
39
39
|
"nx": {},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "8695a9042a55369f8df8f03ffd61c988cd3d3df4"
|
|
41
41
|
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
var styles = {
|
|
2
|
-
"icon": "_icon_y6pspg_4",
|
|
3
|
-
"sizeXS": "_sizeXS_y6pspg_14",
|
|
4
|
-
"sizeS": "_sizeS_y6pspg_18",
|
|
5
|
-
"sizeM": "_sizeM_y6pspg_22",
|
|
6
|
-
"sizeL": "_sizeL_y6pspg_26",
|
|
7
|
-
"light": "_light_y6pspg_30",
|
|
8
|
-
"dark": "_dark_y6pspg_34",
|
|
9
|
-
"allVariants": "_allVariants_y6pspg_48",
|
|
10
|
-
"variant16": "_variant16_y6pspg_53",
|
|
11
|
-
"variant20": "_variant20_y6pspg_54",
|
|
12
|
-
"variant24": "_variant24_y6pspg_55",
|
|
13
|
-
"variant28": "_variant28_y6pspg_58"
|
|
14
|
-
};
|
|
15
|
-
export { styles as default };
|
package/lib/_virtual/loading.js
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import _extends from '@babel/runtime-corejs3/helpers/esm/extends';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
import cn from 'classnames';
|
|
5
|
-
import styles from './index.css.js';
|
|
6
|
-
const sizeStyles = {
|
|
7
|
-
"xs": styles.sizeXS,
|
|
8
|
-
"s": styles.sizeS,
|
|
9
|
-
"m": styles.sizeM,
|
|
10
|
-
"l": styles.sizeL
|
|
11
|
-
};
|
|
12
|
-
const Size = {
|
|
13
|
-
"xs": "xs",
|
|
14
|
-
"s": "s",
|
|
15
|
-
"m": "m",
|
|
16
|
-
"l": "l"
|
|
17
|
-
};
|
|
18
|
-
const LoadingIcon16 = /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/React.createElement("svg", _extends({
|
|
19
|
-
viewBox: "0 0 16 16"
|
|
20
|
-
}, props, {
|
|
21
|
-
ref: ref
|
|
22
|
-
}), /*#__PURE__*/React.createElement("path", {
|
|
23
|
-
d: "M8 3.25a4.75 4.75 0 1 0 4.686 3.968.75.75 0 1 1 1.48-.245q.083.503.084 1.027a6.25 6.25 0 1 1-5.223-6.166.75.75 0 0 1-.245 1.48A5 5 0 0 0 8 3.25",
|
|
24
|
-
style: {
|
|
25
|
-
animation: "rs-icon-rotate 1s linear infinite",
|
|
26
|
-
transformOrigin: "center center"
|
|
27
|
-
}
|
|
28
|
-
})));
|
|
29
|
-
LoadingIcon16.displayName = 'LoadingIcon16';
|
|
30
|
-
const LoadingIcon20 = /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/React.createElement("svg", _extends({
|
|
31
|
-
viewBox: "0 0 20 20"
|
|
32
|
-
}, props, {
|
|
33
|
-
ref: ref
|
|
34
|
-
}), /*#__PURE__*/React.createElement("path", {
|
|
35
|
-
d: "M10 4a6 6 0 1 0 5.92 5.012 1 1 0 0 1 1.972-.326Q18 9.329 18 10a8 8 0 1 1-6.686-7.892 1 1 0 0 1-.326 1.973A6 6 0 0 0 10 4",
|
|
36
|
-
style: {
|
|
37
|
-
animation: "rs-icon-rotate 1s linear infinite",
|
|
38
|
-
transformOrigin: "center center"
|
|
39
|
-
}
|
|
40
|
-
})));
|
|
41
|
-
LoadingIcon20.displayName = 'LoadingIcon20';
|
|
42
|
-
const LoadingIcon24 = /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/React.createElement("svg", _extends({
|
|
43
|
-
viewBox: "0 0 24 24"
|
|
44
|
-
}, props, {
|
|
45
|
-
ref: ref
|
|
46
|
-
}), /*#__PURE__*/React.createElement("path", {
|
|
47
|
-
d: "M12 6a6 6 0 1 0 5.92 5.012 1.5 1.5 0 0 1 2.959-.49q.12.724.121 1.478a9 9 0 1 1-7.522-8.879 1.5 1.5 0 0 1-.49 2.96Q12.508 6 12 6",
|
|
48
|
-
style: {
|
|
49
|
-
animation: "rs-icon-rotate 1s linear infinite",
|
|
50
|
-
transformOrigin: "center center"
|
|
51
|
-
}
|
|
52
|
-
})));
|
|
53
|
-
LoadingIcon24.displayName = 'LoadingIcon24';
|
|
54
|
-
const LoadingIcon28 = /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/React.createElement("svg", _extends({
|
|
55
|
-
viewBox: "0 0 28 28"
|
|
56
|
-
}, props, {
|
|
57
|
-
ref: ref
|
|
58
|
-
}), /*#__PURE__*/React.createElement("path", {
|
|
59
|
-
d: "M14 6.5a7.5 7.5 0 1 0 7.399 6.265 1.5 1.5 0 0 1 2.96-.49q.14.844.141 1.725c0 5.799-4.701 10.5-10.5 10.5S3.5 19.799 3.5 14 8.201 3.5 14 3.5q.813 0 1.595.12a1.5 1.5 0 0 1-.453 2.966A7.6 7.6 0 0 0 14 6.5",
|
|
60
|
-
style: {
|
|
61
|
-
animation: "rs-icon-rotate 1s linear infinite",
|
|
62
|
-
transformOrigin: "center center"
|
|
63
|
-
}
|
|
64
|
-
})));
|
|
65
|
-
LoadingIcon28.displayName = 'LoadingIcon28';
|
|
66
|
-
const LoadingIcon = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
67
|
-
let {
|
|
68
|
-
theme,
|
|
69
|
-
size: sizeFromProps = "m",
|
|
70
|
-
className,
|
|
71
|
-
style,
|
|
72
|
-
['data-render-all-sizes']: renderAllSizes = false,
|
|
73
|
-
...props
|
|
74
|
-
} = _ref;
|
|
75
|
-
const size = sizeFromProps in Size ? sizeFromProps : "m";
|
|
76
|
-
const mainProps = { ...props,
|
|
77
|
-
className: cn(styles.icon, styles[theme], sizeStyles[size], renderAllSizes && styles.allVariants, className),
|
|
78
|
-
style: renderAllSizes ? {
|
|
79
|
-
'--rs-icon-ar-width': 28,
|
|
80
|
-
'--rs-icon-ar-height': 28,
|
|
81
|
-
...style
|
|
82
|
-
} : style,
|
|
83
|
-
ref
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
if (renderAllSizes) {
|
|
87
|
-
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
88
|
-
viewBox: "0 0 28 28"
|
|
89
|
-
}, mainProps), /*#__PURE__*/React.createElement(LoadingIcon16, {
|
|
90
|
-
className: styles.variant16
|
|
91
|
-
}), /*#__PURE__*/React.createElement(LoadingIcon20, {
|
|
92
|
-
className: styles.variant20
|
|
93
|
-
}), /*#__PURE__*/React.createElement(LoadingIcon24, {
|
|
94
|
-
className: styles.variant24
|
|
95
|
-
}), /*#__PURE__*/React.createElement(LoadingIcon28, {
|
|
96
|
-
className: styles.variant28
|
|
97
|
-
}));
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
if (size === Size['xs']) {
|
|
101
|
-
return /*#__PURE__*/React.createElement(LoadingIcon16, mainProps);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
if (size === Size['s']) {
|
|
105
|
-
return /*#__PURE__*/React.createElement(LoadingIcon20, mainProps);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (size === Size['m']) {
|
|
109
|
-
return /*#__PURE__*/React.createElement(LoadingIcon24, mainProps);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return /*#__PURE__*/React.createElement(LoadingIcon28, mainProps);
|
|
113
|
-
});
|
|
114
|
-
LoadingIcon.displayName = 'LoadingIcon';
|
|
115
|
-
LoadingIcon.propTypes = {
|
|
116
|
-
className: PropTypes.string,
|
|
117
|
-
theme: PropTypes.oneOf(["light", "dark"]),
|
|
118
|
-
size: PropTypes.oneOf(["xs", "s", "m", "l"]),
|
|
119
|
-
'data-render-all-sizes': PropTypes.bool,
|
|
120
|
-
style: PropTypes.object
|
|
121
|
-
};
|
|
122
|
-
export { Size, LoadingIcon as default };
|
package/lib/button.d.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Theme } from '@rescui/ui-contexts';
|
|
3
|
-
export declare type ButtonShiftedSide = 'right' | 'left' | 'top' | 'bottom';
|
|
4
|
-
export declare type ButtonSize = 'l' | 'm' | 's' | 'xs';
|
|
5
|
-
export declare type ButtonModeGeneric = 'classic' | 'rock' | 'transparent' | 'outline';
|
|
6
|
-
export declare type ButtonModeClear = 'clear';
|
|
7
|
-
export declare type ButtonType = 'button' | 'submit' | 'reset';
|
|
8
|
-
export declare type ButtonIconPosition = 'left' | 'left-edge' | 'right' | 'right-edge';
|
|
9
|
-
export declare type ButtonFlat = 'left' | 'right';
|
|
10
|
-
export declare type ButtonShifted = 'all' | ButtonShiftedSide | ButtonShiftedSide[];
|
|
11
|
-
declare type ButtonIntrinsicProps = {
|
|
12
|
-
/** Additional class-name */
|
|
13
|
-
className?: string;
|
|
14
|
-
/** Child element */
|
|
15
|
-
children?: React.ReactNode;
|
|
16
|
-
/** Disabled state */
|
|
17
|
-
disabled?: boolean;
|
|
18
|
-
/** Button size */
|
|
19
|
-
size?: ButtonSize;
|
|
20
|
-
/** Appearance theme */
|
|
21
|
-
theme?: Theme;
|
|
22
|
-
/** Shows loading icon, use when some action related to button is in progress */
|
|
23
|
-
busy?: boolean;
|
|
24
|
-
/** @ignore */
|
|
25
|
-
highlighted?: boolean;
|
|
26
|
-
/** @ignore */
|
|
27
|
-
flat?: ButtonFlat;
|
|
28
|
-
/**
|
|
29
|
-
* Allow wrapping inside the button.
|
|
30
|
-
* Do not allow a multiline Button to be placed next to another Button on the same line.
|
|
31
|
-
* */
|
|
32
|
-
allowMultiline?: boolean;
|
|
33
|
-
/**
|
|
34
|
-
* Multiline default state. Use for optimising rerenders of always multiline buttons.
|
|
35
|
-
* @ignore
|
|
36
|
-
* */
|
|
37
|
-
defaultMultiline?: boolean;
|
|
38
|
-
tabIndex?: number;
|
|
39
|
-
title?: string;
|
|
40
|
-
/** Button appearance */
|
|
41
|
-
mode?: ButtonModeGeneric | ButtonModeClear;
|
|
42
|
-
/** **Works only with `mode="clear"`.** Offsets a clear button to one or more sides before the text. Button's background then extends beyond its container. */
|
|
43
|
-
shifted?: ButtonShifted;
|
|
44
|
-
/** Additional icon */
|
|
45
|
-
icon?: React.ReactNode;
|
|
46
|
-
/**
|
|
47
|
-
* **Works only if the `icon` is present.**
|
|
48
|
-
* Additional icon position.
|
|
49
|
-
* `-edge` variants are useful for aligning icons between multiple buttons in a column (some of which may be multiline).
|
|
50
|
-
* @see [RUI-228](https://youtrack.jetbrains.com/issue/RUI-228/Fix-button-icon-size-and-position)
|
|
51
|
-
* */
|
|
52
|
-
iconPosition?: ButtonIconPosition;
|
|
53
|
-
/** Url path for using component as a link. **Transform a Button into a link (`a` element).** */
|
|
54
|
-
href?: string;
|
|
55
|
-
/** [Link target](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#target). **Works only for the link Button.** */
|
|
56
|
-
target?: '_blank' | '_self' | '_parent' | '_top';
|
|
57
|
-
/** [Link rel](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#rel). **Works only for the link Button.** */
|
|
58
|
-
rel?: string;
|
|
59
|
-
/**
|
|
60
|
-
* Completely removes focus ability.
|
|
61
|
-
* We use separate property instead of tabIndex
|
|
62
|
-
* because tabIndex doesn't remove all of the controls behavior.
|
|
63
|
-
* For example, 'space' button press support remains active.
|
|
64
|
-
* We can fix this with a special property.
|
|
65
|
-
* **Transform a Button into a `div` element. Do not use with link props (`href`, `rel`, `target`, etc).**
|
|
66
|
-
* @ignore
|
|
67
|
-
* */
|
|
68
|
-
notFocusable?: boolean;
|
|
69
|
-
/**
|
|
70
|
-
* [More about button types](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attr-type)
|
|
71
|
-
* @type "button" | "submit" | "reset"
|
|
72
|
-
* */
|
|
73
|
-
type?: ButtonType | string;
|
|
74
|
-
/** Click event handler */
|
|
75
|
-
onClick?: React.MouseEventHandler<HTMLButtonElement> | React.MouseEventHandler<HTMLAnchorElement> | React.MouseEventHandler<HTMLDivElement>;
|
|
76
|
-
};
|
|
77
|
-
declare type NativeProps = React.ButtonHTMLAttributes<HTMLButtonElement> | React.AnchorHTMLAttributes<HTMLAnchorElement> | React.BaseHTMLAttributes<HTMLDivElement>;
|
|
78
|
-
export declare type ButtonProps = Omit<NativeProps, keyof ButtonIntrinsicProps> & ButtonIntrinsicProps;
|
|
79
|
-
declare type ButtonPossibleHTMLType = HTMLAnchorElement | HTMLButtonElement | HTMLDivElement;
|
|
80
|
-
export declare const Button: React.ForwardRefExoticComponent<Omit<NativeProps, keyof ButtonIntrinsicProps> & ButtonIntrinsicProps & React.RefAttributes<ButtonPossibleHTMLType>>;
|
|
81
|
-
export default Button;
|
package/lib/button.js
DELETED
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
|
3
|
-
import React, { useState, useRef, cloneElement } from 'react';
|
|
4
|
-
import PropTypes from 'prop-types';
|
|
5
|
-
import cn from 'classnames';
|
|
6
|
-
import { useThemeWithUndefined } from '@rescui/ui-contexts';
|
|
7
|
-
import { useResizeObserver } from '@rescui/use-resize-observer';
|
|
8
|
-
import LoadingIcon from './_virtual/loading.js';
|
|
9
|
-
import styles from './button.p.module.css.js';
|
|
10
|
-
|
|
11
|
-
const calculateShifted = (shiftedProp, side) => shiftedProp === 'all' || shiftedProp === side || Array.isArray(shiftedProp) && _includesInstanceProperty(shiftedProp).call(shiftedProp, side);
|
|
12
|
-
|
|
13
|
-
const MODE_STYLES = {
|
|
14
|
-
classic: styles.modeClassic,
|
|
15
|
-
rock: styles.modeRock,
|
|
16
|
-
transparent: styles.modeTransparent,
|
|
17
|
-
outline: styles.modeOutline,
|
|
18
|
-
clear: styles.modeClear
|
|
19
|
-
};
|
|
20
|
-
const SIZE_STYLES = {
|
|
21
|
-
xs: styles.sizeXs,
|
|
22
|
-
s: styles.sizeS,
|
|
23
|
-
m: styles.sizeM,
|
|
24
|
-
l: styles.sizeL
|
|
25
|
-
};
|
|
26
|
-
const ICON_POSITION_STYLES = {
|
|
27
|
-
left: styles.alignIconLeft,
|
|
28
|
-
'left-edge': styles.alignIconLeftEdge,
|
|
29
|
-
right: styles.alignIconRight,
|
|
30
|
-
'right-edge': styles.alignIconRightEdge
|
|
31
|
-
};
|
|
32
|
-
const Button = /*#__PURE__*/React.forwardRef( // eslint-disable-next-line complexity
|
|
33
|
-
(_ref, forwardedRef) => {
|
|
34
|
-
let {
|
|
35
|
-
className,
|
|
36
|
-
children,
|
|
37
|
-
href,
|
|
38
|
-
type = 'button',
|
|
39
|
-
disabled,
|
|
40
|
-
size = 'm',
|
|
41
|
-
theme: themeFromProps,
|
|
42
|
-
icon,
|
|
43
|
-
iconPosition = 'left',
|
|
44
|
-
busy = false,
|
|
45
|
-
allowMultiline = false,
|
|
46
|
-
defaultMultiline = false,
|
|
47
|
-
flat,
|
|
48
|
-
notFocusable,
|
|
49
|
-
highlighted
|
|
50
|
-
/* supported only for clear mode */
|
|
51
|
-
,
|
|
52
|
-
shifted
|
|
53
|
-
/* supported only for clear mode */
|
|
54
|
-
,
|
|
55
|
-
mode = 'classic',
|
|
56
|
-
...restProps
|
|
57
|
-
} = _ref;
|
|
58
|
-
const [multiline, setMultiline] = useState(defaultMultiline);
|
|
59
|
-
const contentRef = useRef(null);
|
|
60
|
-
const ref = useRef(null);
|
|
61
|
-
|
|
62
|
-
const handleRef = el => {
|
|
63
|
-
ref.current = el;
|
|
64
|
-
|
|
65
|
-
if (forwardedRef) {
|
|
66
|
-
if (typeof forwardedRef === 'function') {
|
|
67
|
-
forwardedRef(el);
|
|
68
|
-
} else {
|
|
69
|
-
forwardedRef.current = el;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
useResizeObserver(contentRef, entry => {
|
|
75
|
-
const target = entry.target;
|
|
76
|
-
const {
|
|
77
|
-
height
|
|
78
|
-
} = entry.contentRect;
|
|
79
|
-
const targetStyles = getComputedStyle(target);
|
|
80
|
-
const singleLineBlockSize = parseInt(targetStyles.lineHeight, 10);
|
|
81
|
-
setMultiline(height > singleLineBlockSize);
|
|
82
|
-
});
|
|
83
|
-
const theme = useThemeWithUndefined(themeFromProps);
|
|
84
|
-
const shiftedLeft = calculateShifted(shifted, 'left');
|
|
85
|
-
const shiftedRight = calculateShifted(shifted, 'right');
|
|
86
|
-
const shiftedTop = calculateShifted(shifted, 'top');
|
|
87
|
-
const shiftedBottom = calculateShifted(shifted, 'bottom'); // check for ignored jsx values and empty string, more info https://reactjs.org/docs/jsx-in-depth.html#booleans-null-and-undefined-are-ignored
|
|
88
|
-
|
|
89
|
-
const isWithoutText = children === null || typeof children === 'undefined' || children === false || children === true || children === '';
|
|
90
|
-
let iconSlot;
|
|
91
|
-
|
|
92
|
-
if ( /*#__PURE__*/React.isValidElement(icon) && busy) {
|
|
93
|
-
iconSlot = /*#__PURE__*/React.createElement(LoadingIcon, {
|
|
94
|
-
className: styles.icon,
|
|
95
|
-
"data-render-all-sizes": true
|
|
96
|
-
});
|
|
97
|
-
} else if ( /*#__PURE__*/React.isValidElement(icon)) {
|
|
98
|
-
var _icon$props;
|
|
99
|
-
|
|
100
|
-
iconSlot = /*#__PURE__*/cloneElement(icon, {
|
|
101
|
-
className: cn((_icon$props = icon.props) === null || _icon$props === void 0 ? void 0 : _icon$props.className, styles.icon),
|
|
102
|
-
'data-render-all-sizes': true
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
const showBusyOverlay = ! /*#__PURE__*/React.isValidElement(icon) && busy;
|
|
107
|
-
const buttonSharedProps = {
|
|
108
|
-
href,
|
|
109
|
-
disabled,
|
|
110
|
-
className: cn(styles.main, MODE_STYLES[mode], SIZE_STYLES[size], ICON_POSITION_STYLES[iconPosition] ?? ICON_POSITION_STYLES.left, styles[theme], {
|
|
111
|
-
[styles.disabled]: disabled,
|
|
112
|
-
[styles.flatLeft]: flat === 'left',
|
|
113
|
-
[styles.flatRight]: flat === 'right',
|
|
114
|
-
[styles.highlighted]: highlighted,
|
|
115
|
-
[styles.withoutText]: isWithoutText,
|
|
116
|
-
[styles.shiftedLeft]: shiftedLeft,
|
|
117
|
-
[styles.shiftedRight]: shiftedRight,
|
|
118
|
-
[styles.shiftedTop]: shiftedTop,
|
|
119
|
-
[styles.shiftedBottom]: shiftedBottom,
|
|
120
|
-
[styles.multiline]: multiline,
|
|
121
|
-
[styles.allowMultiline]: allowMultiline,
|
|
122
|
-
[styles.busy]: busy,
|
|
123
|
-
[styles.busyOverlay]: showBusyOverlay
|
|
124
|
-
}, className)
|
|
125
|
-
}; // Google Translate replaces TextNodes on page which is leading to a React error on manipulating buttonChildren e.g. when switching to the busy state.
|
|
126
|
-
// To prevent this we wrap text node in a span element which itself will not be replaced by Google Translate.
|
|
127
|
-
// More info here: https://github.com/facebook/react/issues/11538
|
|
128
|
-
|
|
129
|
-
const buttonContent = !isWithoutText && /*#__PURE__*/React.createElement("span", {
|
|
130
|
-
className: styles.content,
|
|
131
|
-
"data-rs-internal": "button__content",
|
|
132
|
-
"data-test": "button__content",
|
|
133
|
-
ref: contentRef
|
|
134
|
-
}, children);
|
|
135
|
-
const buttonChildren = /*#__PURE__*/React.createElement(React.Fragment, null, iconSlot, showBusyOverlay && /*#__PURE__*/React.createElement(LoadingIcon, {
|
|
136
|
-
className: styles.busyIcon,
|
|
137
|
-
size: size,
|
|
138
|
-
"data-test": "busy-icon"
|
|
139
|
-
}), buttonContent);
|
|
140
|
-
|
|
141
|
-
if (notFocusable) {
|
|
142
|
-
if (href) {
|
|
143
|
-
console.error('Button with `href` can\'t be completely not focusable. If you want to remove Button with `href` from focus flow, use `tabIndex="-1"` instead of `notFocusable`');
|
|
144
|
-
}
|
|
145
|
-
/** use <div> tag for preventing button controls elements behavior for example 'space' button press support. */
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
149
|
-
"data-test": 'button',
|
|
150
|
-
...restProps,
|
|
151
|
-
ref: handleRef,
|
|
152
|
-
...buttonSharedProps
|
|
153
|
-
}, buttonChildren);
|
|
154
|
-
} else if (href) {
|
|
155
|
-
return /*#__PURE__*/React.createElement("a", {
|
|
156
|
-
"data-test": 'button',
|
|
157
|
-
...restProps,
|
|
158
|
-
ref: handleRef,
|
|
159
|
-
type: type,
|
|
160
|
-
...buttonSharedProps
|
|
161
|
-
}, buttonChildren);
|
|
162
|
-
} else {
|
|
163
|
-
return /*#__PURE__*/React.createElement("button", {
|
|
164
|
-
"data-test": 'button',
|
|
165
|
-
...restProps,
|
|
166
|
-
ref: handleRef,
|
|
167
|
-
|
|
168
|
-
/* eslint-disable-next-line react/button-has-type */
|
|
169
|
-
type: type,
|
|
170
|
-
...buttonSharedProps
|
|
171
|
-
}, buttonChildren);
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
Button.displayName = 'Button';
|
|
175
|
-
|
|
176
|
-
function validateAdditional(propType, callback) {
|
|
177
|
-
return (props, propName) => {
|
|
178
|
-
if (typeof props[propName] !== 'undefined') {
|
|
179
|
-
const cbRes = callback(props, propName);
|
|
180
|
-
|
|
181
|
-
if (cbRes) {
|
|
182
|
-
return cbRes;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
PropTypes.checkPropTypes({
|
|
186
|
-
[propName]: propType
|
|
187
|
-
}, props, 'prop', 'Button');
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
return null;
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
Button.propTypes = {
|
|
195
|
-
className: PropTypes.string,
|
|
196
|
-
children: PropTypes.node,
|
|
197
|
-
disabled: PropTypes.bool,
|
|
198
|
-
href: validateAdditional(PropTypes.string, props => {
|
|
199
|
-
if (typeof props.notFocusable !== 'undefined') {
|
|
200
|
-
return new Error(`'href' prop cannot be used with 'notFocusable' prop`);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
return null;
|
|
204
|
-
}),
|
|
205
|
-
icon: PropTypes.node,
|
|
206
|
-
iconPosition: PropTypes.oneOf(['left', 'left-edge', 'right', 'right-edge']),
|
|
207
|
-
size: PropTypes.oneOf(['l', 'm', 's', 'xs']),
|
|
208
|
-
mode: validateAdditional(PropTypes.oneOf(['classic', 'rock', 'transparent', 'outline', 'clear']), props => {
|
|
209
|
-
if (typeof props.shifted !== 'undefined' && props.mode !== 'clear') {
|
|
210
|
-
return new Error(`'shifted' prop cannot be used when 'mode' prop is not 'clear'.`);
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
return null;
|
|
214
|
-
}),
|
|
215
|
-
theme: PropTypes.oneOf(['light', 'dark']),
|
|
216
|
-
type: PropTypes.oneOf(['button', 'submit', 'reset']),
|
|
217
|
-
onClick: PropTypes.func,
|
|
218
|
-
notFocusable: validateAdditional(PropTypes.bool, props => {
|
|
219
|
-
if (typeof props.href !== 'undefined' || typeof props.target !== 'undefined') {
|
|
220
|
-
return new Error(`'notFocusable' prop cannot be used with 'href' and 'target' props`);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
return null;
|
|
224
|
-
}),
|
|
225
|
-
busy: PropTypes.bool,
|
|
226
|
-
flat: PropTypes.oneOf(['left', 'right']),
|
|
227
|
-
highlighted: PropTypes.bool,
|
|
228
|
-
allowMultiline: PropTypes.bool,
|
|
229
|
-
defaultMultiline: PropTypes.bool,
|
|
230
|
-
shifted: PropTypes.oneOfType([PropTypes.oneOf(['all', 'left', 'right', 'top', 'bottom']), PropTypes.arrayOf(PropTypes.oneOf(['left', 'right', 'top', 'bottom']))])
|
|
231
|
-
};
|
|
232
|
-
export { Button, Button as default };
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
var styles = {
|
|
2
|
-
"light": "_light_1uc95v6_6",
|
|
3
|
-
"dark": "_dark_1uc95v6_9",
|
|
4
|
-
"flatRight": "_flatRight_1uc95v6_13",
|
|
5
|
-
"flatLeft": "_flatLeft_1uc95v6_16",
|
|
6
|
-
"sizeXs": "_sizeXs_1uc95v6_20",
|
|
7
|
-
"sizeS": "_sizeS_1uc95v6_23",
|
|
8
|
-
"sizeM": "_sizeM_1uc95v6_26",
|
|
9
|
-
"sizeL": "_sizeL_1uc95v6_29",
|
|
10
|
-
"modeClassic": "_modeClassic_1uc95v6_33",
|
|
11
|
-
"modeRock": "_modeRock_1uc95v6_36",
|
|
12
|
-
"modeTransparent": "_modeTransparent_1uc95v6_39",
|
|
13
|
-
"modeOutline": "_modeOutline_1uc95v6_42",
|
|
14
|
-
"modeClear": "_modeClear_1uc95v6_45",
|
|
15
|
-
"alignIconLeft": "_alignIconLeft_1uc95v6_49",
|
|
16
|
-
"alignIconLeftEdge": "_alignIconLeftEdge_1uc95v6_52",
|
|
17
|
-
"alignIconRight": "_alignIconRight_1uc95v6_55",
|
|
18
|
-
"alignIconRightEdge": "_alignIconRightEdge_1uc95v6_58",
|
|
19
|
-
"main": "_main_1uc95v6_62",
|
|
20
|
-
"disabled": "_disabled_1uc95v6_139",
|
|
21
|
-
"busy": "_busy_1uc95v6_149",
|
|
22
|
-
"busyOverlay": "_busyOverlay_1uc95v6_153",
|
|
23
|
-
"icon": "_icon_1uc95v6_188",
|
|
24
|
-
"allowMultiline": "_allowMultiline_1uc95v6_203",
|
|
25
|
-
"content": "_content_1uc95v6_207",
|
|
26
|
-
"multiline": "_multiline_1uc95v6_213",
|
|
27
|
-
"withoutText": "_withoutText_1uc95v6_217",
|
|
28
|
-
"busyIcon": "_busyIcon_1uc95v6_222",
|
|
29
|
-
"shiftedLeft": "_shiftedLeft_1uc95v6_243",
|
|
30
|
-
"shiftedRight": "_shiftedRight_1uc95v6_246",
|
|
31
|
-
"shiftedTop": "_shiftedTop_1uc95v6_249",
|
|
32
|
-
"shiftedBottom": "_shiftedBottom_1uc95v6_252"
|
|
33
|
-
};
|
|
34
|
-
export { styles as default };
|