@dckj-npm/dc-material 0.1.26 → 0.1.28
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/build/docs/colorful-button.html +48 -0
- package/build/docs/colorful-input.html +48 -0
- package/build/docs/index.html +48 -0
- package/build/docs/umi.1db9e2cc.css +8 -0
- package/build/docs/umi.c18d41ab.js +1 -0
- package/build/docs/~demos/colorful-button-demo.html +47 -0
- package/build/docs/~demos/colorful-input-demo.html +47 -0
- package/build/lowcode/assets-daily.json +13 -13
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +13 -13
- package/build/lowcode/index.js +1 -1
- package/build/lowcode/meta.design.js +1 -1
- package/build/lowcode/meta.js +1 -1
- package/build/lowcode/preview.js +5 -5
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +6 -6
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +6 -6
- package/dist/BizComps.css +1 -1
- package/dist/BizComps.js +2 -2
- package/dist/BizComps.js.map +1 -1
- package/es/components/radio-group/index.d.ts +8 -0
- package/es/components/radio-group/index.js +7 -0
- package/es/components/radio-group/index.scss +40 -0
- package/es/components/radio-group/radio-group-item.d.ts +48 -0
- package/es/components/radio-group/radio-group-item.js +74 -0
- package/es/components/radio-group/radio-group.d.ts +52 -0
- package/es/components/radio-group/radio-group.js +65 -0
- package/es/index.d.ts +2 -0
- package/es/index.js +4 -0
- package/lib/components/radio-group/index.d.ts +8 -0
- package/lib/components/radio-group/index.js +8 -0
- package/lib/components/radio-group/index.scss +40 -0
- package/lib/components/radio-group/radio-group-item.d.ts +48 -0
- package/lib/components/radio-group/radio-group-item.js +79 -0
- package/lib/components/radio-group/radio-group.d.ts +52 -0
- package/lib/components/radio-group/radio-group.js +72 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +6 -1
- package/lowcode/custom-radio-group/meta.ts +293 -0
- package/lowcode/custom-radio-group-item/meta.ts +229 -0
- package/lowcode_es/custom-radio-group/meta.d.ts +22 -0
- package/lowcode_es/custom-radio-group/meta.js +274 -0
- package/lowcode_es/custom-radio-group-item/meta.d.ts +23 -0
- package/lowcode_es/custom-radio-group-item/meta.js +205 -0
- package/lowcode_es/meta.js +4 -2
- package/lowcode_lib/custom-radio-group/meta.d.ts +22 -0
- package/lowcode_lib/custom-radio-group/meta.js +279 -0
- package/lowcode_lib/custom-radio-group-item/meta.d.ts +23 -0
- package/lowcode_lib/custom-radio-group-item/meta.js +210 -0
- package/lowcode_lib/meta.js +21 -19
- package/package.json +3 -3
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 单选按钮组
|
|
3
|
+
*/
|
|
4
|
+
import RadioGroup from './radio-group';
|
|
5
|
+
import RadioGroupItem from './radio-group-item';
|
|
6
|
+
export type { RadioGroupProps } from './radio-group';
|
|
7
|
+
export type { RadioGroupItemProps } from './radio-group-item';
|
|
8
|
+
export { RadioGroup as CustomRadioGroup, RadioGroupItem as CustomRadioGroupItem, };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
@import '../../variables.scss';
|
|
2
|
+
|
|
3
|
+
.radio-group__panel {
|
|
4
|
+
display: flex;
|
|
5
|
+
gap: 12px;
|
|
6
|
+
width: 100%;
|
|
7
|
+
|
|
8
|
+
.radio-group-item__button {
|
|
9
|
+
flex: 0 0 auto;
|
|
10
|
+
transition-property: all;
|
|
11
|
+
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
|
12
|
+
transition-duration: 250ms;
|
|
13
|
+
font-size: 12px;
|
|
14
|
+
padding: 5px 11px;
|
|
15
|
+
border-radius: 25rem;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.radio-group-item__text {
|
|
19
|
+
flex: 0 0 auto;
|
|
20
|
+
transition-property: all;
|
|
21
|
+
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
|
22
|
+
transition-duration: 250ms;
|
|
23
|
+
font-size: 12px;
|
|
24
|
+
padding: 5px 11px;
|
|
25
|
+
|
|
26
|
+
.radio-group-item__text__line {
|
|
27
|
+
width: 100%;
|
|
28
|
+
height: 1px;
|
|
29
|
+
right: 0;
|
|
30
|
+
left: 0;
|
|
31
|
+
bottom: 0;
|
|
32
|
+
position: absolute;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './index.scss';
|
|
3
|
+
export type RadioGroupItemType = 'button' | 'text';
|
|
4
|
+
export interface RadioGroupItemProps {
|
|
5
|
+
/**
|
|
6
|
+
* 选项
|
|
7
|
+
*/
|
|
8
|
+
label: string;
|
|
9
|
+
/**
|
|
10
|
+
* 值
|
|
11
|
+
*/
|
|
12
|
+
value: string;
|
|
13
|
+
/**
|
|
14
|
+
* 是否选中
|
|
15
|
+
*/
|
|
16
|
+
checked: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* 选中颜色
|
|
19
|
+
*/
|
|
20
|
+
selectColor?: string;
|
|
21
|
+
/**
|
|
22
|
+
* 选中的文字颜色
|
|
23
|
+
*/
|
|
24
|
+
selectTextColor?: string;
|
|
25
|
+
/**
|
|
26
|
+
* 未选中颜色
|
|
27
|
+
*/
|
|
28
|
+
unSelectColor?: string;
|
|
29
|
+
/**
|
|
30
|
+
* 未选中的文字颜色
|
|
31
|
+
*/
|
|
32
|
+
unSelectTextColor?: string;
|
|
33
|
+
/**
|
|
34
|
+
* 类型
|
|
35
|
+
*/
|
|
36
|
+
type?: RadioGroupItemType;
|
|
37
|
+
/**
|
|
38
|
+
* 名称
|
|
39
|
+
*/
|
|
40
|
+
name: string;
|
|
41
|
+
/**
|
|
42
|
+
* 改变事件
|
|
43
|
+
* @param value
|
|
44
|
+
*/
|
|
45
|
+
onChange: (value: string) => void;
|
|
46
|
+
}
|
|
47
|
+
declare const RadioGroupItem: React.FC<RadioGroupItemProps>;
|
|
48
|
+
export default RadioGroupItem;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
3
|
+
var _excluded = ["label", "value", "checked", "type", "name", "selectColor", "selectTextColor", "unSelectColor", "unSelectTextColor", "onChange"];
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import "./index.scss";
|
|
6
|
+
var styleFunction = function styleFunction(type, bgColors, textColors, checked) {
|
|
7
|
+
var bgColor = checked ? bgColors[1] : bgColors[0];
|
|
8
|
+
var textColor = checked ? textColors[1] : textColors[0];
|
|
9
|
+
if (type === 'button') {
|
|
10
|
+
return {
|
|
11
|
+
'backgroundColor': bgColor,
|
|
12
|
+
'color': textColor
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
if (type === 'text') {
|
|
16
|
+
return {
|
|
17
|
+
'color': textColor,
|
|
18
|
+
'position': checked ? 'relative' : 'static'
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
return {};
|
|
22
|
+
};
|
|
23
|
+
var RadioGroupItem = function RadioGroupItem(_ref) {
|
|
24
|
+
var _ref$label = _ref.label,
|
|
25
|
+
label = _ref$label === void 0 ? '标签' : _ref$label,
|
|
26
|
+
_ref$value = _ref.value,
|
|
27
|
+
value = _ref$value === void 0 ? 'value' : _ref$value,
|
|
28
|
+
checked = _ref.checked,
|
|
29
|
+
_ref$type = _ref.type,
|
|
30
|
+
type = _ref$type === void 0 ? 'button' : _ref$type,
|
|
31
|
+
name = _ref.name,
|
|
32
|
+
_ref$selectColor = _ref.selectColor,
|
|
33
|
+
selectColor = _ref$selectColor === void 0 ? '#F5743F' : _ref$selectColor,
|
|
34
|
+
_ref$selectTextColor = _ref.selectTextColor,
|
|
35
|
+
selectTextColor = _ref$selectTextColor === void 0 ? 'white' : _ref$selectTextColor,
|
|
36
|
+
_ref$unSelectColor = _ref.unSelectColor,
|
|
37
|
+
unSelectColor = _ref$unSelectColor === void 0 ? '#F0F0F0' : _ref$unSelectColor,
|
|
38
|
+
_ref$unSelectTextColo = _ref.unSelectTextColor,
|
|
39
|
+
unSelectTextColor = _ref$unSelectTextColo === void 0 ? '#727272' : _ref$unSelectTextColo,
|
|
40
|
+
onChange = _ref.onChange,
|
|
41
|
+
otherProps = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
42
|
+
var _otherProps = otherProps || {};
|
|
43
|
+
var handleChange = function handleChange(event) {
|
|
44
|
+
onChange(event.target.value);
|
|
45
|
+
};
|
|
46
|
+
// 获取特殊的样式
|
|
47
|
+
var customStyle = styleFunction(type, [unSelectColor, selectColor], [unSelectTextColor, selectTextColor], checked);
|
|
48
|
+
if (_otherProps.style) {
|
|
49
|
+
_otherProps.style = _extends({}, _otherProps.style, customStyle);
|
|
50
|
+
} else {
|
|
51
|
+
_otherProps.style = _extends({}, customStyle);
|
|
52
|
+
}
|
|
53
|
+
var className = type === 'button' ? 'radio-group-item__button' : 'radio-group-item__text';
|
|
54
|
+
return /*#__PURE__*/React.createElement("label", _extends({
|
|
55
|
+
key: value,
|
|
56
|
+
className: className
|
|
57
|
+
}, _otherProps), type === 'text' && checked && /*#__PURE__*/React.createElement("span", {
|
|
58
|
+
className: "radio-group-item__text__line",
|
|
59
|
+
style: {
|
|
60
|
+
'background-color': selectColor
|
|
61
|
+
}
|
|
62
|
+
}), /*#__PURE__*/React.createElement("input", {
|
|
63
|
+
type: "radio",
|
|
64
|
+
style: {
|
|
65
|
+
'display': 'none'
|
|
66
|
+
},
|
|
67
|
+
name: name,
|
|
68
|
+
value: value,
|
|
69
|
+
checked: checked,
|
|
70
|
+
onChange: handleChange
|
|
71
|
+
}), label);
|
|
72
|
+
};
|
|
73
|
+
RadioGroupItem.displayName = 'RadioGroupItem';
|
|
74
|
+
export default RadioGroupItem;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './index.scss';
|
|
3
|
+
export interface RadioType {
|
|
4
|
+
label: string;
|
|
5
|
+
value: string;
|
|
6
|
+
}
|
|
7
|
+
export type RadioGroupItemType = 'button' | 'text';
|
|
8
|
+
export interface RadioGroupProps {
|
|
9
|
+
/**
|
|
10
|
+
* 选项
|
|
11
|
+
*/
|
|
12
|
+
options: Array<RadioType>;
|
|
13
|
+
/**
|
|
14
|
+
* 默认值
|
|
15
|
+
*/
|
|
16
|
+
defaultValue?: string;
|
|
17
|
+
/**
|
|
18
|
+
* 是否换行
|
|
19
|
+
*/
|
|
20
|
+
isWrap?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* 选中颜色
|
|
23
|
+
*/
|
|
24
|
+
selectColor?: string;
|
|
25
|
+
/**
|
|
26
|
+
* 选中的文字颜色
|
|
27
|
+
*/
|
|
28
|
+
selectTextColor?: string;
|
|
29
|
+
/**
|
|
30
|
+
* 未选中颜色
|
|
31
|
+
*/
|
|
32
|
+
unSelectColor?: string;
|
|
33
|
+
/**
|
|
34
|
+
* 未选中的文字颜色
|
|
35
|
+
*/
|
|
36
|
+
unSelectTextColor?: string;
|
|
37
|
+
/**
|
|
38
|
+
* 改变事件
|
|
39
|
+
* @param value
|
|
40
|
+
*/
|
|
41
|
+
onChange?: (value: string) => void;
|
|
42
|
+
/**
|
|
43
|
+
* 类型
|
|
44
|
+
*/
|
|
45
|
+
type?: RadioGroupItemType;
|
|
46
|
+
/**
|
|
47
|
+
* 名称
|
|
48
|
+
*/
|
|
49
|
+
name?: string;
|
|
50
|
+
}
|
|
51
|
+
declare const RadioGroup: React.FC<RadioGroupProps>;
|
|
52
|
+
export default RadioGroup;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
3
|
+
var _excluded = ["options", "name", "type", "defaultValue", "selectColor", "selectTextColor", "unSelectColor", "unSelectTextColor", "isWrap", "onChange", "children"];
|
|
4
|
+
import React, { useEffect, useState } from 'react';
|
|
5
|
+
import { convertChildren } from "../../utils/children-node-handle";
|
|
6
|
+
import "./index.scss";
|
|
7
|
+
function uuid() {
|
|
8
|
+
return Math.random().toString(36).substring(2);
|
|
9
|
+
}
|
|
10
|
+
var RadioGroup = function RadioGroup(_ref) {
|
|
11
|
+
var options = _ref.options,
|
|
12
|
+
_ref$name = _ref.name,
|
|
13
|
+
name = _ref$name === void 0 ? uuid() : _ref$name,
|
|
14
|
+
_ref$type = _ref.type,
|
|
15
|
+
type = _ref$type === void 0 ? 'button' : _ref$type,
|
|
16
|
+
defaultValue = _ref.defaultValue,
|
|
17
|
+
_ref$selectColor = _ref.selectColor,
|
|
18
|
+
selectColor = _ref$selectColor === void 0 ? '#F5743F' : _ref$selectColor,
|
|
19
|
+
_ref$selectTextColor = _ref.selectTextColor,
|
|
20
|
+
selectTextColor = _ref$selectTextColor === void 0 ? 'white' : _ref$selectTextColor,
|
|
21
|
+
_ref$unSelectColor = _ref.unSelectColor,
|
|
22
|
+
unSelectColor = _ref$unSelectColor === void 0 ? '#F0F0F0' : _ref$unSelectColor,
|
|
23
|
+
_ref$unSelectTextColo = _ref.unSelectTextColor,
|
|
24
|
+
unSelectTextColor = _ref$unSelectTextColo === void 0 ? '#727272' : _ref$unSelectTextColo,
|
|
25
|
+
_ref$isWrap = _ref.isWrap,
|
|
26
|
+
isWrap = _ref$isWrap === void 0 ? false : _ref$isWrap,
|
|
27
|
+
_ref$onChange = _ref.onChange,
|
|
28
|
+
onChange = _ref$onChange === void 0 ? function () {} : _ref$onChange,
|
|
29
|
+
children = _ref.children,
|
|
30
|
+
otherProps = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
31
|
+
var _otherProps = otherProps || {};
|
|
32
|
+
var _useState = useState(defaultValue || ''),
|
|
33
|
+
selectedValue = _useState[0],
|
|
34
|
+
setSelectedValue = _useState[1];
|
|
35
|
+
useEffect(function () {
|
|
36
|
+
if (defaultValue) {
|
|
37
|
+
setSelectedValue(defaultValue);
|
|
38
|
+
}
|
|
39
|
+
}, [defaultValue]);
|
|
40
|
+
var handleChange = function handleChange(value) {
|
|
41
|
+
setSelectedValue(value);
|
|
42
|
+
onChange(value);
|
|
43
|
+
};
|
|
44
|
+
var wrapClass = isWrap ? 'flex-wrap: wrap;' : 'flex-wrap: nowrap;overflow-x: auto;';
|
|
45
|
+
_otherProps.style = wrapClass + ' ' + _otherProps.style ? _otherProps.style : '';
|
|
46
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
|
47
|
+
className: "radio-group__panel"
|
|
48
|
+
}, _otherProps), options.map(function (option) {
|
|
49
|
+
return convertChildren(children, 'custom-radio-group-item', {
|
|
50
|
+
label: option.label,
|
|
51
|
+
value: option.value,
|
|
52
|
+
key: option.value,
|
|
53
|
+
checked: selectedValue === option.value,
|
|
54
|
+
name: name,
|
|
55
|
+
type: type,
|
|
56
|
+
selectColor: selectColor,
|
|
57
|
+
selectTextColor: selectTextColor,
|
|
58
|
+
unSelectColor: unSelectColor,
|
|
59
|
+
unSelectTextColor: unSelectTextColor,
|
|
60
|
+
onChange: handleChange
|
|
61
|
+
});
|
|
62
|
+
}));
|
|
63
|
+
};
|
|
64
|
+
RadioGroup.displayName = 'RadioGroup';
|
|
65
|
+
export default RadioGroup;
|
package/es/index.d.ts
CHANGED
|
@@ -32,5 +32,7 @@ export type { IntegralTaskProps } from './components/integral-task';
|
|
|
32
32
|
export { default as IntegralTask } from './components/integral-task';
|
|
33
33
|
export type { ButtonProps } from './components/button';
|
|
34
34
|
export { default as Button2 } from './components/button';
|
|
35
|
+
export type { RadioGroupProps, RadioGroupItemProps } from './components/radio-group';
|
|
36
|
+
export { CustomRadioGroup, CustomRadioGroupItem } from './components/radio-group';
|
|
35
37
|
declare const bizCssPrefix = "bizpack";
|
|
36
38
|
export { bizCssPrefix };
|
package/es/index.js
CHANGED
|
@@ -62,5 +62,9 @@ export { default as IntegralTask } from "./components/integral-task";
|
|
|
62
62
|
// 按钮
|
|
63
63
|
|
|
64
64
|
export { default as Button2 } from "./components/button";
|
|
65
|
+
|
|
66
|
+
// 单选组
|
|
67
|
+
|
|
68
|
+
export { CustomRadioGroup, CustomRadioGroupItem } from "./components/radio-group";
|
|
65
69
|
var bizCssPrefix = 'bizpack';
|
|
66
70
|
export { bizCssPrefix };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 单选按钮组
|
|
3
|
+
*/
|
|
4
|
+
import RadioGroup from './radio-group';
|
|
5
|
+
import RadioGroupItem from './radio-group-item';
|
|
6
|
+
export type { RadioGroupProps } from './radio-group';
|
|
7
|
+
export type { RadioGroupItemProps } from './radio-group-item';
|
|
8
|
+
export { RadioGroup as CustomRadioGroup, RadioGroupItem as CustomRadioGroupItem, };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
var _radioGroup = _interopRequireDefault(require("./radio-group"));
|
|
6
|
+
exports.CustomRadioGroup = _radioGroup["default"];
|
|
7
|
+
var _radioGroupItem = _interopRequireDefault(require("./radio-group-item"));
|
|
8
|
+
exports.CustomRadioGroupItem = _radioGroupItem["default"];
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
@import '../../variables.scss';
|
|
2
|
+
|
|
3
|
+
.radio-group__panel {
|
|
4
|
+
display: flex;
|
|
5
|
+
gap: 12px;
|
|
6
|
+
width: 100%;
|
|
7
|
+
|
|
8
|
+
.radio-group-item__button {
|
|
9
|
+
flex: 0 0 auto;
|
|
10
|
+
transition-property: all;
|
|
11
|
+
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
|
12
|
+
transition-duration: 250ms;
|
|
13
|
+
font-size: 12px;
|
|
14
|
+
padding: 5px 11px;
|
|
15
|
+
border-radius: 25rem;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.radio-group-item__text {
|
|
19
|
+
flex: 0 0 auto;
|
|
20
|
+
transition-property: all;
|
|
21
|
+
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
|
22
|
+
transition-duration: 250ms;
|
|
23
|
+
font-size: 12px;
|
|
24
|
+
padding: 5px 11px;
|
|
25
|
+
|
|
26
|
+
.radio-group-item__text__line {
|
|
27
|
+
width: 100%;
|
|
28
|
+
height: 1px;
|
|
29
|
+
right: 0;
|
|
30
|
+
left: 0;
|
|
31
|
+
bottom: 0;
|
|
32
|
+
position: absolute;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './index.scss';
|
|
3
|
+
export type RadioGroupItemType = 'button' | 'text';
|
|
4
|
+
export interface RadioGroupItemProps {
|
|
5
|
+
/**
|
|
6
|
+
* 选项
|
|
7
|
+
*/
|
|
8
|
+
label: string;
|
|
9
|
+
/**
|
|
10
|
+
* 值
|
|
11
|
+
*/
|
|
12
|
+
value: string;
|
|
13
|
+
/**
|
|
14
|
+
* 是否选中
|
|
15
|
+
*/
|
|
16
|
+
checked: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* 选中颜色
|
|
19
|
+
*/
|
|
20
|
+
selectColor?: string;
|
|
21
|
+
/**
|
|
22
|
+
* 选中的文字颜色
|
|
23
|
+
*/
|
|
24
|
+
selectTextColor?: string;
|
|
25
|
+
/**
|
|
26
|
+
* 未选中颜色
|
|
27
|
+
*/
|
|
28
|
+
unSelectColor?: string;
|
|
29
|
+
/**
|
|
30
|
+
* 未选中的文字颜色
|
|
31
|
+
*/
|
|
32
|
+
unSelectTextColor?: string;
|
|
33
|
+
/**
|
|
34
|
+
* 类型
|
|
35
|
+
*/
|
|
36
|
+
type?: RadioGroupItemType;
|
|
37
|
+
/**
|
|
38
|
+
* 名称
|
|
39
|
+
*/
|
|
40
|
+
name: string;
|
|
41
|
+
/**
|
|
42
|
+
* 改变事件
|
|
43
|
+
* @param value
|
|
44
|
+
*/
|
|
45
|
+
onChange: (value: string) => void;
|
|
46
|
+
}
|
|
47
|
+
declare const RadioGroupItem: React.FC<RadioGroupItemProps>;
|
|
48
|
+
export default RadioGroupItem;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports["default"] = void 0;
|
|
6
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
7
|
+
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
require("./index.scss");
|
|
10
|
+
var _excluded = ["label", "value", "checked", "type", "name", "selectColor", "selectTextColor", "unSelectColor", "unSelectTextColor", "onChange"];
|
|
11
|
+
var styleFunction = function styleFunction(type, bgColors, textColors, checked) {
|
|
12
|
+
var bgColor = checked ? bgColors[1] : bgColors[0];
|
|
13
|
+
var textColor = checked ? textColors[1] : textColors[0];
|
|
14
|
+
if (type === 'button') {
|
|
15
|
+
return {
|
|
16
|
+
'backgroundColor': bgColor,
|
|
17
|
+
'color': textColor
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
if (type === 'text') {
|
|
21
|
+
return {
|
|
22
|
+
'color': textColor,
|
|
23
|
+
'position': checked ? 'relative' : 'static'
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
return {};
|
|
27
|
+
};
|
|
28
|
+
var RadioGroupItem = function RadioGroupItem(_ref) {
|
|
29
|
+
var _ref$label = _ref.label,
|
|
30
|
+
label = _ref$label === void 0 ? '标签' : _ref$label,
|
|
31
|
+
_ref$value = _ref.value,
|
|
32
|
+
value = _ref$value === void 0 ? 'value' : _ref$value,
|
|
33
|
+
checked = _ref.checked,
|
|
34
|
+
_ref$type = _ref.type,
|
|
35
|
+
type = _ref$type === void 0 ? 'button' : _ref$type,
|
|
36
|
+
name = _ref.name,
|
|
37
|
+
_ref$selectColor = _ref.selectColor,
|
|
38
|
+
selectColor = _ref$selectColor === void 0 ? '#F5743F' : _ref$selectColor,
|
|
39
|
+
_ref$selectTextColor = _ref.selectTextColor,
|
|
40
|
+
selectTextColor = _ref$selectTextColor === void 0 ? 'white' : _ref$selectTextColor,
|
|
41
|
+
_ref$unSelectColor = _ref.unSelectColor,
|
|
42
|
+
unSelectColor = _ref$unSelectColor === void 0 ? '#F0F0F0' : _ref$unSelectColor,
|
|
43
|
+
_ref$unSelectTextColo = _ref.unSelectTextColor,
|
|
44
|
+
unSelectTextColor = _ref$unSelectTextColo === void 0 ? '#727272' : _ref$unSelectTextColo,
|
|
45
|
+
onChange = _ref.onChange,
|
|
46
|
+
otherProps = (0, _objectWithoutPropertiesLoose2["default"])(_ref, _excluded);
|
|
47
|
+
var _otherProps = otherProps || {};
|
|
48
|
+
var handleChange = function handleChange(event) {
|
|
49
|
+
onChange(event.target.value);
|
|
50
|
+
};
|
|
51
|
+
// 获取特殊的样式
|
|
52
|
+
var customStyle = styleFunction(type, [unSelectColor, selectColor], [unSelectTextColor, selectTextColor], checked);
|
|
53
|
+
if (_otherProps.style) {
|
|
54
|
+
_otherProps.style = (0, _extends2["default"])({}, _otherProps.style, customStyle);
|
|
55
|
+
} else {
|
|
56
|
+
_otherProps.style = (0, _extends2["default"])({}, customStyle);
|
|
57
|
+
}
|
|
58
|
+
var className = type === 'button' ? 'radio-group-item__button' : 'radio-group-item__text';
|
|
59
|
+
return /*#__PURE__*/_react["default"].createElement("label", (0, _extends2["default"])({
|
|
60
|
+
key: value,
|
|
61
|
+
className: className
|
|
62
|
+
}, _otherProps), type === 'text' && checked && /*#__PURE__*/_react["default"].createElement("span", {
|
|
63
|
+
className: "radio-group-item__text__line",
|
|
64
|
+
style: {
|
|
65
|
+
'background-color': selectColor
|
|
66
|
+
}
|
|
67
|
+
}), /*#__PURE__*/_react["default"].createElement("input", {
|
|
68
|
+
type: "radio",
|
|
69
|
+
style: {
|
|
70
|
+
'display': 'none'
|
|
71
|
+
},
|
|
72
|
+
name: name,
|
|
73
|
+
value: value,
|
|
74
|
+
checked: checked,
|
|
75
|
+
onChange: handleChange
|
|
76
|
+
}), label);
|
|
77
|
+
};
|
|
78
|
+
RadioGroupItem.displayName = 'RadioGroupItem';
|
|
79
|
+
var _default = exports["default"] = RadioGroupItem;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './index.scss';
|
|
3
|
+
export interface RadioType {
|
|
4
|
+
label: string;
|
|
5
|
+
value: string;
|
|
6
|
+
}
|
|
7
|
+
export type RadioGroupItemType = 'button' | 'text';
|
|
8
|
+
export interface RadioGroupProps {
|
|
9
|
+
/**
|
|
10
|
+
* 选项
|
|
11
|
+
*/
|
|
12
|
+
options: Array<RadioType>;
|
|
13
|
+
/**
|
|
14
|
+
* 默认值
|
|
15
|
+
*/
|
|
16
|
+
defaultValue?: string;
|
|
17
|
+
/**
|
|
18
|
+
* 是否换行
|
|
19
|
+
*/
|
|
20
|
+
isWrap?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* 选中颜色
|
|
23
|
+
*/
|
|
24
|
+
selectColor?: string;
|
|
25
|
+
/**
|
|
26
|
+
* 选中的文字颜色
|
|
27
|
+
*/
|
|
28
|
+
selectTextColor?: string;
|
|
29
|
+
/**
|
|
30
|
+
* 未选中颜色
|
|
31
|
+
*/
|
|
32
|
+
unSelectColor?: string;
|
|
33
|
+
/**
|
|
34
|
+
* 未选中的文字颜色
|
|
35
|
+
*/
|
|
36
|
+
unSelectTextColor?: string;
|
|
37
|
+
/**
|
|
38
|
+
* 改变事件
|
|
39
|
+
* @param value
|
|
40
|
+
*/
|
|
41
|
+
onChange?: (value: string) => void;
|
|
42
|
+
/**
|
|
43
|
+
* 类型
|
|
44
|
+
*/
|
|
45
|
+
type?: RadioGroupItemType;
|
|
46
|
+
/**
|
|
47
|
+
* 名称
|
|
48
|
+
*/
|
|
49
|
+
name?: string;
|
|
50
|
+
}
|
|
51
|
+
declare const RadioGroup: React.FC<RadioGroupProps>;
|
|
52
|
+
export default RadioGroup;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports["default"] = void 0;
|
|
6
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
7
|
+
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _childrenNodeHandle = require("../../utils/children-node-handle");
|
|
10
|
+
require("./index.scss");
|
|
11
|
+
var _excluded = ["options", "name", "type", "defaultValue", "selectColor", "selectTextColor", "unSelectColor", "unSelectTextColor", "isWrap", "onChange", "children"];
|
|
12
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
13
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
14
|
+
function uuid() {
|
|
15
|
+
return Math.random().toString(36).substring(2);
|
|
16
|
+
}
|
|
17
|
+
var RadioGroup = function RadioGroup(_ref) {
|
|
18
|
+
var options = _ref.options,
|
|
19
|
+
_ref$name = _ref.name,
|
|
20
|
+
name = _ref$name === void 0 ? uuid() : _ref$name,
|
|
21
|
+
_ref$type = _ref.type,
|
|
22
|
+
type = _ref$type === void 0 ? 'button' : _ref$type,
|
|
23
|
+
defaultValue = _ref.defaultValue,
|
|
24
|
+
_ref$selectColor = _ref.selectColor,
|
|
25
|
+
selectColor = _ref$selectColor === void 0 ? '#F5743F' : _ref$selectColor,
|
|
26
|
+
_ref$selectTextColor = _ref.selectTextColor,
|
|
27
|
+
selectTextColor = _ref$selectTextColor === void 0 ? 'white' : _ref$selectTextColor,
|
|
28
|
+
_ref$unSelectColor = _ref.unSelectColor,
|
|
29
|
+
unSelectColor = _ref$unSelectColor === void 0 ? '#F0F0F0' : _ref$unSelectColor,
|
|
30
|
+
_ref$unSelectTextColo = _ref.unSelectTextColor,
|
|
31
|
+
unSelectTextColor = _ref$unSelectTextColo === void 0 ? '#727272' : _ref$unSelectTextColo,
|
|
32
|
+
_ref$isWrap = _ref.isWrap,
|
|
33
|
+
isWrap = _ref$isWrap === void 0 ? false : _ref$isWrap,
|
|
34
|
+
_ref$onChange = _ref.onChange,
|
|
35
|
+
onChange = _ref$onChange === void 0 ? function () {} : _ref$onChange,
|
|
36
|
+
children = _ref.children,
|
|
37
|
+
otherProps = (0, _objectWithoutPropertiesLoose2["default"])(_ref, _excluded);
|
|
38
|
+
var _otherProps = otherProps || {};
|
|
39
|
+
var _useState = (0, _react.useState)(defaultValue || ''),
|
|
40
|
+
selectedValue = _useState[0],
|
|
41
|
+
setSelectedValue = _useState[1];
|
|
42
|
+
(0, _react.useEffect)(function () {
|
|
43
|
+
if (defaultValue) {
|
|
44
|
+
setSelectedValue(defaultValue);
|
|
45
|
+
}
|
|
46
|
+
}, [defaultValue]);
|
|
47
|
+
var handleChange = function handleChange(value) {
|
|
48
|
+
setSelectedValue(value);
|
|
49
|
+
onChange(value);
|
|
50
|
+
};
|
|
51
|
+
var wrapClass = isWrap ? 'flex-wrap: wrap;' : 'flex-wrap: nowrap;overflow-x: auto;';
|
|
52
|
+
_otherProps.style = wrapClass + ' ' + _otherProps.style ? _otherProps.style : '';
|
|
53
|
+
return /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({
|
|
54
|
+
className: "radio-group__panel"
|
|
55
|
+
}, _otherProps), options.map(function (option) {
|
|
56
|
+
return (0, _childrenNodeHandle.convertChildren)(children, 'custom-radio-group-item', {
|
|
57
|
+
label: option.label,
|
|
58
|
+
value: option.value,
|
|
59
|
+
key: option.value,
|
|
60
|
+
checked: selectedValue === option.value,
|
|
61
|
+
name: name,
|
|
62
|
+
type: type,
|
|
63
|
+
selectColor: selectColor,
|
|
64
|
+
selectTextColor: selectTextColor,
|
|
65
|
+
unSelectColor: unSelectColor,
|
|
66
|
+
unSelectTextColor: unSelectTextColor,
|
|
67
|
+
onChange: handleChange
|
|
68
|
+
});
|
|
69
|
+
}));
|
|
70
|
+
};
|
|
71
|
+
RadioGroup.displayName = 'RadioGroup';
|
|
72
|
+
var _default = exports["default"] = RadioGroup;
|
package/lib/index.d.ts
CHANGED
|
@@ -32,5 +32,7 @@ export type { IntegralTaskProps } from './components/integral-task';
|
|
|
32
32
|
export { default as IntegralTask } from './components/integral-task';
|
|
33
33
|
export type { ButtonProps } from './components/button';
|
|
34
34
|
export { default as Button2 } from './components/button';
|
|
35
|
+
export type { RadioGroupProps, RadioGroupItemProps } from './components/radio-group';
|
|
36
|
+
export { CustomRadioGroup, CustomRadioGroupItem } from './components/radio-group';
|
|
35
37
|
declare const bizCssPrefix = "bizpack";
|
|
36
38
|
export { bizCssPrefix };
|
package/lib/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
exports.__esModule = true;
|
|
5
|
-
exports.bizCssPrefix = exports.Title2 = exports.Title1 = exports.TeletextList = exports.TagC = exports.TabMessage = exports.TabContainerItem = exports.TabContainer = exports.Swiper = exports.SearchBar = exports.Position = exports.NoticeBar = exports.Navigation = exports.MessageList = exports.MenuList = exports.IntegralTask = exports.GridNav = exports.Button2 = void 0;
|
|
5
|
+
exports.bizCssPrefix = exports.Title2 = exports.Title1 = exports.TeletextList = exports.TagC = exports.TabMessage = exports.TabContainerItem = exports.TabContainer = exports.Swiper = exports.SearchBar = exports.Position = exports.NoticeBar = exports.Navigation = exports.MessageList = exports.MenuList = exports.IntegralTask = exports.GridNav = exports.CustomRadioGroupItem = exports.CustomRadioGroup = exports.Button2 = void 0;
|
|
6
6
|
var _swiper = _interopRequireDefault(require("./components/swiper"));
|
|
7
7
|
exports.Swiper = _swiper["default"];
|
|
8
8
|
var _bottomNavigation = _interopRequireDefault(require("./components/bottom-navigation"));
|
|
@@ -36,6 +36,9 @@ var _integralTask = _interopRequireDefault(require("./components/integral-task")
|
|
|
36
36
|
exports.IntegralTask = _integralTask["default"];
|
|
37
37
|
var _button = _interopRequireDefault(require("./components/button"));
|
|
38
38
|
exports.Button2 = _button["default"];
|
|
39
|
+
var _radioGroup = require("./components/radio-group");
|
|
40
|
+
exports.CustomRadioGroup = _radioGroup.CustomRadioGroup;
|
|
41
|
+
exports.CustomRadioGroupItem = _radioGroup.CustomRadioGroupItem;
|
|
39
42
|
// 轮播图
|
|
40
43
|
|
|
41
44
|
// 底部导航
|
|
@@ -70,4 +73,6 @@ exports.Button2 = _button["default"];
|
|
|
70
73
|
|
|
71
74
|
// 按钮
|
|
72
75
|
|
|
76
|
+
// 单选组
|
|
77
|
+
|
|
73
78
|
var bizCssPrefix = exports.bizCssPrefix = 'bizpack';
|