@nutui/nutui-react-taro 1.3.9 → 1.3.10-beta.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/CHANGELOG.md +36 -0
- package/dist/esm/Address.js +4 -2
- package/dist/esm/Audio.js +3 -3
- package/dist/esm/Button.js +2 -2
- package/dist/esm/Card.js +4 -4
- package/dist/esm/Checkbox.js +2 -3
- package/dist/esm/CheckboxGroup.js +4 -2
- package/dist/esm/Dialog.js +3 -3
- package/dist/esm/Elevator.js +2 -2
- package/dist/esm/Input.js +2 -2
- package/dist/esm/Menu.js +2 -2
- package/dist/esm/MenuItem.js +2 -2
- package/dist/esm/NoticeBar.js +2 -2
- package/dist/esm/Price.js +2 -2
- package/dist/esm/Radio.js +1 -3
- package/dist/esm/RadioGroup.js +4 -2
- package/dist/esm/Signature.js +3 -3
- package/dist/esm/TabbarItem.js +2 -2
- package/dist/esm/Tag.js +2 -2
- package/dist/esm/Uploader.js +3 -3
- package/dist/esm/{address.taro-f16cef31.js → address.taro-8d642b4a.js} +11 -1
- package/dist/esm/{audio.taro-c2f9948a.js → audio.taro-b42a082b.js} +1 -1
- package/dist/esm/{button.taro-a9ebb937.js → button.taro-7e924b72.js} +3 -1
- package/dist/esm/{card.taro-1bc35ebe.js → card.taro-59f65b66.js} +2 -2
- package/dist/esm/checkbox.taro-d8656076.js +249 -0
- package/dist/esm/{dialog.taro-492e2b9a.js → dialog.taro-0c35b35f.js} +1 -1
- package/dist/esm/{elevator.taro-ead49158.js → elevator.taro-d7d65470.js} +1 -1
- package/dist/esm/index.taro-c092d216.js +227 -0
- package/dist/esm/{input.taro-39b99dbc.js → input.taro-cc46bbc3.js} +11 -4
- package/dist/esm/{menu.taro-f8ca86db.js → menu.taro-4abed328.js} +3 -2
- package/dist/esm/{menuitem.taro-7bf564c9.js → menuitem.taro-06a135a5.js} +1 -2
- package/dist/esm/{noticebar.taro-77b5a2c9.js → noticebar.taro-4915fed3.js} +12 -16
- package/dist/esm/nutui-react.es.js +17 -19
- package/dist/esm/{price.taro-97393d8f.js → price.taro-8801462e.js} +28 -22
- package/dist/esm/{signature.taro-0b3abea5.js → signature.taro-57f8de06.js} +1 -1
- package/dist/esm/{tabbaritem.taro-94cd62c2.js → tabbaritem.taro-fb90f659.js} +6 -5
- package/dist/esm/{tag.taro-95d7f5c2.js → tag.taro-84d40117.js} +6 -4
- package/dist/esm/types/src/packages/checkbox/checkbox.d.ts +6 -1
- package/dist/esm/types/src/packages/checkbox/checkbox.taro.d.ts +6 -1
- package/dist/esm/types/src/packages/checkboxgroup/checkboxgroup.d.ts +2 -0
- package/dist/esm/types/src/packages/checkboxgroup/checkboxgroup.taro.d.ts +2 -0
- package/dist/esm/types/src/packages/checkboxgroup/type.d.ts +6 -0
- package/dist/esm/types/src/packages/input/input.d.ts +1 -0
- package/dist/esm/types/src/packages/input/input.taro.d.ts +1 -0
- package/dist/esm/types/src/packages/nutui.react.taro.scss.d.ts +91 -0
- package/dist/esm/types/src/packages/price/price.d.ts +2 -0
- package/dist/esm/types/src/packages/price/price.taro.d.ts +2 -0
- package/dist/esm/types/src/packages/radiogroup/radiogroup.d.ts +2 -0
- package/dist/esm/types/src/packages/radiogroup/radiogroup.taro.d.ts +2 -0
- package/dist/esm/types/src/packages/radiogroup/type.d.ts +7 -0
- package/dist/esm/types/src/packages/tabbaritem/tabbaritem.d.ts +1 -1
- package/dist/esm/types/src/packages/tabbaritem/tabbaritem.taro.d.ts +1 -1
- package/dist/esm/{uploader.taro-63a36a30.js → uploader.taro-a03bb003.js} +1 -1
- 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/nutui.react.es.js +170 -78
- package/dist/nutui.react.umd.js +169 -77
- package/dist/packages/badge/badge.scss +10 -10
- package/dist/packages/button/button.scss +3 -3
- package/dist/packages/cell/cell.scss +1 -4
- package/dist/packages/cellgroup/cellgroup.scss +8 -0
- package/dist/packages/countdown/countdown.scss +1 -1
- package/dist/packages/infiniteloading/infiniteloading.scss +1 -1
- package/dist/packages/inputnumber/inputnumber.scss +3 -3
- package/dist/packages/noticebar/noticebar.scss +3 -0
- package/dist/packages/price/price.scss +27 -11
- package/dist/packages/radio/radio.scss +8 -7
- package/dist/packages/shortpassword/shortpassword.scss +4 -4
- package/dist/packages/skeleton/skeleton.scss +1 -1
- package/dist/packages/swiper/swiper.scss +4 -4
- package/dist/packages/switch/switch.scss +8 -8
- package/dist/packages/timepannel/timepannel.scss +3 -3
- package/dist/packages/timeselect/timeselect.scss +4 -4
- package/dist/style.css +1 -1
- package/dist/style.es.js +1 -1
- package/dist/styles/variables.scss +573 -248
- package/dist/types/index.d.ts +19 -3
- package/package.json +1 -1
- package/dist/esm/checkbox.taro-104557c1.js +0 -121
- package/dist/esm/checkboxgroup.taro-3d380042.js +0 -110
- package/dist/esm/radio.taro-95d43860.js +0 -112
- package/dist/esm/radiogroup.taro-b5dad516.js +0 -95
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React$1, { CSSProperties, ReactNode, FunctionComponent, ReactHTML, ReactElement, MouseEvent as MouseEvent$1, ChangeEvent, FocusEvent, HTMLInputTypeAttribute,
|
|
1
|
+
import React$1, { CSSProperties, ReactNode, FunctionComponent, ReactHTML, ReactElement, MouseEvent as MouseEvent$1, MouseEventHandler, ChangeEvent, FocusEvent, HTMLInputTypeAttribute, RefObject, ForwardRefExoticComponent, PropsWithChildren, Component } from 'react';
|
|
2
2
|
import Taro from '@tarojs/taro';
|
|
3
3
|
|
|
4
4
|
interface IComponent {
|
|
@@ -378,7 +378,7 @@ declare const Tabbar: FunctionComponent<Partial<TabbarProps>>;
|
|
|
378
378
|
interface TabbarItemProps extends IComponent {
|
|
379
379
|
dot: boolean;
|
|
380
380
|
size: string | number;
|
|
381
|
-
|
|
381
|
+
className: string;
|
|
382
382
|
tabTitle: string;
|
|
383
383
|
icon: string;
|
|
384
384
|
href: string;
|
|
@@ -599,14 +599,26 @@ interface CalendarProps {
|
|
|
599
599
|
}
|
|
600
600
|
declare const Calendar: FunctionComponent<Partial<CalendarProps> & React$1.HTMLAttributes<HTMLDivElement>>;
|
|
601
601
|
|
|
602
|
+
interface RadioGroupOptionType {
|
|
603
|
+
label: string;
|
|
604
|
+
value: string;
|
|
605
|
+
disabled?: boolean;
|
|
606
|
+
onChange?: MouseEventHandler<HTMLDivElement>;
|
|
607
|
+
}
|
|
608
|
+
|
|
602
609
|
interface CheckboxGroupProps {
|
|
603
610
|
disabled: boolean;
|
|
604
611
|
checkedValue: string[];
|
|
605
612
|
max: number | undefined;
|
|
606
613
|
onChange: (value: string[]) => void;
|
|
614
|
+
options: RadioGroupOptionType[];
|
|
607
615
|
}
|
|
608
616
|
declare const CheckboxGroup: React$1.ForwardRefExoticComponent<Partial<CheckboxGroupProps> & Omit<React$1.HTMLAttributes<HTMLDivElement>, "onChange"> & React$1.RefAttributes<unknown>>;
|
|
609
617
|
|
|
618
|
+
interface InheritParentProps {
|
|
619
|
+
getParentVals?: () => string[] | undefined;
|
|
620
|
+
max?: number | undefined;
|
|
621
|
+
}
|
|
610
622
|
interface CheckboxProps extends IComponent {
|
|
611
623
|
checked: boolean;
|
|
612
624
|
disabled: boolean;
|
|
@@ -621,7 +633,7 @@ interface CheckboxProps extends IComponent {
|
|
|
621
633
|
label: string;
|
|
622
634
|
onChange: (state: boolean, label: string) => void;
|
|
623
635
|
}
|
|
624
|
-
declare const Checkbox: FunctionComponent<Partial<CheckboxProps> & Omit<React$1.HTMLAttributes<HTMLDivElement>, 'onChange'
|
|
636
|
+
declare const Checkbox: FunctionComponent<Partial<CheckboxProps> & Omit<React$1.HTMLAttributes<HTMLDivElement>, 'onChange'> & InheritParentProps> & {
|
|
625
637
|
Group: typeof CheckboxGroup;
|
|
626
638
|
};
|
|
627
639
|
|
|
@@ -690,6 +702,7 @@ declare type InputRule = {
|
|
|
690
702
|
};
|
|
691
703
|
interface InputProps extends IComponent {
|
|
692
704
|
type: InputType;
|
|
705
|
+
name: string;
|
|
693
706
|
defaultValue: any;
|
|
694
707
|
placeholder: string;
|
|
695
708
|
label: string;
|
|
@@ -751,6 +764,7 @@ interface RadioGroupProps {
|
|
|
751
764
|
textPosition: Position$1;
|
|
752
765
|
direction: Direction;
|
|
753
766
|
onChange: (value: string | number | boolean) => void;
|
|
767
|
+
options: RadioGroupOptionType[];
|
|
754
768
|
}
|
|
755
769
|
declare const RadioGroup: React$1.ForwardRefExoticComponent<Partial<RadioGroupProps> & Omit<React$1.HTMLAttributes<HTMLDivElement>, "onChange"> & React$1.RefAttributes<unknown>>;
|
|
756
770
|
|
|
@@ -1448,6 +1462,8 @@ interface PriceProps {
|
|
|
1448
1462
|
symbol: string;
|
|
1449
1463
|
decimalDigits: number;
|
|
1450
1464
|
thousands: boolean;
|
|
1465
|
+
position: string;
|
|
1466
|
+
size: string;
|
|
1451
1467
|
className: string;
|
|
1452
1468
|
style: React$1.CSSProperties;
|
|
1453
1469
|
}
|
package/package.json
CHANGED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
-
var _excluded = ["iconName", "iconSize", "label", "className", "textPosition", "iconActiveName", "checked", "disabled", "onChange", "indeterminate", "iconClassPrefix", "iconFontClassName", "iconIndeterminateName", "getParentVals", "max"];
|
|
5
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
6
|
-
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; }
|
|
7
|
-
import React__default, { useState, useEffect } from 'react';
|
|
8
|
-
import { I as Icon } from './icon.taro-1d0d4fb7.js';
|
|
9
|
-
import { C as CheckboxGroup } from './checkboxgroup.taro-3d380042.js';
|
|
10
|
-
import { c as cn } from './bem-893ad28d.js';
|
|
11
|
-
import { C as ComponentDefaults } from './typings-1c5f2628.js';
|
|
12
|
-
var defaultProps = _objectSpread(_objectSpread({}, ComponentDefaults), {}, {
|
|
13
|
-
checked: false,
|
|
14
|
-
disabled: false,
|
|
15
|
-
textPosition: 'right',
|
|
16
|
-
iconSize: 18,
|
|
17
|
-
iconName: 'check-normal',
|
|
18
|
-
iconActiveName: 'checked',
|
|
19
|
-
iconClassPrefix: 'nut-icon',
|
|
20
|
-
iconFontClassName: 'nutui-iconfont',
|
|
21
|
-
iconIndeterminateName: 'check-disabled',
|
|
22
|
-
onChange: function onChange(state, label) {}
|
|
23
|
-
});
|
|
24
|
-
var Checkbox = function Checkbox(props) {
|
|
25
|
-
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
|
|
26
|
-
children = _defaultProps$props.children;
|
|
27
|
-
var b = cn('checkbox');
|
|
28
|
-
var iconName = props.iconName,
|
|
29
|
-
iconSize = props.iconSize,
|
|
30
|
-
label = props.label,
|
|
31
|
-
className = props.className,
|
|
32
|
-
textPosition = props.textPosition,
|
|
33
|
-
iconActiveName = props.iconActiveName,
|
|
34
|
-
checked = props.checked,
|
|
35
|
-
disabled = props.disabled,
|
|
36
|
-
onChange = props.onChange,
|
|
37
|
-
indeterminate = props.indeterminate,
|
|
38
|
-
iconClassPrefix = props.iconClassPrefix,
|
|
39
|
-
iconFontClassName = props.iconFontClassName,
|
|
40
|
-
iconIndeterminateName = props.iconIndeterminateName,
|
|
41
|
-
getParentVals = props.getParentVals,
|
|
42
|
-
max = props.max,
|
|
43
|
-
rest = _objectWithoutProperties(props, _excluded);
|
|
44
|
-
var _useState = useState(checked),
|
|
45
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
46
|
-
innerChecked = _useState2[0],
|
|
47
|
-
setInnerChecked = _useState2[1];
|
|
48
|
-
var _useState3 = useState(disabled),
|
|
49
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
50
|
-
innerDisabled = _useState4[0],
|
|
51
|
-
setDisabled = _useState4[1];
|
|
52
|
-
var _useState5 = useState(indeterminate),
|
|
53
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
54
|
-
_indeterminate = _useState6[0],
|
|
55
|
-
setIndeterminate = _useState6[1];
|
|
56
|
-
useEffect(function () {
|
|
57
|
-
setInnerChecked(checked);
|
|
58
|
-
setDisabled(disabled);
|
|
59
|
-
}, [disabled, checked]);
|
|
60
|
-
useEffect(function () {
|
|
61
|
-
setIndeterminate(indeterminate);
|
|
62
|
-
}, [indeterminate]);
|
|
63
|
-
var getIconName = function getIconName() {
|
|
64
|
-
if (!innerChecked) {
|
|
65
|
-
return iconName;
|
|
66
|
-
}
|
|
67
|
-
if (_indeterminate) {
|
|
68
|
-
return iconIndeterminateName;
|
|
69
|
-
}
|
|
70
|
-
return iconActiveName;
|
|
71
|
-
};
|
|
72
|
-
var renderIcon = function renderIcon() {
|
|
73
|
-
return React__default.createElement(Icon, {
|
|
74
|
-
classPrefix: iconClassPrefix,
|
|
75
|
-
fontClassName: iconFontClassName,
|
|
76
|
-
name: getIconName(),
|
|
77
|
-
size: iconSize,
|
|
78
|
-
className: color()
|
|
79
|
-
});
|
|
80
|
-
};
|
|
81
|
-
var color = function color() {
|
|
82
|
-
if (innerDisabled) {
|
|
83
|
-
return 'nut-checkbox__icon--disable';
|
|
84
|
-
}
|
|
85
|
-
if (innerChecked) {
|
|
86
|
-
if (_indeterminate) {
|
|
87
|
-
return 'nut-checkbox__icon--indeterminate';
|
|
88
|
-
}
|
|
89
|
-
return 'nut-checkbox__icon';
|
|
90
|
-
}
|
|
91
|
-
return 'nut-checkbox__icon--unchecked';
|
|
92
|
-
// return !innerDisabled ? (!innerChecked ? '#d6d6d6' : '#fa2c19') : '#f5f5f5'
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
var renderLabel = function renderLabel() {
|
|
96
|
-
return React__default.createElement("span", {
|
|
97
|
-
className: "".concat(b('label', {
|
|
98
|
-
disabled: innerDisabled
|
|
99
|
-
}), " ")
|
|
100
|
-
}, children || label);
|
|
101
|
-
};
|
|
102
|
-
var handleClick = function handleClick() {
|
|
103
|
-
if (!disabled) {
|
|
104
|
-
var latest = !innerChecked;
|
|
105
|
-
if (max !== undefined && latest && getParentVals().length >= max) return;
|
|
106
|
-
onChange && onChange(latest, label || children);
|
|
107
|
-
setInnerChecked(latest);
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
return React__default.createElement("div", _objectSpread(_objectSpread({
|
|
111
|
-
className: "".concat(b({
|
|
112
|
-
reverse: textPosition === 'left'
|
|
113
|
-
}), " ").concat(className || '')
|
|
114
|
-
}, rest), {}, {
|
|
115
|
-
onClick: handleClick
|
|
116
|
-
}), renderIcon(), renderLabel());
|
|
117
|
-
};
|
|
118
|
-
Checkbox.defaultProps = defaultProps;
|
|
119
|
-
Checkbox.displayName = 'NutCheckBox';
|
|
120
|
-
Checkbox.Group = CheckboxGroup;
|
|
121
|
-
export { Checkbox as C };
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
5
|
-
var _excluded = ["className", "disabled", "onChange", "checkedValue", "max"];
|
|
6
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
7
|
-
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; }
|
|
8
|
-
import React__default, { useState, useImperativeHandle, useEffect } from 'react';
|
|
9
|
-
import { c as cn } from './bem-893ad28d.js';
|
|
10
|
-
var defaultProps = {
|
|
11
|
-
disabled: false,
|
|
12
|
-
checkedValue: [],
|
|
13
|
-
max: undefined,
|
|
14
|
-
onChange: function onChange(value) {}
|
|
15
|
-
};
|
|
16
|
-
var CheckboxGroup = React__default.forwardRef(function (props, ref) {
|
|
17
|
-
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
|
|
18
|
-
children = _defaultProps$props.children;
|
|
19
|
-
var b = cn('checkboxgroup');
|
|
20
|
-
var className = props.className,
|
|
21
|
-
disabled = props.disabled,
|
|
22
|
-
onChange = props.onChange,
|
|
23
|
-
checkedValue = props.checkedValue,
|
|
24
|
-
max = props.max,
|
|
25
|
-
rest = _objectWithoutProperties(props, _excluded);
|
|
26
|
-
var _useState = useState(disabled),
|
|
27
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
28
|
-
innerDisabled = _useState2[0],
|
|
29
|
-
setInnerDisabled = _useState2[1];
|
|
30
|
-
var _useState3 = useState(checkedValue),
|
|
31
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
32
|
-
innerValue = _useState4[0],
|
|
33
|
-
setInnerValue = _useState4[1];
|
|
34
|
-
useImperativeHandle(ref, function () {
|
|
35
|
-
return {
|
|
36
|
-
toggleAll: function toggleAll(state) {
|
|
37
|
-
if (state === false) {
|
|
38
|
-
setInnerValue([]);
|
|
39
|
-
} else {
|
|
40
|
-
var childrenLabel = [];
|
|
41
|
-
React__default.Children.map(children, function (child) {
|
|
42
|
-
var childProps = child.props;
|
|
43
|
-
console.log(child);
|
|
44
|
-
childrenLabel.push(childProps.label || child.children);
|
|
45
|
-
});
|
|
46
|
-
setInnerValue(childrenLabel);
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
toggleReverse: function toggleReverse() {
|
|
50
|
-
var childrenLabel = [];
|
|
51
|
-
React__default.Children.map(children, function (child) {
|
|
52
|
-
var childProps = child.props;
|
|
53
|
-
childrenLabel.push(childProps.label || child.children);
|
|
54
|
-
});
|
|
55
|
-
var reverse = childrenLabel.filter(function (c) {
|
|
56
|
-
return (innerValue === null || innerValue === void 0 ? void 0 : innerValue.findIndex(function (v) {
|
|
57
|
-
return v === c;
|
|
58
|
-
})) === -1;
|
|
59
|
-
});
|
|
60
|
-
setInnerValue(reverse);
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
});
|
|
64
|
-
useEffect(function () {
|
|
65
|
-
setInnerDisabled(disabled);
|
|
66
|
-
setInnerValue(checkedValue);
|
|
67
|
-
}, [disabled, checkedValue]);
|
|
68
|
-
function handleChildChange(state, label) {
|
|
69
|
-
if (max !== undefined && innerValue && innerValue.length > max) return;
|
|
70
|
-
if (innerValue) {
|
|
71
|
-
var clippedValue = [];
|
|
72
|
-
if (state) {
|
|
73
|
-
clippedValue = [].concat(_toConsumableArray(innerValue), [label]);
|
|
74
|
-
} else {
|
|
75
|
-
innerValue === null || innerValue === void 0 ? void 0 : innerValue.splice(innerValue === null || innerValue === void 0 ? void 0 : innerValue.indexOf(label), 1);
|
|
76
|
-
clippedValue = _toConsumableArray(innerValue);
|
|
77
|
-
}
|
|
78
|
-
setInnerValue(clippedValue);
|
|
79
|
-
onChange && onChange(clippedValue);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
function validateChildChecked(child) {
|
|
83
|
-
if (!innerValue) return false;
|
|
84
|
-
return (innerValue === null || innerValue === void 0 ? void 0 : innerValue.indexOf(child.props.label || child.children)) > -1;
|
|
85
|
-
}
|
|
86
|
-
function getParentVals() {
|
|
87
|
-
return innerValue;
|
|
88
|
-
}
|
|
89
|
-
function cloneChildren() {
|
|
90
|
-
return React__default.Children.map(children, function (child) {
|
|
91
|
-
var childChecked = validateChildChecked(child);
|
|
92
|
-
if (child.type.displayName !== 'NutCheckBox') {
|
|
93
|
-
return React__default.cloneElement(child);
|
|
94
|
-
}
|
|
95
|
-
return React__default.cloneElement(child, {
|
|
96
|
-
disabled: innerDisabled,
|
|
97
|
-
checked: childChecked,
|
|
98
|
-
onChange: handleChildChange,
|
|
99
|
-
getParentVals: getParentVals,
|
|
100
|
-
max: max
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
return React__default.createElement("div", _objectSpread({
|
|
105
|
-
className: "".concat(b(), " ").concat(className || '')
|
|
106
|
-
}, rest), cloneChildren());
|
|
107
|
-
});
|
|
108
|
-
CheckboxGroup.defaultProps = defaultProps;
|
|
109
|
-
CheckboxGroup.displayName = 'NutCheckboxGroup';
|
|
110
|
-
export { CheckboxGroup as C };
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
-
var _excluded = ["className", "disabled", "checked", "shape", "textPosition", "value", "iconName", "iconActiveName", "iconSize", "onChange", "iconClassPrefix", "iconFontClassName"];
|
|
5
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
6
|
-
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; }
|
|
7
|
-
import React__default, { useState, useContext, useEffect } from 'react';
|
|
8
|
-
import { I as Icon } from './icon.taro-1d0d4fb7.js';
|
|
9
|
-
import { a as RadioContext, R as RadioGroup } from './radiogroup.taro-b5dad516.js';
|
|
10
|
-
import { C as ComponentDefaults } from './typings-1c5f2628.js';
|
|
11
|
-
var defaultProps = _objectSpread(_objectSpread({}, ComponentDefaults), {}, {
|
|
12
|
-
disabled: false,
|
|
13
|
-
checked: false,
|
|
14
|
-
shape: 'round',
|
|
15
|
-
value: '',
|
|
16
|
-
textPosition: 'right',
|
|
17
|
-
iconName: 'check-normal',
|
|
18
|
-
iconActiveName: 'check-checked',
|
|
19
|
-
iconSize: 18,
|
|
20
|
-
onChange: function onChange(e) {}
|
|
21
|
-
});
|
|
22
|
-
var Radio = function Radio(props) {
|
|
23
|
-
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
|
|
24
|
-
children = _defaultProps$props.children;
|
|
25
|
-
var className = props.className,
|
|
26
|
-
disabled = props.disabled,
|
|
27
|
-
checked = props.checked,
|
|
28
|
-
shape = props.shape,
|
|
29
|
-
textPosition = props.textPosition,
|
|
30
|
-
value = props.value,
|
|
31
|
-
iconName = props.iconName,
|
|
32
|
-
iconActiveName = props.iconActiveName,
|
|
33
|
-
iconSize = props.iconSize,
|
|
34
|
-
onChange = props.onChange,
|
|
35
|
-
iconClassPrefix = props.iconClassPrefix,
|
|
36
|
-
iconFontClassName = props.iconFontClassName,
|
|
37
|
-
rest = _objectWithoutProperties(props, _excluded);
|
|
38
|
-
var componentName = 'nut-radio';
|
|
39
|
-
var _useState = useState(checked),
|
|
40
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
41
|
-
checkedStatement = _useState2[0],
|
|
42
|
-
setCheckedStatement = _useState2[1];
|
|
43
|
-
var _useState3 = useState(value),
|
|
44
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
45
|
-
valueStatement = _useState4[0],
|
|
46
|
-
setValueStatement = _useState4[1];
|
|
47
|
-
var _useState5 = useState(disabled),
|
|
48
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
49
|
-
disabledStatement = _useState6[0],
|
|
50
|
-
setDisabledStatement = _useState6[1];
|
|
51
|
-
var context = useContext(RadioContext);
|
|
52
|
-
useEffect(function () {
|
|
53
|
-
setDisabledStatement(disabled);
|
|
54
|
-
setValueStatement(value);
|
|
55
|
-
setCheckedStatement(checked);
|
|
56
|
-
}, [disabled, value, checked]);
|
|
57
|
-
var renderLabel = function renderLabel() {
|
|
58
|
-
return React__default.createElement("div", {
|
|
59
|
-
className: "".concat(componentName, "__label ").concat(disabledStatement ? "".concat(componentName, "__label--disabled") : '')
|
|
60
|
-
}, children);
|
|
61
|
-
};
|
|
62
|
-
var renderButton = function renderButton() {
|
|
63
|
-
return React__default.createElement("div", {
|
|
64
|
-
className: "".concat(componentName, "__button ").concat(checkedStatement && "".concat(componentName, "__button--active"), " ").concat(disabledStatement ? "".concat(componentName, "__button--disabled") : '')
|
|
65
|
-
}, children);
|
|
66
|
-
};
|
|
67
|
-
var color = function color() {
|
|
68
|
-
if (disabledStatement) {
|
|
69
|
-
return 'nut-radio__icon--disable';
|
|
70
|
-
}
|
|
71
|
-
if (checkedStatement) {
|
|
72
|
-
return 'nut-radio__icon';
|
|
73
|
-
}
|
|
74
|
-
return 'nut-radio__icon--unchecked';
|
|
75
|
-
};
|
|
76
|
-
var renderIcon = function renderIcon() {
|
|
77
|
-
var iconName = props.iconName,
|
|
78
|
-
iconSize = props.iconSize,
|
|
79
|
-
iconActiveName = props.iconActiveName;
|
|
80
|
-
return React__default.createElement(Icon, {
|
|
81
|
-
classPrefix: iconClassPrefix,
|
|
82
|
-
fontClassName: iconFontClassName,
|
|
83
|
-
name: checkedStatement ? iconActiveName : iconName,
|
|
84
|
-
size: iconSize,
|
|
85
|
-
className: color()
|
|
86
|
-
});
|
|
87
|
-
};
|
|
88
|
-
var renderRadioItem = function renderRadioItem() {
|
|
89
|
-
if (shape === 'button') {
|
|
90
|
-
return renderButton();
|
|
91
|
-
}
|
|
92
|
-
if (reverseState) {
|
|
93
|
-
return [renderLabel(), renderIcon()];
|
|
94
|
-
}
|
|
95
|
-
return [renderIcon(), renderLabel()];
|
|
96
|
-
};
|
|
97
|
-
var handleClick = function handleClick(e) {
|
|
98
|
-
if (disabledStatement || checkedStatement) return;
|
|
99
|
-
setCheckedStatement(!checkedStatement);
|
|
100
|
-
onChange && onChange(e);
|
|
101
|
-
context && context.onChange(valueStatement);
|
|
102
|
-
};
|
|
103
|
-
var reverseState = textPosition === 'left';
|
|
104
|
-
return React__default.createElement("div", _objectSpread({
|
|
105
|
-
className: "nut-radio ".concat(className),
|
|
106
|
-
onClick: handleClick
|
|
107
|
-
}, rest), renderRadioItem());
|
|
108
|
-
};
|
|
109
|
-
Radio.defaultProps = defaultProps;
|
|
110
|
-
Radio.displayName = 'NutRadio';
|
|
111
|
-
Radio.RadioGroup = RadioGroup;
|
|
112
|
-
export { Radio as R };
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
-
var _excluded = ["className", "value", "onChange", "textPosition", "direction"];
|
|
5
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
6
|
-
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; }
|
|
7
|
-
import React__default, { useState, useEffect } from 'react';
|
|
8
|
-
import { c as cn } from './bem-893ad28d.js';
|
|
9
|
-
var radioContext = {
|
|
10
|
-
onChange: function onChange(val) {}
|
|
11
|
-
};
|
|
12
|
-
var RadioContext = React__default.createContext(radioContext);
|
|
13
|
-
var defaultProps = {
|
|
14
|
-
value: null,
|
|
15
|
-
textPosition: 'right',
|
|
16
|
-
onChange: function onChange(value) {},
|
|
17
|
-
direction: 'vertical'
|
|
18
|
-
};
|
|
19
|
-
var RadioGroup = React__default.forwardRef(function (props, ref) {
|
|
20
|
-
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
|
|
21
|
-
children = _defaultProps$props.children;
|
|
22
|
-
cn('RadioGroup');
|
|
23
|
-
var className = props.className,
|
|
24
|
-
value = props.value,
|
|
25
|
-
_onChange = props.onChange,
|
|
26
|
-
textPosition = props.textPosition,
|
|
27
|
-
direction = props.direction,
|
|
28
|
-
rest = _objectWithoutProperties(props, _excluded);
|
|
29
|
-
var _useState = useState(value),
|
|
30
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
31
|
-
val2State = _useState2[0],
|
|
32
|
-
setVal2State = _useState2[1];
|
|
33
|
-
// useImperativeHandle(ref, () => ({
|
|
34
|
-
// toggleAll(state: boolean) {
|
|
35
|
-
// console.log(state)
|
|
36
|
-
// if (state === false) {
|
|
37
|
-
// setInnerValue([])
|
|
38
|
-
// } else {
|
|
39
|
-
// const childrenLabel: string[] = []
|
|
40
|
-
// React.Children.map(children, (child) => {
|
|
41
|
-
// const childProps = (child as any).props
|
|
42
|
-
// childrenLabel.push(childProps.label || (child as any).children)
|
|
43
|
-
// })
|
|
44
|
-
// setInnerValue(childrenLabel)
|
|
45
|
-
// }
|
|
46
|
-
// },
|
|
47
|
-
// }))
|
|
48
|
-
useEffect(function () {
|
|
49
|
-
setVal2State(value);
|
|
50
|
-
}, [value]);
|
|
51
|
-
// function handleChildChange(state: boolean, label: string) {
|
|
52
|
-
// if (innerValue) {
|
|
53
|
-
// let clippedValue = []
|
|
54
|
-
// if (state) {
|
|
55
|
-
// clippedValue = [...innerValue, label]
|
|
56
|
-
// } else {
|
|
57
|
-
// innerValue?.splice(innerValue?.indexOf(label), 1)
|
|
58
|
-
// clippedValue = [...innerValue]
|
|
59
|
-
// }
|
|
60
|
-
// setInnerValue(clippedValue)
|
|
61
|
-
// onChange && onChange(clippedValue)
|
|
62
|
-
// }
|
|
63
|
-
// }
|
|
64
|
-
function validateChildChecked(child) {
|
|
65
|
-
if (val2State === null) return false;
|
|
66
|
-
return val2State === child.props.value;
|
|
67
|
-
}
|
|
68
|
-
function cloneChildren() {
|
|
69
|
-
return React__default.Children.map(children, function (child, index) {
|
|
70
|
-
var childChecked = validateChildChecked(child);
|
|
71
|
-
if (child.type.displayName !== 'NutRadio') {
|
|
72
|
-
return React__default.cloneElement(child);
|
|
73
|
-
}
|
|
74
|
-
return React__default.cloneElement(child, {
|
|
75
|
-
textPosition: textPosition,
|
|
76
|
-
checked: childChecked
|
|
77
|
-
// onChange: handleChildChange,
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return React__default.createElement(RadioContext.Provider, {
|
|
83
|
-
value: {
|
|
84
|
-
onChange: function onChange(val) {
|
|
85
|
-
setVal2State(val);
|
|
86
|
-
_onChange && _onChange(val);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}, React__default.createElement("div", _objectSpread({
|
|
90
|
-
className: "nut-radiogroup nut-radiogroup--".concat(props.direction)
|
|
91
|
-
}, rest), cloneChildren()));
|
|
92
|
-
});
|
|
93
|
-
RadioGroup.defaultProps = defaultProps;
|
|
94
|
-
RadioGroup.displayName = 'NutRadioGroup';
|
|
95
|
-
export { RadioGroup as R, RadioContext as a };
|