@nutui/nutui-react 2.0.0-alpha.4 → 2.0.0-alpha.5
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/CHANGELOG.md +15 -0
- package/dist/esm/Avatar.js +30 -25
- package/dist/esm/AvatarGroup.js +10 -15
- package/dist/esm/Checkbox.js +1 -2
- package/dist/esm/CheckboxGroup.js +18 -20
- package/dist/esm/Ellipsis.js +13 -12
- package/dist/esm/Empty.js +18 -26
- package/dist/esm/Skeleton.js +1 -1
- package/dist/esm/Swipe.js +4 -10
- package/dist/esm/Tabbar/style/index.js +1 -1
- package/dist/esm/cellgroup2.js +5 -4
- package/dist/esm/checkbox2.js +34 -47
- package/dist/locales/base.js +1 -1
- package/dist/locales/en-US.js +1 -1
- package/dist/locales/id-ID.js +1 -1
- package/dist/locales/zh-CN.js +1 -1
- package/dist/locales/zh-TW.js +1 -1
- package/dist/locales/zh-UG.js +1 -1
- package/dist/nutui.react.mjs +306 -250
- package/dist/nutui.react.umd.js +306 -250
- package/dist/packages/cellgroup/cellgroup.scss +20 -16
- package/dist/packages/checkbox/checkbox.scss +8 -11
- package/dist/packages/empty/empty.scss +0 -9
- package/dist/packages/tabbar/tabbar.scss +1 -0
- package/dist/style.css +1 -1
- package/dist/style.mjs +1 -1
- package/dist/styles/themes/default.scss +0 -1
- package/dist/types/index.d.ts +34 -46
- package/package.json +1 -1
- package/dist/esm/Icon.js +0 -83
- package/dist/packages/icon/icon.scss +0 -0
- /package/dist/esm/{AvatarContext.js → context.js} +0 -0
package/dist/esm/checkbox2.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
-
var _excluded = ["icon", "
|
|
4
|
+
var _excluded = ["icon", "label", "className", "activeIcon", "checked", "value", "defaultChecked", "disabled", "onChange", "indeterminate", "indeterminateIcon"], _excluded2 = ["labelPosition"];
|
|
5
5
|
function ownKeys(object, enumerableOnly) {
|
|
6
6
|
var keys = Object.keys(object);
|
|
7
7
|
if (Object.getOwnPropertySymbols) {
|
|
@@ -25,113 +25,100 @@ function _objectSpread(target) {
|
|
|
25
25
|
}
|
|
26
26
|
import React__default, { createContext, useContext, useState, useEffect } from "react";
|
|
27
27
|
import { CheckNormal, CheckDisabled, Checked } from "@nutui/icons-react";
|
|
28
|
+
import classNames from "classnames";
|
|
28
29
|
import CheckboxGroup from "./CheckboxGroup.js";
|
|
29
|
-
import { c as cn } from "./bem.js";
|
|
30
30
|
import { C as ComponentDefaults } from "./typings.js";
|
|
31
31
|
import { u as usePropsValue } from "./use-props-value.js";
|
|
32
32
|
var CheckboxGroupContext = createContext(null);
|
|
33
33
|
var Context = CheckboxGroupContext;
|
|
34
34
|
var defaultProps = _objectSpread(_objectSpread({}, ComponentDefaults), {}, {
|
|
35
35
|
disabled: false,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
iconFontClassName: "nutui-iconfont",
|
|
42
|
-
indeterminateIcon: "check-disabled",
|
|
43
|
-
onChange: function onChange(state) {
|
|
36
|
+
labelPosition: "right",
|
|
37
|
+
icon: null,
|
|
38
|
+
activeIcon: null,
|
|
39
|
+
indeterminateIcon: null,
|
|
40
|
+
onChange: function onChange(value) {
|
|
44
41
|
}
|
|
45
42
|
});
|
|
43
|
+
var classPrefix = "nut-checkbox";
|
|
46
44
|
var Checkbox = function Checkbox2(props) {
|
|
47
45
|
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props), children = _defaultProps$props.children;
|
|
48
|
-
var
|
|
49
|
-
var
|
|
50
|
-
var textPosition = others.textPosition, rest = _objectWithoutProperties(others, _excluded2);
|
|
46
|
+
var icon = props.icon, label = props.label, className = props.className, activeIcon = props.activeIcon, checked = props.checked, value = props.value, defaultChecked = props.defaultChecked, disabled = props.disabled, onChange2 = props.onChange, indeterminate = props.indeterminate, indeterminateIcon = props.indeterminateIcon, others = _objectWithoutProperties(props, _excluded);
|
|
47
|
+
var labelPosition = others.labelPosition, rest = _objectWithoutProperties(others, _excluded2);
|
|
51
48
|
var ctx = useContext(Context);
|
|
52
49
|
var _usePropsValue = usePropsValue({
|
|
53
50
|
value: props.checked,
|
|
54
51
|
defaultValue: props.defaultChecked,
|
|
55
52
|
finalValue: defaultChecked,
|
|
56
53
|
onChange: onChange2
|
|
57
|
-
}), _usePropsValue2 = _slicedToArray(_usePropsValue, 2),
|
|
54
|
+
}), _usePropsValue2 = _slicedToArray(_usePropsValue, 2), innerChecked = _usePropsValue2[0], setChecked = _usePropsValue2[1];
|
|
58
55
|
var _useState = useState(disabled), _useState2 = _slicedToArray(_useState, 2), innerDisabled = _useState2[0], setDisabled = _useState2[1];
|
|
59
|
-
var _useState3 = useState(indeterminate), _useState4 = _slicedToArray(_useState3, 2),
|
|
56
|
+
var _useState3 = useState(indeterminate), _useState4 = _slicedToArray(_useState3, 2), innerIndeterminate = _useState4[0], setIndeterminate = _useState4[1];
|
|
60
57
|
useEffect(function() {
|
|
61
|
-
!ctx && setChecked(checked);
|
|
62
58
|
setDisabled(disabled);
|
|
59
|
+
}, [disabled]);
|
|
60
|
+
useEffect(function() {
|
|
63
61
|
setIndeterminate(indeterminate);
|
|
64
|
-
}, [
|
|
62
|
+
}, [indeterminate]);
|
|
65
63
|
if (ctx) {
|
|
66
|
-
if (ctx.
|
|
67
|
-
|
|
64
|
+
if (ctx.labelPosition !== void 0) {
|
|
65
|
+
labelPosition = ctx.labelPosition;
|
|
68
66
|
}
|
|
69
|
-
innerDisabled = ctx.disabled;
|
|
70
|
-
|
|
67
|
+
innerDisabled = ctx.disabled !== void 0 ? ctx.disabled : innerDisabled;
|
|
68
|
+
innerChecked = ctx.value.includes(value);
|
|
71
69
|
setChecked = function setChecked2(checked2) {
|
|
72
70
|
if (ctx.disabled)
|
|
73
71
|
return;
|
|
74
72
|
if (checked2)
|
|
75
|
-
ctx.check(
|
|
73
|
+
ctx.check(value);
|
|
76
74
|
if (!checked2)
|
|
77
|
-
ctx.uncheck(
|
|
75
|
+
ctx.uncheck(value);
|
|
78
76
|
};
|
|
79
77
|
}
|
|
80
78
|
var renderIcon = function renderIcon2() {
|
|
81
|
-
if (!
|
|
79
|
+
if (!innerChecked) {
|
|
82
80
|
return React__default.isValidElement(icon) ? icon : React__default.createElement(CheckNormal, {
|
|
83
|
-
width: iconSize,
|
|
84
|
-
height: iconSize,
|
|
85
81
|
className: color()
|
|
86
82
|
});
|
|
87
83
|
}
|
|
88
|
-
if (
|
|
84
|
+
if (innerIndeterminate) {
|
|
89
85
|
return React__default.isValidElement(indeterminateIcon) ? indeterminateIcon : React__default.createElement(CheckDisabled, {
|
|
90
|
-
width: iconSize,
|
|
91
|
-
height: iconSize,
|
|
92
86
|
className: color()
|
|
93
87
|
});
|
|
94
88
|
}
|
|
95
|
-
return React__default.isValidElement(
|
|
96
|
-
width: iconSize,
|
|
97
|
-
height: iconSize,
|
|
89
|
+
return React__default.isValidElement(activeIcon) ? activeIcon : React__default.createElement(Checked, {
|
|
98
90
|
className: color()
|
|
99
91
|
});
|
|
100
92
|
};
|
|
101
93
|
var color = function color2() {
|
|
102
94
|
if (innerDisabled) {
|
|
103
|
-
return "
|
|
95
|
+
return "".concat(classPrefix, "__icon--disable");
|
|
104
96
|
}
|
|
105
|
-
if (
|
|
106
|
-
if (
|
|
107
|
-
return "
|
|
97
|
+
if (innerChecked) {
|
|
98
|
+
if (innerIndeterminate) {
|
|
99
|
+
return "".concat(classPrefix, "__icon--indeterminate");
|
|
108
100
|
}
|
|
109
|
-
return "
|
|
101
|
+
return "".concat(classPrefix, "__icon");
|
|
110
102
|
}
|
|
111
|
-
return "
|
|
103
|
+
return "".concat(classPrefix, "__icon--unchecked");
|
|
112
104
|
};
|
|
113
105
|
var renderLabel = function renderLabel2() {
|
|
114
106
|
return React__default.createElement("span", {
|
|
115
|
-
className: "".concat(
|
|
116
|
-
disabled: innerDisabled
|
|
117
|
-
}), " ")
|
|
107
|
+
className: classNames("".concat(classPrefix, "__label "), _defineProperty({}, "".concat(classPrefix, "__label--disabled"), innerDisabled))
|
|
118
108
|
}, children || label);
|
|
119
109
|
};
|
|
120
110
|
var handleClick = function handleClick2() {
|
|
121
111
|
if (disabled)
|
|
122
112
|
return;
|
|
123
|
-
var latestChecked = !
|
|
113
|
+
var latestChecked = !innerChecked;
|
|
124
114
|
if (ctx && ctx.max !== void 0) {
|
|
125
|
-
if (latestChecked && ctx.
|
|
115
|
+
if (latestChecked && ctx.value.length >= ctx.max)
|
|
126
116
|
return;
|
|
127
117
|
}
|
|
128
|
-
onChange2 && onChange2(latestChecked, label || children);
|
|
129
118
|
setChecked(latestChecked);
|
|
130
119
|
};
|
|
131
120
|
return React__default.createElement("div", _objectSpread(_objectSpread({
|
|
132
|
-
className: "".concat(
|
|
133
|
-
reverse: textPosition === "left"
|
|
134
|
-
}), " ").concat(className || "")
|
|
121
|
+
className: classNames(classPrefix, className, _defineProperty({}, "".concat(classPrefix, "--reverse"), labelPosition === "left"))
|
|
135
122
|
}, rest), {}, {
|
|
136
123
|
onClick: handleClick
|
|
137
124
|
}), renderIcon(), renderLabel());
|
package/dist/locales/base.js
CHANGED
package/dist/locales/en-US.js
CHANGED
package/dist/locales/id-ID.js
CHANGED
package/dist/locales/zh-CN.js
CHANGED
package/dist/locales/zh-TW.js
CHANGED
package/dist/locales/zh-UG.js
CHANGED