@pagopa/mui-italia
Version:
[Material-UI](https://mui.com/core/) theme inspired by [Bootstrap Italia](https://italia.github.io/bootstrap-italia/).
17 lines (16 loc) • 1.2 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const jsx_runtime_1 = require("react/jsx-runtime");
const Chip_1 = require("../Chip");
const material_1 = require("@mui/material");
// Here we need a Box with a ‘contents’ display to ensure that the buttons
// are rendered as if they were direct children of the container Box.
// This way, the buttons are positioned correctly within the TextField.
const MultiSelectChips = ({ selectedOptions, getOptionLabel, disabled, handleChipDelete, slotProps, }) => {
const getOptionKey = (option, index) => {
const label = getOptionLabel(option);
return `selected-chip-${index}-${label}`;
};
return ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ display: "contents", role: "list" }, slotProps.list, { children: selectedOptions.map((option, index) => ((0, jsx_runtime_1.jsx)(Chip_1.Chip, Object.assign({ label: getOptionLabel(option), onDelete: () => handleChipDelete(option), disabled: disabled, "aria-setsize": selectedOptions.length, "aria-posinset": index + 1, role: "listitem", size: "small" }, slotProps.chip), getOptionKey(option, index)))) })));
};
exports.default = MultiSelectChips;