@canonical/react-ds-core 0.10.0-experimental.0 → 0.10.0-experimental.3
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/esm/ui/Badge/Badge.js +21 -0
- package/dist/esm/ui/Badge/Badge.js.map +1 -0
- package/dist/esm/ui/Badge/hooks/useBadge.js +23 -0
- package/dist/esm/ui/Badge/hooks/useBadge.js.map +1 -0
- package/dist/esm/ui/Badge/index.js +4 -0
- package/dist/esm/ui/Badge/index.js.map +1 -0
- package/dist/esm/ui/Badge/styles.css +21 -0
- package/dist/esm/ui/Badge/types.js +3 -0
- package/dist/esm/ui/Badge/types.js.map +1 -0
- package/dist/esm/ui/Chip/styles.css +7 -0
- package/dist/esm/ui/Rule/Rule.js +16 -0
- package/dist/esm/ui/Rule/Rule.js.map +1 -0
- package/dist/esm/ui/Rule/index.js +4 -0
- package/dist/esm/ui/Rule/index.js.map +1 -0
- package/dist/esm/ui/Rule/styles.css +16 -0
- package/dist/esm/ui/Rule/types.js +3 -0
- package/dist/esm/ui/Rule/types.js.map +1 -0
- package/dist/esm/ui/Tooltip/common/TooltipArea/TooltipArea.js +1 -1
- package/dist/esm/ui/Tooltip/common/TooltipArea/TooltipArea.js.map +1 -1
- package/dist/esm/ui/Tooltip/common/TooltipArea/styles.css +1 -1
- package/dist/esm/ui/index.js +2 -0
- package/dist/esm/ui/index.js.map +1 -1
- package/dist/types/ui/Badge/Badge.d.ts +11 -0
- package/dist/types/ui/Badge/Badge.d.ts.map +1 -0
- package/dist/types/ui/Badge/hooks/useBadge.d.ts +7 -0
- package/dist/types/ui/Badge/hooks/useBadge.d.ts.map +1 -0
- package/dist/types/ui/Badge/index.d.ts +3 -0
- package/dist/types/ui/Badge/index.d.ts.map +1 -0
- package/dist/types/ui/Badge/types.d.ts +42 -0
- package/dist/types/ui/Badge/types.d.ts.map +1 -0
- package/dist/types/ui/Button/types.d.ts +6 -2
- package/dist/types/ui/Button/types.d.ts.map +1 -1
- package/dist/types/ui/Rule/Rule.d.ts +12 -0
- package/dist/types/ui/Rule/Rule.d.ts.map +1 -0
- package/dist/types/ui/Rule/index.d.ts +3 -0
- package/dist/types/ui/Rule/index.d.ts.map +1 -0
- package/dist/types/ui/Rule/types.d.ts +12 -0
- package/dist/types/ui/Rule/types.d.ts.map +1 -0
- package/dist/types/ui/index.d.ts +2 -0
- package/dist/types/ui/index.d.ts.map +1 -1
- package/package.json +10 -10
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import "./styles.css";
|
|
3
|
+
import useBadge from "./hooks/useBadge.js";
|
|
4
|
+
const componentCssClassName = "ds badge";
|
|
5
|
+
/**
|
|
6
|
+
* description of the Badge component
|
|
7
|
+
* @returns {React.ReactElement} - Rendered Badge
|
|
8
|
+
* @implements syntax:core:component:badge:1.0.0
|
|
9
|
+
*/
|
|
10
|
+
const Badge = ({ value, className, severity, humanizeOptions, pluralizeOptions, ...props }) => {
|
|
11
|
+
const { displayValue, title } = useBadge({
|
|
12
|
+
value,
|
|
13
|
+
humanizeOptions,
|
|
14
|
+
pluralizeOptions,
|
|
15
|
+
});
|
|
16
|
+
return (_jsx("span", { title: title, className: [componentCssClassName, severity, className]
|
|
17
|
+
.filter(Boolean)
|
|
18
|
+
.join(" "), ...props, children: displayValue }));
|
|
19
|
+
};
|
|
20
|
+
export default Badge;
|
|
21
|
+
//# sourceMappingURL=Badge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Badge.js","sourceRoot":"","sources":["../../../../src/ui/Badge/Badge.tsx"],"names":[],"mappings":";AAIA,OAAO,cAAc,CAAC;AACtB,OAAO,QAAQ,MAAM,qBAAqB,CAAC;AAE3C,MAAM,qBAAqB,GAAG,UAAU,CAAC;AAEzC;;;;GAIG;AACH,MAAM,KAAK,GAAG,CAAC,EACb,KAAK,EACL,SAAS,EACT,QAAQ,EACR,eAAe,EACf,gBAAgB,EAChB,GAAG,KAAK,EACG,EAAsB,EAAE;IACnC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,GAAG,QAAQ,CAAC;QACvC,KAAK;QACL,eAAe;QACf,gBAAgB;KACjB,CAAC,CAAC;IAEH,OAAO,CACL,eACE,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,CAAC,qBAAqB,EAAE,QAAQ,EAAE,SAAS,CAAC;aACpD,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,GAAG,CAAC,KACR,KAAK,YAER,YAAY,GACR,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,KAAK,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { humanizeNumber, pluralize, } from "@canonical/utils";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
const DEFAULT_HUMANIZE_OPTIONS = {
|
|
4
|
+
overflowIndicator: "+",
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* A hook to manage a Badge's internal state
|
|
8
|
+
*/
|
|
9
|
+
const useBadge = ({ value, humanizeOptions, pluralizeOptions, }) => {
|
|
10
|
+
// Badge values must be at least 0 to preserve their purpose as natural number indicators
|
|
11
|
+
const valueToUse = useMemo(() => Math.max(0, value), [value]);
|
|
12
|
+
const displayValue = useMemo(() => {
|
|
13
|
+
const options = { ...DEFAULT_HUMANIZE_OPTIONS, ...humanizeOptions };
|
|
14
|
+
return humanizeNumber(valueToUse, options).displayValue;
|
|
15
|
+
}, [valueToUse, humanizeOptions]);
|
|
16
|
+
const title = useMemo(() => `${displayValue} ${pluralize(valueToUse, pluralizeOptions)}`, [valueToUse, displayValue, pluralizeOptions]);
|
|
17
|
+
return useMemo(() => ({
|
|
18
|
+
displayValue,
|
|
19
|
+
title,
|
|
20
|
+
}), [displayValue, title]);
|
|
21
|
+
};
|
|
22
|
+
export default useBadge;
|
|
23
|
+
//# sourceMappingURL=useBadge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBadge.js","sourceRoot":"","sources":["../../../../../src/ui/Badge/hooks/useBadge.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,cAAc,EACd,SAAS,GACV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAGhC,MAAM,wBAAwB,GAA0B;IACtD,iBAAiB,EAAE,GAAG;CACvB,CAAC;AAEF;;GAEG;AACH,MAAM,QAAQ,GAAG,CAAC,EAChB,KAAK,EACL,eAAe,EACf,gBAAgB,GACF,EAAkB,EAAE;IAClC,yFAAyF;IACzF,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAE9D,MAAM,YAAY,GAAW,OAAO,CAAC,GAAG,EAAE;QACxC,MAAM,OAAO,GAAG,EAAE,GAAG,wBAAwB,EAAE,GAAG,eAAe,EAAE,CAAC;QAEpE,OAAO,cAAc,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,YAAY,CAAC;IAC1D,CAAC,EAAE,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC,CAAC;IAElC,MAAM,KAAK,GAAW,OAAO,CAC3B,GAAG,EAAE,CAAC,GAAG,YAAY,IAAI,SAAS,CAAC,UAAU,EAAE,gBAAgB,CAAC,EAAE,EAClE,CAAC,UAAU,EAAE,YAAY,EAAE,gBAAgB,CAAC,CAC7C,CAAC;IAEF,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC,CAAC;QACL,YAAY;QACZ,KAAK;KACN,CAAC,EACF,CAAC,YAAY,EAAE,KAAK,CAAC,CACtB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/ui/Badge/index.ts"],"names":[],"mappings":"AAAA,mDAAmD;AAEnD,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,YAAY,CAAC;AAC9C,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/* Badge.css */
|
|
2
|
+
.ds.badge {
|
|
3
|
+
/** Pull the badge closer to the edge of a chip */
|
|
4
|
+
--badge-chip-margin-tweak: 0.15rem;
|
|
5
|
+
|
|
6
|
+
/* Base badge styles using tokens */
|
|
7
|
+
background-color: var(--intent-color, var(--badge-color-background));
|
|
8
|
+
border-radius: var(--badge-border-radius);
|
|
9
|
+
box-sizing: content-box;
|
|
10
|
+
color: var(--intent-color-text, var(--badge-color-text));
|
|
11
|
+
display: inline-block;
|
|
12
|
+
font-size: var(--badge-font-size);
|
|
13
|
+
font-weight: var(--badge-font-weight);
|
|
14
|
+
line-height: var(--badge-line-height);
|
|
15
|
+
margin-bottom: var(--badge-margin-bottom);
|
|
16
|
+
max-width: var(--badge-max-width);
|
|
17
|
+
min-width: var(--badge-min-width);
|
|
18
|
+
overflow: hidden;
|
|
19
|
+
padding: var(--badge-padding-vertical) var(--badge-padding-horizontal);
|
|
20
|
+
text-align: center;
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/ui/Badge/types.ts"],"names":[],"mappings":"AAAA,mDAAmD"}
|
|
@@ -76,4 +76,11 @@
|
|
|
76
76
|
var(--chip-color-background-active)
|
|
77
77
|
);
|
|
78
78
|
}
|
|
79
|
+
|
|
80
|
+
/* Context-specific styling for badges within chips */
|
|
81
|
+
& .ds.badge {
|
|
82
|
+
align-self: center;
|
|
83
|
+
margin-left: var(--spacing-horizontal-small);
|
|
84
|
+
margin-right: var(--badge-chip-margin-tweak);
|
|
85
|
+
}
|
|
79
86
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import "./styles.css";
|
|
3
|
+
const componentCssClassName = "ds rule";
|
|
4
|
+
/**
|
|
5
|
+
* A component that separates content into logical groups.
|
|
6
|
+
* @TODO implement fixed-width behavior after implementation of the Grid
|
|
7
|
+
* @returns {React.ReactElement} - Rendered Rule
|
|
8
|
+
* @implements syntax:core:component:rule:1.0.0
|
|
9
|
+
*/
|
|
10
|
+
const Rule = ({ className, emphasis, ...props }) => {
|
|
11
|
+
return (_jsx("hr", { className: [componentCssClassName, emphasis, className]
|
|
12
|
+
.filter(Boolean)
|
|
13
|
+
.join(" "), ...props }));
|
|
14
|
+
};
|
|
15
|
+
export default Rule;
|
|
16
|
+
//# sourceMappingURL=Rule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Rule.js","sourceRoot":"","sources":["../../../../src/ui/Rule/Rule.tsx"],"names":[],"mappings":";AAIA,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,SAAS,CAAC;AAExC;;;;;GAKG;AACH,MAAM,IAAI,GAAG,CAAC,EACZ,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACE,EAAsB,EAAE;IAClC,OAAO,CACL,aACE,SAAS,EAAE,CAAC,qBAAqB,EAAE,QAAQ,EAAE,SAAS,CAAC;aACpD,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,GAAG,CAAC,KACR,KAAK,GACT,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/ui/Rule/index.ts"],"names":[],"mappings":"AAAA,mDAAmD;AAEnD,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,WAAW,CAAC;AAC5C,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/* @canonical/generator-ds 0.10.0-experimental.2 */
|
|
2
|
+
|
|
3
|
+
.ds.rule {
|
|
4
|
+
background-color: var(
|
|
5
|
+
--intent-separator-bar-color,
|
|
6
|
+
var(--rule-color-background)
|
|
7
|
+
);
|
|
8
|
+
border-width: var(--rule-border-width);
|
|
9
|
+
height: var(--intent-separator-bar-height, var(--rule-height));
|
|
10
|
+
margin-block-start: var(--rule-margin-top);
|
|
11
|
+
/* global modifiers can change the height of the rule. Subtract the actual height of the rule from the target height to keep baseline alignment */
|
|
12
|
+
margin-block-end: calc(
|
|
13
|
+
var(--rule-height-with-margin) -
|
|
14
|
+
var(--intent-separator-bar-height, var(--rule-height))
|
|
15
|
+
);
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/ui/Rule/types.ts"],"names":[],"mappings":"AAAA,mDAAmD"}
|
|
@@ -19,7 +19,7 @@ const TooltipArea = ({ children, style, className, Message, distance = "6px", ta
|
|
|
19
19
|
.join(" "), onPointerEnter: handleTriggerEnter, onFocus: handleTriggerFocus, ref: popupRef, style: {
|
|
20
20
|
...messageElementStyle,
|
|
21
21
|
...popupPositionStyle,
|
|
22
|
-
// @ts-
|
|
22
|
+
// @ts-expect-error allow binding arrow size to distance, as it is needed both in JS and CSS calculations
|
|
23
23
|
"--tooltip-spacing-arrow-size": distance,
|
|
24
24
|
...(autoFit &&
|
|
25
25
|
bestPosition?.autoFitOffset && {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TooltipArea.js","sourceRoot":"","sources":["../../../../../../src/ui/Tooltip/common/TooltipArea/TooltipArea.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAGzC,OAAO,cAAc,CAAC;AACtB,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,MAAM,qBAAqB,GAAG,iBAAiB,CAAC;AAEhD;;;GAGG;AACH,MAAM,WAAW,GAAG,CAAC,EACnB,QAAQ,EACR,KAAK,EACL,SAAS,EACT,OAAO,EACP,QAAQ,GAAG,KAAK,EAChB,eAAe,EACf,sBAAsB,EACtB,kBAAkB,EAClB,uBAAuB,EACvB,mBAAmB,EACnB,aAAa,EACb,OAAO,EACP,GAAG,KAAK,EACS,EAAgB,EAAE;IACnC,MAAM,EACJ,SAAS,EACT,QAAQ,EACR,kBAAkB,EAClB,OAAO,EACP,MAAM,EACN,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,YAAY,GACb,GAAG,QAAQ,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC;IAE9C,MAAM,qBAAqB,GAAG,CAC5B,KAAC,OAAO,IACN,EAAE,EAAE,OAAO,EACX,SAAS,EAAE;YACT,YAAY,EAAE,YAAY;YAC1B,uBAAuB;YACvB,OAAO,IAAI,SAAS;SACrB;aACE,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,GAAG,CAAC,EACZ,cAAc,EAAE,kBAAkB,EAClC,OAAO,EAAE,kBAAkB,EAC3B,GAAG,EAAE,QAAQ,EACb,KAAK,EAAE;YACL,GAAG,mBAAmB;YACtB,GAAG,kBAAkB;YACrB,
|
|
1
|
+
{"version":3,"file":"TooltipArea.js","sourceRoot":"","sources":["../../../../../../src/ui/Tooltip/common/TooltipArea/TooltipArea.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAGzC,OAAO,cAAc,CAAC;AACtB,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,MAAM,qBAAqB,GAAG,iBAAiB,CAAC;AAEhD;;;GAGG;AACH,MAAM,WAAW,GAAG,CAAC,EACnB,QAAQ,EACR,KAAK,EACL,SAAS,EACT,OAAO,EACP,QAAQ,GAAG,KAAK,EAChB,eAAe,EACf,sBAAsB,EACtB,kBAAkB,EAClB,uBAAuB,EACvB,mBAAmB,EACnB,aAAa,EACb,OAAO,EACP,GAAG,KAAK,EACS,EAAgB,EAAE;IACnC,MAAM,EACJ,SAAS,EACT,QAAQ,EACR,kBAAkB,EAClB,OAAO,EACP,MAAM,EACN,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,YAAY,GACb,GAAG,QAAQ,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC;IAE9C,MAAM,qBAAqB,GAAG,CAC5B,KAAC,OAAO,IACN,EAAE,EAAE,OAAO,EACX,SAAS,EAAE;YACT,YAAY,EAAE,YAAY;YAC1B,uBAAuB;YACvB,OAAO,IAAI,SAAS;SACrB;aACE,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,GAAG,CAAC,EACZ,cAAc,EAAE,kBAAkB,EAClC,OAAO,EAAE,kBAAkB,EAC3B,GAAG,EAAE,QAAQ,EACb,KAAK,EAAE;YACL,GAAG,mBAAmB;YACtB,GAAG,kBAAkB;YACrB,yGAAyG;YACzG,8BAA8B,EAAE,QAAQ;YACxC,GAAG,CAAC,OAAO;gBACT,YAAY,EAAE,aAAa,IAAI;gBAC7B,4BAA4B,EAAE,GAAG,YAAY,EAAE,aAAa,CAAC,GAAG,IAAI,CAAC,IAAI;gBACzE,6BAA6B,EAAE,GAAG,YAAY,EAAE,aAAa,CAAC,IAAI,IAAI,CAAC,IAAI;aAC5E,CAAC;SACL,EACD,MAAM,EAAE,MAAM,YAEb,OAAO,GACA,CACX,CAAC;IAEF,OAAO;IACL,0GAA0G;IAC1G,gBACE,SAAS,EAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EACvE,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,kBAAkB,EAC3B,MAAM,EAAE,iBAAiB,EACzB,cAAc,EAAE,kBAAkB,EAClC,cAAc,EAAE,kBAAkB,aAElC,eACE,EAAE,EAAE,eAAe,EACnB,KAAK,EAAE,kBAAkB,EACzB,SAAS,EAAE,CAAC,QAAQ,EAAE,sBAAsB,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EACvE,GAAG,EAAE,SAAS,sBACI,OAAO,YAExB,QAAQ,GACJ,EAIN,OAAO,MAAM,KAAK,WAAW;gBAC5B,CAAC,CAAC,sEAAsE;oBACtE,8FAA8F;oBAC9F,oCAAoC;oBACpC,YAAY,CAAC,qBAAqB,EAAE,aAAa,IAAI,QAAQ,CAAC,IAAI,CAAC;gBACrE,CAAC,CAAC,qBAAqB,IACpB,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
display: inline-block;
|
|
7
7
|
|
|
8
8
|
& > * {
|
|
9
|
-
/* The tooltip targets must have no margin in order for tooltip placements to work correctly */
|
|
9
|
+
/* biome-ignore lint/complexity/noImportantStyles: The tooltip targets must have no margin in order for tooltip placements to work correctly */
|
|
10
10
|
margin: 0 !important;
|
|
11
11
|
}
|
|
12
12
|
}
|
package/dist/esm/ui/index.js
CHANGED
package/dist/esm/ui/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ui/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ui/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type React from "react";
|
|
2
|
+
import type { BadgeProps } from "./types.js";
|
|
3
|
+
import "./styles.css";
|
|
4
|
+
/**
|
|
5
|
+
* description of the Badge component
|
|
6
|
+
* @returns {React.ReactElement} - Rendered Badge
|
|
7
|
+
* @implements syntax:core:component:badge:1.0.0
|
|
8
|
+
*/
|
|
9
|
+
declare const Badge: ({ value, className, severity, humanizeOptions, pluralizeOptions, ...props }: BadgeProps) => React.ReactElement;
|
|
10
|
+
export default Badge;
|
|
11
|
+
//# sourceMappingURL=Badge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Badge.d.ts","sourceRoot":"","sources":["../../../../src/ui/Badge/Badge.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,cAAc,CAAC;AAKtB;;;;GAIG;AACH,QAAA,MAAM,KAAK,GAAI,6EAOZ,UAAU,KAAG,KAAK,CAAC,YAkBrB,CAAC;AAEF,eAAe,KAAK,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { UseBadgeProps, UseBadgeResult } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* A hook to manage a Badge's internal state
|
|
4
|
+
*/
|
|
5
|
+
declare const useBadge: ({ value, humanizeOptions, pluralizeOptions, }: UseBadgeProps) => UseBadgeResult;
|
|
6
|
+
export default useBadge;
|
|
7
|
+
//# sourceMappingURL=useBadge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBadge.d.ts","sourceRoot":"","sources":["../../../../../src/ui/Badge/hooks/useBadge.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAMjE;;GAEG;AACH,QAAA,MAAM,QAAQ,GAAI,+CAIf,aAAa,KAAG,cAsBlB,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ui/Badge/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,YAAY,CAAC;AAC9C,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { ModifierFamily } from "@canonical/ds-types";
|
|
2
|
+
import type { HumanizeNumberOptions, PluralizeOptions } from "@canonical/utils";
|
|
3
|
+
import type { HTMLAttributes } from "react";
|
|
4
|
+
export interface BadgeProps extends HTMLAttributes<HTMLSpanElement> {
|
|
5
|
+
/**
|
|
6
|
+
* Numeric value to be displayed.
|
|
7
|
+
*/
|
|
8
|
+
value: number;
|
|
9
|
+
/**
|
|
10
|
+
* Visual appearance of the badge, typically reflecting status.
|
|
11
|
+
* Options include:
|
|
12
|
+
* - "positive": Indicates a positive status
|
|
13
|
+
* - "negative": Indicates a negative status
|
|
14
|
+
* - "caution": Indicates a cautionary status
|
|
15
|
+
* - "information": Indicates an informative status
|
|
16
|
+
* // TODO neutral intent is currently defined in a very button-centric way. It should unset other appearances, but it currently applies default button styling.
|
|
17
|
+
* Possibly we will need to revisit this by binding component variables without component name prefix, so that neutral can reset components to their neutral state.
|
|
18
|
+
*
|
|
19
|
+
* When no appearance is specified, uses the default badge styling.
|
|
20
|
+
*/
|
|
21
|
+
severity?: ModifierFamily<"severity">;
|
|
22
|
+
/**
|
|
23
|
+
* Options for humanizing the numeric value displayed in the badge.
|
|
24
|
+
*/
|
|
25
|
+
humanizeOptions?: HumanizeNumberOptions;
|
|
26
|
+
/**
|
|
27
|
+
* Options for the pluralization of the item being counted.
|
|
28
|
+
*/
|
|
29
|
+
pluralizeOptions?: PluralizeOptions;
|
|
30
|
+
}
|
|
31
|
+
export type UseBadgeProps = Pick<BadgeProps, "value" | "humanizeOptions" | "pluralizeOptions">;
|
|
32
|
+
/**
|
|
33
|
+
* Result of the useBadge hook.
|
|
34
|
+
* Contains the formatted display value and ARIA label for accessibility.
|
|
35
|
+
*/
|
|
36
|
+
export interface UseBadgeResult {
|
|
37
|
+
/** Formatted value to be displayed in the badge */
|
|
38
|
+
displayValue: string | number;
|
|
39
|
+
/** Title attribute, for displaying additional context about the badge on hover */
|
|
40
|
+
title: string;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/ui/Badge/types.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAChF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAE5C,MAAM,WAAW,UAAW,SAAQ,cAAc,CAAC,eAAe,CAAC;IACjE;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;IAEtC;;OAEG;IACH,eAAe,CAAC,EAAE,qBAAqB,CAAC;IAExC;;OAEG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACrC;AAED,MAAM,MAAM,aAAa,GAAG,IAAI,CAC9B,UAAU,EACV,OAAO,GAAG,iBAAiB,GAAG,kBAAkB,CACjD,CAAC;AAEF;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,mDAAmD;IACnD,YAAY,EAAE,MAAM,GAAG,MAAM,CAAC;IAC9B,kFAAkF;IAClF,KAAK,EAAE,MAAM,CAAC;CACf"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ModifierFamily } from "@canonical/ds-types";
|
|
1
2
|
import type { ButtonHTMLAttributes, ReactNode } from "react";
|
|
2
3
|
export interface BaseProps {
|
|
3
4
|
id?: string;
|
|
@@ -10,8 +11,11 @@ export interface BaseProps {
|
|
|
10
11
|
* `aria-label` prop to ensure that the button label is applied properly. Otherwise, the label will be set to [object Object].
|
|
11
12
|
* */
|
|
12
13
|
children: ReactNode;
|
|
13
|
-
/**
|
|
14
|
-
|
|
14
|
+
/**
|
|
15
|
+
* The visual style of the button
|
|
16
|
+
* TODO link button will be a separate component in the future
|
|
17
|
+
* */
|
|
18
|
+
appearance?: ModifierFamily<"severity"> | "base" | "link";
|
|
15
19
|
}
|
|
16
20
|
type Props = BaseProps & ButtonHTMLAttributes<HTMLButtonElement>;
|
|
17
21
|
export default Props;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/ui/Button/types.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE7D,MAAM,WAAW,SAAS;IAExB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;SAKK;IACL,QAAQ,EAAE,SAAS,CAAC;IACpB
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/ui/Button/types.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE7D,MAAM,WAAW,SAAS;IAExB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;SAKK;IACL,QAAQ,EAAE,SAAS,CAAC;IACpB;;;SAGK;IACL,UAAU,CAAC,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,MAAM,GAAG,MAAM,CAAC;CAC3D;AAED,KAAK,KAAK,GAAG,SAAS,GAAG,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;AAEjE,eAAe,KAAK,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type React from "react";
|
|
2
|
+
import type { RuleProps } from "./types.js";
|
|
3
|
+
import "./styles.css";
|
|
4
|
+
/**
|
|
5
|
+
* A component that separates content into logical groups.
|
|
6
|
+
* @TODO implement fixed-width behavior after implementation of the Grid
|
|
7
|
+
* @returns {React.ReactElement} - Rendered Rule
|
|
8
|
+
* @implements syntax:core:component:rule:1.0.0
|
|
9
|
+
*/
|
|
10
|
+
declare const Rule: ({ className, emphasis, ...props }: RuleProps) => React.ReactElement;
|
|
11
|
+
export default Rule;
|
|
12
|
+
//# sourceMappingURL=Rule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Rule.d.ts","sourceRoot":"","sources":["../../../../src/ui/Rule/Rule.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,cAAc,CAAC;AAItB;;;;;GAKG;AACH,QAAA,MAAM,IAAI,GAAI,mCAIX,SAAS,KAAG,KAAK,CAAC,YASpB,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ui/Rule/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,WAAW,CAAC;AAC5C,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ModifierFamily } from "@canonical/ds-types";
|
|
2
|
+
import type { HTMLAttributes } from "react";
|
|
3
|
+
/**
|
|
4
|
+
We have used the `HTMLDivElement` as a default props base.
|
|
5
|
+
If your component is based on a different HTML element, please update it accordingly.
|
|
6
|
+
See https://developer.mozilla.org/en-US/docs/Web/API/HTML_DOM_API for a full list of HTML elements interfaces.
|
|
7
|
+
*/
|
|
8
|
+
export interface RuleProps extends HTMLAttributes<HTMLHRElement> {
|
|
9
|
+
className?: string;
|
|
10
|
+
emphasis?: ModifierFamily<"emphasis">;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/ui/Rule/types.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAE5C;;;;EAIE;AACF,MAAM,WAAW,SAAU,SAAQ,cAAc,CAAC,aAAa,CAAC;IAE9D,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,QAAQ,CAAC,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;CACvC"}
|
package/dist/types/ui/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canonical/react-ds-core",
|
|
3
|
-
"version": "0.10.0-experimental.
|
|
3
|
+
"version": "0.10.0-experimental.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -34,28 +34,28 @@
|
|
|
34
34
|
"check:ts": "tsc --noEmit",
|
|
35
35
|
"storybook": "storybook dev -p 6006 --no-open --host 0.0.0.0",
|
|
36
36
|
"test": "bun run test:vitest",
|
|
37
|
-
"test:watch": "bun run test:vitest:watch",
|
|
38
37
|
"test:vitest": "vitest run",
|
|
39
38
|
"test:vitest:watch": "vitest"
|
|
40
39
|
},
|
|
41
40
|
"dependencies": {
|
|
42
|
-
"@canonical/storybook-config": "^0.10.0-experimental.
|
|
43
|
-
"@canonical/styles": "^0.10.0-experimental.
|
|
44
|
-
"@canonical/utils": "^0.10.0-experimental.
|
|
41
|
+
"@canonical/storybook-config": "^0.10.0-experimental.3",
|
|
42
|
+
"@canonical/styles": "^0.10.0-experimental.3",
|
|
43
|
+
"@canonical/utils": "^0.10.0-experimental.3",
|
|
45
44
|
"react": "^19.1.0",
|
|
46
45
|
"react-dom": "^19.1.0"
|
|
47
46
|
},
|
|
48
47
|
"devDependencies": {
|
|
49
|
-
"@biomejs/biome": "
|
|
50
|
-
"@canonical/biome-config": "^0.10.0-experimental.
|
|
51
|
-
"@canonical/
|
|
48
|
+
"@biomejs/biome": "2.2.2",
|
|
49
|
+
"@canonical/biome-config": "^0.10.0-experimental.3",
|
|
50
|
+
"@canonical/ds-types": "^0.10.0-experimental.3",
|
|
51
|
+
"@canonical/typescript-config-react": "^0.10.0-experimental.3",
|
|
52
52
|
"@chromatic-com/storybook": "^4.0.0",
|
|
53
53
|
"@testing-library/jest-dom": "^6.6.3",
|
|
54
54
|
"@testing-library/react": "^16.3.0",
|
|
55
55
|
"@types/node": "^24.0.0",
|
|
56
56
|
"@types/react": "^19.1.8",
|
|
57
57
|
"@types/react-dom": "^19.1.6",
|
|
58
|
-
"@vitejs/plugin-react": "^
|
|
58
|
+
"@vitejs/plugin-react": "^5.0.0",
|
|
59
59
|
"copyfiles": "^2.4.1",
|
|
60
60
|
"globals": "^16.2.0",
|
|
61
61
|
"jsdom": "^26.1.0",
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"vite-tsconfig-paths": "^5.1.4",
|
|
66
66
|
"vitest": "^3.2.3"
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "99c01818f83645f82a1a8971e5da18ce35eff68c"
|
|
69
69
|
}
|