@_nu/react-switch
Advanced tools
+6
-0
@@ -6,2 +6,8 @@ # Change Log | ||
| ## [0.1.7](https://github.com/nu-system/react/compare/@_nu/react-switch@0.1.6...@_nu/react-switch@0.1.7) (2020-12-14) | ||
| ### Bug Fixes | ||
| - switch 添加 componentsProps ([66582e8](https://github.com/nu-system/react/commit/66582e8db328d267c7dfed14239f4f9378b9277f)) | ||
| ## [0.1.6](https://github.com/nu-system/react/compare/@_nu/react-switch@0.1.5...@_nu/react-switch@0.1.6) (2020-08-18) | ||
@@ -8,0 +14,0 @@ |
+1
-0
@@ -15,4 +15,5 @@ import * as React from 'react'; | ||
| type?: 'checkbox' | 'radio'; | ||
| componentProps?: {}; | ||
| } | ||
| declare const _default: (props?: ComponentProps) => JSX.Element; | ||
| export default _default; |
+121
-33
@@ -1,8 +0,65 @@ | ||
| function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
| function _extends() { | ||
| _extends = | ||
| Object.assign || | ||
| function (target) { | ||
| for (var i = 1; i < arguments.length; i++) { | ||
| var source = arguments[i]; | ||
| for (var key in source) { | ||
| if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
| target[key] = source[key]; | ||
| } | ||
| } | ||
| } | ||
| return target; | ||
| }; | ||
| return _extends.apply(this, arguments); | ||
| } | ||
| function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
| function _typeof(obj) { | ||
| '@babel/helpers - typeof'; | ||
| if (typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol') { | ||
| _typeof = function _typeof(obj) { | ||
| return typeof obj; | ||
| }; | ||
| } else { | ||
| _typeof = function _typeof(obj) { | ||
| return obj && | ||
| typeof Symbol === 'function' && | ||
| obj.constructor === Symbol && | ||
| obj !== Symbol.prototype | ||
| ? 'symbol' | ||
| : typeof obj; | ||
| }; | ||
| } | ||
| return _typeof(obj); | ||
| } | ||
| function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } | ||
| function _objectWithoutProperties(source, excluded) { | ||
| if (source == null) return {}; | ||
| var target = _objectWithoutPropertiesLoose(source, excluded); | ||
| var key, i; | ||
| if (Object.getOwnPropertySymbols) { | ||
| var sourceSymbolKeys = Object.getOwnPropertySymbols(source); | ||
| for (i = 0; i < sourceSymbolKeys.length; i++) { | ||
| key = sourceSymbolKeys[i]; | ||
| if (excluded.indexOf(key) >= 0) continue; | ||
| if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; | ||
| target[key] = source[key]; | ||
| } | ||
| } | ||
| return target; | ||
| } | ||
| function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } | ||
| function _objectWithoutPropertiesLoose(source, excluded) { | ||
| if (source == null) return {}; | ||
| var target = {}; | ||
| var sourceKeys = Object.keys(source); | ||
| var key, i; | ||
| for (i = 0; i < sourceKeys.length; i++) { | ||
| key = sourceKeys[i]; | ||
| if (excluded.indexOf(key) >= 0) continue; | ||
| target[key] = source[key]; | ||
| } | ||
| return target; | ||
| } | ||
@@ -24,6 +81,7 @@ /** | ||
| */ | ||
| // eslint-disable-next-line react/prop-types | ||
| var RenderIcon = function RenderIcon(_ref) { | ||
| var Icon = _ref.Icon, | ||
| props = _objectWithoutProperties(_ref, ["Icon"]); | ||
| props = _objectWithoutProperties(_ref, ['Icon']); | ||
@@ -34,3 +92,5 @@ if (!Icon) { | ||
| return _typeof(Icon) === 'object' ? React.cloneElement(Icon, props) : /*#__PURE__*/React.createElement(Icon, props); | ||
| return _typeof(Icon) === 'object' | ||
| ? React.cloneElement(Icon, props) | ||
| : /*#__PURE__*/ React.createElement(Icon, props); | ||
| }; | ||
@@ -51,24 +111,49 @@ /** | ||
| var NuSwitch = React.forwardRef(function NuSwitch(_ref2, ref) { | ||
| var Component = _ref2.Component, | ||
| Icon = _ref2.Icon, | ||
| type = _ref2.type, | ||
| children = _ref2.children, | ||
| className = _ref2.className, | ||
| classNameInput = _ref2.classNameInput, | ||
| defaultClass = _ref2.defaultClass, | ||
| otherProps = _objectWithoutProperties(_ref2, ["Component", "Icon", "type", "children", "className", "classNameInput", "defaultClass"]); | ||
| Icon = _ref2.Icon, | ||
| type = _ref2.type, | ||
| children = _ref2.children, | ||
| _ref2$className = _ref2.className, | ||
| className = _ref2$className === void 0 ? '' : _ref2$className, | ||
| classNameInput = _ref2.classNameInput, | ||
| defaultClass = _ref2.defaultClass, | ||
| componentProps = _ref2.componentProps, | ||
| otherProps = _objectWithoutProperties(_ref2, [ | ||
| 'Component', | ||
| 'Icon', | ||
| 'type', | ||
| 'children', | ||
| 'className', | ||
| 'classNameInput', | ||
| 'defaultClass', | ||
| 'componentProps', | ||
| ]); | ||
| return /*#__PURE__*/React.createElement(Component, { | ||
| className: classNames(defaultClass.component, className) | ||
| }, /*#__PURE__*/React.createElement("input", _extends({ | ||
| className: classNames(defaultClass.input, classNameInput), | ||
| ref: ref, | ||
| type: type | ||
| }, otherProps)), /*#__PURE__*/React.createElement(RenderIcon, { | ||
| Icon: Icon, | ||
| checked: otherProps.checked, | ||
| disabeld: otherProps.disabeld | ||
| }), children); | ||
| return /*#__PURE__*/ React.createElement( | ||
| Component, | ||
| _extends( | ||
| { | ||
| className: classNames(defaultClass.component, className), | ||
| }, | ||
| componentProps, | ||
| ), | ||
| /*#__PURE__*/ React.createElement( | ||
| 'input', | ||
| _extends( | ||
| { | ||
| className: classNames(defaultClass.input, classNameInput), | ||
| ref: ref, | ||
| type: type, | ||
| }, | ||
| otherProps, | ||
| ), | ||
| ), | ||
| /*#__PURE__*/ React.createElement(RenderIcon, { | ||
| Icon: Icon, | ||
| checked: otherProps.checked, | ||
| disabeld: otherProps.disabeld, | ||
| }), | ||
| children, | ||
| ); | ||
| }); | ||
@@ -78,12 +163,12 @@ NuSwitch.defaultProps = { | ||
| component: 'nu_switch', | ||
| input: '_input' | ||
| input: '_input', | ||
| }, | ||
| Component: 'label', | ||
| Icon: /*#__PURE__*/React.createElement("i", { | ||
| className: "_icon" | ||
| Icon: /*#__PURE__*/ React.createElement('i', { | ||
| className: '_icon', | ||
| }), | ||
| type: 'checkbox', | ||
| children: null, | ||
| className: '', | ||
| classNameInput: '' | ||
| classNameInput: '', | ||
| componentProps: {}, | ||
| }; | ||
@@ -94,3 +179,3 @@ NuSwitch.propTypes = { | ||
| component: PropTypes.string, | ||
| input: PropTypes.string | ||
| input: PropTypes.string, | ||
| }), | ||
@@ -110,5 +195,8 @@ | ||
| /** 容器组件的 props */ | ||
| componentProps: PropTypes.object, | ||
| /** 图标 */ | ||
| Icon: PropTypes.oneOfType([PropTypes.node, PropTypes.func]) | ||
| Icon: PropTypes.oneOfType([PropTypes.node, PropTypes.func]), | ||
| }; | ||
| export default NuSwitch; | ||
| export default NuSwitch; |
+1
-0
@@ -15,4 +15,5 @@ import * as React from 'react'; | ||
| type?: 'checkbox' | 'radio'; | ||
| componentProps?: {}; | ||
| } | ||
| declare const _default: (props?: ComponentProps) => JSX.Element; | ||
| export default _default; |
+12
-6
@@ -31,2 +31,3 @@ "use strict"; | ||
| */ | ||
| // eslint-disable-next-line react/prop-types | ||
| var RenderIcon = function RenderIcon(_ref) { | ||
@@ -62,10 +63,12 @@ var Icon = _ref.Icon, | ||
| children = _ref2.children, | ||
| className = _ref2.className, | ||
| _ref2$className = _ref2.className, | ||
| className = _ref2$className === void 0 ? '' : _ref2$className, | ||
| classNameInput = _ref2.classNameInput, | ||
| defaultClass = _ref2.defaultClass, | ||
| otherProps = _objectWithoutProperties(_ref2, ["Component", "Icon", "type", "children", "className", "classNameInput", "defaultClass"]); | ||
| componentProps = _ref2.componentProps, | ||
| otherProps = _objectWithoutProperties(_ref2, ["Component", "Icon", "type", "children", "className", "classNameInput", "defaultClass", "componentProps"]); | ||
| return /*#__PURE__*/_react.default.createElement(Component, { | ||
| return /*#__PURE__*/_react.default.createElement(Component, _extends({ | ||
| className: (0, _classnames.default)(defaultClass.component, className) | ||
| }, /*#__PURE__*/_react.default.createElement("input", _extends({ | ||
| }, componentProps), /*#__PURE__*/_react.default.createElement("input", _extends({ | ||
| className: (0, _classnames.default)(defaultClass.input, classNameInput), | ||
@@ -92,4 +95,4 @@ ref: ref, | ||
| children: null, | ||
| className: '', | ||
| classNameInput: '' | ||
| classNameInput: '', | ||
| componentProps: {} | ||
| }; | ||
@@ -115,2 +118,5 @@ NuSwitch.propTypes = { | ||
| /** 容器组件的 props */ | ||
| componentProps: _propTypes.default.object, | ||
| /** 图标 */ | ||
@@ -117,0 +123,0 @@ Icon: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]) |
+2
-2
| { | ||
| "name": "@_nu/react-switch", | ||
| "version": "0.1.6", | ||
| "version": "0.1.7", | ||
| "description": "No UI dependency switch of react", | ||
@@ -48,3 +48,3 @@ "main": "lib/index.js", | ||
| }, | ||
| "gitHead": "45e70088c55e1d9b5fa29e684e2c090ea8f84830" | ||
| "gitHead": "a4af0435326d547b7eb090ac2ce1d5e030e84607" | ||
| } |
+1
-0
@@ -15,4 +15,5 @@ import * as React from 'react'; | ||
| type?: 'checkbox' | 'radio'; | ||
| componentProps?: {}; | ||
| } | ||
| declare const _default: (props?: ComponentProps) => JSX.Element; | ||
| export default _default; |
+11
-3
@@ -17,2 +17,3 @@ /** | ||
| */ | ||
| // eslint-disable-next-line react/prop-types | ||
| const RenderIcon = ({ Icon, ...props }) => { | ||
@@ -48,5 +49,7 @@ if (!Icon) { | ||
| children, | ||
| className, | ||
| // eslint-disable-next-line react/prop-types | ||
| className = '', | ||
| classNameInput, | ||
| defaultClass, | ||
| componentProps, | ||
| ...otherProps | ||
@@ -57,3 +60,6 @@ }, | ||
| return ( | ||
| <Component className={classNames(defaultClass.component, className)}> | ||
| <Component | ||
| className={classNames(defaultClass.component, className)} | ||
| {...componentProps} | ||
| > | ||
| <input | ||
@@ -84,4 +90,4 @@ className={classNames(defaultClass.input, classNameInput)} | ||
| children: null, | ||
| className: '', | ||
| classNameInput: '', | ||
| componentProps: {}, | ||
| }; | ||
@@ -103,2 +109,4 @@ | ||
| Component: PropTypes.node, | ||
| /** 容器组件的 props */ | ||
| componentProps: PropTypes.object, | ||
| /** 图标 */ | ||
@@ -105,0 +113,0 @@ Icon: PropTypes.oneOfType([PropTypes.node, PropTypes.func]), |
18759
9.06%457
28.37%