@payfit/unity-components
Version:
73 lines (72 loc) • 2.79 kB
JavaScript
import e from "../../../hooks/use-id.js";
import { CheckboxIndicator as t } from "../../checkbox/parts/CheckboxIndicator.js";
import { MultiSelectContext as n } from "../Multiselect.context.js";
import { MultiSelectSeparator as r } from "./MultiSelectSeparator.js";
import { forwardRef as i, useContext as a } from "react";
import { uyTv as o } from "@payfit/unity-themes";
import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
import { ListBoxItem as u } from "react-aria-components/ListBox";
//#region src/core/components/multi-select/parts/MultiSelectOption.tsx
var d = o({
slots: {
base: [
"uy:flex uy:flex-col uy:transition",
"uy:w-full uy:ps-150 uy:pe-150 uy:py-100",
"uy:rounded-50 uy:cursor-pointer",
"uy:outline-none",
"uy:data-[hovered=true]:bg-surface-neutral-hover",
"uy:data-[pressed=true]:bg-surface-neutral-pressed",
"uy:data-[focus-visible=true]:relative uy:data-[focus-visible=true]:z-10 uy:data-[focus-visible=true]:outline uy:data-[focus-visible=true]:outline-2 uy:data-[focus-visible=true]:outline-solid uy:data-[focus-visible=true]:outline-utility-focus-ring uy:data-[focus-visible=true]:outline-offset-2"
],
label: "uy:inline-flex uy:items-center uy:gap-100 uy:text-content-neutral uy:typography-body",
helperText: "uy:inline-block uy:typography-body uy:text-content-neutral-low uy:pl-3.5"
},
variants: {
isDisabled: {
true: {
base: "uy:cursor-not-allowed!",
label: "uy:text-content-neutral-disabled",
helperText: "uy:text-content-neutral-disabled"
},
false: { base: "" }
},
indentStandaloneOptions: { true: { base: "uy:ps-[calc(var(--uy-spacing-150)+var(--uy-spacing-300))]" } }
}
});
function f(e, t) {
if (t !== void 0) return t;
if (typeof e == "string") return e;
}
function p({ value: i, children: o, isDisabled: p, helperText: m, textValue: h, withSeparator: g, ..._ }, v) {
let y = e(), { indentStandaloneOptions: b } = a(n), { base: x, label: S, helperText: C } = d({
isDisabled: p,
indentStandaloneOptions: b
});
return /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c(u, {
"data-dd-privacy": "mask",
..._,
"data-unity-slot": "multi-select-option",
ref: v,
id: i,
isDisabled: p,
textValue: f(o, h),
className: x(),
"aria-describedby": m ? `${y}-helper-text` : void 0,
children: ({ isSelected: e }) => /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ l("div", {
className: S(),
children: [/* @__PURE__ */ c(t, {
isSelected: e,
isDisabled: p,
"data-dd-privacy": "hidden"
}), o]
}), m && /* @__PURE__ */ c("span", {
id: `${y}-helper-text`,
className: C(),
children: m
})] })
}), g && /* @__PURE__ */ c(r, {})] });
}
p.displayName = "MultiSelectOption";
var m = i(p);
//#endregion
export { m as MultiSelectOption };