@geneui/components 3.0.0-next-b9961e0-15012025 → 3.0.0-next-ff984eb-15012025
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/Badge.js +36 -0
- package/components/atoms/Badge/Badge.d.ts +48 -0
- package/components/atoms/Badge/index.d.ts +1 -0
- package/index.d.ts +5 -4
- package/index.js +1 -0
- package/package.json +1 -1
package/Badge.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import { c as classNames } from './index-ce02421b.js';
|
|
3
|
+
import { s as styleInject } from './style-inject.es-746bb8ed.js';
|
|
4
|
+
|
|
5
|
+
var css_248z = ".badge{position:relative;width:-webkit-fit-content;width:-moz-fit-content;width:fit-content}.badge__content{align-items:center;display:flex;justify-content:center;-webkit-user-select:none;user-select:none}.badge__content_position_absolute{position:absolute;z-index:1}.badge__content_position_absolute.badge__content_size_small,.badge__content_position_absolute.badge__content_size_smallNudge{inset-block-start:-.6rem;inset-inline-end:-.6rem}.badge__content_position_absolute.badge__content_size_xSmall{inset-block-start:-.4rem;inset-inline-end:-.4rem}.badge__content_position_absolute.badge__content_size_3xSmall{inset-block-start:-.2rem;inset-inline-end:-.2rem}.badge__content_size_small{border-radius:var(--guit-ref-radius-medium);height:var(--guit-sem-dimension-height-small);min-width:var(--guit-sem-dimension-width-small)}.badge__content_size_smallNudge{border-radius:var(--guit-ref-radius-full);height:var(--guit-sem-dimension-height-small-nudge);width:var(--guit-sem-dimension-width-small-nudge)}.badge__content_size_xSmall{border-radius:var(--guit-ref-radius-full);height:var(--guit-sem-dimension-height-xsmall);width:var(--guit-sem-dimension-width-xsmall)}.badge__content_size_3xSmall{border-radius:var(--guit-ref-radius-full);height:var(--guit-sem-dimension-height-3xsmall);width:var(--guit-sem-dimension-width-3xsmall)}.badge__content_color_brand{background-color:var(--guit-sem-color-background-brand-2);color:var(--guit-sem-color-foreground-inverse)}.badge__content_color_brand.badge__content_bordered{border-color:var(--guit-sem-color-border-neutral-1)}.badge__content_color_neutral{background-color:var(--guit-sem-color-background-neutral-4);color:var(--guit-sem-color-foreground-neutral-2)}.badge__content_color_neutral.badge__content_bordered{border-color:var(--guit-sem-color-border-neutral-1)}.badge__content_color_red{background-color:var(--guit-sem-color-background-accent-red-2);color:var(--guit-sem-color-foreground-inverse)}.badge__content_color_red.badge__content_bordered{border-color:var(--guit-sem-color-border-neutral-1)}.badge__content_color_inverse{background-color:var(--guit-sem-color-foreground-inverse);color:var(--guit-sem-color-foreground-neutral-2)}.badge__content_color_inverse.badge__content_bordered{border-color:var(--guit-sem-color-border-neutral-2)}.badge__content:has(.badge__num){padding:var(--guit-ref-spacing-4xsmall) var(--guit-ref-spacing-2xsmall)}.badge__content_bordered{border:var(--guit-sem-border-default-width) var(--guit-sem-border-default-style)}.badge__num{font-family:var(--guit-sem-font-label-medium-default-semibold-font-family);font-size:var(--guit-sem-font-label-medium-default-semibold-font-size);font-weight:var(--guit-sem-font-label-medium-default-medium-font-weight);line-height:var(--guit-sem-font-label-medium-default-semibold-line-height)}";
|
|
6
|
+
styleInject(css_248z);
|
|
7
|
+
|
|
8
|
+
const MAX_VALUE = 99;
|
|
9
|
+
const getValue = (value, maxValue, size) => {
|
|
10
|
+
if (!Number(value) || size !== "small" || !value)
|
|
11
|
+
return null;
|
|
12
|
+
if (!maxValue)
|
|
13
|
+
return value;
|
|
14
|
+
const calculatedMaxValue = maxValue > 0 && maxValue < MAX_VALUE ? maxValue : MAX_VALUE;
|
|
15
|
+
return value > calculatedMaxValue ? `${calculatedMaxValue}+` : value;
|
|
16
|
+
};
|
|
17
|
+
const getSize = (withChildren, size) => {
|
|
18
|
+
if (!withChildren || size === "xSmall")
|
|
19
|
+
return size;
|
|
20
|
+
return "3xSmall";
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Numeric Badge component is a small, circular indicator that displays numerical information, often used to highlight counts or statuses. It is typically positioned adjacent to icons or labels, providing users with a quick visual cue about the number of notifications, messages, or items requiring attention.
|
|
24
|
+
*/
|
|
25
|
+
const Badge = ({ className, appearance = "brand", withBorder, size = "small", value, maxValue = 99, children }) => {
|
|
26
|
+
const badgeSize = getSize(!!children, size);
|
|
27
|
+
const badgeValue = getValue(value, maxValue, badgeSize);
|
|
28
|
+
return (React__default.createElement("div", { className: classNames("badge", className) },
|
|
29
|
+
React__default.createElement("div", { className: classNames(`badge__content badge__content_color_${appearance} badge__content_size_${badgeSize}`, {
|
|
30
|
+
badge__content_bordered: withBorder,
|
|
31
|
+
badge__content_position_absolute: children
|
|
32
|
+
}) }, !!badgeValue && React__default.createElement("p", { className: "badge__num" }, badgeValue)),
|
|
33
|
+
children));
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export { Badge as default };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { FC, JSX } from "react";
|
|
2
|
+
import "./Badge.scss";
|
|
3
|
+
interface IBadgeProps {
|
|
4
|
+
/**
|
|
5
|
+
* Determines whether the badge component should display a border around it.
|
|
6
|
+
* When set to `true`, the `badge` will render with a visible `border`.
|
|
7
|
+
*/
|
|
8
|
+
withBorder?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Size <br>
|
|
11
|
+
* Possible values: `small | smallNudge | xSmall | 3xSmall`
|
|
12
|
+
*/
|
|
13
|
+
size?: "small" | "smallNudge" | "xSmall" | "3xSmall";
|
|
14
|
+
/**
|
|
15
|
+
* Determines the visual appearance of the `badge`. <br>
|
|
16
|
+
* Possible values: `brand | neutral | red | inverse`
|
|
17
|
+
*/
|
|
18
|
+
appearance?: "brand" | "neutral" | "red" | "inverse";
|
|
19
|
+
/**
|
|
20
|
+
* The value will shown as content of the `badge`.
|
|
21
|
+
*/
|
|
22
|
+
value?: number;
|
|
23
|
+
/**
|
|
24
|
+
* Specifies the maximum value to display inside the `badge`.
|
|
25
|
+
* If the badge's `value` exceeds this maximum, it will display as `{maxValue}+`.
|
|
26
|
+
* The maximum allowable value for `maxValue` is capped at `99`.
|
|
27
|
+
*/
|
|
28
|
+
maxValue?: number;
|
|
29
|
+
/**
|
|
30
|
+
* Additional class for the parent element.
|
|
31
|
+
* This prop should be used to set placement properties for the element relative to its parent using `BEM` conventions.
|
|
32
|
+
*/
|
|
33
|
+
className?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Specifies the element or component on which the `badge` will be displayed.
|
|
36
|
+
* The `badge` is positioned `relative` to this child `element`, allowing it to overlay or attach to the `element`.
|
|
37
|
+
*
|
|
38
|
+
* **Note**: When using the `children` prop, only `xSmall` and `3xSmall` sizes are supported for the `badge`.
|
|
39
|
+
*
|
|
40
|
+
* The default size for the badge when `children` is provided is `3xSmall`.
|
|
41
|
+
*/
|
|
42
|
+
children?: JSX.Element;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Numeric Badge component is a small, circular indicator that displays numerical information, often used to highlight counts or statuses. It is typically positioned adjacent to icons or labels, providing users with a quick visual cue about the number of notifications, messages, or items requiring attention.
|
|
46
|
+
*/
|
|
47
|
+
declare const Badge: FC<IBadgeProps>;
|
|
48
|
+
export { IBadgeProps, Badge as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { IBadgeProps, default } from "./Badge";
|
package/index.d.ts
CHANGED
|
@@ -6,10 +6,11 @@ export { default as Pill, IPillProps } from "./components/atoms/Pill";
|
|
|
6
6
|
export { default as Divider, IDividerProps } from "./components/atoms/Divider";
|
|
7
7
|
export { default as Info, IInfoProps } from "./components/atoms/Info";
|
|
8
8
|
export { default as Button, IButtonProps } from "./components/atoms/Button";
|
|
9
|
-
export { default as
|
|
10
|
-
export { default as
|
|
11
|
-
export { default as
|
|
12
|
-
export { default as
|
|
9
|
+
export { default as Badge, IBadgeProps } from "./components/atoms/Badge";
|
|
10
|
+
export { default as Scrollbar, IScrollbarProps } from "./components/atoms/Scrollbar";
|
|
11
|
+
export { default as Tooltip, ITooltipProps } from "./components/molecules/Tooltip";
|
|
12
|
+
export { default as ProgressBar, IProgressBarProps } from "./components/molecules/ProgressBar";
|
|
13
|
+
export { default as Tag, ITagProps } from "./components/molecules/Tag";
|
|
13
14
|
export { default as GeneUIProvider, GeneUIDesignSystemContext, IGeneUIDesignSystemContext, IGeneUIProviderProps } from "./components/providers/GeneUIProvider";
|
|
14
15
|
export { default as useDebounce } from "./hooks/useDebounceCallback";
|
|
15
16
|
export { default as useEllipsisDetection } from "./hooks/useEllipsisDetection";
|
package/index.js
CHANGED
|
@@ -6,6 +6,7 @@ export { default as Pill } from './Pill.js';
|
|
|
6
6
|
export { default as Divider } from './Divider.js';
|
|
7
7
|
export { default as Info } from './Info.js';
|
|
8
8
|
export { default as Button } from './Button.js';
|
|
9
|
+
export { default as Badge } from './Badge.js';
|
|
9
10
|
export { default as Scrollbar } from './Scrollbar.js';
|
|
10
11
|
export { default as Tooltip } from './Tooltip.js';
|
|
11
12
|
export { default as ProgressBar } from './ProgressBar.js';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geneui/components",
|
|
3
3
|
"description": "The Gene UI components library designed for BI tools",
|
|
4
|
-
"version": "3.0.0-next-
|
|
4
|
+
"version": "3.0.0-next-ff984eb-15012025",
|
|
5
5
|
"author": "SoftConstruct",
|
|
6
6
|
"homepage": "https://github.com/softconstruct/gene-ui-components#readme",
|
|
7
7
|
"repository": {
|