@activecollab/components 2.0.395 → 2.0.396
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
|
@@ -8,24 +8,35 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
8
8
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
9
9
|
var _Styles = require("./Styles");
|
|
10
10
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
var getLabel = function getLabel(value, cap) {
|
|
12
|
+
if (!value) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
return cap && value > cap ? "".concat(cap, "+") : value;
|
|
16
|
+
};
|
|
17
|
+
|
|
11
18
|
/**
|
|
12
19
|
* @component Badge
|
|
13
20
|
* @description
|
|
14
|
-
*
|
|
15
|
-
*
|
|
21
|
+
* A small pill that sits on the corner of an avatar or an icon, or stands in a
|
|
22
|
+
* row on its own. It shows a count, or nothing at all when it marks a state.
|
|
16
23
|
*
|
|
17
24
|
* @prop {position} - dictates the position of a badge.
|
|
18
|
-
* @prop {dimension} - controls the
|
|
25
|
+
* @prop {dimension} - controls the height of a badge in pixels. The width grows with the content.
|
|
26
|
+
* @prop {shape} - "pill" adds horizontal padding so the badge reads as long.
|
|
27
|
+
* @prop {cap} - the highest number shown. Above it the badge renders `{cap}+`.
|
|
19
28
|
* @prop {backgroundColor} - background-color of a badge.
|
|
29
|
+
* @prop {textColor} - color of the number.
|
|
30
|
+
* @prop {isStandalone} - takes the badge out of absolute positioning.
|
|
20
31
|
*
|
|
21
32
|
* @example
|
|
22
33
|
* <IconButton variant="text gray" size="big">
|
|
23
34
|
* <BellOffIcon />
|
|
24
|
-
* <Badge position="top-right" backgroundColor="red" dimension={16} />
|
|
35
|
+
* <Badge position="top-right" backgroundColor="var(--red-alert)" dimension={16} value={7} cap={99} />
|
|
25
36
|
* </IconButton>
|
|
26
37
|
*
|
|
27
38
|
* @see
|
|
28
|
-
* https://system.activecollab.com/?path=/story/components-
|
|
39
|
+
* https://system.activecollab.com/?path=/story/components-indicators-badge--badge
|
|
29
40
|
*/
|
|
30
41
|
var Badge = exports.Badge = function Badge(_ref) {
|
|
31
42
|
var _ref$dimension = _ref.dimension,
|
|
@@ -34,17 +45,27 @@ var Badge = exports.Badge = function Badge(_ref) {
|
|
|
34
45
|
_ref$position = _ref.position,
|
|
35
46
|
position = _ref$position === void 0 ? "bottom-left" : _ref$position,
|
|
36
47
|
backgroundColor = _ref.backgroundColor,
|
|
48
|
+
textColor = _ref.textColor,
|
|
37
49
|
value = _ref.value,
|
|
50
|
+
cap = _ref.cap,
|
|
51
|
+
_ref$shape = _ref.shape,
|
|
52
|
+
shape = _ref$shape === void 0 ? "circle" : _ref$shape,
|
|
53
|
+
_ref$shadows = _ref.shadows,
|
|
54
|
+
shadows = _ref$shadows === void 0 ? false : _ref$shadows,
|
|
38
55
|
_ref$isStandalone = _ref.isStandalone,
|
|
39
56
|
isStandalone = _ref$isStandalone === void 0 ? false : _ref$isStandalone;
|
|
57
|
+
var label = getLabel(value, cap);
|
|
40
58
|
return /*#__PURE__*/_react.default.createElement(_Styles.StyledBadge, {
|
|
41
59
|
className: (0, _classnames.default)("c-badge", className),
|
|
42
60
|
dimension: dimension,
|
|
43
61
|
position: position,
|
|
62
|
+
shape: shape,
|
|
63
|
+
shadows: shadows,
|
|
64
|
+
hasLabel: label !== null,
|
|
44
65
|
isStandalone: isStandalone,
|
|
45
66
|
backgroundColor: backgroundColor,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
},
|
|
67
|
+
textColor: textColor,
|
|
68
|
+
role: "status"
|
|
69
|
+
}, label);
|
|
49
70
|
};
|
|
50
71
|
//# sourceMappingURL=Badge.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Badge.js","names":["_react","_interopRequireDefault","require","_classnames","_Styles","e","__esModule","default","Badge","exports","_ref","_ref$dimension","dimension","className","_ref$position","position","backgroundColor","
|
|
1
|
+
{"version":3,"file":"Badge.js","names":["_react","_interopRequireDefault","require","_classnames","_Styles","e","__esModule","default","getLabel","value","cap","concat","Badge","exports","_ref","_ref$dimension","dimension","className","_ref$position","position","backgroundColor","textColor","_ref$shape","shape","_ref$shadows","shadows","_ref$isStandalone","isStandalone","label","createElement","StyledBadge","classNames","hasLabel","role"],"sources":["../../../../src/components/Badge/Badge.tsx"],"sourcesContent":["import React from \"react\";\n\nimport classNames from \"classnames\";\n\nimport { StyledBadge } from \"./Styles\";\n\ntype Position = \"top-left\" | \"top-right\" | \"bottom-right\" | \"bottom-left\";\ntype Shape = \"circle\" | \"pill\";\n\nexport interface BadgeProps {\n position?: Position;\n dimension?: number;\n className?: string;\n backgroundColor?: string;\n textColor?: string;\n value?: number;\n cap?: number;\n shape?: Shape;\n shadows?: boolean;\n isStandalone?: boolean;\n}\n\nconst getLabel = (value?: number, cap?: number) => {\n if (!value) {\n return null;\n }\n\n return cap && value > cap ? `${cap}+` : value;\n};\n\n/**\n * @component Badge\n * @description\n * A small pill that sits on the corner of an avatar or an icon, or stands in a\n * row on its own. It shows a count, or nothing at all when it marks a state.\n *\n * @prop {position} - dictates the position of a badge.\n * @prop {dimension} - controls the height of a badge in pixels. The width grows with the content.\n * @prop {shape} - \"pill\" adds horizontal padding so the badge reads as long.\n * @prop {cap} - the highest number shown. Above it the badge renders `{cap}+`.\n * @prop {backgroundColor} - background-color of a badge.\n * @prop {textColor} - color of the number.\n * @prop {isStandalone} - takes the badge out of absolute positioning.\n *\n * @example\n * <IconButton variant=\"text gray\" size=\"big\">\n * <BellOffIcon />\n * <Badge position=\"top-right\" backgroundColor=\"var(--red-alert)\" dimension={16} value={7} cap={99} />\n * </IconButton>\n *\n * @see\n * https://system.activecollab.com/?path=/story/components-indicators-badge--badge\n */\nexport const Badge = ({\n dimension = 8,\n className,\n position = \"bottom-left\",\n backgroundColor,\n textColor,\n value,\n cap,\n shape = \"circle\",\n shadows = false,\n isStandalone = false,\n}: BadgeProps) => {\n const label = getLabel(value, cap);\n\n return (\n <StyledBadge\n className={classNames(\"c-badge\", className)}\n dimension={dimension}\n position={position}\n shape={shape}\n shadows={shadows}\n hasLabel={label !== null}\n isStandalone={isStandalone}\n backgroundColor={backgroundColor}\n textColor={textColor}\n role=\"status\"\n >\n {label}\n </StyledBadge>\n );\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,WAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA,IAAAE,OAAA,GAAAF,OAAA;AAAuC,SAAAD,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAkBvC,IAAMG,QAAQ,GAAG,SAAXA,QAAQA,CAAIC,KAAc,EAAEC,GAAY,EAAK;EACjD,IAAI,CAACD,KAAK,EAAE;IACV,OAAO,IAAI;EACb;EAEA,OAAOC,GAAG,IAAID,KAAK,GAAGC,GAAG,MAAAC,MAAA,CAAMD,GAAG,SAA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ACzBD,YAAY,EAAEA,YAAa;IAC3BP,eAAe,EAAEA,eAAgB;IACjCC,SAAS,EAAEA,SAAU;IACrBY,IAAI,EAAC;EAAQ,GAEZL,KACU,CAAC;AAElB,CAAC","ignoreList":[]}
|
|
@@ -7,33 +7,63 @@ exports.StyledBadge = void 0;
|
|
|
7
7
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
8
8
|
var _FontStyle = require("../FontStyle");
|
|
9
9
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
10
|
+
var DEFAULT_DIMENSION = 8;
|
|
11
|
+
var LARGE_FONT_FROM_DIMENSION = 18;
|
|
12
|
+
var CIRCLE_PADDING_INLINE = 5;
|
|
13
|
+
var PILL_PADDING_INLINE = 10;
|
|
14
|
+
var DIGIT_INLINE_SIZE = 7;
|
|
15
|
+
var SMALL_CIRCLE_BELOW_DIMENSION = 16;
|
|
16
|
+
var dimensionOf = function dimensionOf(props) {
|
|
17
|
+
var _props$dimension;
|
|
18
|
+
return (_props$dimension = props.dimension) !== null && _props$dimension !== void 0 ? _props$dimension : DEFAULT_DIMENSION;
|
|
19
|
+
};
|
|
20
|
+
var paddingInlineOf = function paddingInlineOf(props) {
|
|
21
|
+
if (!props.hasLabel) {
|
|
22
|
+
return 0;
|
|
23
|
+
}
|
|
24
|
+
if (props.shape === "pill") {
|
|
25
|
+
return PILL_PADDING_INLINE;
|
|
26
|
+
}
|
|
27
|
+
var dimension = dimensionOf(props);
|
|
28
|
+
if (dimension >= SMALL_CIRCLE_BELOW_DIMENSION) {
|
|
29
|
+
return CIRCLE_PADDING_INLINE;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// A small circle keeps a single digit inside its box only with less padding.
|
|
33
|
+
return Math.max(0, Math.floor((dimension - DIGIT_INLINE_SIZE) / 2));
|
|
34
|
+
};
|
|
10
35
|
var StyledBadge = exports.StyledBadge = _styledComponents.default.div.withConfig({
|
|
11
36
|
displayName: "Styles__StyledBadge",
|
|
12
37
|
componentId: "sc-6o8do5-0"
|
|
13
|
-
})(["", " align-items:center;background-color:", ";
|
|
38
|
+
})(["", " 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.FontStyle, function (props) {
|
|
14
39
|
return !props.backgroundColor ? "var(--color-primary)" : props.backgroundColor;
|
|
15
40
|
}, function (props) {
|
|
16
|
-
return props
|
|
41
|
+
return dimensionOf(props) + "px";
|
|
42
|
+
}, function (props) {
|
|
43
|
+
return !props.textColor ? "var(--color-theme-100)" : props.textColor;
|
|
17
44
|
}, function (props) {
|
|
18
|
-
return props
|
|
45
|
+
return dimensionOf(props) >= LARGE_FONT_FROM_DIMENSION ? "12px" : "10px";
|
|
19
46
|
}, function (props) {
|
|
20
|
-
return props
|
|
47
|
+
return dimensionOf(props) + "px";
|
|
21
48
|
}, function (props) {
|
|
22
|
-
return
|
|
49
|
+
return paddingInlineOf(props) + "px";
|
|
23
50
|
}, function (_ref) {
|
|
24
|
-
var
|
|
25
|
-
return
|
|
51
|
+
var shadows = _ref.shadows;
|
|
52
|
+
return shadows && (0, _styledComponents.css)(["box-shadow:var(--shadow-tertiary);text-shadow:0 1px 2px rgba(0,0,0,0.25);"]);
|
|
26
53
|
}, function (_ref2) {
|
|
27
|
-
var
|
|
28
|
-
return
|
|
54
|
+
var isStandalone = _ref2.isStandalone;
|
|
55
|
+
return isStandalone && (0, _styledComponents.css)(["position:static;z-index:0;"]);
|
|
29
56
|
}, function (_ref3) {
|
|
30
57
|
var position = _ref3.position;
|
|
31
|
-
return position === "top-
|
|
58
|
+
return position === "top-left" && (0, _styledComponents.css)(["inset-block-start:0;inset-inline-start:0;"]);
|
|
32
59
|
}, function (_ref4) {
|
|
33
60
|
var position = _ref4.position;
|
|
34
|
-
return position === "
|
|
61
|
+
return position === "top-right" && (0, _styledComponents.css)(["inset-block-start:0;inset-inline-end:0;"]);
|
|
35
62
|
}, function (_ref5) {
|
|
36
63
|
var position = _ref5.position;
|
|
64
|
+
return position === "bottom-right" && (0, _styledComponents.css)(["inset-block-end:0;inset-inline-end:0;"]);
|
|
65
|
+
}, function (_ref6) {
|
|
66
|
+
var position = _ref6.position;
|
|
37
67
|
return position === "bottom-left" && (0, _styledComponents.css)(["inset-block-end:0;inset-inline-start:0;"]);
|
|
38
68
|
});
|
|
39
69
|
//# sourceMappingURL=Styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Styles.js","names":["_styledComponents","_interopRequireWildcard","require","_FontStyle","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","StyledBadge","exports","styled","div","withConfig","displayName","componentId","FontStyle","
|
|
1
|
+
{"version":3,"file":"Styles.js","names":["_styledComponents","_interopRequireWildcard","require","_FontStyle","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","DEFAULT_DIMENSION","LARGE_FONT_FROM_DIMENSION","CIRCLE_PADDING_INLINE","PILL_PADDING_INLINE","DIGIT_INLINE_SIZE","SMALL_CIRCLE_BELOW_DIMENSION","dimensionOf","props","_props$dimension","dimension","paddingInlineOf","hasLabel","shape","Math","max","floor","StyledBadge","exports","styled","div","withConfig","displayName","componentId","FontStyle","backgroundColor","textColor","_ref","shadows","css","_ref2","isStandalone","_ref3","position","_ref4","_ref5","_ref6"],"sources":["../../../../src/components/Badge/Styles.ts"],"sourcesContent":["import styled, { css } from \"styled-components\";\n\nimport { BadgeProps } from \"./Badge\";\nimport { FontStyle } from \"../FontStyle\";\n\nconst DEFAULT_DIMENSION = 8;\nconst LARGE_FONT_FROM_DIMENSION = 18;\nconst CIRCLE_PADDING_INLINE = 5;\nconst PILL_PADDING_INLINE = 10;\nconst DIGIT_INLINE_SIZE = 7;\nconst SMALL_CIRCLE_BELOW_DIMENSION = 16;\n\ntype StyledBadgeProps = Partial<BadgeProps> & { hasLabel?: boolean };\n\nconst dimensionOf = (props: StyledBadgeProps) =>\n props.dimension ?? DEFAULT_DIMENSION;\n\nconst paddingInlineOf = (props: StyledBadgeProps) => {\n if (!props.hasLabel) {\n return 0;\n }\n\n if (props.shape === \"pill\") {\n return PILL_PADDING_INLINE;\n }\n\n const dimension = dimensionOf(props);\n\n if (dimension >= SMALL_CIRCLE_BELOW_DIMENSION) {\n return CIRCLE_PADDING_INLINE;\n }\n\n // A small circle keeps a single digit inside its box only with less padding.\n return Math.max(0, Math.floor((dimension - DIGIT_INLINE_SIZE) / 2));\n};\n\nexport const StyledBadge = styled.div<StyledBadgeProps>`\n ${FontStyle}\n align-items: center;\n background-color: ${(props) =>\n !props.backgroundColor ? \"var(--color-primary)\" : props.backgroundColor};\n block-size: ${(props) => dimensionOf(props) + \"px\"};\n border-radius: 999px;\n box-sizing: border-box;\n color: ${(props) =>\n !props.textColor ? \"var(--color-theme-100)\" : props.textColor};\n display: flex;\n font-size: ${(props) =>\n dimensionOf(props) >= LARGE_FONT_FROM_DIMENSION ? \"12px\" : \"10px\"};\n font-variant-numeric: tabular-nums;\n font-weight: 700;\n inline-size: auto;\n justify-content: center;\n min-inline-size: ${(props) => dimensionOf(props) + \"px\"};\n padding-inline: ${(props) => paddingInlineOf(props) + \"px\"};\n pointer-events: none;\n position: absolute;\n z-index: 1;\n\n ${({ shadows }) =>\n shadows &&\n css`\n box-shadow: var(--shadow-tertiary);\n text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);\n `}\n\n ${({ isStandalone }) =>\n isStandalone &&\n css`\n position: static;\n z-index: 0;\n `}\n\n ${({ position }) =>\n position === \"top-left\" &&\n css`\n inset-block-start: 0;\n inset-inline-start: 0;\n `}\n\n ${({ position }) =>\n position === \"top-right\" &&\n css`\n inset-block-start: 0;\n inset-inline-end: 0;\n `}\n\n ${({ position }) =>\n position === \"bottom-right\" &&\n css`\n inset-block-end: 0;\n inset-inline-end: 0;\n `}\n\n ${({ position }) =>\n position === \"bottom-left\" &&\n css`\n inset-block-end: 0;\n inset-inline-start: 0;\n `}\n`;\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,uBAAA,CAAAC,OAAA;AAGA,IAAAC,UAAA,GAAAD,OAAA;AAAyC,SAAAD,wBAAAG,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAL,uBAAA,YAAAA,wBAAAG,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,cAAAM,EAAA,IAAAd,CAAA,gBAAAc,EAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB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KAAA;EAAA,IAAGH,QAAQ,GAAAG,KAAA,CAARH,QAAQ;EAAA,OACbA,QAAQ,KAAK,aAAa,QAC1BJ,qBAAG,8CAGF;AAAA,EACJ","ignoreList":[]}
|
|
@@ -1,32 +1,41 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
type Position = "top-left" | "top-right" | "bottom-right" | "bottom-left";
|
|
3
|
+
type Shape = "circle" | "pill";
|
|
3
4
|
export interface BadgeProps {
|
|
4
5
|
position?: Position;
|
|
5
6
|
dimension?: number;
|
|
6
7
|
className?: string;
|
|
7
8
|
backgroundColor?: string;
|
|
9
|
+
textColor?: string;
|
|
8
10
|
value?: number;
|
|
11
|
+
cap?: number;
|
|
12
|
+
shape?: Shape;
|
|
13
|
+
shadows?: boolean;
|
|
9
14
|
isStandalone?: boolean;
|
|
10
15
|
}
|
|
11
16
|
/**
|
|
12
17
|
* @component Badge
|
|
13
18
|
* @description
|
|
14
|
-
*
|
|
15
|
-
*
|
|
19
|
+
* A small pill that sits on the corner of an avatar or an icon, or stands in a
|
|
20
|
+
* row on its own. It shows a count, or nothing at all when it marks a state.
|
|
16
21
|
*
|
|
17
22
|
* @prop {position} - dictates the position of a badge.
|
|
18
|
-
* @prop {dimension} - controls the
|
|
23
|
+
* @prop {dimension} - controls the height of a badge in pixels. The width grows with the content.
|
|
24
|
+
* @prop {shape} - "pill" adds horizontal padding so the badge reads as long.
|
|
25
|
+
* @prop {cap} - the highest number shown. Above it the badge renders `{cap}+`.
|
|
19
26
|
* @prop {backgroundColor} - background-color of a badge.
|
|
27
|
+
* @prop {textColor} - color of the number.
|
|
28
|
+
* @prop {isStandalone} - takes the badge out of absolute positioning.
|
|
20
29
|
*
|
|
21
30
|
* @example
|
|
22
31
|
* <IconButton variant="text gray" size="big">
|
|
23
32
|
* <BellOffIcon />
|
|
24
|
-
* <Badge position="top-right" backgroundColor="red" dimension={16} />
|
|
33
|
+
* <Badge position="top-right" backgroundColor="var(--red-alert)" dimension={16} value={7} cap={99} />
|
|
25
34
|
* </IconButton>
|
|
26
35
|
*
|
|
27
36
|
* @see
|
|
28
|
-
* https://system.activecollab.com/?path=/story/components-
|
|
37
|
+
* https://system.activecollab.com/?path=/story/components-indicators-badge--badge
|
|
29
38
|
*/
|
|
30
|
-
export declare const Badge: ({ dimension, className, position, backgroundColor, value, isStandalone, }: BadgeProps) => React.JSX.Element;
|
|
39
|
+
export declare const Badge: ({ dimension, className, position, backgroundColor, textColor, value, cap, shape, shadows, isStandalone, }: BadgeProps) => React.JSX.Element;
|
|
31
40
|
export {};
|
|
32
41
|
//# sourceMappingURL=Badge.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Badge.d.ts","sourceRoot":"","sources":["../../../../src/components/Badge/Badge.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,KAAK,QAAQ,GAAG,UAAU,GAAG,WAAW,GAAG,cAAc,GAAG,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"Badge.d.ts","sourceRoot":"","sources":["../../../../src/components/Badge/Badge.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,KAAK,QAAQ,GAAG,UAAU,GAAG,WAAW,GAAG,cAAc,GAAG,aAAa,CAAC;AAC1E,KAAK,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;AAE/B,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAUD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,KAAK,GAAI,2GAWnB,UAAU,sBAmBZ,CAAC"}
|
|
@@ -1,24 +1,35 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import classNames from "classnames";
|
|
3
3
|
import { StyledBadge } from "./Styles";
|
|
4
|
+
const getLabel = (value, cap) => {
|
|
5
|
+
if (!value) {
|
|
6
|
+
return null;
|
|
7
|
+
}
|
|
8
|
+
return cap && value > cap ? cap + "+" : value;
|
|
9
|
+
};
|
|
10
|
+
|
|
4
11
|
/**
|
|
5
12
|
* @component Badge
|
|
6
13
|
* @description
|
|
7
|
-
*
|
|
8
|
-
*
|
|
14
|
+
* A small pill that sits on the corner of an avatar or an icon, or stands in a
|
|
15
|
+
* row on its own. It shows a count, or nothing at all when it marks a state.
|
|
9
16
|
*
|
|
10
17
|
* @prop {position} - dictates the position of a badge.
|
|
11
|
-
* @prop {dimension} - controls the
|
|
18
|
+
* @prop {dimension} - controls the height of a badge in pixels. The width grows with the content.
|
|
19
|
+
* @prop {shape} - "pill" adds horizontal padding so the badge reads as long.
|
|
20
|
+
* @prop {cap} - the highest number shown. Above it the badge renders `{cap}+`.
|
|
12
21
|
* @prop {backgroundColor} - background-color of a badge.
|
|
22
|
+
* @prop {textColor} - color of the number.
|
|
23
|
+
* @prop {isStandalone} - takes the badge out of absolute positioning.
|
|
13
24
|
*
|
|
14
25
|
* @example
|
|
15
26
|
* <IconButton variant="text gray" size="big">
|
|
16
27
|
* <BellOffIcon />
|
|
17
|
-
* <Badge position="top-right" backgroundColor="red" dimension={16} />
|
|
28
|
+
* <Badge position="top-right" backgroundColor="var(--red-alert)" dimension={16} value={7} cap={99} />
|
|
18
29
|
* </IconButton>
|
|
19
30
|
*
|
|
20
31
|
* @see
|
|
21
|
-
* https://system.activecollab.com/?path=/story/components-
|
|
32
|
+
* https://system.activecollab.com/?path=/story/components-indicators-badge--badge
|
|
22
33
|
*/
|
|
23
34
|
export const Badge = _ref => {
|
|
24
35
|
let _ref$dimension = _ref.dimension,
|
|
@@ -27,17 +38,27 @@ export const Badge = _ref => {
|
|
|
27
38
|
_ref$position = _ref.position,
|
|
28
39
|
position = _ref$position === void 0 ? "bottom-left" : _ref$position,
|
|
29
40
|
backgroundColor = _ref.backgroundColor,
|
|
41
|
+
textColor = _ref.textColor,
|
|
30
42
|
value = _ref.value,
|
|
43
|
+
cap = _ref.cap,
|
|
44
|
+
_ref$shape = _ref.shape,
|
|
45
|
+
shape = _ref$shape === void 0 ? "circle" : _ref$shape,
|
|
46
|
+
_ref$shadows = _ref.shadows,
|
|
47
|
+
shadows = _ref$shadows === void 0 ? false : _ref$shadows,
|
|
31
48
|
_ref$isStandalone = _ref.isStandalone,
|
|
32
49
|
isStandalone = _ref$isStandalone === void 0 ? false : _ref$isStandalone;
|
|
50
|
+
const label = getLabel(value, cap);
|
|
33
51
|
return /*#__PURE__*/React.createElement(StyledBadge, {
|
|
34
52
|
className: classNames("c-badge", className),
|
|
35
53
|
dimension: dimension,
|
|
36
54
|
position: position,
|
|
55
|
+
shape: shape,
|
|
56
|
+
shadows: shadows,
|
|
57
|
+
hasLabel: label !== null,
|
|
37
58
|
isStandalone: isStandalone,
|
|
38
59
|
backgroundColor: backgroundColor,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
},
|
|
60
|
+
textColor: textColor,
|
|
61
|
+
role: "status"
|
|
62
|
+
}, label);
|
|
42
63
|
};
|
|
43
64
|
//# sourceMappingURL=Badge.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Badge.js","names":["React","classNames","StyledBadge","Badge","_ref","_ref$dimension","dimension","className","_ref$position","position","backgroundColor","
|
|
1
|
+
{"version":3,"file":"Badge.js","names":["React","classNames","StyledBadge","getLabel","value","cap","Badge","_ref","_ref$dimension","dimension","className","_ref$position","position","backgroundColor","textColor","_ref$shape","shape","_ref$shadows","shadows","_ref$isStandalone","isStandalone","label","createElement","hasLabel","role"],"sources":["../../../../src/components/Badge/Badge.tsx"],"sourcesContent":["import React from \"react\";\n\nimport classNames from \"classnames\";\n\nimport { StyledBadge } from \"./Styles\";\n\ntype Position = \"top-left\" | \"top-right\" | \"bottom-right\" | \"bottom-left\";\ntype Shape = \"circle\" | \"pill\";\n\nexport interface BadgeProps {\n position?: Position;\n dimension?: number;\n className?: string;\n backgroundColor?: string;\n textColor?: string;\n value?: number;\n cap?: number;\n shape?: Shape;\n shadows?: boolean;\n isStandalone?: boolean;\n}\n\nconst getLabel = (value?: number, cap?: number) => {\n if (!value) {\n return null;\n }\n\n return cap && value > cap ? `${cap}+` : value;\n};\n\n/**\n * @component Badge\n * @description\n * A small pill that sits on the corner of an avatar or an icon, or stands in a\n * row on its own. It shows a count, or nothing at all when it marks a state.\n *\n * @prop {position} - dictates the position of a badge.\n * @prop {dimension} - controls the height of a badge in pixels. The width grows with the content.\n * @prop {shape} - \"pill\" adds horizontal padding so the badge reads as long.\n * @prop {cap} - the highest number shown. Above it the badge renders `{cap}+`.\n * @prop {backgroundColor} - background-color of a badge.\n * @prop {textColor} - color of the number.\n * @prop {isStandalone} - takes the badge out of absolute positioning.\n *\n * @example\n * <IconButton variant=\"text gray\" size=\"big\">\n * <BellOffIcon />\n * <Badge position=\"top-right\" backgroundColor=\"var(--red-alert)\" dimension={16} value={7} cap={99} />\n * </IconButton>\n *\n * @see\n * https://system.activecollab.com/?path=/story/components-indicators-badge--badge\n */\nexport const Badge = ({\n dimension = 8,\n className,\n position = \"bottom-left\",\n backgroundColor,\n textColor,\n value,\n cap,\n shape = \"circle\",\n shadows = false,\n isStandalone = false,\n}: BadgeProps) => {\n const label = getLabel(value, cap);\n\n return (\n <StyledBadge\n className={classNames(\"c-badge\", className)}\n dimension={dimension}\n position={position}\n shape={shape}\n shadows={shadows}\n hasLabel={label !== null}\n isStandalone={isStandalone}\n backgroundColor={backgroundColor}\n textColor={textColor}\n role=\"status\"\n >\n {label}\n </StyledBadge>\n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W;IACVQ,SAAS,EAAET,UAAU,CAAC,SAAS,EAAES,SAAS,CAAE;IAC5CD,SAAS,EAAEA,SAAU;IACrBG,QAAQ,EAAEA,QAAS;IACnBI,KAAK,EAAEA,KAAM;IACbE,OAAO,EAAEA,OAAQ;IACjBK,QAAQ,EAAEF,KAAK,KAAK,IAAK;IACzBD,YAAY,EAAEA,YAAa;IAC3BP,eAAe,EAAEA,eAAgB;IACjCC,SAAS,EAAEA,SAAU;IACrBU,IAAI,EAAC;EAAQ,GAEZH,KACU,CAAC;AAElB,CAAC","ignoreList":[]}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import { BadgeProps } from "./Badge";
|
|
2
|
-
|
|
2
|
+
type StyledBadgeProps = Partial<BadgeProps> & {
|
|
3
|
+
hasLabel?: boolean;
|
|
4
|
+
};
|
|
5
|
+
export declare const StyledBadge: import("styled-components").StyledComponent<"div", any, StyledBadgeProps, never>;
|
|
6
|
+
export {};
|
|
3
7
|
//# sourceMappingURL=Styles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Styles.d.ts","sourceRoot":"","sources":["../../../../src/components/Badge/Styles.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"Styles.d.ts","sourceRoot":"","sources":["../../../../src/components/Badge/Styles.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAUrC,KAAK,gBAAgB,GAAG,OAAO,CAAC,UAAU,CAAC,GAAG;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAwBrE,eAAO,MAAM,WAAW,kFAgEvB,CAAC"}
|
|
@@ -1,22 +1,50 @@
|
|
|
1
1
|
import styled, { css } from "styled-components";
|
|
2
2
|
import { FontStyle } from "../FontStyle";
|
|
3
|
+
const DEFAULT_DIMENSION = 8;
|
|
4
|
+
const LARGE_FONT_FROM_DIMENSION = 18;
|
|
5
|
+
const CIRCLE_PADDING_INLINE = 5;
|
|
6
|
+
const PILL_PADDING_INLINE = 10;
|
|
7
|
+
const DIGIT_INLINE_SIZE = 7;
|
|
8
|
+
const SMALL_CIRCLE_BELOW_DIMENSION = 16;
|
|
9
|
+
const dimensionOf = props => {
|
|
10
|
+
var _props$dimension;
|
|
11
|
+
return (_props$dimension = props.dimension) != null ? _props$dimension : DEFAULT_DIMENSION;
|
|
12
|
+
};
|
|
13
|
+
const paddingInlineOf = props => {
|
|
14
|
+
if (!props.hasLabel) {
|
|
15
|
+
return 0;
|
|
16
|
+
}
|
|
17
|
+
if (props.shape === "pill") {
|
|
18
|
+
return PILL_PADDING_INLINE;
|
|
19
|
+
}
|
|
20
|
+
const dimension = dimensionOf(props);
|
|
21
|
+
if (dimension >= SMALL_CIRCLE_BELOW_DIMENSION) {
|
|
22
|
+
return CIRCLE_PADDING_INLINE;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// A small circle keeps a single digit inside its box only with less padding.
|
|
26
|
+
return Math.max(0, Math.floor((dimension - DIGIT_INLINE_SIZE) / 2));
|
|
27
|
+
};
|
|
3
28
|
export const StyledBadge = styled.div.withConfig({
|
|
4
29
|
displayName: "Styles__StyledBadge",
|
|
5
30
|
componentId: "sc-6o8do5-0"
|
|
6
|
-
})(["", " align-items:center;background-color:", ";
|
|
7
|
-
let
|
|
8
|
-
return
|
|
31
|
+
})(["", " 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, props => !props.backgroundColor ? "var(--color-primary)" : props.backgroundColor, props => dimensionOf(props) + "px", props => !props.textColor ? "var(--color-theme-100)" : props.textColor, props => dimensionOf(props) >= LARGE_FONT_FROM_DIMENSION ? "12px" : "10px", props => dimensionOf(props) + "px", props => paddingInlineOf(props) + "px", _ref => {
|
|
32
|
+
let shadows = _ref.shadows;
|
|
33
|
+
return shadows && css(["box-shadow:var(--shadow-tertiary);text-shadow:0 1px 2px rgba(0,0,0,0.25);"]);
|
|
9
34
|
}, _ref2 => {
|
|
10
|
-
let
|
|
11
|
-
return
|
|
35
|
+
let isStandalone = _ref2.isStandalone;
|
|
36
|
+
return isStandalone && css(["position:static;z-index:0;"]);
|
|
12
37
|
}, _ref3 => {
|
|
13
38
|
let position = _ref3.position;
|
|
14
|
-
return position === "top-
|
|
39
|
+
return position === "top-left" && css(["inset-block-start:0;inset-inline-start:0;"]);
|
|
15
40
|
}, _ref4 => {
|
|
16
41
|
let position = _ref4.position;
|
|
17
|
-
return position === "
|
|
42
|
+
return position === "top-right" && css(["inset-block-start:0;inset-inline-end:0;"]);
|
|
18
43
|
}, _ref5 => {
|
|
19
44
|
let position = _ref5.position;
|
|
45
|
+
return position === "bottom-right" && css(["inset-block-end:0;inset-inline-end:0;"]);
|
|
46
|
+
}, _ref6 => {
|
|
47
|
+
let position = _ref6.position;
|
|
20
48
|
return position === "bottom-left" && css(["inset-block-end:0;inset-inline-start:0;"]);
|
|
21
49
|
});
|
|
22
50
|
//# sourceMappingURL=Styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Styles.js","names":["styled","css","FontStyle","
|
|
1
|
+
{"version":3,"file":"Styles.js","names":["styled","css","FontStyle","DEFAULT_DIMENSION","LARGE_FONT_FROM_DIMENSION","CIRCLE_PADDING_INLINE","PILL_PADDING_INLINE","DIGIT_INLINE_SIZE","SMALL_CIRCLE_BELOW_DIMENSION","dimensionOf","props","_props$dimension","dimension","paddingInlineOf","hasLabel","shape","Math","max","floor","StyledBadge","div","withConfig","displayName","componentId","backgroundColor","textColor","_ref","shadows","_ref2","isStandalone","_ref3","position","_ref4","_ref5","_ref6"],"sources":["../../../../src/components/Badge/Styles.ts"],"sourcesContent":["import styled, { css } from \"styled-components\";\n\nimport { BadgeProps } from \"./Badge\";\nimport { FontStyle } from \"../FontStyle\";\n\nconst DEFAULT_DIMENSION = 8;\nconst LARGE_FONT_FROM_DIMENSION = 18;\nconst CIRCLE_PADDING_INLINE = 5;\nconst PILL_PADDING_INLINE = 10;\nconst DIGIT_INLINE_SIZE = 7;\nconst SMALL_CIRCLE_BELOW_DIMENSION = 16;\n\ntype StyledBadgeProps = Partial<BadgeProps> & { hasLabel?: boolean };\n\nconst dimensionOf = (props: StyledBadgeProps) =>\n props.dimension ?? DEFAULT_DIMENSION;\n\nconst paddingInlineOf = (props: StyledBadgeProps) => {\n if (!props.hasLabel) {\n return 0;\n }\n\n if (props.shape === \"pill\") {\n return PILL_PADDING_INLINE;\n }\n\n const dimension = dimensionOf(props);\n\n if (dimension >= SMALL_CIRCLE_BELOW_DIMENSION) {\n return CIRCLE_PADDING_INLINE;\n }\n\n // A small circle keeps a single digit inside its box only with less padding.\n return Math.max(0, Math.floor((dimension - DIGIT_INLINE_SIZE) / 2));\n};\n\nexport const StyledBadge = styled.div<StyledBadgeProps>`\n ${FontStyle}\n align-items: center;\n background-color: ${(props) =>\n !props.backgroundColor ? \"var(--color-primary)\" : props.backgroundColor};\n block-size: ${(props) => dimensionOf(props) + \"px\"};\n border-radius: 999px;\n box-sizing: border-box;\n color: ${(props) =>\n !props.textColor ? \"var(--color-theme-100)\" : props.textColor};\n display: flex;\n font-size: ${(props) =>\n dimensionOf(props) >= LARGE_FONT_FROM_DIMENSION ? \"12px\" : \"10px\"};\n font-variant-numeric: tabular-nums;\n font-weight: 700;\n inline-size: auto;\n justify-content: center;\n min-inline-size: ${(props) => dimensionOf(props) + \"px\"};\n padding-inline: ${(props) => paddingInlineOf(props) + \"px\"};\n pointer-events: none;\n position: absolute;\n z-index: 1;\n\n ${({ shadows }) =>\n shadows &&\n css`\n box-shadow: var(--shadow-tertiary);\n text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);\n `}\n\n ${({ isStandalone }) =>\n isStandalone &&\n css`\n position: static;\n z-index: 0;\n `}\n\n ${({ position }) =>\n position === \"top-left\" &&\n css`\n inset-block-start: 0;\n inset-inline-start: 0;\n `}\n\n ${({ position }) =>\n position === \"top-right\" &&\n css`\n inset-block-start: 0;\n inset-inline-end: 0;\n `}\n\n ${({ position }) =>\n position === \"bottom-right\" &&\n css`\n inset-block-end: 0;\n inset-inline-end: 0;\n `}\n\n ${({ position }) =>\n position === \"bottom-left\" &&\n css`\n inset-block-end: 0;\n inset-inline-start: 0;\n `}\n`;\n"],"mappings":"AAAA,OAAOA,MAAM,IAAIC,GAAG,QAAQ,mBAAmB;AAG/C,SAASC,SAAS,QAAQ,cAAc;AAExC,MAAMC,iBAAiB,GAAG,CAAC;AAC3B,MAAMC,yBAAyB,GAAG,EAAE;AACpC,MAAMC,qBAAqB,GAAG,CAAC;AAC/B,MAAMC,mBAAmB,GAAG,EAAE;AAC9B,MAAMC,iBAAiB,GAAG,CAAC;AAC3B,MAAMC,4BAA4B,GAAG,EAAE;AAIvC,MAAMC,WAAW,GAAIC,KAAuB;EAAA,IAAAC,gBAAA;EAAA,QAAAA,gBAAA,GAC1CD,KAAK,CAACE,SAAS,YAAAD,gBAAA,GAAIR,iBAAiB;AAAA;AAEtC,MAAMU,eAAe,GAAIH,KAAuB,IAAK;EACnD,IAAI,CAACA,KAAK,CAACI,QAAQ,EAAE;IACnB,OAAO,CAAC;EACV;EAEA,IAAIJ,KAAK,CAACK,KAAK,KAAK,MAAM,EAAE;IAC1B,OAAOT,mBAAmB;EAC5B;EAEA,MAAMM,SAAS,GAAGH,WAAW,CAACC,KAAK,CAAC;EAEpC,IAAIE,SAAS,IAAIJ,4BAA4B,EAAE;IAC7C,OAAOH,qBAAqB;EAC9B;;EAEA;EACA,OAAOW,IAAI,CAACC,GAAG,CAAC,CAAC,EAAED,IAAI,CAACE,KAAK,CAAC,CAACN,SAAS,GAAGL,iBAAiB,IAAI,CAAC,CAAC,CAAC;AACrE,CAAC;AAED,OAA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":[]}
|
|
@@ -12,6 +12,6 @@ export declare const StyledCounterButtonReset: import("styled-components").Style
|
|
|
12
12
|
export declare const StyledCounterButtonLabel: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("..").IBodyProps & Omit<import("../Typography/Typography").ITypographyProps, "variant" | "weight"> & import("react").RefAttributes<HTMLDivElement>>, any, {
|
|
13
13
|
$active?: boolean;
|
|
14
14
|
}, never>;
|
|
15
|
-
export declare const StyledBadge: import("styled-components").StyledComponent<({ dimension, className, position, backgroundColor, value, isStandalone, }: import("..").BadgeProps) => import("react").JSX.Element, any, {}, never>;
|
|
15
|
+
export declare const StyledBadge: import("styled-components").StyledComponent<({ dimension, className, position, backgroundColor, textColor, value, cap, shape, shadows, isStandalone, }: import("..").BadgeProps) => import("react").JSX.Element, any, {}, never>;
|
|
16
16
|
export {};
|
|
17
17
|
//# sourceMappingURL=Styles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Styles.d.ts","sourceRoot":"","sources":["../../../../src/components/CounterButton/Styles.ts"],"names":[],"mappings":"AASA,UAAU,wBAAwB;IAChC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,eAAO,MAAM,0BAA0B,oEAKtC,CAAC;AAIF,eAAO,MAAM,mBAAmB;;4FAsC/B,CAAC;AAIF,eAAO,MAAM,wBAAwB;;sEAWpC,CAAC;AAIF,eAAO,MAAM,wBAAwB;cAA6B,OAAO;SAoBxE,CAAC;AAIF,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"Styles.d.ts","sourceRoot":"","sources":["../../../../src/components/CounterButton/Styles.ts"],"names":[],"mappings":"AASA,UAAU,wBAAwB;IAChC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,eAAO,MAAM,0BAA0B,oEAKtC,CAAC;AAIF,eAAO,MAAM,mBAAmB;;4FAsC/B,CAAC;AAIF,eAAO,MAAM,wBAAwB;;sEAWpC,CAAC;AAIF,eAAO,MAAM,wBAAwB;cAA6B,OAAO;SAoBxE,CAAC;AAIF,eAAO,MAAM,WAAW,kOAGvB,CAAC"}
|