@homebound/beam 2.158.0 → 2.159.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/dist/components/Chip.d.ts +5 -1
- package/dist/components/Chip.js +17 -3
- package/package.json +1 -1
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { Margin, Only, Xss } from "../Css";
|
|
2
|
+
declare type ChipType = "caution" | "warning" | "success" | "neutral";
|
|
3
|
+
export declare const ChipTypes: Record<ChipType, ChipType>;
|
|
2
4
|
export interface ChipProps<X> {
|
|
3
5
|
text: string;
|
|
4
6
|
xss?: X;
|
|
7
|
+
type?: ChipType;
|
|
5
8
|
}
|
|
6
9
|
/** Kinda like a chip, but read-only, so no `onClick` or `hover`. */
|
|
7
|
-
export declare function Chip<X extends Only<Xss<Margin>, X>>(props: ChipProps<X>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare function Chip<X extends Only<Xss<Margin>, X>>({ type, ...props }: ChipProps<X>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
11
|
+
export {};
|
package/dist/components/Chip.js
CHANGED
|
@@ -1,19 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Chip = void 0;
|
|
3
|
+
exports.Chip = exports.ChipTypes = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
5
|
const PresentationContext_1 = require("./PresentationContext");
|
|
6
6
|
const Css_1 = require("../Css");
|
|
7
7
|
const useTestIds_1 = require("../utils/useTestIds");
|
|
8
|
+
// exporting for using in type prop as constant - this could be moved and become a global list for colors
|
|
9
|
+
exports.ChipTypes = {
|
|
10
|
+
caution: "caution",
|
|
11
|
+
warning: "warning",
|
|
12
|
+
success: "success",
|
|
13
|
+
neutral: "neutral",
|
|
14
|
+
};
|
|
8
15
|
/** Kinda like a chip, but read-only, so no `onClick` or `hover`. */
|
|
9
|
-
function Chip(props) {
|
|
16
|
+
function Chip({ type = exports.ChipTypes.neutral, ...props }) {
|
|
10
17
|
const { text, xss = {} } = props;
|
|
11
18
|
const { fieldProps } = (0, PresentationContext_1.usePresentationContext)();
|
|
12
19
|
const compact = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.compact;
|
|
13
20
|
const tid = (0, useTestIds_1.useTestIds)(props, "chip");
|
|
14
21
|
return ((0, jsx_runtime_1.jsx)("span", Object.assign({ css: {
|
|
15
|
-
...Css_1.Css[compact ? "xs" : "sm"].dif.aic.br16.pl1.px1.pyPx(2).gray900
|
|
22
|
+
...Css_1.Css[compact ? "xs" : "sm"].dif.aic.br16.pl1.px1.pyPx(2).gray900.$,
|
|
23
|
+
...typeStyles[type],
|
|
16
24
|
...xss,
|
|
17
25
|
} }, tid, { title: text }, { children: (0, jsx_runtime_1.jsx)("span", Object.assign({ css: Css_1.Css.lineClamp1.breakAll.$ }, { children: text }), void 0) }), void 0));
|
|
18
26
|
}
|
|
19
27
|
exports.Chip = Chip;
|
|
28
|
+
const typeStyles = {
|
|
29
|
+
caution: Css_1.Css.bgYellow200.$,
|
|
30
|
+
warning: Css_1.Css.bgRed100.$,
|
|
31
|
+
success: Css_1.Css.bgGreen100.$,
|
|
32
|
+
neutral: Css_1.Css.bgGray200.$,
|
|
33
|
+
};
|