@public-ui/components
Version:
Contains all web components that belong to KoliBri - The accessible HTML-Standard.
78 lines (77 loc) • 3.23 kB
JavaScript
/*!
* KoliBri - The accessible HTML-Standard
*/
import { h } from "@stencil/core";
import { isObject, isString } from "lodash-es";
import KolIconButtonFc from "../../functional-components/IconButton";
import KolInputContainerFc from "../../functional-components/InputContainer";
import { IconFC } from "../../internal/functional-components/icon/component";
function getInputContainerProps(state) {
let icons = undefined;
let smartButton;
if ('_icons' in state) {
icons = state._icons;
}
if ('_smartButton' in state) {
smartButton = state._smartButton;
}
return {
icons,
smartButton,
disabled: state._disabled,
msg: state._msg,
touched: state._touched,
};
}
const InputContainerStateWrapperFc = ({ state, startAdornment: defaultStartAdornment, endAdornment: defaultEndAdornment }, children) => {
var _a, _b;
const { icons, smartButton, disabled, msg, touched } = getInputContainerProps(state);
let leftIconProps = icons === null || icons === void 0 ? void 0 : icons.left;
if (isString(leftIconProps)) {
leftIconProps = { icon: leftIconProps };
}
let rightIconProps = icons === null || icons === void 0 ? void 0 : icons.right;
if (isString(rightIconProps)) {
rightIconProps = { icon: rightIconProps };
}
const startAdornment = [];
const endAdornment = [];
if (defaultStartAdornment) {
if (Array.isArray(defaultStartAdornment)) {
startAdornment.push(...defaultStartAdornment);
}
else {
startAdornment.push(defaultStartAdornment);
}
}
if (leftIconProps) {
if (isObject(leftIconProps)) {
startAdornment.push(h(IconFC, { class: "kol-input-container__icon", icons: leftIconProps.icon, label: (_a = leftIconProps.label) !== null && _a !== void 0 ? _a : '', style: leftIconProps.style }));
}
else {
startAdornment.push(h(IconFC, { class: "kol-input-container__icon", icons: leftIconProps, label: "" }));
}
}
if (isObject(smartButton)) {
endAdornment.push(h(KolIconButtonFc, Object.assign({ componentName: "button", class: "kol-input-container__smart-button" }, smartButton, { hideLabel: true, disabled: disabled })));
}
if (rightIconProps) {
if (isObject(rightIconProps)) {
endAdornment.push(h(IconFC, { class: "kol-input-container__icon", icons: rightIconProps.icon, label: (_b = rightIconProps.label) !== null && _b !== void 0 ? _b : '', style: rightIconProps.style }));
}
else {
endAdornment.push(h(IconFC, { class: "kol-input-container__icon", icons: rightIconProps, label: "" }));
}
}
if (defaultEndAdornment) {
if (Array.isArray(defaultEndAdornment)) {
endAdornment.push(...defaultEndAdornment);
}
else {
endAdornment.push(defaultEndAdornment);
}
}
return (h(KolInputContainerFc, { disabled: disabled, msg: msg, touched: touched, startAdornment: startAdornment, endAdornment: endAdornment }, children));
};
export default InputContainerStateWrapperFc;
//# sourceMappingURL=InputContainerStateWrapper.js.map