@payfit/unity-components
Version:
78 lines (77 loc) • 3.01 kB
JavaScript
import { uyTv as e } from "@payfit/unity-themes";
import { jsx as t, jsxs as n } from "react/jsx-runtime";
import { useTranslation as r } from "react-i18next";
import { Button as i } from "react-aria-components/Button";
import { Icon as a } from "@payfit/unity-icons";
import { SelectValue as o } from "react-aria-components/Select";
//#region src/core/components/select/parts/SelectButton.tsx
var s = e({
slots: {
base: "uy:flex uy:flex-row uy:items-center uy:gap-100 uy:h-5.5 uy:sm:h-500 uy:py-125 uy:sm:py-100 uy:px-150 uy:rounded-100 uy:sm:rounded-75 uy:border-solid uy:focus-visible:ring-2 uy:focus-visible:ring-utility-focus-ring uy:focus-visible:ring-offset-2 uy:outline-none uy:border",
selectValue: ["uy:min-w-0 uy:whitespace-nowrap uy:text-ellipsis uy:typography-body uy:flex-grow uy:text-left uy:overflow-hidden", "uy:data-[placeholder]:text-content-neutral-lowest"],
iconWrapper: "uy:flex uy:shrink-0 uy:gap-50",
icon: ""
},
variants: {
isDisabled: { true: {
base: "uy:border-border-form-disabled uy:bg-surface-form-disabled",
selectValue: "uy:text-content-form-disabled",
icon: "uy:text-content-neutral-lowest-disabled"
} },
isInvalid: { true: { base: "uy:border-border-form-error uy:bg-surface-form-error" } },
isReadOnly: { true: {
base: "uy:border-border-form-disabled uy:bg-surface-form-disabled",
selectValue: "uy:text-content-form-readonly",
icon: "uy:text-content-neutral-lowest-disabled"
} }
},
compoundVariants: [{
isDisabled: !1,
isInvalid: !1,
isReadOnly: !1,
className: {
base: "uy:border-border-form-enabled uy:hover:border-border-form-hover uy:bg-surface-form-enabled uy:hover:bg-surface-form-hover uy:active:border-border-form-active",
selectValue: "uy:text-content-form-enabled uy:hover:text-content-form-hover",
icon: "uy:text-content-neutral-lowest uy:hover:text-content-neutral-lowest-hover"
}
}],
defaultVariants: {
isDisabled: !1,
isInvalid: !1,
isReadOnly: !1
}
}), c = ({ isDisabled: e, isInvalid: c, isReadOnly: l, isOpen: u, renderValue: d }) => {
let { t: f } = r("unity"), { base: p, selectValue: m, iconWrapper: h, icon: g } = s({
isDisabled: e,
isInvalid: c,
isReadOnly: l
});
return /* @__PURE__ */ n(i, {
"data-dd-privacy": "mask",
className: p(),
isDisabled: e,
"data-unity-slot": "select-button",
children: [d ? /* @__PURE__ */ t(o, {
className: m(),
translate: "no",
children: ({ state: e }) => e.selectedItems[0] ? d(e.selectedItems[0]) : null
}) : /* @__PURE__ */ t(o, {
className: m(),
translate: "no"
}), /* @__PURE__ */ n("div", {
className: h(),
children: [c && /* @__PURE__ */ t(a, {
src: "WarningCircleOutlined",
color: "content.form.invalid",
alt: f((e) => e.unity.component.formField.formInput.error.alt)
}), /* @__PURE__ */ t(a, {
className: g(),
"aria-hidden": "true",
src: u ? "CaretUpOutlined" : "CaretDownOutlined"
})]
})]
});
};
c.displayName = "SelectButton";
//#endregion
export { c as SelectButton };