@activecollab/components 2.0.395 → 2.0.397
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/dist/cjs/components/Badge/Badge.js +29 -8
- package/dist/cjs/components/Badge/Badge.js.map +1 -1
- package/dist/cjs/components/Badge/Styles.js +41 -11
- package/dist/cjs/components/Badge/Styles.js.map +1 -1
- package/dist/esm/components/Badge/Badge.d.ts +15 -6
- package/dist/esm/components/Badge/Badge.d.ts.map +1 -1
- package/dist/esm/components/Badge/Badge.js +29 -8
- package/dist/esm/components/Badge/Badge.js.map +1 -1
- package/dist/esm/components/Badge/Styles.d.ts +5 -1
- package/dist/esm/components/Badge/Styles.d.ts.map +1 -1
- package/dist/esm/components/Badge/Styles.js +35 -7
- package/dist/esm/components/Badge/Styles.js.map +1 -1
- package/dist/esm/components/CounterButton/Styles.d.ts +1 -1
- package/dist/esm/components/CounterButton/Styles.d.ts.map +1 -1
- package/dist/index.js +70 -19
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -15071,54 +15071,95 @@
|
|
|
15071
15071
|
});
|
|
15072
15072
|
Breadcrumbs.displayName = "Breadcrumbs";
|
|
15073
15073
|
|
|
15074
|
+
var DEFAULT_DIMENSION = 8;
|
|
15075
|
+
var LARGE_FONT_FROM_DIMENSION = 18;
|
|
15076
|
+
var CIRCLE_PADDING_INLINE = 5;
|
|
15077
|
+
var PILL_PADDING_INLINE = 10;
|
|
15078
|
+
var DIGIT_INLINE_SIZE = 7;
|
|
15079
|
+
var SMALL_CIRCLE_BELOW_DIMENSION = 16;
|
|
15080
|
+
var dimensionOf = function dimensionOf(props) {
|
|
15081
|
+
var _props$dimension;
|
|
15082
|
+
return (_props$dimension = props.dimension) !== null && _props$dimension !== void 0 ? _props$dimension : DEFAULT_DIMENSION;
|
|
15083
|
+
};
|
|
15084
|
+
var paddingInlineOf = function paddingInlineOf(props) {
|
|
15085
|
+
if (!props.hasLabel) {
|
|
15086
|
+
return 0;
|
|
15087
|
+
}
|
|
15088
|
+
if (props.shape === "pill") {
|
|
15089
|
+
return PILL_PADDING_INLINE;
|
|
15090
|
+
}
|
|
15091
|
+
var dimension = dimensionOf(props);
|
|
15092
|
+
if (dimension >= SMALL_CIRCLE_BELOW_DIMENSION) {
|
|
15093
|
+
return CIRCLE_PADDING_INLINE;
|
|
15094
|
+
}
|
|
15095
|
+
|
|
15096
|
+
// A small circle keeps a single digit inside its box only with less padding.
|
|
15097
|
+
return Math.max(0, Math.floor((dimension - DIGIT_INLINE_SIZE) / 2));
|
|
15098
|
+
};
|
|
15074
15099
|
var StyledBadge$1 = styled__default["default"].div.withConfig({
|
|
15075
15100
|
displayName: "Styles__StyledBadge",
|
|
15076
15101
|
componentId: "sc-6o8do5-0"
|
|
15077
|
-
})(["", " align-items:center;background-color:", ";
|
|
15102
|
+
})(["", " align-items:center;background-color:", ";block-size:", ";border-radius:999px;box-sizing:border-box;color:", ";display:flex;font-size:", ";font-variant-numeric:tabular-nums;font-weight:700;inline-size:auto;justify-content:center;min-inline-size:", ";padding-inline:", ";pointer-events:none;position:absolute;z-index:1;", " ", " ", " ", " ", " ", ""], FontStyle, function (props) {
|
|
15078
15103
|
return !props.backgroundColor ? "var(--color-primary)" : props.backgroundColor;
|
|
15079
15104
|
}, function (props) {
|
|
15080
|
-
return props
|
|
15105
|
+
return dimensionOf(props) + "px";
|
|
15081
15106
|
}, function (props) {
|
|
15082
|
-
return props.
|
|
15107
|
+
return !props.textColor ? "var(--color-theme-100)" : props.textColor;
|
|
15083
15108
|
}, function (props) {
|
|
15084
|
-
return props
|
|
15109
|
+
return dimensionOf(props) >= LARGE_FONT_FROM_DIMENSION ? "12px" : "10px";
|
|
15085
15110
|
}, function (props) {
|
|
15086
|
-
return
|
|
15111
|
+
return dimensionOf(props) + "px";
|
|
15112
|
+
}, function (props) {
|
|
15113
|
+
return paddingInlineOf(props) + "px";
|
|
15087
15114
|
}, function (_ref) {
|
|
15088
|
-
var
|
|
15089
|
-
return
|
|
15115
|
+
var shadows = _ref.shadows;
|
|
15116
|
+
return shadows && styled.css(["box-shadow:var(--shadow-tertiary);text-shadow:0 1px 2px rgba(0,0,0,0.25);"]);
|
|
15090
15117
|
}, function (_ref2) {
|
|
15091
|
-
var
|
|
15092
|
-
return
|
|
15118
|
+
var isStandalone = _ref2.isStandalone;
|
|
15119
|
+
return isStandalone && styled.css(["position:static;z-index:0;"]);
|
|
15093
15120
|
}, function (_ref3) {
|
|
15094
15121
|
var position = _ref3.position;
|
|
15095
|
-
return position === "top-
|
|
15122
|
+
return position === "top-left" && styled.css(["inset-block-start:0;inset-inline-start:0;"]);
|
|
15096
15123
|
}, function (_ref4) {
|
|
15097
15124
|
var position = _ref4.position;
|
|
15098
|
-
return position === "
|
|
15125
|
+
return position === "top-right" && styled.css(["inset-block-start:0;inset-inline-end:0;"]);
|
|
15099
15126
|
}, function (_ref5) {
|
|
15100
15127
|
var position = _ref5.position;
|
|
15128
|
+
return position === "bottom-right" && styled.css(["inset-block-end:0;inset-inline-end:0;"]);
|
|
15129
|
+
}, function (_ref6) {
|
|
15130
|
+
var position = _ref6.position;
|
|
15101
15131
|
return position === "bottom-left" && styled.css(["inset-block-end:0;inset-inline-start:0;"]);
|
|
15102
15132
|
});
|
|
15103
15133
|
|
|
15134
|
+
var getLabel = function getLabel(value, cap) {
|
|
15135
|
+
if (!value) {
|
|
15136
|
+
return null;
|
|
15137
|
+
}
|
|
15138
|
+
return cap && value > cap ? "".concat(cap, "+") : value;
|
|
15139
|
+
};
|
|
15140
|
+
|
|
15104
15141
|
/**
|
|
15105
15142
|
* @component Badge
|
|
15106
15143
|
* @description
|
|
15107
|
-
*
|
|
15108
|
-
*
|
|
15144
|
+
* A small pill that sits on the corner of an avatar or an icon, or stands in a
|
|
15145
|
+
* row on its own. It shows a count, or nothing at all when it marks a state.
|
|
15109
15146
|
*
|
|
15110
15147
|
* @prop {position} - dictates the position of a badge.
|
|
15111
|
-
* @prop {dimension} - controls the
|
|
15148
|
+
* @prop {dimension} - controls the height of a badge in pixels. The width grows with the content.
|
|
15149
|
+
* @prop {shape} - "pill" adds horizontal padding so the badge reads as long.
|
|
15150
|
+
* @prop {cap} - the highest number shown. Above it the badge renders `{cap}+`.
|
|
15112
15151
|
* @prop {backgroundColor} - background-color of a badge.
|
|
15152
|
+
* @prop {textColor} - color of the number.
|
|
15153
|
+
* @prop {isStandalone} - takes the badge out of absolute positioning.
|
|
15113
15154
|
*
|
|
15114
15155
|
* @example
|
|
15115
15156
|
* <IconButton variant="text gray" size="big">
|
|
15116
15157
|
* <BellOffIcon />
|
|
15117
|
-
* <Badge position="top-right" backgroundColor="red" dimension={16} />
|
|
15158
|
+
* <Badge position="top-right" backgroundColor="var(--red-alert)" dimension={16} value={7} cap={99} />
|
|
15118
15159
|
* </IconButton>
|
|
15119
15160
|
*
|
|
15120
15161
|
* @see
|
|
15121
|
-
* https://system.activecollab.com/?path=/story/components-
|
|
15162
|
+
* https://system.activecollab.com/?path=/story/components-indicators-badge--badge
|
|
15122
15163
|
*/
|
|
15123
15164
|
var Badge = function Badge(_ref) {
|
|
15124
15165
|
var _ref$dimension = _ref.dimension,
|
|
@@ -15127,18 +15168,28 @@
|
|
|
15127
15168
|
_ref$position = _ref.position,
|
|
15128
15169
|
position = _ref$position === void 0 ? "bottom-left" : _ref$position,
|
|
15129
15170
|
backgroundColor = _ref.backgroundColor,
|
|
15171
|
+
textColor = _ref.textColor,
|
|
15130
15172
|
value = _ref.value,
|
|
15173
|
+
cap = _ref.cap,
|
|
15174
|
+
_ref$shape = _ref.shape,
|
|
15175
|
+
shape = _ref$shape === void 0 ? "circle" : _ref$shape,
|
|
15176
|
+
_ref$shadows = _ref.shadows,
|
|
15177
|
+
shadows = _ref$shadows === void 0 ? false : _ref$shadows,
|
|
15131
15178
|
_ref$isStandalone = _ref.isStandalone,
|
|
15132
15179
|
isStandalone = _ref$isStandalone === void 0 ? false : _ref$isStandalone;
|
|
15180
|
+
var label = getLabel(value, cap);
|
|
15133
15181
|
return /*#__PURE__*/React__default["default"].createElement(StyledBadge$1, {
|
|
15134
15182
|
className: classNames__default["default"]("c-badge", className),
|
|
15135
15183
|
dimension: dimension,
|
|
15136
15184
|
position: position,
|
|
15185
|
+
shape: shape,
|
|
15186
|
+
shadows: shadows,
|
|
15187
|
+
hasLabel: label !== null,
|
|
15137
15188
|
isStandalone: isStandalone,
|
|
15138
15189
|
backgroundColor: backgroundColor,
|
|
15139
|
-
|
|
15140
|
-
|
|
15141
|
-
},
|
|
15190
|
+
textColor: textColor,
|
|
15191
|
+
role: "status"
|
|
15192
|
+
}, label);
|
|
15142
15193
|
};
|
|
15143
15194
|
|
|
15144
15195
|
var _excluded$1p = ["weight", "children"];
|