@homebound/beam 2.360.0 → 2.361.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.
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
|
+
import { Xss } from "../Css";
|
|
2
3
|
import { PresentationFieldProps } from "../components/PresentationContext";
|
|
4
|
+
type ToggleChipXss = Xss<"color" | "backgroundColor">;
|
|
3
5
|
type ToggleChipItemProps = {
|
|
4
6
|
label: string;
|
|
5
7
|
value: string;
|
|
@@ -15,6 +17,7 @@ export interface ToggleChipGroupProps extends Pick<PresentationFieldProps, "labe
|
|
|
15
17
|
options: ToggleChipItemProps[];
|
|
16
18
|
values: string[];
|
|
17
19
|
onChange: (values: string[]) => void;
|
|
20
|
+
xss?: ToggleChipXss;
|
|
18
21
|
}
|
|
19
22
|
export declare function ToggleChipGroup(props: ToggleChipGroupProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
20
23
|
export {};
|
|
@@ -14,18 +14,19 @@ function ToggleChipGroup(props) {
|
|
|
14
14
|
var _a;
|
|
15
15
|
const { fieldProps } = (0, PresentationContext_1.usePresentationContext)();
|
|
16
16
|
const { labelLeftFieldWidth = "50%" } = fieldProps !== null && fieldProps !== void 0 ? fieldProps : {};
|
|
17
|
-
const { values, label, labelStyle = (_a = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.labelStyle) !== null && _a !== void 0 ? _a : "above", options } = props;
|
|
17
|
+
const { values, label, labelStyle = (_a = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.labelStyle) !== null && _a !== void 0 ? _a : "above", options, xss } = props;
|
|
18
18
|
const state = (0, react_stately_1.useCheckboxGroupState)({ ...props, value: values });
|
|
19
19
|
const { groupProps, labelProps } = (0, react_aria_1.useCheckboxGroup)(props, state);
|
|
20
20
|
const tid = (0, useTestIds_1.useTestIds)(props, "toggleChip");
|
|
21
21
|
return ((0, jsx_runtime_1.jsxs)("div", { ...groupProps, css: Css_1.Css.relative.df.fdc.if(labelStyle === "left").fdr.gap2.maxw100.jcsb.$, children: [(0, jsx_runtime_1.jsx)(Label_1.Label, { label: label, ...labelProps, hidden: labelStyle === "hidden", inline: labelStyle !== "above" }), (0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.df.gap1
|
|
22
22
|
.add("flexWrap", "wrap")
|
|
23
23
|
.if(labelStyle === "left")
|
|
24
|
-
.w(labelLeftFieldWidth).$, children: options.map((o) => ((0, jsx_runtime_1.jsx)(ToggleChip, { value: o.value, groupState: state, selected: state.value.includes(o.value), label: o.label, disabled: o.disabled, ...tid[o.value] }, o.value))) })] }));
|
|
24
|
+
.w(labelLeftFieldWidth).$, children: options.map((o) => ((0, jsx_runtime_1.jsx)(ToggleChip, { value: o.value, groupState: state, selected: state.value.includes(o.value), label: o.label, disabled: o.disabled, xss: xss, ...tid[o.value] }, o.value))) })] }));
|
|
25
25
|
}
|
|
26
26
|
exports.ToggleChipGroup = ToggleChipGroup;
|
|
27
27
|
function ToggleChip(props) {
|
|
28
|
-
|
|
28
|
+
var _a, _b, _c;
|
|
29
|
+
const { label, value, groupState, selected: isSelected, disabled = false, xss, ...others } = props;
|
|
29
30
|
const isDisabled = !!disabled;
|
|
30
31
|
const ref = (0, react_1.useRef)(null);
|
|
31
32
|
const { inputProps } = (0, react_aria_1.useCheckboxGroupItem)({ value, "aria-label": label, isDisabled }, groupState, ref);
|
|
@@ -38,8 +39,8 @@ function ToggleChip(props) {
|
|
|
38
39
|
...Css_1.Css.relative.dib.br16.sm.px1.cursorPointer.pyPx(4).bgGray200.if(isDisabled).cursorNotAllowed.gray600.pr1.$,
|
|
39
40
|
...(isSelected
|
|
40
41
|
? {
|
|
41
|
-
...Css_1.Css.
|
|
42
|
-
":hover:not([data-disabled='true'])": Css_1.Css.
|
|
42
|
+
...Css_1.Css.color((_a = xss === null || xss === void 0 ? void 0 : xss.color) !== null && _a !== void 0 ? _a : Css_1.Palette.White).bgColor((_b = xss === null || xss === void 0 ? void 0 : xss.backgroundColor) !== null && _b !== void 0 ? _b : Css_1.Palette.Blue700).$,
|
|
43
|
+
":hover:not([data-disabled='true'])": Css_1.Css.bgColor((_c = xss === null || xss === void 0 ? void 0 : xss.backgroundColor) !== null && _c !== void 0 ? _c : Css_1.Palette.Blue800).$,
|
|
43
44
|
}
|
|
44
45
|
: { ":hover:not([data-disabled='true'])": Css_1.Css.bgGray300.$ }),
|
|
45
46
|
...(isFocusVisible ? Css_1.Css.bshFocus.$ : {}),
|