ngx-bar-rating
Advanced tools
Comparing version 1.1.0 to 2.0.0
@@ -1,1 +0,206 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@angular/common"),require("@angular/forms")):"function"==typeof define&&define.amd?define(["exports","@angular/core","@angular/common","@angular/forms"],e):e(t.ngxBarRating=t.ngxBarRating||{},t.ng.core,t.ng.common,t.ng.forms)}(this,function(t,e,n,r){"use strict";var i={provide:r.NG_VALUE_ACCESSOR,useExisting:e.forwardRef(function(){return a}),multi:!0},o={provide:r.NG_VALIDATORS,useExisting:e.forwardRef(function(){return a}),multi:!0},a=function(){function t(t){this.changeDetectorRef=t,this.contexts=[],this.max=5,this.readOnly=!1,this.theme="default",this.showText=!1,this.titles=[],this.required=!1,this.hover=new e.EventEmitter,this.leave=new e.EventEmitter,this.rateChange=new e.EventEmitter(!0),this.onChange=function(t){},this.onTouched=function(){}}return t.prototype.ngOnChanges=function(t){t.rate&&this.update(this.rate)},t.prototype.ngOnInit=function(){var t=this;this.contexts=Array.from({length:this.max},function(e,n){return{selected:!1,fraction:!1,click:function(e){return t.handleClick(e,n+1)},enter:function(){return t.handleEnter(n+1)}}}),this.updateState(this.rate)},t.prototype.update=function(t,e){void 0===e&&(e=!0),this.readOnly||this.disabled||this.rate===t||(this.rate=t,this.rateChange.emit(this.rate)),e&&(this.onChange(this.rate),this.onTouched()),this.updateState(this.rate)},t.prototype.reset=function(){this.leave.emit(this.nextRate),this.updateState(this.rate)},t.prototype.updateState=function(t){var e=this;this.nextRate=t-1,this.contexts=Array.from({length:this.max},function(n,r){return{selected:r+1<=t,fraction:(r+1===Math.round(t)&&t%1)>=.5,click:function(t){return e.handleClick(t,r)},enter:function(){return e.handleEnter(r)}}})},t.prototype.handleClick=function(t,e){t.preventDefault(),t.stopPropagation(),this.update(e+1)},t.prototype.handleEnter=function(t){this.disabled||this.readOnly||(this.contexts.map(function(e,n){e.active=n<=t,e.fraction=!1,e.selected=!1}),this.nextRate=t,this.hover.emit(t))},t.prototype.writeValue=function(t){this.update(t,!1),this.changeDetectorRef.markForCheck()},t.prototype.validate=function(t){return this.required&&!t.value?{required:!0}:null},t.prototype.registerOnChange=function(t){this.onChange=t},t.prototype.registerOnTouched=function(t){this.onTouched=t},t.prototype.setDisabledState=function(t){this.disabled=t},t}();a.decorators=[{type:e.Component,args:[{selector:"bar-rating",template:'\n <div [class]="\'br br-\' + theme" [class.br-readonly]="readOnly" [class.br-disabled]="disabled">\n\n <div class="br-units" (mouseleave)="reset()">\n\n <div class="br-unit" *ngFor="let unit of contexts" [class.br-fraction]="unit.fraction"\n [class.br-selected]="unit.selected" [class.br-active]="unit.active"\n (click)="unit.click($event)" (mouseenter)="unit.enter()"></div>\n\n </div>\n\n <div *ngIf="showText" class="br-text">{{ nextRate | rateTitle: titles}}</div>\n </div>\n ',styles:["\n *{box-sizing:border-box}.br{position:relative;margin:15px 0}.br-units{display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:nowrap;flex-wrap:nowrap}.br-unit{cursor:pointer;-webkit-font-smoothing:antialiased;text-rendering:auto}.br-disabled .br-unit,.br-readonly .br-unit{cursor:default}\n "],providers:[i,o],changeDetection:e.ChangeDetectionStrategy.OnPush}]}],a.ctorParameters=function(){return[{type:e.ChangeDetectorRef}]},a.propDecorators={rate:[{type:e.Input}],max:[{type:e.Input}],readOnly:[{type:e.Input}],theme:[{type:e.Input}],showText:[{type:e.Input}],titles:[{type:e.Input}],required:[{type:e.Input}],hover:[{type:e.Output}],leave:[{type:e.Output}],rateChange:[{type:e.Output}]};var s=function(){function t(){}return t.prototype.transform=function(t,e){return void 0===t&&(t=0),e[t]||t+1},t}();s.decorators=[{type:e.Pipe,args:[{name:"rateTitle"}]}],s.ctorParameters=function(){return[]};var u=function(){function t(){}return t}();u.decorators=[{type:e.NgModule,args:[{declarations:[a,s],imports:[n.CommonModule,r.FormsModule],exports:[a]}]}],u.ctorParameters=function(){return[]},t.BarRatingModule=u,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/forms'), require('@angular/common')) : | ||
typeof define === 'function' && define.amd ? define('ngx-bar-rating', ['exports', '@angular/core', '@angular/forms', '@angular/common'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['ngx-bar-rating'] = {}, global.ng.core, global.ng.forms, global.ng.common)); | ||
}(this, (function (exports, core, forms, common) { 'use strict'; | ||
/** This allows support [(ngModel)] and ngControl. */ | ||
var RATING_VALUE_ACCESSOR = { | ||
provide: forms.NG_VALUE_ACCESSOR, | ||
useExisting: core.forwardRef(function () { return BarRating; }), | ||
multi: true | ||
}; | ||
/** This allows control required validation. */ | ||
var RATING_VALUE_VALIDATOR = { | ||
provide: forms.NG_VALIDATORS, | ||
useExisting: core.forwardRef(function () { return BarRating; }), | ||
multi: true, | ||
}; | ||
var BarRating = /** @class */ (function () { | ||
function BarRating(changeDetectorRef) { | ||
this.changeDetectorRef = changeDetectorRef; | ||
this.contexts = []; | ||
/** Maximal rating that can be given using this widget. */ | ||
this.max = 5; | ||
/** A flag indicating if rating can be updated. */ | ||
this.readOnly = false; | ||
/** Set the theme */ | ||
this.theme = 'default'; | ||
/** Show rating title */ | ||
this.showText = false; | ||
/** Replace rate value with a title */ | ||
this.titles = []; | ||
/** A flag indicating if rating is required for form validation. */ | ||
this.required = false; | ||
/** | ||
* An event fired when a user is hovering over a given rating. | ||
* Event's payload equals to the rating being hovered over. | ||
*/ | ||
this.hover = new core.EventEmitter(); | ||
/** | ||
* An event fired when a user stops hovering over a given rating. | ||
* Event's payload equals to the rating of the last item being hovered over. | ||
*/ | ||
this.leave = new core.EventEmitter(); | ||
/** | ||
* An event fired when a user selects a new rating. | ||
* Event's payload equals to the newly selected rating. | ||
*/ | ||
this.rateChange = new core.EventEmitter(true); | ||
this.onChange = function (_) { | ||
}; | ||
this.onTouched = function () { | ||
}; | ||
} | ||
BarRating.prototype.ngOnChanges = function (changes) { | ||
if (changes.rate) { | ||
this.update(this.rate); | ||
} | ||
}; | ||
BarRating.prototype.ngOnInit = function () { | ||
var _this = this; | ||
this.contexts = Array.from({ length: this.max }, function (context, i) { return ({ | ||
selected: false, | ||
fraction: false, | ||
active: false, | ||
click: function (e) { return _this.handleClick(e, i + 1); }, | ||
enter: function () { return _this.handleEnter(i + 1); } | ||
}); }); | ||
this.updateState(this.rate); | ||
}; | ||
BarRating.prototype.update = function (newRate, internalChange) { | ||
if (internalChange === void 0) { internalChange = true; } | ||
if (!this.readOnly && !this.disabled && this.rate !== newRate) { | ||
this.rate = newRate; | ||
this.rateChange.emit(this.rate); | ||
} | ||
if (internalChange) { | ||
this.onChange(this.rate); | ||
this.onTouched(); | ||
} | ||
this.updateState(this.rate); | ||
}; | ||
/** Reset rate value */ | ||
BarRating.prototype.reset = function () { | ||
this.leave.emit(this.nextRate); | ||
this.updateState(this.rate); | ||
}; | ||
BarRating.prototype.updateState = function (nextValue) { | ||
var _this = this; | ||
/** Set rate value as text */ | ||
this.nextRate = nextValue - 1; | ||
/** Set the rating */ | ||
this.contexts = Array.from({ length: this.max }, function (context, index) { return ({ | ||
selected: index + 1 <= nextValue, | ||
fraction: (index + 1 === Math.round(nextValue) && nextValue % 1) >= 0.5, | ||
active: false, | ||
click: function (e) { return _this.handleClick(e, index); }, | ||
enter: function () { return _this.handleEnter(index); } | ||
}); }); | ||
}; | ||
BarRating.prototype.handleClick = function (e, value) { | ||
/** (NOT TESTED) Remove 300ms click delay on touch devices */ | ||
e.preventDefault(); | ||
e.stopPropagation(); | ||
this.update(value + 1); | ||
}; | ||
BarRating.prototype.handleEnter = function (index) { | ||
if (!this.disabled && !this.readOnly) { | ||
/** Add selected class for rating hover */ | ||
this.contexts.map(function (context, i) { | ||
context.active = i <= index; | ||
context.fraction = false; | ||
context.selected = false; | ||
}); | ||
this.nextRate = index; | ||
this.hover.emit(index); | ||
} | ||
}; | ||
/** This is the initial value set to the component */ | ||
BarRating.prototype.writeValue = function (value) { | ||
this.update(value, false); | ||
this.changeDetectorRef.markForCheck(); | ||
}; | ||
BarRating.prototype.validate = function (c) { | ||
return (this.required && !c.value) ? { required: true } : null; | ||
}; | ||
BarRating.prototype.registerOnChange = function (fn) { | ||
this.onChange = fn; | ||
}; | ||
BarRating.prototype.registerOnTouched = function (fn) { | ||
this.onTouched = fn; | ||
}; | ||
BarRating.prototype.setDisabledState = function (isDisabled) { | ||
this.disabled = isDisabled; | ||
}; | ||
return BarRating; | ||
}()); | ||
BarRating.decorators = [ | ||
{ type: core.Component, args: [{ | ||
selector: 'bar-rating', | ||
template: "<div class=\"br br-{{theme}}\"\n [class.br-readonly]=\"readOnly\"\n [class.br-disabled]=\"disabled\">\n\n <div class=\"br-units\" (mouseleave)=\"reset()\">\n\n <div class=\"br-unit\" *ngFor=\"let unit of contexts\"\n [class.br-fraction]=\"unit.fraction\"\n [class.br-selected]=\"unit.selected\"\n [class.br-active]=\"unit.active\"\n (click)=\"unit.click($event)\"\n (mouseenter)=\"unit.enter()\"></div>\n </div>\n\n <div *ngIf=\"showText\" class=\"br-text\">{{ nextRate | rateTitle: titles }}</div>\n</div>\n", | ||
providers: [RATING_VALUE_ACCESSOR, RATING_VALUE_VALIDATOR], | ||
changeDetection: core.ChangeDetectionStrategy.OnPush, | ||
styles: ["*{box-sizing:border-box}.br{margin:15px 0;position:relative}.br-units{display:flex;flex-wrap:nowrap}.br-unit{-webkit-font-smoothing:antialiased;cursor:pointer;text-rendering:auto}.br-disabled .br-unit,.br-readonly .br-unit{cursor:default}"] | ||
},] } | ||
]; | ||
BarRating.ctorParameters = function () { return [ | ||
{ type: core.ChangeDetectorRef } | ||
]; }; | ||
BarRating.propDecorators = { | ||
rate: [{ type: core.Input }], | ||
max: [{ type: core.Input }], | ||
readOnly: [{ type: core.Input }], | ||
theme: [{ type: core.Input }], | ||
showText: [{ type: core.Input }], | ||
titles: [{ type: core.Input }], | ||
required: [{ type: core.Input }], | ||
hover: [{ type: core.Output }], | ||
leave: [{ type: core.Output }], | ||
rateChange: [{ type: core.Output }] | ||
}; | ||
var BarRatingPipe = /** @class */ (function () { | ||
function BarRatingPipe() { | ||
} | ||
BarRatingPipe.prototype.transform = function (value, titles) { | ||
if (value === void 0) { value = 0; } | ||
/** Initialize value with 0 in case of undefined */ | ||
return titles[value] || value + 1; | ||
}; | ||
return BarRatingPipe; | ||
}()); | ||
BarRatingPipe.decorators = [ | ||
{ type: core.Pipe, args: [{ | ||
name: 'rateTitle' | ||
},] } | ||
]; | ||
var BarRatingModule = /** @class */ (function () { | ||
function BarRatingModule() { | ||
} | ||
return BarRatingModule; | ||
}()); | ||
BarRatingModule.decorators = [ | ||
{ type: core.NgModule, args: [{ | ||
declarations: [BarRating, BarRatingPipe], | ||
imports: [ | ||
common.CommonModule, | ||
forms.FormsModule | ||
], | ||
exports: [BarRating] | ||
},] } | ||
]; | ||
/** | ||
* Generated bundle index. Do not edit. | ||
*/ | ||
exports.BarRating = BarRating; | ||
exports.BarRatingModule = BarRatingModule; | ||
exports.ɵa = BarRatingPipe; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
}))); | ||
//# sourceMappingURL=ngx-bar-rating.umd.js.map |
{ | ||
"name": "ngx-bar-rating", | ||
"version": "1.1.0", | ||
"version": "2.0.0", | ||
"description": "Angular Bar Rating", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/MurhafSousli/ngx-bar-rating.git" | ||
}, | ||
"homepage": "https://github.com/MurhafSousli/ngx-bar-rating#readme", | ||
"bugs": { | ||
"url": "https://github.com/MurhafSousli/ngx-bar-rating/issues" | ||
}, | ||
"keywords": [ | ||
"bar-rating", | ||
"rating", | ||
"angular4", | ||
"angular2", | ||
"angular", | ||
@@ -17,19 +22,18 @@ "bar", | ||
"author": "Murhaf Sousli <murhafsousi@gmail.com>", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+ssh://git@github.com:MurhafSousli/ngx-bar-rating.git" | ||
}, | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/MurhafSousli/ngx-bar-rating/issues" | ||
"peerDependencies": { | ||
"@angular/common": "^10.1.3", | ||
"@angular/core": "^10.1.3" | ||
}, | ||
"homepage": "https://github.com/MurhafSousli/ngx-bar-rating#readme", | ||
"dependencies": { | ||
"tslib": "^2.0.0" | ||
}, | ||
"main": "bundles/ngx-bar-rating.umd.js", | ||
"module": "index.js", | ||
"typings": "index.d.ts", | ||
"peerDependencies": { | ||
"@angular/common": ">=2.0.0 <2.4.6 || >=2.4.8 <4.0.0-beta.6 || >=4.0.0-beta.8", | ||
"@angular/core": ">=2.0.0 <2.4.6 || >=2.4.8 <4.0.0-beta.6 || >=4.0.0-beta.8", | ||
"@angular/forms": ">=2.0.0 <2.4.6 || >=2.4.8 <4.0.0-beta.6 || >=4.0.0-beta.8" | ||
} | ||
} | ||
"module": "fesm2015/ngx-bar-rating.js", | ||
"es2015": "fesm2015/ngx-bar-rating.js", | ||
"esm2015": "esm2015/ngx-bar-rating.js", | ||
"fesm2015": "fesm2015/ngx-bar-rating.js", | ||
"typings": "ngx-bar-rating.d.ts", | ||
"metadata": "ngx-bar-rating.metadata.json", | ||
"sideEffects": false | ||
} |
@@ -30,17 +30,5 @@ <p align="center"> | ||
`npm install --save ngx-bar-rating` | ||
`npm i ngx-bar-rating` | ||
### SystemJS | ||
If you are using SystemJS, you should also adjust your configuration to point to the UMD bundle. | ||
In your systemjs config file, map needs to tell the System loader where to look for ngx-bar-rating: | ||
``` | ||
map: { | ||
'ngx-bar-rating': 'node_modules/ngx-bar-rating/bundles/ngx-bar-rating.umd.js', | ||
} | ||
``` | ||
Here is a working [plunkr](https://plnkr.co/edit/ZLSw4BV3ejRYkuWWAmoF?p=preview) | ||
<a name="usage"/> | ||
@@ -47,0 +35,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
96124
664
31
190
1
+ Addedtslib@^2.0.0
+ Added@angular/common@10.2.5(transitive)
+ Added@angular/core@10.2.5(transitive)
+ Addedrxjs@6.6.7(transitive)
+ Addedtslib@1.14.1(transitive)
+ Addedzone.js@0.10.3(transitive)
- Removed@angular/common@19.0.5(transitive)
- Removed@angular/core@19.0.5(transitive)
- Removed@angular/forms@19.0.5(transitive)
- Removed@angular/platform-browser@19.0.5(transitive)
- Removedrxjs@7.8.1(transitive)
- Removedzone.js@0.15.0(transitive)