@public-ui/components
Version:
Contains all web components that belong to KoliBri - The accessible HTML-Standard.
83 lines (79 loc) • 3.3 kB
JavaScript
/*!
* KoliBri - The accessible HTML-Standard
*/
import { a as __rest } from './tslib.es6-QNbPBOk5.js';
import { h } from './index-BQlHOxik.js';
import { I as InputFc } from './Input-DQJln-L5.js';
import { a as createRelatedUniqueId } from './dev.utils-02Sl9bQo.js';
import { a as getRenderStates } from './FormFieldStateWrapper-BWTMRKXT.js';
const SuggestionsFc = (_a) => {
var { id, suggestions } = _a, other = __rest(_a, ["id", "suggestions"]);
if (!suggestions) {
return null;
}
return (h("datalist", Object.assign({ id: createRelatedUniqueId(id, 'list') }, other), suggestions.map((option) => (h("option", { value: option })))));
};
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(InputFc, Object.assign({}, getInputProps(state, other, customSuggestions)));
};
export { InputStateWrapper as I, SuggestionsFc as S };
//# sourceMappingURL=InputStateWrapper-CDDIvfo0.js.map
//# sourceMappingURL=InputStateWrapper-CDDIvfo0.js.map