UNPKG

wix-style-react

Version:
36 lines (31 loc) 1.2 kB
import inputWithOptionsDriverFactory from '../InputWithOptions/InputWithOptions.driver'; var multiSelectCheckboxDriverFactory = function multiSelectCheckboxDriverFactory(_ref) { var element = _ref.element; var _inputWithOptionsDriv = inputWithOptionsDriverFactory({ element: element }), driver = _inputWithOptionsDriv.driver, inputDriver = _inputWithOptionsDriv.inputDriver, dropdownLayoutDriver = _inputWithOptionsDriv.dropdownLayoutDriver; var _getLabels = function getLabels() { var delimiter = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ", "; return inputDriver.getValue().split(delimiter); }; var multiSelectCheckboxDriver = Object.assign(driver, { getNumOfLabels: function getNumOfLabels() { return _getLabels().length; }, getLabels: function getLabels(delimiter) { return _getLabels(delimiter); }, getLabelAt: function getLabelAt(index, delimiters) { return _getLabels(delimiters)[index]; } }); return { driver: multiSelectCheckboxDriver, inputDriver: inputDriver, dropdownLayoutDriver: dropdownLayoutDriver }; }; export default multiSelectCheckboxDriverFactory;