@hi-ui/badge
Advanced tools
Comparing version 4.0.6 to 4.0.7
# @hi-ui/badge | ||
## 4.0.7 | ||
### Patch Changes | ||
- [#2672](https://github.com/XiaoMi/hiui/pull/2672) [`1ebe27830`](https://github.com/XiaoMi/hiui/commit/1ebe2783098b3a8cd980bd10076d67635463800e) Thanks [@zyprepare](https://github.com/zyprepare)! - build: 升级到 rollup3,重新构建发布组件 | ||
- Updated dependencies [[`1ebe27830`](https://github.com/XiaoMi/hiui/commit/1ebe2783098b3a8cd980bd10076d67635463800e)]: | ||
- @hi-ui/core@4.0.6 | ||
- @hi-ui/classname@4.0.2 | ||
- @hi-ui/env@4.0.2 | ||
- @hi-ui/type-assertion@4.0.2 | ||
## 4.0.6 | ||
@@ -4,0 +16,0 @@ |
@@ -13,30 +13,10 @@ /** @LICENSE | ||
var _typeof = require("@babel/runtime/helpers/typeof"); | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
var tslib = require('tslib'); | ||
var React = require('react'); | ||
var classname = require('@hi-ui/classname'); | ||
var env = require('@hi-ui/env'); | ||
var typeAssertion = require('@hi-ui/type-assertion'); | ||
var types = require('./types.js'); | ||
function _interopDefaultLegacy(e) { | ||
return e && _typeof(e) === 'object' && 'default' in e ? e : { | ||
'default': e | ||
}; | ||
} | ||
var React__default = /*#__PURE__*/_interopDefaultLegacy(React); | ||
var _prefix = classname.getPrefixCls('badge'); // 支持字符串和 number hover 显示,其他过滤 | ||
var _prefix = classname.getPrefixCls('badge'); | ||
// 支持字符串和 number hover 显示,其他过滤 | ||
var getShowContent = function getShowContent(content) { | ||
@@ -55,21 +35,18 @@ if (!['number', 'string'].includes(_typeof(content))) return ""; | ||
*/ | ||
var Badge = /*#__PURE__*/React.forwardRef(function (_a, ref) { | ||
var _a$prefixCls = _a.prefixCls, | ||
prefixCls = _a$prefixCls === void 0 ? _prefix : _a$prefixCls, | ||
className = _a.className, | ||
children = _a.children, | ||
_a$type = _a.type, | ||
type = _a$type === void 0 ? 'bubble' : _a$type, | ||
_a$max = _a.max, | ||
max = _a$max === void 0 ? 99 : _a$max, | ||
offset = _a.offset, | ||
content = _a.content, | ||
color = _a.color, | ||
_a$visible = _a.visible, | ||
visible = _a$visible === void 0 ? true : _a$visible, | ||
style = _a.style, | ||
rest = tslib.__rest(_a, ["prefixCls", "className", "children", "type", "max", "offset", "content", "color", "visible", "style"]); | ||
prefixCls = _a$prefixCls === void 0 ? _prefix : _a$prefixCls, | ||
className = _a.className, | ||
children = _a.children, | ||
_a$type = _a.type, | ||
type = _a$type === void 0 ? 'bubble' : _a$type, | ||
_a$max = _a.max, | ||
max = _a$max === void 0 ? 99 : _a$max, | ||
offset = _a.offset, | ||
content = _a.content, | ||
color = _a.color, | ||
_a$visible = _a.visible, | ||
visible = _a$visible === void 0 ? true : _a$visible, | ||
style = _a.style, | ||
rest = tslib.__rest(_a, ["prefixCls", "className", "children", "type", "max", "offset", "content", "color", "visible", "style"]); | ||
var badgeStyle = React.useMemo(function () { | ||
@@ -79,3 +56,2 @@ var style = { | ||
}; | ||
if (Array.isArray(offset)) { | ||
@@ -87,3 +63,2 @@ env.invariant(typeof offset[0] === 'number', 'The offset[0] prop should be number type.'); | ||
} | ||
return style; | ||
@@ -93,3 +68,2 @@ }, [offset, color]); | ||
if (typeof content !== 'number') return content; | ||
if (typeof max !== 'number') { | ||
@@ -99,3 +73,2 @@ env.invariant(false, 'The max prop should be number.'); | ||
} | ||
return content > max ? max + "+" : content; | ||
@@ -105,3 +78,3 @@ }, [content, max]); | ||
if (type === types.BadgeTypeEnum.DOT) { | ||
return /*#__PURE__*/React__default["default"].createElement("span", { | ||
return /*#__PURE__*/React.createElement("span", { | ||
className: prefixCls + "__dot", | ||
@@ -111,3 +84,2 @@ style: badgeStyle | ||
} | ||
if ( /*#__PURE__*/React.isValidElement(count)) { | ||
@@ -121,4 +93,3 @@ return /*#__PURE__*/React.cloneElement(count, { | ||
} | ||
return /*#__PURE__*/React__default["default"].createElement("span", { | ||
return /*#__PURE__*/React.createElement("span", { | ||
className: prefixCls + "__value", | ||
@@ -131,3 +102,3 @@ style: badgeStyle, | ||
var cls = classname.cx(prefixCls, className, typeAssertion.isNullish(children) && prefixCls + "--independent"); | ||
return /*#__PURE__*/React__default["default"].createElement("span", Object.assign({ | ||
return /*#__PURE__*/React.createElement("span", Object.assign({ | ||
ref: ref, | ||
@@ -138,7 +109,5 @@ className: cls, | ||
}); | ||
if (env.__DEV__) { | ||
Badge.displayName = 'Badge'; | ||
} | ||
exports.Badge = Badge; |
@@ -15,11 +15,7 @@ /** @LICENSE | ||
}); | ||
require('./styles/index.scss.js'); | ||
var Badge = require('./Badge.js'); | ||
var types = require('./types.js'); | ||
exports.Badge = Badge.Badge; | ||
exports["default"] = Badge.Badge; | ||
exports.BadgeTypeEnum = types.BadgeTypeEnum; |
@@ -16,7 +16,4 @@ /** @LICENSE | ||
var css_248z = ".hi-v4-badge {-webkit-box-sizing: border-box;box-sizing: border-box;margin: 0;padding: 0;border: none;outline: none;font-size: var(--hi-v4-text-size-md, 0.875rem);vertical-align: middle;display: inline-block;position: relative;line-height: 1;}.hi-v4-badge__value {-webkit-transform: translateX(50%);transform: translateX(50%);position: absolute;z-index: 1;right: 0;top: calc(-12px);min-width: 8px;height: 20px;line-height: 20px;padding: 0 var(--hi-v4-spacing-3, 6px);color: var(--hi-v4-color-static-white, #fff);font-size: var(--hi-v4-text-size-sm, 0.75rem);letter-spacing: 0;text-align: center;border: var(--hi-v4-border-size-semibold, 2px solid) var(--hi-v4-color-static-white, #fff);background-color: var(--hi-v4-color-danger-500, var(--hi-v4-color-red-500, #ff5959));border-radius: var(--hi-v4-border-radius-full, 9999px);-webkit-box-sizing: content-box;box-sizing: content-box;}.hi-v4-badge__dot {position: absolute;z-index: 1;top: calc(-7px);right: calc(-7px);width: 10px;height: 10px;background-color: var(--hi-v4-color-danger-500, var(--hi-v4-color-red-500, #ff5959));border: var(--hi-v4-border-size-semibold, 2px solid) var(--hi-v4-color-static-white, #fff);border-radius: var(--hi-v4-border-radius-full, 9999px);-webkit-box-sizing: content-box;box-sizing: content-box;}.hi-v4-badge__custom {-webkit-transform: translate(50%, -50%);transform: translate(50%, -50%);position: absolute;top: 0;right: 0;z-index: 1;}.hi-v4-badge--independent .hi-v4-badge__dot,.hi-v4-badge--independent .hi-v4-badge__value,.hi-v4-badge--independent .hi-v4-badge__custom {position: relative;top: auto;right: auto;-webkit-transform: none;transform: none;display: block;}"; | ||
var __styleInject__ = require('style-inject')["default"]; | ||
__styleInject__(css_248z); | ||
exports["default"] = css_248z; |
@@ -12,5 +12,2 @@ /** @LICENSE | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
var BadgeTypeEnum = { | ||
@@ -17,0 +14,0 @@ DOT: 'dot', |
import _typeof from "@babel/runtime/helpers/esm/typeof"; | ||
/** @LICENSE | ||
@@ -18,6 +17,4 @@ * @hi-ui/badge | ||
import { BadgeTypeEnum } from './types.js'; | ||
var _prefix = getPrefixCls('badge'); // 支持字符串和 number hover 显示,其他过滤 | ||
var _prefix = getPrefixCls('badge'); | ||
// 支持字符串和 number hover 显示,其他过滤 | ||
var getShowContent = function getShowContent(content) { | ||
@@ -36,21 +33,18 @@ if (!['number', 'string'].includes(_typeof(content))) return ""; | ||
*/ | ||
var Badge = /*#__PURE__*/forwardRef(function (_a, ref) { | ||
var _a$prefixCls = _a.prefixCls, | ||
prefixCls = _a$prefixCls === void 0 ? _prefix : _a$prefixCls, | ||
className = _a.className, | ||
children = _a.children, | ||
_a$type = _a.type, | ||
type = _a$type === void 0 ? 'bubble' : _a$type, | ||
_a$max = _a.max, | ||
max = _a$max === void 0 ? 99 : _a$max, | ||
offset = _a.offset, | ||
content = _a.content, | ||
color = _a.color, | ||
_a$visible = _a.visible, | ||
visible = _a$visible === void 0 ? true : _a$visible, | ||
style = _a.style, | ||
rest = __rest(_a, ["prefixCls", "className", "children", "type", "max", "offset", "content", "color", "visible", "style"]); | ||
prefixCls = _a$prefixCls === void 0 ? _prefix : _a$prefixCls, | ||
className = _a.className, | ||
children = _a.children, | ||
_a$type = _a.type, | ||
type = _a$type === void 0 ? 'bubble' : _a$type, | ||
_a$max = _a.max, | ||
max = _a$max === void 0 ? 99 : _a$max, | ||
offset = _a.offset, | ||
content = _a.content, | ||
color = _a.color, | ||
_a$visible = _a.visible, | ||
visible = _a$visible === void 0 ? true : _a$visible, | ||
style = _a.style, | ||
rest = __rest(_a, ["prefixCls", "className", "children", "type", "max", "offset", "content", "color", "visible", "style"]); | ||
var badgeStyle = useMemo(function () { | ||
@@ -60,3 +54,2 @@ var style = { | ||
}; | ||
if (Array.isArray(offset)) { | ||
@@ -68,3 +61,2 @@ invariant(typeof offset[0] === 'number', 'The offset[0] prop should be number type.'); | ||
} | ||
return style; | ||
@@ -74,3 +66,2 @@ }, [offset, color]); | ||
if (typeof content !== 'number') return content; | ||
if (typeof max !== 'number') { | ||
@@ -80,3 +71,2 @@ invariant(false, 'The max prop should be number.'); | ||
} | ||
return content > max ? max + "+" : content; | ||
@@ -91,3 +81,2 @@ }, [content, max]); | ||
} | ||
if ( /*#__PURE__*/isValidElement(count)) { | ||
@@ -101,3 +90,2 @@ return /*#__PURE__*/cloneElement(count, { | ||
} | ||
return /*#__PURE__*/React.createElement("span", { | ||
@@ -117,7 +105,5 @@ className: prefixCls + "__value", | ||
}); | ||
if (__DEV__) { | ||
Badge.displayName = 'Badge'; | ||
} | ||
export { Badge }; |
@@ -12,5 +12,3 @@ /** @LICENSE | ||
var css_248z = ".hi-v4-badge {-webkit-box-sizing: border-box;box-sizing: border-box;margin: 0;padding: 0;border: none;outline: none;font-size: var(--hi-v4-text-size-md, 0.875rem);vertical-align: middle;display: inline-block;position: relative;line-height: 1;}.hi-v4-badge__value {-webkit-transform: translateX(50%);transform: translateX(50%);position: absolute;z-index: 1;right: 0;top: calc(-12px);min-width: 8px;height: 20px;line-height: 20px;padding: 0 var(--hi-v4-spacing-3, 6px);color: var(--hi-v4-color-static-white, #fff);font-size: var(--hi-v4-text-size-sm, 0.75rem);letter-spacing: 0;text-align: center;border: var(--hi-v4-border-size-semibold, 2px solid) var(--hi-v4-color-static-white, #fff);background-color: var(--hi-v4-color-danger-500, var(--hi-v4-color-red-500, #ff5959));border-radius: var(--hi-v4-border-radius-full, 9999px);-webkit-box-sizing: content-box;box-sizing: content-box;}.hi-v4-badge__dot {position: absolute;z-index: 1;top: calc(-7px);right: calc(-7px);width: 10px;height: 10px;background-color: var(--hi-v4-color-danger-500, var(--hi-v4-color-red-500, #ff5959));border: var(--hi-v4-border-size-semibold, 2px solid) var(--hi-v4-color-static-white, #fff);border-radius: var(--hi-v4-border-radius-full, 9999px);-webkit-box-sizing: content-box;box-sizing: content-box;}.hi-v4-badge__custom {-webkit-transform: translate(50%, -50%);transform: translate(50%, -50%);position: absolute;top: 0;right: 0;z-index: 1;}.hi-v4-badge--independent .hi-v4-badge__dot,.hi-v4-badge--independent .hi-v4-badge__value,.hi-v4-badge--independent .hi-v4-badge__custom {position: relative;top: auto;right: auto;-webkit-transform: none;transform: none;display: block;}"; | ||
__styleInject__(css_248z); | ||
export { css_248z as default }; |
{ | ||
"name": "@hi-ui/badge", | ||
"version": "4.0.6", | ||
"version": "4.0.7", | ||
"description": "A sub-package for @hi-ui/hiui.", | ||
@@ -46,8 +46,8 @@ "keywords": [], | ||
"dependencies": { | ||
"@hi-ui/classname": "^4.0.1", | ||
"@hi-ui/env": "^4.0.1", | ||
"@hi-ui/type-assertion": "^4.0.1" | ||
"@hi-ui/classname": "^4.0.2", | ||
"@hi-ui/env": "^4.0.2", | ||
"@hi-ui/type-assertion": "^4.0.2" | ||
}, | ||
"peerDependencies": { | ||
"@hi-ui/core": ">=4.0.0", | ||
"@hi-ui/core": ">=4.0.6", | ||
"react": ">=16.8.6", | ||
@@ -57,4 +57,4 @@ "react-dom": ">=16.8.6" | ||
"devDependencies": { | ||
"@hi-ui/core": "^4.0.4", | ||
"@hi-ui/core-css": "^4.1.1", | ||
"@hi-ui/core": "^4.0.6", | ||
"@hi-ui/core-css": "^4.1.3", | ||
"react": "^17.0.1", | ||
@@ -61,0 +61,0 @@ "react-dom": "^17.0.1" |
17123
352
Updated@hi-ui/classname@^4.0.2
Updated@hi-ui/env@^4.0.2
Updated@hi-ui/type-assertion@^4.0.2