@vectara/vectara-ui 19.2.0 → 19.3.1

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.
@@ -1,9 +1,10 @@
1
1
  type Props = {
2
2
  children: React.ReactNode;
3
+ size?: "s" | "m";
3
4
  isActive?: boolean;
4
5
  onClick: () => void;
5
6
  append?: React.ReactNode;
6
7
  "data-testid"?: string;
7
8
  };
8
- export declare const VuiChip: ({ children, isActive, append, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
9
+ export declare const VuiChip: ({ children, size, isActive, append, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
9
10
  export {};
@@ -12,8 +12,8 @@ var __rest = (this && this.__rest) || function (s, e) {
12
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  import classNames from "classnames";
14
14
  export const VuiChip = (_a) => {
15
- var { children, isActive, append } = _a, rest = __rest(_a, ["children", "isActive", "append"]);
16
- const classes = classNames("vuiChip", {
15
+ var { children, size = "m", isActive, append } = _a, rest = __rest(_a, ["children", "size", "isActive", "append"]);
16
+ const classes = classNames("vuiChip", `vuiChip--${size}`, {
17
17
  "vuiChip-isActive": isActive
18
18
  });
19
19
  return (_jsxs("button", Object.assign({ className: classes }, rest, { children: [_jsx("div", Object.assign({ className: "vuiChip__label" }, { children: children })), append && _jsx("div", Object.assign({ className: "vuiChip__append" }, { children: append }))] })));
@@ -4,7 +4,6 @@
4
4
  gap: $sizeXs;
5
5
  border: 1px solid var(--vui-color-border-light);
6
6
  background-color: var(--vui-color-light-shade);
7
- padding: $sizeXxs $sizeS;
8
7
  border-radius: $sizeM;
9
8
  transition: all $transitionSpeed;
10
9
  box-shadow: $shadowSmallStart;
@@ -17,20 +16,45 @@
17
16
 
18
17
  .vuiChip__label {
19
18
  font-weight: $fontWeightStrong;
20
- font-size: $fontSizeStandard;
21
19
  color: var(--vui-color-text);
22
- // Ensures consistent chip height regardless of whether
23
- // append is present or not.
24
- line-height: 1.6;
25
20
  }
26
21
 
27
22
  .vuiChip__append {
28
23
  color: var(--vui-color-subdued-shade);
29
- padding: $sizeXxs $sizeXs;
30
24
  font-size: $fontSizeSmall;
31
25
  border-radius: $sizeS;
32
26
  }
33
27
 
28
+ .vuiChip--s {
29
+ padding: $sizeXxs $sizeXs;
30
+
31
+ .vuiChip__label {
32
+ font-size: $fontSizeSmall;
33
+ // Ensures consistent chip height regardless of whether
34
+ // append is present or not.
35
+ line-height: 1.8;
36
+ }
37
+
38
+ .vuiChip__append {
39
+ padding: $sizeXxs $sizeXxs;
40
+ }
41
+ }
42
+
43
+ .vuiChip--m {
44
+ padding: $sizeXxs $sizeS;
45
+
46
+ .vuiChip__label {
47
+ font-size: $fontSizeStandard;
48
+ // Ensures consistent chip height regardless of whether
49
+ // append is present or not.
50
+ line-height: 1.6;
51
+ }
52
+
53
+ .vuiChip__append {
54
+ padding: $sizeXxs $sizeXs;
55
+ }
56
+ }
57
+
34
58
  .vuiChip-isActive {
35
59
  border: 1px solid var(--vui-color-primary-shade);
36
60
  background-color: var(--vui-color-empty-shade);
@@ -23,7 +23,7 @@
23
23
 
24
24
  .vuiSelect--s {
25
25
  select {
26
- padding: $sizeXxs $sizeS;
26
+ padding: $sizeXxs * 1.5 $sizeS;
27
27
  font-size: $fontSizeSmall;
28
28
  padding-right: 36px;
29
29
  }
@@ -1531,7 +1531,6 @@ fieldset {
1531
1531
  gap: 8px;
1532
1532
  border: 1px solid var(--vui-color-border-light);
1533
1533
  background-color: var(--vui-color-light-shade);
1534
- padding: 4px 12px;
1535
1534
  border-radius: 16px;
1536
1535
  transition: all 0.2s;
1537
1536
  box-shadow: rgba(60, 64, 67, 0.3) 0px 0px 0px 0px, rgba(60, 64, 67, 0.15) 0px 0px 0px 0px;
@@ -1543,18 +1542,37 @@ fieldset {
1543
1542
 
1544
1543
  .vuiChip__label {
1545
1544
  font-weight: 500;
1546
- font-size: 14px;
1547
1545
  color: var(--vui-color-text);
1548
- line-height: 1.6;
1549
1546
  }
1550
1547
 
1551
1548
  .vuiChip__append {
1552
1549
  color: var(--vui-color-subdued-shade);
1553
- padding: 4px 8px;
1554
1550
  font-size: 12px;
1555
1551
  border-radius: 12px;
1556
1552
  }
1557
1553
 
1554
+ .vuiChip--s {
1555
+ padding: 4px 8px;
1556
+ }
1557
+ .vuiChip--s .vuiChip__label {
1558
+ font-size: 12px;
1559
+ line-height: 1.8;
1560
+ }
1561
+ .vuiChip--s .vuiChip__append {
1562
+ padding: 4px 4px;
1563
+ }
1564
+
1565
+ .vuiChip--m {
1566
+ padding: 4px 12px;
1567
+ }
1568
+ .vuiChip--m .vuiChip__label {
1569
+ font-size: 14px;
1570
+ line-height: 1.6;
1571
+ }
1572
+ .vuiChip--m .vuiChip__append {
1573
+ padding: 4px 8px;
1574
+ }
1575
+
1558
1576
  .vuiChip-isActive {
1559
1577
  border: 1px solid var(--vui-color-primary-shade);
1560
1578
  background-color: var(--vui-color-empty-shade);
@@ -3017,7 +3035,7 @@ h2.react-datepicker__current-month {
3017
3035
  }
3018
3036
 
3019
3037
  .vuiSelect--s select {
3020
- padding: 4px 12px;
3038
+ padding: 6px 12px;
3021
3039
  font-size: 12px;
3022
3040
  padding-right: 36px;
3023
3041
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vectara/vectara-ui",
3
- "version": "19.2.0",
3
+ "version": "19.3.1",
4
4
  "homepage": "./",
5
5
  "description": "Vectara's design system, codified as a React and Sass component library",
6
6
  "author": "Vectara",
@@ -0,0 +1,53 @@
1
+ import { useState } from "react";
2
+ import { VuiChip, VuiFlexContainer, VuiSpacer, VuiToggle } from "../../../lib";
3
+
4
+ export const Small = () => {
5
+ const [hasCounts, setHasCounts] = useState(false);
6
+ const [activeOption, setActiveOption] = useState<"all" | "a" | "b" | "c">("all");
7
+
8
+ return (
9
+ <>
10
+ <VuiToggle checked={hasCounts} onChange={() => setHasCounts(!hasCounts)} label="Append counts" />
11
+
12
+ <VuiSpacer size="m" />
13
+
14
+ <VuiFlexContainer spacing="xs">
15
+ <VuiChip
16
+ size="s"
17
+ onClick={() => setActiveOption("all")}
18
+ isActive={activeOption === "all"}
19
+ append={hasCounts ? 100 : undefined}
20
+ >
21
+ All options
22
+ </VuiChip>
23
+
24
+ <VuiChip
25
+ size="s"
26
+ onClick={() => setActiveOption("a")}
27
+ isActive={activeOption === "a"}
28
+ append={hasCounts ? 2 : undefined}
29
+ >
30
+ Option A
31
+ </VuiChip>
32
+
33
+ <VuiChip
34
+ size="s"
35
+ onClick={() => setActiveOption("b")}
36
+ isActive={activeOption === "b"}
37
+ append={hasCounts ? 81 : undefined}
38
+ >
39
+ Option B
40
+ </VuiChip>
41
+
42
+ <VuiChip
43
+ size="s"
44
+ onClick={() => setActiveOption("c")}
45
+ isActive={activeOption === "c"}
46
+ append={hasCounts ? 16 : undefined}
47
+ >
48
+ Option C
49
+ </VuiChip>
50
+ </VuiFlexContainer>
51
+ </>
52
+ );
53
+ };
@@ -1,11 +1,22 @@
1
1
  import { Chip } from "./Chip";
2
+ import { Small } from "./Small";
3
+
2
4
  const ChipSource = require("!!raw-loader!./Chip");
5
+ const SmallSource = require("!!raw-loader!./Small");
3
6
 
4
7
  export const chip = {
5
8
  name: "Chip",
6
9
  path: "/chip",
7
- example: {
8
- component: <Chip />,
9
- source: ChipSource.default.toString()
10
- }
10
+ examples: [
11
+ {
12
+ name: "Chip",
13
+ component: <Chip />,
14
+ source: ChipSource.default.toString()
15
+ },
16
+ {
17
+ name: "Small",
18
+ component: <Small />,
19
+ source: SmallSource.default.toString()
20
+ }
21
+ ]
11
22
  };