@rescui/checkbox 0.8.5 → 0.8.7-RUI-226-Update-card-cn-6e43cc89.60
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 +12 -7
- package/lib/_virtual/warning.js +90 -21
- package/lib/checkbox.js +32 -44
- package/lib/index.css +117 -110
- package/lib/index.js +1 -1
- package/lib/parts/checkbox-control-inner.js +24 -41
- package/lib/parts/checkbox-control.js +32 -42
- package/lib/parts/checkbox-list.js +25 -37
- package/lib/parts/checkbox-manager.js +31 -45
- package/lib/parts/checkbox.p.module.css.js +28 -28
- package/lib/parts/group-context.js +2 -2
- package/lib/parts/marks.js +35 -52
- package/lib/public-api.p.css +38 -26
- package/lib/public-api.pcss +38 -26
- package/package.json +11 -11
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
var styles = {
|
|
2
|
-
"icon": "
|
|
3
|
-
"sizeXS": "
|
|
4
|
-
"sizeS": "
|
|
5
|
-
"sizeM": "
|
|
6
|
-
"sizeL": "
|
|
7
|
-
"light": "
|
|
8
|
-
"dark": "
|
|
2
|
+
"icon": "_icon_15yklic_4",
|
|
3
|
+
"sizeXS": "_sizeXS_15yklic_14",
|
|
4
|
+
"sizeS": "_sizeS_15yklic_18",
|
|
5
|
+
"sizeM": "_sizeM_15yklic_22",
|
|
6
|
+
"sizeL": "_sizeL_15yklic_26",
|
|
7
|
+
"light": "_light_15yklic_30",
|
|
8
|
+
"dark": "_dark_15yklic_34",
|
|
9
|
+
"allVariants": "_allVariants_15yklic_48",
|
|
10
|
+
"variant16": "_variant16_15yklic_53",
|
|
11
|
+
"variant20": "_variant20_15yklic_54",
|
|
12
|
+
"variant24": "_variant24_15yklic_55",
|
|
13
|
+
"variant28": "_variant28_15yklic_58"
|
|
9
14
|
};
|
|
10
15
|
export { styles as default };
|
package/lib/_virtual/warning.js
CHANGED
|
@@ -1,37 +1,106 @@
|
|
|
1
1
|
import _extends from '@babel/runtime-corejs3/helpers/esm/extends';
|
|
2
|
-
import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/esm/objectWithoutProperties';
|
|
3
2
|
import React from 'react';
|
|
4
3
|
import PropTypes from 'prop-types';
|
|
5
4
|
import cn from 'classnames';
|
|
6
5
|
import styles from './index.css.js';
|
|
7
|
-
|
|
8
|
-
var sizeStyles = {
|
|
6
|
+
const sizeStyles = {
|
|
9
7
|
"xs": styles.sizeXS,
|
|
10
8
|
"s": styles.sizeS,
|
|
11
9
|
"m": styles.sizeM,
|
|
12
10
|
"l": styles.sizeL
|
|
13
11
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
const Size = {
|
|
13
|
+
"xs": "xs",
|
|
14
|
+
"s": "s",
|
|
15
|
+
"m": "m",
|
|
16
|
+
"l": "l"
|
|
17
|
+
};
|
|
18
|
+
const WarningIcon16 = /*#__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: "m6.303 1.989-5.027 8.874C.483 12.263 1.494 14 3.103 14h9.793c1.609 0 2.62-1.736 1.827-3.137L9.696 1.99C8.949.67 7.05.67 6.303 1.989M8 12a1 1 0 1 1 0-2 1 1 0 0 1 0 2m0-8a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-1 0v-4A.5.5 0 0 1 8 4"
|
|
24
|
+
})));
|
|
25
|
+
WarningIcon16.displayName = 'WarningIcon16';
|
|
26
|
+
const WarningIcon20 = /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/React.createElement("svg", _extends({
|
|
27
|
+
viewBox: "0 0 20 20"
|
|
28
|
+
}, props, {
|
|
29
|
+
ref: ref
|
|
30
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
31
|
+
d: "m8.042 3.141-5.8 10.24C1.327 14.997 2.494 17 4.35 17h11.3c1.856 0 3.023-2.003 2.108-3.62l-5.8-10.239c-.862-1.521-3.054-1.521-3.916 0M10 5.25a.75.75 0 0 1 .75.75v5a.75.75 0 0 1-1.5 0V6a.75.75 0 0 1 .75-.75m0 9.25a1 1 0 1 1 0-2 1 1 0 0 1 0 2"
|
|
32
|
+
})));
|
|
33
|
+
WarningIcon20.displayName = 'WarningIcon20';
|
|
34
|
+
const WarningIcon24 = /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/React.createElement("svg", _extends({
|
|
35
|
+
viewBox: "0 0 24 24"
|
|
36
|
+
}, props, {
|
|
37
|
+
ref: ref
|
|
38
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
39
|
+
d: "m9.52 3.446-7.346 12.97C1.014 18.463 2.492 21 4.844 21h14.312c2.352 0 3.83-2.537 2.67-4.584L14.48 3.446c-1.092-1.928-3.868-1.928-4.96 0M12 7a1 1 0 0 1 1 1v5a1 1 0 1 1-2 0V8a1 1 0 0 1 1-1m0 11a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3"
|
|
40
|
+
})));
|
|
41
|
+
WarningIcon24.displayName = 'WarningIcon24';
|
|
42
|
+
const WarningIcon28 = /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/React.createElement("svg", _extends({
|
|
43
|
+
viewBox: "0 0 28 28"
|
|
44
|
+
}, props, {
|
|
45
|
+
ref: ref
|
|
46
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
47
|
+
d: "M11.26 4.598 3.14 18.933C1.858 21.195 3.492 24 6.09 24h15.82c2.599 0 4.232-2.805 2.951-5.067l-8.12-14.335c-1.207-2.13-4.275-2.13-5.481 0M14 8a1 1 0 0 1 1 1v6a1 1 0 1 1-2 0V9a1 1 0 0 1 1-1m0 12a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3"
|
|
48
|
+
})));
|
|
49
|
+
WarningIcon28.displayName = 'WarningIcon28';
|
|
50
|
+
const WarningIcon = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
51
|
+
let {
|
|
52
|
+
theme,
|
|
53
|
+
size: sizeFromProps = "m",
|
|
54
|
+
className,
|
|
55
|
+
style,
|
|
56
|
+
['data-render-all-sizes']: renderAllSizes = false,
|
|
57
|
+
...props
|
|
58
|
+
} = _ref;
|
|
59
|
+
const size = sizeFromProps in Size ? sizeFromProps : "m";
|
|
60
|
+
const mainProps = { ...props,
|
|
61
|
+
className: cn(styles.icon, styles[theme], sizeStyles[size], renderAllSizes && styles.allVariants, className),
|
|
62
|
+
style: renderAllSizes ? {
|
|
63
|
+
'--rs-icon-ar-width': 28,
|
|
64
|
+
'--rs-icon-ar-height': 28,
|
|
65
|
+
...style
|
|
66
|
+
} : style,
|
|
67
|
+
ref
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
if (renderAllSizes) {
|
|
71
|
+
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
72
|
+
viewBox: "0 0 28 28"
|
|
73
|
+
}, mainProps), /*#__PURE__*/React.createElement(WarningIcon16, {
|
|
74
|
+
className: styles.variant16
|
|
75
|
+
}), /*#__PURE__*/React.createElement(WarningIcon20, {
|
|
76
|
+
className: styles.variant20
|
|
77
|
+
}), /*#__PURE__*/React.createElement(WarningIcon24, {
|
|
78
|
+
className: styles.variant24
|
|
79
|
+
}), /*#__PURE__*/React.createElement(WarningIcon28, {
|
|
80
|
+
className: styles.variant28
|
|
81
|
+
}));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (size === Size['xs']) {
|
|
85
|
+
return /*#__PURE__*/React.createElement(WarningIcon16, mainProps);
|
|
86
|
+
}
|
|
19
87
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
88
|
+
if (size === Size['s']) {
|
|
89
|
+
return /*#__PURE__*/React.createElement(WarningIcon20, mainProps);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (size === Size['m']) {
|
|
93
|
+
return /*#__PURE__*/React.createElement(WarningIcon24, mainProps);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return /*#__PURE__*/React.createElement(WarningIcon28, mainProps);
|
|
28
97
|
});
|
|
98
|
+
WarningIcon.displayName = 'WarningIcon';
|
|
29
99
|
WarningIcon.propTypes = {
|
|
30
100
|
className: PropTypes.string,
|
|
31
101
|
theme: PropTypes.oneOf(["light", "dark"]),
|
|
32
|
-
size: PropTypes.oneOf(["xs", "s", "m", "l"])
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
size: "m"
|
|
102
|
+
size: PropTypes.oneOf(["xs", "s", "m", "l"]),
|
|
103
|
+
'data-render-all-sizes': PropTypes.bool,
|
|
104
|
+
style: PropTypes.object
|
|
36
105
|
};
|
|
37
|
-
export { WarningIcon as default };
|
|
106
|
+
export { Size, WarningIcon as default };
|
package/lib/checkbox.js
CHANGED
|
@@ -1,58 +1,44 @@
|
|
|
1
|
-
import "core-js/modules/es.object.to-string.js";
|
|
2
|
-
import "core-js/modules/web.dom-collections.for-each.js";
|
|
3
|
-
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
4
|
-
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
|
5
|
-
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
|
6
|
-
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
|
7
|
-
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
|
8
|
-
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
|
9
|
-
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
|
10
|
-
var _excluded = ["children", "className", "disabled", "mode", "size", "theme", "onMouseEnter", "onMouseLeave", "onClick", "error"];
|
|
11
|
-
|
|
12
|
-
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
13
|
-
|
|
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
|
-
|
|
16
1
|
import React, { useContext } from 'react';
|
|
17
2
|
import PropTypes from 'prop-types';
|
|
18
3
|
import { MenuItem } from '@rescui/menu';
|
|
19
4
|
import { useThemeWithUndefined } from '@rescui/ui-contexts';
|
|
20
5
|
import cn from 'classnames';
|
|
21
6
|
import WarningIcon from './_virtual/warning.js';
|
|
22
|
-
import CheckboxControl from './parts/checkbox-control.js';
|
|
23
7
|
import { GroupContext } from './parts/group-context.js';
|
|
8
|
+
import CheckboxControl from './parts/checkbox-control.js';
|
|
24
9
|
import styles from './parts/checkbox.p.module.css.js';
|
|
25
|
-
|
|
10
|
+
const THEME_STYLES = {
|
|
26
11
|
light: styles.themeLight,
|
|
27
12
|
dark: styles.themeDark
|
|
28
13
|
};
|
|
29
|
-
|
|
14
|
+
const SIZE_STYLES = {
|
|
30
15
|
s: styles.checkboxSizeS,
|
|
31
16
|
m: styles.checkboxSizeM,
|
|
32
17
|
l: styles.checkboxSizeL
|
|
33
18
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
19
|
+
const Checkbox = /*#__PURE__*/React.forwardRef(function Checkbox(_ref, ref) {
|
|
20
|
+
let {
|
|
21
|
+
children,
|
|
22
|
+
className,
|
|
23
|
+
disabled,
|
|
24
|
+
mode = 'classic',
|
|
25
|
+
size: propsSize = 'm',
|
|
26
|
+
theme: themeFromProps,
|
|
27
|
+
// eslint-disable-next-line react/prop-types
|
|
28
|
+
onMouseEnter,
|
|
29
|
+
// eslint-disable-next-line react/prop-types
|
|
30
|
+
onMouseLeave,
|
|
31
|
+
// eslint-disable-next-line react/prop-types
|
|
32
|
+
onClick,
|
|
33
|
+
error,
|
|
34
|
+
...restProps
|
|
35
|
+
} = _ref;
|
|
36
|
+
const theme = useThemeWithUndefined(themeFromProps);
|
|
37
|
+
const {
|
|
38
|
+
inGroup,
|
|
39
|
+
size: contextSize
|
|
40
|
+
} = useContext(GroupContext);
|
|
41
|
+
const size = !inGroup ? propsSize : contextSize || propsSize;
|
|
56
42
|
return /*#__PURE__*/React.createElement("div", {
|
|
57
43
|
className: cn(className, styles.container, THEME_STYLES[theme], SIZE_STYLES[size]),
|
|
58
44
|
"data-rs-internal": 'checkbox'
|
|
@@ -66,22 +52,24 @@ var Checkbox = /*#__PURE__*/React.forwardRef(function Checkbox(_ref, ref) {
|
|
|
66
52
|
onMouseLeave: onMouseLeave,
|
|
67
53
|
onClick: onClick,
|
|
68
54
|
tabIndex: null,
|
|
69
|
-
icon: /*#__PURE__*/React.createElement(CheckboxControl,
|
|
55
|
+
icon: /*#__PURE__*/React.createElement(CheckboxControl, {
|
|
70
56
|
ref: ref,
|
|
71
57
|
disabled: disabled,
|
|
72
58
|
size: size,
|
|
73
59
|
mode: mode,
|
|
74
60
|
theme: theme,
|
|
75
61
|
isError: Boolean(error),
|
|
76
|
-
notUseLabelTag: true
|
|
77
|
-
|
|
62
|
+
notUseLabelTag: true,
|
|
63
|
+
...restProps
|
|
64
|
+
})
|
|
78
65
|
}, children), error && typeof error !== 'boolean' && /*#__PURE__*/React.createElement("div", {
|
|
79
66
|
className: styles.errorMessage,
|
|
80
67
|
"data-test": "checkbox-error-message",
|
|
81
68
|
"data-rs-internal": "checkbox__error-message"
|
|
82
69
|
}, /*#__PURE__*/React.createElement(WarningIcon, {
|
|
83
70
|
"data-rs-internal": "checkbox__error-icon",
|
|
84
|
-
className: styles.errorIcon
|
|
71
|
+
className: styles.errorIcon,
|
|
72
|
+
"data-render-all-sizes": true
|
|
85
73
|
}), /*#__PURE__*/React.createElement("span", null, error)));
|
|
86
74
|
});
|
|
87
75
|
Checkbox.propTypes = {
|