UNPKG

@ozen-ui/kit

Version:

React component library

24 lines (23 loc) 993 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useAutocompleteBaseInput = void 0; var tslib_1 = require("tslib"); var useControlled_1 = require("../../../../hooks/useControlled"); var useAutocompleteBaseInput = function (_a) { var inputValueProp = _a.inputValue, onChange = _a.onChange; var _b = tslib_1.__read((0, useControlled_1.useControlled)({ value: inputValueProp, defaultValue: '', name: 'AutocompleteBaseInput', state: 'inputValue', }), 2), inputValue = _b[0], setInputValueState = _b[1]; var setInputValue = function (event, value) { setInputValueState(value); onChange === null || onChange === void 0 ? void 0 : onChange(event, value !== null && value !== void 0 ? value : ''); }; return { value: inputValue !== null && inputValue !== void 0 ? inputValue : '', setValue: setInputValue, }; }; exports.useAutocompleteBaseInput = useAutocompleteBaseInput;