nice-elements 1.7.5 → 1.7.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/README.md +1 -1
- package/bower.json +1 -1
- package/dist/nice.js +52 -47
- package/dist/nice.min.js +1 -1
- package/dist/style.css +52 -11
- package/dist/style.css.map +1 -1
- package/dist/style.min.css +2 -2
- package/package.json +1 -1
- package/src/components/nice-checkbox/nice-checkbox.html +3 -3
- package/src/components/nice-checkbox/nice-checkbox.js +7 -5
- package/src/components/nice-checkbox/nice-checkbox.scss +25 -2
- package/src/components/nice-choice/nice-choice.html +2 -1
- package/src/components/nice-choice/nice-choice.js +34 -35
- package/src/components/nice-choice/nice-choice.scss +34 -10
- package/src/components/nice-dropdown/nice-dropdown.html +1 -2
- package/src/components/nice-dropdown/nice-dropdown.js +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## v1.7.7 (10.1.2023)
|
|
4
|
+
|
|
5
|
+
- fixed nice-checkbox shrink problem,
|
|
6
|
+
- added isDisabled to nice-checkbox,
|
|
7
|
+
- changed nice-choice to match nice-checkbox,
|
|
8
|
+
- worked on nice-choice disabled state
|
|
9
|
+
|
|
10
|
+
## v1.7.6 (9.1.2023)
|
|
11
|
+
|
|
12
|
+
- added form required check to nice dropdown
|
|
13
|
+
|
|
3
14
|
## v1.7.5 (29.12.2022)
|
|
4
15
|
|
|
5
16
|
- fixed replace true bug
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|

|
|
2
2
|
|
|
3
|
-
# Nice elements v1.7.
|
|
3
|
+
# Nice elements v1.7.7
|
|
4
4
|
|
|
5
5
|
Nice elements is an AngularJS v1.5.8 module that contains nice form elements like inputs, choice fields, search, toggle, dropdown, etc.
|
|
6
6
|
|
package/bower.json
CHANGED
package/dist/nice.js
CHANGED
|
@@ -410,7 +410,7 @@ angular.module('niceElements')
|
|
|
410
410
|
* # niceCheckbox
|
|
411
411
|
*/
|
|
412
412
|
angular.module('niceElements')
|
|
413
|
-
.directive('niceCheckbox', function() {
|
|
413
|
+
.directive('niceCheckbox', function () {
|
|
414
414
|
return {
|
|
415
415
|
templateUrl: 'src/components/nice-checkbox/nice-checkbox.html',
|
|
416
416
|
restrict: 'E',
|
|
@@ -418,12 +418,14 @@ angular.module('niceElements')
|
|
|
418
418
|
model: '=',
|
|
419
419
|
title: '@',
|
|
420
420
|
noMargin: '@',
|
|
421
|
-
onChange: '&?'
|
|
421
|
+
onChange: '&?',
|
|
422
|
+
isDisabled: '=',
|
|
422
423
|
},
|
|
423
|
-
controller: function($scope) {
|
|
424
|
-
if($scope.model === undefined) $scope.model = false;
|
|
424
|
+
controller: function ($scope) {
|
|
425
|
+
if ($scope.model === undefined) $scope.model = false;
|
|
425
426
|
|
|
426
|
-
$scope.toggle = function(){
|
|
427
|
+
$scope.toggle = function () {
|
|
428
|
+
if ($scope.isDisabled) return;
|
|
427
429
|
$scope.model = !$scope.model;
|
|
428
430
|
if ($scope.onChange) $scope.onChange({ model: $scope.model });
|
|
429
431
|
};
|
|
@@ -473,17 +475,17 @@ angular.module('niceElements')
|
|
|
473
475
|
attr.multiple = angular.isDefined(attr.multiple);
|
|
474
476
|
|
|
475
477
|
scope.firstTime = true;
|
|
476
|
-
scope.checkIfFirstTime = function(){
|
|
477
|
-
if (scope.firstTime){
|
|
478
|
+
scope.checkIfFirstTime = function () {
|
|
479
|
+
if (scope.firstTime) {
|
|
478
480
|
scope.firstTime = false;
|
|
479
481
|
return true;
|
|
480
|
-
}else{
|
|
482
|
+
} else {
|
|
481
483
|
return false;
|
|
482
484
|
}
|
|
483
485
|
};
|
|
484
486
|
|
|
485
487
|
// If selected is not yet defined
|
|
486
|
-
if(!angular.isDefined(scope.model)){
|
|
488
|
+
if (!angular.isDefined(scope.model)) {
|
|
487
489
|
if (scope.multiple) {
|
|
488
490
|
scope.model = [];
|
|
489
491
|
}
|
|
@@ -493,7 +495,7 @@ angular.module('niceElements')
|
|
|
493
495
|
if (scope.listIsObj) {
|
|
494
496
|
scope.internalList = scope.list;
|
|
495
497
|
} else {
|
|
496
|
-
scope.internalList =_.map(scope.list, function(val) {
|
|
498
|
+
scope.internalList = _.map(scope.list, function (val) {
|
|
497
499
|
var obj = {};
|
|
498
500
|
obj[scope.objKey] = val;
|
|
499
501
|
obj[scope.objValue] = val;
|
|
@@ -504,9 +506,9 @@ angular.module('niceElements')
|
|
|
504
506
|
// Set internalSelected
|
|
505
507
|
if (scope.selectedIsObj) {
|
|
506
508
|
scope.internalSelected = scope.model;
|
|
507
|
-
}else {
|
|
509
|
+
} else {
|
|
508
510
|
if (scope.multiple) {
|
|
509
|
-
scope.internalSelected =_.map(scope.model, function(val) {
|
|
511
|
+
scope.internalSelected = _.map(scope.model, function (val) {
|
|
510
512
|
var obj = {};
|
|
511
513
|
obj[scope.objKey] = val;
|
|
512
514
|
obj[scope.objValue] = val;
|
|
@@ -518,14 +520,14 @@ angular.module('niceElements')
|
|
|
518
520
|
obj[scope.objKey] = scope.model;
|
|
519
521
|
obj[scope.objValue] = scope.model;
|
|
520
522
|
scope.internalSelected = obj;
|
|
521
|
-
}else{
|
|
523
|
+
} else {
|
|
522
524
|
scope.internalSelected = scope.internalList[0];
|
|
523
525
|
}
|
|
524
526
|
}
|
|
525
527
|
}
|
|
526
528
|
},
|
|
527
|
-
controller: function($rootScope, $scope) {
|
|
528
|
-
var getFilter = function(item){
|
|
529
|
+
controller: function ($rootScope, $scope) {
|
|
530
|
+
var getFilter = function (item) {
|
|
529
531
|
// Create filter for finding object by objValue with _.where()
|
|
530
532
|
var filter = {};
|
|
531
533
|
if (item.hasOwnProperty($scope.objKey))
|
|
@@ -535,40 +537,39 @@ angular.module('niceElements')
|
|
|
535
537
|
return filter;
|
|
536
538
|
};
|
|
537
539
|
|
|
538
|
-
$scope.setDefault = function(){
|
|
539
|
-
if(!$scope.multiple){
|
|
540
|
+
$scope.setDefault = function () {
|
|
541
|
+
if (!$scope.multiple) {
|
|
540
542
|
$scope.internalSelected = $scope.internalList[0];
|
|
541
543
|
}
|
|
542
544
|
};
|
|
543
545
|
|
|
544
|
-
$scope.isItemSelected = function(item){
|
|
546
|
+
$scope.isItemSelected = function (item) {
|
|
545
547
|
if (!$scope.internalSelected)
|
|
546
548
|
return false;
|
|
547
549
|
// Which item is selected
|
|
548
550
|
if ($scope.multiple) {
|
|
549
|
-
|
|
550
|
-
}else{
|
|
551
|
-
|
|
551
|
+
return _.where($scope.internalSelected, getFilter(item)).length > 0;
|
|
552
|
+
} else {
|
|
553
|
+
return $scope.internalSelected[$scope.objKey] == item[$scope.objKey];
|
|
552
554
|
}
|
|
553
555
|
};
|
|
554
556
|
|
|
555
|
-
$scope.toggle = function(item) {
|
|
556
|
-
if (
|
|
557
|
-
|
|
557
|
+
$scope.toggle = function (item) {
|
|
558
|
+
if ($scope.isDisabled) return;
|
|
559
|
+
$scope.formChoice.$setDirty();
|
|
558
560
|
|
|
559
|
-
|
|
560
|
-
|
|
561
|
+
if (!$scope.multiple) {
|
|
562
|
+
$scope.internalSelected = item;
|
|
563
|
+
} else {
|
|
564
|
+
if ($scope.isItemSelected(item)) {
|
|
565
|
+
$scope.internalSelected = _.without($scope.internalSelected, _.findWhere($scope.internalSelected, getFilter(item)));
|
|
561
566
|
} else {
|
|
562
|
-
|
|
563
|
-
$scope.internalSelected = _.without($scope.internalSelected, _.findWhere($scope.internalSelected, getFilter(item)));
|
|
564
|
-
} else {
|
|
565
|
-
$scope.internalSelected.push(item);
|
|
566
|
-
}
|
|
567
|
+
$scope.internalSelected.push(item);
|
|
567
568
|
}
|
|
568
569
|
}
|
|
569
570
|
};
|
|
570
571
|
|
|
571
|
-
$scope.getLabel = function(item){
|
|
572
|
+
$scope.getLabel = function (item) {
|
|
572
573
|
return item[$scope.objValue];
|
|
573
574
|
};
|
|
574
575
|
|
|
@@ -576,8 +577,8 @@ angular.module('niceElements')
|
|
|
576
577
|
// Set internalList
|
|
577
578
|
if ($scope.listIsObj) {
|
|
578
579
|
$scope.internalList = $scope.list;
|
|
579
|
-
}else{
|
|
580
|
-
$scope.internalList =_.map($scope.list, function(val) {
|
|
580
|
+
} else {
|
|
581
|
+
$scope.internalList = _.map($scope.list, function (val) {
|
|
581
582
|
var obj = {};
|
|
582
583
|
obj[$scope.objKey] = val;
|
|
583
584
|
obj[$scope.objValue] = val;
|
|
@@ -588,11 +589,11 @@ angular.module('niceElements')
|
|
|
588
589
|
|
|
589
590
|
$scope.$watchCollection('internalSelected', function (value_new, value_old) {
|
|
590
591
|
// Update $scope.selected based on settings
|
|
591
|
-
if (value_new && (!angular.equals(value_new, value_old) || $scope.checkIfFirstTime())){
|
|
592
|
-
if ($scope.selectedIsObj){
|
|
592
|
+
if (value_new && (!angular.equals(value_new, value_old) || $scope.checkIfFirstTime())) {
|
|
593
|
+
if ($scope.selectedIsObj) {
|
|
593
594
|
$scope.model = value_new;
|
|
594
595
|
} else {
|
|
595
|
-
if ($scope.multiple){
|
|
596
|
+
if ($scope.multiple) {
|
|
596
597
|
$scope.model = _.map(value_new, $scope.objKey);
|
|
597
598
|
} else {
|
|
598
599
|
$scope.model = value_new[$scope.objKey];
|
|
@@ -604,8 +605,8 @@ angular.module('niceElements')
|
|
|
604
605
|
|
|
605
606
|
$scope.$watchCollection('model', function (value_new, value_old) {
|
|
606
607
|
if (!angular.equals(value_new, value_old)) {
|
|
607
|
-
if (!value_new){
|
|
608
|
-
if(!$scope.multiple)
|
|
608
|
+
if (!value_new) {
|
|
609
|
+
if (!$scope.multiple)
|
|
609
610
|
$scope.internalSelected = $scope.internalList[0];
|
|
610
611
|
else
|
|
611
612
|
$scope.internalSelected = [];
|
|
@@ -626,7 +627,7 @@ angular.module('niceElements')
|
|
|
626
627
|
}
|
|
627
628
|
}
|
|
628
629
|
|
|
629
|
-
if(!value_new){
|
|
630
|
+
if (!value_new) {
|
|
630
631
|
if (!$scope.multiple) {
|
|
631
632
|
$scope.internalSelected = $scope.internalList[0];
|
|
632
633
|
}
|
|
@@ -2354,7 +2355,6 @@ angular.module('niceElements')
|
|
|
2354
2355
|
$scope.noMargin = $scope.noMargin === 'true' || $scope.noMargin === true;
|
|
2355
2356
|
$scope.multiple = $scope.multiple === 'true' || $scope.multiple === true;
|
|
2356
2357
|
$scope.clearOnSelect = $scope.clearOnSelect === 'true' || $scope.clearOnSelect === true;
|
|
2357
|
-
$scope.valid = $scope.formDropdown;
|
|
2358
2358
|
$scope.isOpen = false;
|
|
2359
2359
|
$scope.selected = null;
|
|
2360
2360
|
$scope.selectedIndex = 0;
|
|
@@ -2624,6 +2624,11 @@ angular.module('niceElements')
|
|
|
2624
2624
|
}
|
|
2625
2625
|
}
|
|
2626
2626
|
});
|
|
2627
|
+
|
|
2628
|
+
// Handle required
|
|
2629
|
+
$timeout(function () {
|
|
2630
|
+
$scope.formDropdown.$setValidity('required', !(!$scope.selected && $scope.required));
|
|
2631
|
+
});
|
|
2627
2632
|
}
|
|
2628
2633
|
|
|
2629
2634
|
// ----------------------------------- Watch for keydown and keypress -----------------------------------
|
|
@@ -5559,11 +5564,11 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
|
|
|
5559
5564
|
|
|
5560
5565
|
|
|
5561
5566
|
$templateCache.put('src/components/nice-checkbox/nice-checkbox.html',
|
|
5562
|
-
"<div class=\"nice-component nice-checkbox\" ng-class=\"{ 'checked': model, 'margin-bottom-0' : noMargin }\" ng-click=\"toggle()\">\n" +
|
|
5563
|
-
"<button class=\"btn checkbox\">\n" +
|
|
5567
|
+
"<div class=\"nice-component nice-checkbox\" ng-class=\"{ 'checked': model, 'margin-bottom-0' : noMargin, 'nice-checkbox-disabled': isDisabled }\" ng-click=\"toggle()\">\n" +
|
|
5568
|
+
"<button class=\"btn checkbox\" ng-disabled=\"isDisabled\">\n" +
|
|
5564
5569
|
"<nice-icon class=\"check\" icon=\"icon-check\"></nice-icon>\n" +
|
|
5565
5570
|
"</button>\n" +
|
|
5566
|
-
"<div ng-if=\"title\" class=\"message\">{{ title }}</div>\n" +
|
|
5571
|
+
"<div ng-if=\"title\" class=\"message\" ng-class=\"{ 'nice-disabled': isDisabled }\">{{ title }}</div>\n" +
|
|
5567
5572
|
"</div>"
|
|
5568
5573
|
);
|
|
5569
5574
|
|
|
@@ -5576,7 +5581,8 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
|
|
|
5576
5581
|
"<ul class=\"list-unstyled\" ng-class=\"{ 'disabled': isDisabled }\">\n" +
|
|
5577
5582
|
"<li ng-repeat=\"item in internalList\" ng-class=\"{ 'selected' : isItemSelected(item) }\" ng-click=\"toggle(item)\">\n" +
|
|
5578
5583
|
"<button class=\"choice-checkbox\" ng-class=\"{'circle' : !multiple }\" ng-disabled=\"isDisabled\">\n" +
|
|
5579
|
-
"<nice-icon icon=\"icon-check\"></nice-icon>\n" +
|
|
5584
|
+
"<nice-icon ng-if=\"multiple\" icon=\"icon-check\"></nice-icon>\n" +
|
|
5585
|
+
"<div ng-if=\"!multiple\" class=\"multiple-circle\"></div>\n" +
|
|
5580
5586
|
"</button>\n" +
|
|
5581
5587
|
"<div ng-transclude class=\"choice-label\">{{ getLabel(item) }}</div>\n" +
|
|
5582
5588
|
"</li>\n" +
|
|
@@ -5888,7 +5894,7 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
|
|
|
5888
5894
|
|
|
5889
5895
|
|
|
5890
5896
|
$templateCache.put('src/components/nice-dropdown/nice-dropdown.html',
|
|
5891
|
-
"<div class=\"nice-component nice-dropdown\" ng-class=\"{ 'margin-bottom-0': noMargin, 'nice-component-inline': isInline }\">\n" +
|
|
5897
|
+
"<div class=\"nice-component nice-dropdown\" ng-class=\"{ 'margin-bottom-0': noMargin, 'nice-component-inline': isInline }\" ng-form=\"formDropdown\">\n" +
|
|
5892
5898
|
"<div class=\"row\">\n" +
|
|
5893
5899
|
"<nice-title title=\"title\" help=\"help\" required=\"required\" label-width=\"labelWidth\"></nice-title>\n" +
|
|
5894
5900
|
"<div class=\"nice-field col-xs-12\" ng-class=\"[ fieldWidth ? fieldWidth : 'col-sm-8', { 'open': isOpen, 'nice-disabled': isDisabled || emptyList } ]\" click-outside=\"close()\" is-open=\"{{ isOpen }}\">\n" +
|
|
@@ -5932,7 +5938,6 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
|
|
|
5932
5938
|
"</div>\n" +
|
|
5933
5939
|
"</div>\n" +
|
|
5934
5940
|
"</div>\n" +
|
|
5935
|
-
"<div ng-form=\"formDropdown\"></div>\n" +
|
|
5936
5941
|
"</div>"
|
|
5937
5942
|
);
|
|
5938
5943
|
|