rc-segmented
Advanced tools
Comparing version 1.2.1 to 1.3.0
@@ -9,2 +9,6 @@ import * as React from 'react'; | ||
value: SegmentedRawOption; | ||
/** | ||
* html `title` property for label | ||
*/ | ||
title?: string; | ||
} | ||
@@ -11,0 +15,0 @@ declare type SegmentedOptions = (SegmentedRawOption | SegmentedLabeledOption)[]; |
@@ -1,5 +0,5 @@ | ||
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2"; | ||
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray"; | ||
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties"; | ||
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; | ||
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2"; | ||
import _typeof from "@babel/runtime/helpers/esm/typeof"; | ||
@@ -14,6 +14,22 @@ var _excluded = ["prefixCls", "direction", "options", "disabled", "defaultValue", "value", "onChange", "className", "motionName"]; | ||
function getValidTitle(option) { | ||
if (typeof option.title !== 'undefined') { | ||
return option.title; | ||
} // read `label` when title is `undefined` | ||
if (_typeof(option.label) !== 'object') { | ||
var _option$label; | ||
return (_option$label = option.label) === null || _option$label === void 0 ? void 0 : _option$label.toString(); | ||
} | ||
} | ||
function normalizeOptions(options) { | ||
return options.map(function (option) { | ||
if (_typeof(option) === 'object') { | ||
return option || {}; | ||
if (_typeof(option) === 'object' && option !== null) { | ||
var validTitle = getValidTitle(option); | ||
return _objectSpread(_objectSpread({}, option), {}, { | ||
title: validTitle | ||
}); | ||
} | ||
@@ -23,2 +39,3 @@ | ||
label: option === null || option === void 0 ? void 0 : option.toString(), | ||
title: option === null || option === void 0 ? void 0 : option.toString(), | ||
value: option | ||
@@ -42,2 +59,3 @@ }; | ||
label = _ref.label, | ||
title = _ref.title, | ||
value = _ref.value, | ||
@@ -63,3 +81,4 @@ onChange = _ref.onChange; | ||
}), /*#__PURE__*/React.createElement("div", { | ||
className: "".concat(prefixCls, "-item-label") | ||
className: "".concat(prefixCls, "-item-label"), | ||
title: title | ||
}, label)); | ||
@@ -66,0 +85,0 @@ }; |
@@ -9,2 +9,6 @@ import * as React from 'react'; | ||
value: SegmentedRawOption; | ||
/** | ||
* html `title` property for label | ||
*/ | ||
title?: string; | ||
} | ||
@@ -11,0 +15,0 @@ declare type SegmentedOptions = (SegmentedRawOption | SegmentedLabeledOption)[]; |
@@ -12,4 +12,2 @@ "use strict"; | ||
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2")); | ||
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray")); | ||
@@ -21,2 +19,4 @@ | ||
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2")); | ||
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")); | ||
@@ -38,6 +38,22 @@ | ||
function getValidTitle(option) { | ||
if (typeof option.title !== 'undefined') { | ||
return option.title; | ||
} // read `label` when title is `undefined` | ||
if ((0, _typeof2.default)(option.label) !== 'object') { | ||
var _option$label; | ||
return (_option$label = option.label) === null || _option$label === void 0 ? void 0 : _option$label.toString(); | ||
} | ||
} | ||
function normalizeOptions(options) { | ||
return options.map(function (option) { | ||
if ((0, _typeof2.default)(option) === 'object') { | ||
return option || {}; | ||
if ((0, _typeof2.default)(option) === 'object' && option !== null) { | ||
var validTitle = getValidTitle(option); | ||
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, option), {}, { | ||
title: validTitle | ||
}); | ||
} | ||
@@ -47,2 +63,3 @@ | ||
label: option === null || option === void 0 ? void 0 : option.toString(), | ||
title: option === null || option === void 0 ? void 0 : option.toString(), | ||
value: option | ||
@@ -66,2 +83,3 @@ }; | ||
label = _ref.label, | ||
title = _ref.title, | ||
value = _ref.value, | ||
@@ -87,3 +105,4 @@ onChange = _ref.onChange; | ||
}), /*#__PURE__*/React.createElement("div", { | ||
className: "".concat(prefixCls, "-item-label") | ||
className: "".concat(prefixCls, "-item-label"), | ||
title: title | ||
}, label)); | ||
@@ -90,0 +109,0 @@ }; |
{ | ||
"name": "rc-segmented", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"description": "React segmented controls used in ant.design", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
40728
563