@public-ui/components
Version:
Contains all web components that belong to KoliBri - The accessible HTML-Standard.
29 lines (28 loc) • 1.56 kB
JavaScript
/*!
* KoliBri - The accessible HTML-Standard
*/
import { __rest } from "tslib";
import { Fragment, h } from "@stencil/core";
import clsx from "../../../utils/clsx";
import NativeOptionFc from "../NativeOption/NativeOption";
const NativeOptionListFc = ({ baseClassName, preKey, options, disabled, value: selectedValue, OptionProps = {}, OptionGroupProps = {}, }) => {
if (!(options === null || options === void 0 ? void 0 : options.length)) {
return null;
}
return (h(Fragment, null, options.map((option, index) => {
const key = [preKey, `-${index}`].join('');
if ('options' in option) {
if (!options.length) {
return null;
}
const { label } = option, other = __rest(option, ["label"]);
return (h("optgroup", Object.assign({ class: clsx(`${baseClassName}__optgroup`, { [`${baseClassName}__optgroup--disabled`]: disabled }), key: key }, OptionGroupProps, { label: label === null || label === void 0 ? void 0 : label.toString(), disabled: disabled }), h(NativeOptionListFc, Object.assign({ baseClassName: baseClassName, OptionGroupProps: OptionGroupProps, OptionProps: OptionProps, value: selectedValue, preKey: key }, other))));
}
if ('value' in option) {
return h(NativeOptionFc, Object.assign({ key: key, baseClassName: baseClassName }, OptionProps, { index: key, selectedValue: selectedValue }, option));
}
return null;
})));
};
export default NativeOptionListFc;
//# sourceMappingURL=NativeOptionList.js.map