@public-ui/components
Version:
Contains all web components that belong to KoliBri - The accessible HTML-Standard.
72 lines (71 loc) • 2.87 kB
JavaScript
/*!
* KoliBri - The accessible HTML-Standard
*/
import { __rest } from "tslib";
import { h } from "@stencil/core";
import KolInputFc from "../../functional-components/inputs/Input";
import SuggestionsFc from "../../functional-components/Suggestions";
import { getRenderStates } from "../_helpers/getRenderStates";
function getInputProps(state, other, customSuggestions) {
var _a;
const renderStates = getRenderStates(state);
const ariaDescribedBy = [...renderStates.ariaDescribedBy, ...((_a = other.ariaDescribedBy) !== null && _a !== void 0 ? _a : [])];
const props = {
id: state._id,
hideLabel: state._hideLabel,
label: state._label,
disabled: state._disabled,
name: state._name,
};
if ('_accessKey' in state)
props.accessKey = state._accessKey;
if ('_type' in state)
props.type = state._type;
if ('_value' in state)
props.value = state._value;
if ('_required' in state)
props.required = state._required;
if ('_maxLength' in state && '_maxLengthBehavior' in state && state._maxLengthBehavior === 'hard')
props.maxlength = state._maxLength;
if ('_placeholder' in state)
props.placeholder = state._placeholder;
if ('_autoComplete' in state)
props.autoComplete = state._autoComplete;
if ('_spellCheck' in state)
props.spellcheck = state._spellCheck;
if ('_pattern' in state)
props.pattern = state._pattern;
if ('_readOnly' in state)
props.readonly = state._readOnly;
if ('_min' in state)
props.min = state._min;
if ('_max' in state)
props.max = state._max;
if ('_step' in state)
props.step = state._step;
if ('_multiple' in state)
props.multiple = state._multiple;
if ('_checked' in state)
props.checked = state._checked;
if ('_indeterminate' in state)
props.indeterminate = state._indeterminate;
if ('_touched' in state)
props.touched = state._touched;
if ('_msg' in state)
props.msg = state._msg;
if ('_shortKey' in state)
props['aria-keyshortcuts'] = state._shortKey;
if ('_suggestions' in state && !customSuggestions) {
const hasSuggestions = Array.isArray(state._suggestions) && state._suggestions.length > 0;
if (hasSuggestions) {
props.suggestions = (h(SuggestionsFc, { id: state._id, suggestions: state._suggestions }));
}
}
return Object.assign(Object.assign(Object.assign({}, props), other), { ariaDescribedBy });
}
const InputStateWrapper = (_a) => {
var { state, customSuggestions } = _a, other = __rest(_a, ["state", "customSuggestions"]);
return h(KolInputFc, Object.assign({}, getInputProps(state, other, customSuggestions)));
};
export default InputStateWrapper;
//# sourceMappingURL=InputStateWrapper.js.map