@ebay/ebayui-core
Version:
Collection of core eBay components; considered to be the building blocks for all composite structures, pages & apps.
32 lines (31 loc) • 758 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
class StarRating {
onCreate() {
this.state = {
value: 0,
};
}
onInput(input) {
let value = parseInt(input.value) || 0;
if (value > 5) {
value = 0;
}
this.state.value = value;
}
handleClick(value, originalEvent, el) {
if (!el.disabled) {
this.state.value = value;
}
this.emitEvent("change", value, originalEvent, el);
}
emitEvent(name, value, originalEvent, el) {
if (!el.disabled) {
this.emit(name, {
originalEvent,
value: value,
});
}
}
}
module.exports = StarRating;