@rescui/checkbox 0.7.3 → 0.8.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.
- package/lib/_virtual/index.css.js +10 -0
- package/lib/_virtual/warning.js +37 -0
- package/lib/checkbox.js +34 -8
- package/lib/index.css +347 -82
- package/lib/parts/checkbox-list.js +23 -5
- package/lib/parts/checkbox.p.module.css.js +28 -21
- package/lib/public-api.p.css +284 -5
- package/lib/public-api.pcss +284 -5
- package/package.json +6 -6
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
var styles = {
|
|
2
|
+
"icon": "_icon_ekw7ne_4",
|
|
3
|
+
"sizeXS": "_sizeXS_ekw7ne_14",
|
|
4
|
+
"sizeS": "_sizeS_ekw7ne_18",
|
|
5
|
+
"sizeM": "_sizeM_ekw7ne_22",
|
|
6
|
+
"sizeL": "_sizeL_ekw7ne_26",
|
|
7
|
+
"light": "_light_ekw7ne_30",
|
|
8
|
+
"dark": "_dark_ekw7ne_34"
|
|
9
|
+
};
|
|
10
|
+
export { styles as default };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import _extends from '@babel/runtime-corejs3/helpers/esm/extends';
|
|
2
|
+
import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/esm/objectWithoutProperties';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import cn from 'classnames';
|
|
6
|
+
import styles from './index.css.js';
|
|
7
|
+
var _excluded = ["theme", "size", "className"];
|
|
8
|
+
var sizeStyles = {
|
|
9
|
+
"xs": styles.sizeXS,
|
|
10
|
+
"s": styles.sizeS,
|
|
11
|
+
"m": styles.sizeM,
|
|
12
|
+
"l": styles.sizeL
|
|
13
|
+
};
|
|
14
|
+
var WarningIcon = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
15
|
+
var theme = _ref.theme,
|
|
16
|
+
size = _ref.size,
|
|
17
|
+
className = _ref.className,
|
|
18
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
19
|
+
|
|
20
|
+
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
21
|
+
viewBox: "0 0 24 24"
|
|
22
|
+
}, props, {
|
|
23
|
+
className: cn(styles.icon, styles[theme], sizeStyles[size], className),
|
|
24
|
+
ref: ref
|
|
25
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
26
|
+
d: "M2.769 20h18.363a.615.615 0 00.546-.891L12.504 2.8a.566.566 0 00-.989-.002C9.8 5.891 4.026 16.101 2.322 19.112A.61.61 0 002.77 20zm8.229-12h2v6h-2V8zm0 8h2v2h-2v-2z"
|
|
27
|
+
}));
|
|
28
|
+
});
|
|
29
|
+
WarningIcon.propTypes = {
|
|
30
|
+
className: PropTypes.string,
|
|
31
|
+
theme: PropTypes.oneOf(["light", "dark"]),
|
|
32
|
+
size: PropTypes.oneOf(["xs", "s", "m", "l"])
|
|
33
|
+
};
|
|
34
|
+
WarningIcon.defaultProps = {
|
|
35
|
+
size: "m"
|
|
36
|
+
};
|
|
37
|
+
export { WarningIcon as default };
|
package/lib/checkbox.js
CHANGED
|
@@ -13,33 +13,55 @@ function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (
|
|
|
13
13
|
|
|
14
14
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? Object.defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
15
15
|
|
|
16
|
-
import React from 'react';
|
|
16
|
+
import React, { useContext } from 'react';
|
|
17
17
|
import PropTypes from 'prop-types';
|
|
18
18
|
import { MenuItem } from '@rescui/menu';
|
|
19
|
+
import { useThemeWithUndefined } from '@rescui/ui-contexts';
|
|
19
20
|
import cn from 'classnames';
|
|
21
|
+
import WarningIcon from './_virtual/warning.js';
|
|
20
22
|
import CheckboxControl from './parts/checkbox-control.js';
|
|
23
|
+
import { GroupContext } from './parts/group-context.js';
|
|
21
24
|
import styles from './parts/checkbox.p.module.css.js';
|
|
25
|
+
var THEME_STYLES = {
|
|
26
|
+
light: styles.themeLight,
|
|
27
|
+
dark: styles.themeDark
|
|
28
|
+
};
|
|
29
|
+
var SIZE_STYLES = {
|
|
30
|
+
s: styles.checkboxSizeS,
|
|
31
|
+
m: styles.checkboxSizeM,
|
|
32
|
+
l: styles.checkboxSizeL
|
|
33
|
+
};
|
|
22
34
|
var Checkbox = /*#__PURE__*/React.forwardRef(function Checkbox(_ref, ref) {
|
|
23
35
|
var children = _ref.children,
|
|
24
36
|
className = _ref.className,
|
|
25
37
|
disabled = _ref.disabled,
|
|
26
38
|
_ref$mode = _ref.mode,
|
|
27
39
|
mode = _ref$mode === void 0 ? 'classic' : _ref$mode,
|
|
28
|
-
size = _ref.size,
|
|
29
|
-
|
|
40
|
+
_ref$size = _ref.size,
|
|
41
|
+
propsSize = _ref$size === void 0 ? 'm' : _ref$size,
|
|
42
|
+
themeFromProps = _ref.theme,
|
|
30
43
|
onMouseEnter = _ref.onMouseEnter,
|
|
31
44
|
onMouseLeave = _ref.onMouseLeave,
|
|
32
45
|
onClick = _ref.onClick,
|
|
33
46
|
error = _ref.error,
|
|
34
47
|
restProps = _objectWithoutProperties(_ref, _excluded);
|
|
35
48
|
|
|
36
|
-
|
|
49
|
+
var theme = useThemeWithUndefined(themeFromProps);
|
|
50
|
+
|
|
51
|
+
var _useContext = useContext(GroupContext),
|
|
52
|
+
inGroup = _useContext.inGroup,
|
|
53
|
+
contextSize = _useContext.size;
|
|
54
|
+
|
|
55
|
+
var size = !inGroup ? propsSize : contextSize || propsSize;
|
|
56
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
57
|
+
className: cn(className, styles.container, THEME_STYLES[theme], SIZE_STYLES[size]),
|
|
58
|
+
"data-rs-internal": 'checkbox'
|
|
59
|
+
}, /*#__PURE__*/React.createElement(MenuItem, {
|
|
37
60
|
tag: 'label',
|
|
38
61
|
mode: 'clear',
|
|
39
62
|
size: size,
|
|
40
63
|
theme: theme,
|
|
41
64
|
disabled: disabled,
|
|
42
|
-
className: className,
|
|
43
65
|
onMouseEnter: onMouseEnter,
|
|
44
66
|
onMouseLeave: onMouseLeave,
|
|
45
67
|
onClick: onClick,
|
|
@@ -54,9 +76,13 @@ var Checkbox = /*#__PURE__*/React.forwardRef(function Checkbox(_ref, ref) {
|
|
|
54
76
|
notUseLabelTag: true
|
|
55
77
|
}, restProps))
|
|
56
78
|
}, children), error && typeof error !== 'boolean' && /*#__PURE__*/React.createElement("div", {
|
|
57
|
-
className:
|
|
58
|
-
"data-test": "checkbox-error-message"
|
|
59
|
-
|
|
79
|
+
className: styles.errorMessage,
|
|
80
|
+
"data-test": "checkbox-error-message",
|
|
81
|
+
"data-rs-internal": "checkbox__error-message"
|
|
82
|
+
}, /*#__PURE__*/React.createElement(WarningIcon, {
|
|
83
|
+
"data-rs-internal": "checkbox__error-icon",
|
|
84
|
+
className: styles.errorIcon
|
|
85
|
+
}), /*#__PURE__*/React.createElement("span", null, error)));
|
|
60
86
|
});
|
|
61
87
|
Checkbox.propTypes = {
|
|
62
88
|
checked: PropTypes.bool,
|