@vectara/vectara-ui 16.8.0 → 16.10.0
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/lib/components/badge/Badge.d.ts +2 -1
- package/lib/components/badge/Badge.js +2 -2
- package/lib/components/badge/_index.scss +20 -3
- package/lib/components/button/BaseButton.d.ts +1 -0
- package/lib/components/button/BaseButton.js +27 -18
- package/lib/components/button/baseButton.scss +5 -0
- package/lib/sassUtils/_typography.scss +1 -0
- package/lib/styles/index.css +25 -3
- package/package.json +1 -1
- package/src/docs/pages/badge/BadgeColors.tsx +38 -7
- package/src/docs/pages/button/Icons.tsx +1 -1
- package/src/docs/pages/button/Truncate.tsx +1 -1
|
@@ -11,6 +11,7 @@ type Props = {
|
|
|
11
11
|
target?: LinkProps["target"];
|
|
12
12
|
track?: LinkProps["track"];
|
|
13
13
|
isSelected?: boolean;
|
|
14
|
+
size?: "s" | "m" | "l";
|
|
14
15
|
};
|
|
15
|
-
export declare const VuiBadge: ({ children, className, color, onClick, onClose, href, target, track, isSelected, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export declare const VuiBadge: ({ children, className, color, onClick, onClose, href, target, track, isSelected, size, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
16
17
|
export {};
|
|
@@ -21,10 +21,10 @@ import { VuiFlexItem } from "../flex/FlexItem";
|
|
|
21
21
|
import { createId } from "../../utils/createId";
|
|
22
22
|
export const BADGE_COLOR = ["accent", "primary", "danger", "warning", "success", "neutral"];
|
|
23
23
|
export const VuiBadge = (_a) => {
|
|
24
|
-
var { children, className, color, onClick, onClose, href, target, track, isSelected } = _a, rest = __rest(_a, ["children", "className", "color", "onClick", "onClose", "href", "target", "track", "isSelected"]);
|
|
24
|
+
var { children, className, color, onClick, onClose, href, target, track, isSelected, size = "m" } = _a, rest = __rest(_a, ["children", "className", "color", "onClick", "onClose", "href", "target", "track", "isSelected", "size"]);
|
|
25
25
|
const { createLink } = useVuiContext();
|
|
26
26
|
const id = onClose ? createId() : undefined;
|
|
27
|
-
const classes = classNames(className, "vuiBadge", `vuiBadge--${color}`, {
|
|
27
|
+
const classes = classNames(className, "vuiBadge", `vuiBadge--${size}`, `vuiBadge--${color}`, {
|
|
28
28
|
"vuiBadge--clickable": onClick !== null && onClick !== void 0 ? onClick : href
|
|
29
29
|
});
|
|
30
30
|
const content = (_jsxs(VuiFlexContainer, Object.assign({ alignItems: "center", spacing: "xxs" }, { children: [isSelected && (_jsx(VuiFlexItem, { children: _jsx(VuiIcon, Object.assign({ size: "xs", color: "inherit", className: "vuiBadge__icon" }, { children: _jsx(BiCheck, {}) })) })), _jsx(VuiFlexItem, Object.assign({ id: id }, { children: _jsx("div", Object.assign({ className: "vuiBadge__content" }, { children: children })) })), onClose && (_jsx(VuiFlexItem, { children: _jsx(VuiIconButton, { "aria-label": "Remove", "aria-describedby": id, size: "xs", color: "subdued", className: "vuiBadge__icon", onClick: (e) => {
|
|
@@ -2,13 +2,30 @@
|
|
|
2
2
|
|
|
3
3
|
.vuiBadge {
|
|
4
4
|
display: inline-block;
|
|
5
|
+
font-family: inherit;
|
|
6
|
+
white-space: nowrap;
|
|
7
|
+
text-decoration: none;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.vuiBadge--l {
|
|
11
|
+
font-size: $fontSizeMedium;
|
|
12
|
+
line-height: 1.25;
|
|
13
|
+
padding: $sizeXs $sizeS;
|
|
14
|
+
border-radius: $sizeL;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.vuiBadge--m {
|
|
5
18
|
font-size: $fontSizeSmall;
|
|
6
19
|
line-height: 1.25;
|
|
7
20
|
padding: $sizeXxs $sizeXs;
|
|
8
21
|
border-radius: $sizeS;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.vuiBadge--s {
|
|
25
|
+
font-size: $fontSizeXsmall;
|
|
26
|
+
line-height: 1.25;
|
|
27
|
+
padding: $sizeXxxs $sizeXs;
|
|
28
|
+
border-radius: $sizeS;
|
|
12
29
|
}
|
|
13
30
|
|
|
14
31
|
.vuiBadge--clickable {
|
|
@@ -26,6 +26,7 @@ export type BaseButtonProps = {
|
|
|
26
26
|
isSubmit?: boolean;
|
|
27
27
|
isLoading?: boolean;
|
|
28
28
|
truncate?: boolean;
|
|
29
|
+
"aria-label"?: string;
|
|
29
30
|
};
|
|
30
31
|
export declare const BaseButton: import("react").ForwardRefExoticComponent<BaseButtonProps & {
|
|
31
32
|
spinnerColor?: "accent" | "primary" | "success" | "warning" | "danger" | "subdued" | "empty" | "dark" | undefined;
|
|
@@ -15,6 +15,7 @@ import classNames from "classnames";
|
|
|
15
15
|
import { getTrackingProps } from "../../utils/getTrackingProps";
|
|
16
16
|
import { useVuiContext } from "../context/Context";
|
|
17
17
|
import { VuiSpinner } from "../spinner/Spinner";
|
|
18
|
+
import { VuiTooltip } from "../tooltip/Tooltip";
|
|
18
19
|
const alignToClassMap = {
|
|
19
20
|
left: "vuiBaseButton--alignLeft",
|
|
20
21
|
center: "vuiBaseButton--alignCenter",
|
|
@@ -27,12 +28,13 @@ const sizeToSpinnerSizeMap = {
|
|
|
27
28
|
l: "m"
|
|
28
29
|
};
|
|
29
30
|
export const BaseButton = forwardRef((_a, ref) => {
|
|
30
|
-
var { children, icon, iconSide = "left", align = "center", className, size = "m", fullWidth, onClick, onMouseOver, onMouseOut, onMouseMove, tabIndex, isInert, isDisabled, href, target, track, htmlFor, isSubmit, isLoading, spinnerColor, truncate } = _a, rest = __rest(_a, ["children", "icon", "iconSide", "align", "className", "size", "fullWidth", "onClick", "onMouseOver", "onMouseOut", "onMouseMove", "tabIndex", "isInert", "isDisabled", "href", "target", "track", "htmlFor", "isSubmit", "isLoading", "spinnerColor", "truncate"]);
|
|
31
|
+
var { children, icon, iconSide = "left", align = "center", className, size = "m", fullWidth, onClick, onMouseOver, onMouseOut, onMouseMove, tabIndex, isInert, isDisabled, href, target, track, htmlFor, isSubmit, isLoading, spinnerColor, truncate, "aria-label": ariaLabel } = _a, rest = __rest(_a, ["children", "icon", "iconSide", "align", "className", "size", "fullWidth", "onClick", "onMouseOver", "onMouseOut", "onMouseMove", "tabIndex", "isInert", "isDisabled", "href", "target", "track", "htmlFor", "isSubmit", "isLoading", "spinnerColor", "truncate", "aria-label"]);
|
|
31
32
|
const { createLink } = useVuiContext();
|
|
32
33
|
const classes = classNames("vuiBaseButton", className, `vuiBaseButton--${size}`, alignToClassMap[align], {
|
|
33
34
|
"vuiBaseButton-isInert": isInert,
|
|
34
35
|
"vuiBaseButton-isDisabled": isDisabled,
|
|
35
36
|
"vuiBaseButton--fullWidth": fullWidth,
|
|
37
|
+
"vuiBaseButton--truncate": truncate,
|
|
36
38
|
[`vuiBaseButton--${isLoading ? "left" : iconSide}`]: (Boolean(icon) || isLoading) && Boolean(children)
|
|
37
39
|
});
|
|
38
40
|
let iconContainer;
|
|
@@ -42,33 +44,40 @@ export const BaseButton = forwardRef((_a, ref) => {
|
|
|
42
44
|
else if (icon) {
|
|
43
45
|
iconContainer = _jsx("span", Object.assign({ className: "vuiBaseButtonIconContainer" }, { children: icon }));
|
|
44
46
|
}
|
|
45
|
-
|
|
46
|
-
// for uploading files and adding a button to trigger it.
|
|
47
|
+
let button;
|
|
47
48
|
if (htmlFor) {
|
|
48
|
-
|
|
49
|
+
// This is useful for controlling other elements, e.g. creating an <input type="file" />
|
|
50
|
+
// for uploading files and adding a button to trigger it.
|
|
51
|
+
button = (_jsxs("label", Object.assign({ "aria-label": ariaLabel, htmlFor: htmlFor, className: classes, tabIndex: tabIndex }, rest, { children: [iconContainer, children] })));
|
|
49
52
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
+
else if (href && !isDisabled) {
|
|
54
|
+
// Anchor tags can't be disabled, so we'll just render a button instead
|
|
55
|
+
// if isDisabled is true.
|
|
53
56
|
const wrapperClasses = classNames("vuiBaseButtonLinkWrapper", {
|
|
54
57
|
"vuiBaseButtonLinkWrapper--fullWidth": fullWidth
|
|
55
58
|
});
|
|
56
|
-
|
|
59
|
+
button = createLink(Object.assign(Object.assign({ className: wrapperClasses, href,
|
|
57
60
|
onClick,
|
|
58
61
|
onMouseOver,
|
|
59
62
|
onMouseOut,
|
|
60
63
|
onMouseMove, children: (
|
|
61
64
|
//* Wrap a button otherwise the flex layout breaks */}
|
|
62
|
-
_jsxs("button", Object.assign({ className: classes, tabIndex: -1, ref: ref }, { children: [iconContainer, children] }))), target,
|
|
65
|
+
_jsxs("button", Object.assign({ "aria-label": ariaLabel, className: classes, tabIndex: -1, ref: ref }, { children: [iconContainer, children] }))), target,
|
|
63
66
|
tabIndex }, rest), getTrackingProps(track)));
|
|
64
67
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
68
|
+
else {
|
|
69
|
+
const labelClasses = classNames({
|
|
70
|
+
"vuiBaseButtonLabel--truncate": truncate
|
|
71
|
+
});
|
|
72
|
+
const props = Object.assign({ onClick,
|
|
73
|
+
onMouseOver,
|
|
74
|
+
onMouseOut,
|
|
75
|
+
onMouseMove,
|
|
76
|
+
tabIndex, type: isSubmit ? "submit" : "button", disabled: isDisabled }, rest);
|
|
77
|
+
button = (_jsxs("button", Object.assign({ "aria-label": ariaLabel, className: classes }, props, { ref: ref }, { children: [iconContainer, _jsx("span", Object.assign({ className: labelClasses }, { children: children }))] })));
|
|
78
|
+
}
|
|
79
|
+
if (ariaLabel) {
|
|
80
|
+
return _jsx(VuiTooltip, Object.assign({ tip: ariaLabel }, { children: button }));
|
|
81
|
+
}
|
|
82
|
+
return button;
|
|
74
83
|
});
|
package/lib/styles/index.css
CHANGED
|
@@ -592,13 +592,30 @@ fieldset {
|
|
|
592
592
|
|
|
593
593
|
.vuiBadge {
|
|
594
594
|
display: inline-block;
|
|
595
|
+
font-family: inherit;
|
|
596
|
+
white-space: nowrap;
|
|
597
|
+
text-decoration: none;
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
.vuiBadge--l {
|
|
601
|
+
font-size: 16px;
|
|
602
|
+
line-height: 1.25;
|
|
603
|
+
padding: 8px 12px;
|
|
604
|
+
border-radius: 24px;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
.vuiBadge--m {
|
|
595
608
|
font-size: 12px;
|
|
596
609
|
line-height: 1.25;
|
|
597
610
|
padding: 4px 8px;
|
|
598
611
|
border-radius: 12px;
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
.vuiBadge--s {
|
|
615
|
+
font-size: 10px;
|
|
616
|
+
line-height: 1.25;
|
|
617
|
+
padding: 2px 8px;
|
|
618
|
+
border-radius: 12px;
|
|
602
619
|
}
|
|
603
620
|
|
|
604
621
|
.vuiBadge--clickable {
|
|
@@ -749,6 +766,11 @@ fieldset {
|
|
|
749
766
|
width: 100%;
|
|
750
767
|
}
|
|
751
768
|
|
|
769
|
+
.vuiBaseButton--truncate {
|
|
770
|
+
overflow: hidden;
|
|
771
|
+
text-overflow: ellipsis;
|
|
772
|
+
}
|
|
773
|
+
|
|
752
774
|
.vuiBaseButton--xs {
|
|
753
775
|
font-size: 12px;
|
|
754
776
|
padding: 4px 8px;
|
package/package.json
CHANGED
|
@@ -1,13 +1,44 @@
|
|
|
1
1
|
import { BADGE_COLOR, VuiBadge, VuiFlexContainer, VuiFlexItem } from "../../../lib";
|
|
2
|
+
import { Subsection } from "../../components/Subsection";
|
|
2
3
|
|
|
3
4
|
export const BadgeColors = () => {
|
|
4
5
|
return (
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
<
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
<>
|
|
7
|
+
<Subsection title="Large">
|
|
8
|
+
<VuiFlexContainer>
|
|
9
|
+
{BADGE_COLOR.map((color) => (
|
|
10
|
+
<VuiFlexItem grow={false} key={color}>
|
|
11
|
+
<VuiBadge size="l" color={color}>
|
|
12
|
+
Color {color}
|
|
13
|
+
</VuiBadge>
|
|
14
|
+
</VuiFlexItem>
|
|
15
|
+
))}
|
|
16
|
+
</VuiFlexContainer>
|
|
17
|
+
</Subsection>
|
|
18
|
+
|
|
19
|
+
<Subsection title="Medium">
|
|
20
|
+
<VuiFlexContainer>
|
|
21
|
+
{BADGE_COLOR.map((color) => (
|
|
22
|
+
<VuiFlexItem grow={false} key={color}>
|
|
23
|
+
<VuiBadge size="m" color={color}>
|
|
24
|
+
Color {color}
|
|
25
|
+
</VuiBadge>
|
|
26
|
+
</VuiFlexItem>
|
|
27
|
+
))}
|
|
28
|
+
</VuiFlexContainer>
|
|
29
|
+
</Subsection>
|
|
30
|
+
|
|
31
|
+
<Subsection title="Small">
|
|
32
|
+
<VuiFlexContainer>
|
|
33
|
+
{BADGE_COLOR.map((color) => (
|
|
34
|
+
<VuiFlexItem grow={false} key={color}>
|
|
35
|
+
<VuiBadge size="s" color={color}>
|
|
36
|
+
Color {color}
|
|
37
|
+
</VuiBadge>
|
|
38
|
+
</VuiFlexItem>
|
|
39
|
+
))}
|
|
40
|
+
</VuiFlexContainer>
|
|
41
|
+
</Subsection>
|
|
42
|
+
</>
|
|
12
43
|
);
|
|
13
44
|
};
|
|
@@ -18,7 +18,7 @@ export const Icons = () => {
|
|
|
18
18
|
</Subsection>
|
|
19
19
|
|
|
20
20
|
<Subsection title="Icon only">
|
|
21
|
-
<VuiButtonPrimary icon={icon} color="primary" size="m" />
|
|
21
|
+
<VuiButtonPrimary icon={icon} color="primary" size="m" aria-label="Add to favorites" />
|
|
22
22
|
</Subsection>
|
|
23
23
|
</>
|
|
24
24
|
);
|