nice-elements 1.12.12 → 1.13.0

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 CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## v1.13.0 (20.1.2026)
4
+
5
+ - created nice options component
6
+
3
7
  ## v1.12.12 (6.1.2026)
4
8
 
5
9
  - added addButtonDisabled prop to nice dropdown
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ![Nice elements](https://github.com/Klemen1337/angularjs-nice-elements/raw/master/demo/assets/logo.png)
2
2
 
3
- # Nice elements v1.12.12
3
+ # Nice elements v1.13.0
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
 
@@ -50,6 +50,7 @@ Nice elements is an AngularJS v1.5.8 module that contains nice form elements lik
50
50
  - nice-view
51
51
  - nice-virtual-scroll
52
52
  - nice-on-scroll
53
+ - nice-options
53
54
  - ~~nice-datetime-picker~~ (DEPREACATED)
54
55
  - ~~nice-datetimerange-picker~~ (DEPREACATED)
55
56
  - ~~nice-dtp~~ (DEPREACATED)
package/bower.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nice-elements",
3
- "version": "1.12.12",
3
+ "version": "1.13.0",
4
4
  "authors": [
5
5
  "Klemen Kastelic <klemen@olaii.com>"
6
6
  ],
package/dist/nice.js CHANGED
@@ -171,7 +171,7 @@ angular.module('niceElements')
171
171
  label: '@'
172
172
  },
173
173
  link: function postLink(scope, element, attrs) {
174
- if (angular.isDefined(scope.model)) {
174
+ if (angular.isDefined(scope.model)){
175
175
  scope.model = false;
176
176
  }
177
177
  }
@@ -320,7 +320,7 @@ angular.module('niceElements')
320
320
  scope.endDateMinute = moment(scope.endDate).minutes();
321
321
  }
322
322
  }
323
-
323
+
324
324
  scope.month = angular.copy(moment(scope.startDate));
325
325
  const start = angular.copy(moment(scope.startDate));
326
326
  _removeTimeWithDate(start.date(0));
@@ -464,7 +464,7 @@ angular.module('niceElements')
464
464
 
465
465
  // ------------------ Check if dates are equal without time ------------------
466
466
  scope.isSameDay = function (date1, date2) {
467
- if (!date1 || !date2) return false;
467
+ if(!date1 || !date2) return false;
468
468
  const d1 = _removeTime(angular.copy(date1));
469
469
  const d2 = _removeTime(angular.copy(date2));
470
470
  return d1.isSame(d2);
@@ -473,7 +473,7 @@ angular.module('niceElements')
473
473
 
474
474
  // ------------------ Check if date is between start and end date ------------------
475
475
  scope.isBetweenRange = function (date) {
476
- if (!scope.endDate || !scope.startDate) return false;
476
+ if(!scope.endDate || !scope.startDate) return false;
477
477
  return (date.isBefore(moment(scope.endDate)) && date.isAfter(moment(scope.startDate)));
478
478
  };
479
479
 
@@ -3857,25 +3857,25 @@ angular.module('niceElements')
3857
3857
  };
3858
3858
  });
3859
3859
 
3860
- 'use strict';
3861
-
3862
- /**
3863
- * @ngdoc directive
3864
- * @name niceElements.directive:niceIcon
3865
- * @description
3866
- * # niceIcon
3867
- */
3868
- angular.module('niceElements')
3869
- .directive('niceIcon', function () {
3870
- return {
3871
- templateUrl: 'src/components/nice-icon/nice-icon.html',
3872
- restrict: 'E',
3873
- replace: true,
3874
- scope: {
3875
- icon: '@',
3876
- size: '=',
3877
- },
3878
- };
3860
+ 'use strict';
3861
+
3862
+ /**
3863
+ * @ngdoc directive
3864
+ * @name niceElements.directive:niceIcon
3865
+ * @description
3866
+ * # niceIcon
3867
+ */
3868
+ angular.module('niceElements')
3869
+ .directive('niceIcon', function () {
3870
+ return {
3871
+ templateUrl: 'src/components/nice-icon/nice-icon.html',
3872
+ restrict: 'E',
3873
+ replace: true,
3874
+ scope: {
3875
+ icon: '@',
3876
+ size: '=',
3877
+ },
3878
+ };
3879
3879
  });
3880
3880
  angular.module('niceElements')
3881
3881
  .directive('niceInput', function ($timeout) {
@@ -4525,11 +4525,11 @@ angular.module('niceElements')
4525
4525
  * @description
4526
4526
  * # niceOnScroll
4527
4527
  */
4528
- angular.module('niceElements').directive('niceOnScroll', function () {
4528
+ angular.module('niceElements').directive('niceOnScroll', function() {
4529
4529
  return {
4530
4530
  restrict: 'A',
4531
- link: function (scope, element, attrs) {
4532
- element.on('scroll', function () {
4531
+ link: function(scope, element, attrs) {
4532
+ element.on('scroll', function() {
4533
4533
  scope.$apply(attrs.niceOnScroll);
4534
4534
  });
4535
4535
  }
@@ -4537,6 +4537,75 @@ angular.module('niceElements').directive('niceOnScroll', function () {
4537
4537
  });
4538
4538
  'use strict';
4539
4539
 
4540
+ /**
4541
+ * @ngdoc directive
4542
+ * @name niceElements.directive:niceOptions
4543
+ * @description
4544
+ * # niceOptions
4545
+ */
4546
+ angular.module('niceElements')
4547
+ .directive('niceOptions', function () {
4548
+ return {
4549
+ templateUrl: 'src/components/nice-options/nice-options.html',
4550
+ restrict: 'E',
4551
+ transclude: true,
4552
+ scope: {
4553
+ model: '=',
4554
+ niceTitle: '@',
4555
+ isDisabled: '=',
4556
+ fieldWidth: '@',
4557
+ labelWidth: '@',
4558
+ noMargin: '@',
4559
+ onChange: '&?',
4560
+ isInline: '=',
4561
+ help: '@',
4562
+ required: '=',
4563
+ options: '=',
4564
+ selectedIsKey: '=',
4565
+ valueKey: "@"
4566
+ },
4567
+ controller: function ($scope, $timeout) {
4568
+ if (!$scope.fieldWidth) $scope.fieldWidth = 'col-sm-8';
4569
+ if (!$scope.labelWidth) $scope.labelWidth = 'col-sm-4';
4570
+ if (!$scope.valueKey) $scope.valueKey = 'id';
4571
+ $scope.noMargin = angular.isDefined($scope.noMargin);
4572
+
4573
+ // Check if selected
4574
+ $scope.isSelected = function(option) {
4575
+ if (!$scope.model) return false;
4576
+ if ($scope.selectedIsKey) {
4577
+ return $scope.model == option[$scope.valueKey];
4578
+ } else {
4579
+ return $scope.model[$scope.valueKey] == option[$scope.valueKey];
4580
+ }
4581
+ };
4582
+
4583
+ // Select option
4584
+ $scope.selectOption = function(option) {
4585
+ if ($scope.isSelected(option) && !$scope.required) {
4586
+ $scope.model = null;
4587
+ } else if ($scope.selectedIsKey) {
4588
+ $scope.model = option[$scope.valueKey];
4589
+ } else {
4590
+ $scope.model = option;
4591
+ }
4592
+
4593
+ $timeout(function () {
4594
+ if ($scope.onChange) $scope.onChange({ model: $scope.model });
4595
+ $scope.formNiceOptions.$setDirty();
4596
+ });
4597
+ };
4598
+
4599
+ // Select default
4600
+ if (!$scope.model && $scope.options && $scope.required) {
4601
+ $scope.selectOption($scope.options[0]);
4602
+ }
4603
+ }
4604
+ };
4605
+ });
4606
+
4607
+ 'use strict';
4608
+
4540
4609
  /**
4541
4610
  * @ngdoc directive
4542
4611
  * @name niceElements.directive:nicePercent
@@ -4793,7 +4862,7 @@ angular.module('niceElements')
4793
4862
  * # niceProgressBar
4794
4863
  */
4795
4864
  angular.module('niceElements')
4796
- .directive('niceProgressBar', function () {
4865
+ .directive('niceProgressBar', function() {
4797
4866
  return {
4798
4867
  restrict: 'E',
4799
4868
  replace: true,
@@ -4809,29 +4878,29 @@ angular.module('niceElements')
4809
4878
  help: '@'
4810
4879
  },
4811
4880
 
4812
- controller: function ($scope, $element, $timeout) {
4881
+ controller: function($scope, $element, $timeout) {
4813
4882
  $scope.width = 0;
4814
- $scope.resize = function () {
4815
- $timeout(function () {
4883
+ $scope.resize = function(){
4884
+ $timeout(function() {
4816
4885
  $scope.width = $element[0].getElementsByClassName("progress")[0].offsetWidth;
4817
- }, 100);
4886
+ },100);
4818
4887
  };
4819
- window.onresize = function () {
4888
+ window.onresize = function() {
4820
4889
  $scope.resize();
4821
4890
  };
4822
4891
  $scope.resize();
4823
4892
 
4893
+
4824
4894
 
4825
-
4826
- $scope.$watch("value", function (valueNew, valueOld) {
4895
+ $scope.$watch("value", function(valueNew, valueOld){
4827
4896
  $scope.calculate();
4828
4897
  });
4829
4898
 
4830
- $scope.$watch("max", function (valueNew, valueOld) {
4899
+ $scope.$watch("max", function(valueNew, valueOld){
4831
4900
  $scope.calculate();
4832
4901
  });
4833
4902
 
4834
- $scope.calculate = function () {
4903
+ $scope.calculate = function(){
4835
4904
  $scope.percentage = ($scope.value / $scope.max) * 100;
4836
4905
  };
4837
4906
 
@@ -5492,7 +5561,7 @@ angular.module('niceElements')
5492
5561
  controller: function ($scope, $transclude) {
5493
5562
  $scope.hasActions = $transclude().length > 0;
5494
5563
 
5495
- $scope.setOrder = function (key) {
5564
+ $scope.setOrder = function(key) {
5496
5565
  if (!$scope.canOrder) return;
5497
5566
  if ($scope.order == "!" + key) {
5498
5567
  $scope.order = null;
@@ -5504,18 +5573,18 @@ angular.module('niceElements')
5504
5573
  if ($scope.orderChanged) $scope.orderChanged($scope.order);
5505
5574
  }
5506
5575
 
5507
- $scope.rowStyle = function (column, row) {
5576
+ $scope.rowStyle = function(column, row) {
5508
5577
  if (!column.valueStyle) return;
5509
5578
  return column.valueStyle(row[column.key], row);
5510
- }
5511
-
5512
- $scope.rowClass = function (column, row) {
5579
+ }
5580
+
5581
+ $scope.rowClass = function(column, row) {
5513
5582
  if (!column.valueClass) return;
5514
5583
  return column.valueClass(row[column.key], row);
5515
5584
  }
5516
-
5517
- $scope.handleFreeze = function (column, isFirst, isLast, index) {
5518
- return {
5585
+
5586
+ $scope.handleFreeze = function(column, isFirst, isLast, index) {
5587
+ return {
5519
5588
  'nice-table-freeze-left': ($scope.freezeFirst && isFirst) || column.freeze,
5520
5589
  'nice-table-freeze-right': $scope.freezeLast && isLast && !$scope.hasActions
5521
5590
  }
@@ -5964,21 +6033,21 @@ angular.module('niceElements')
5964
6033
  if (!$scope.rowHeight) $scope.rowHeight = 50;
5965
6034
 
5966
6035
  // ------------------------- Prepare data -------------------------
5967
- $scope.prepareData = function () {
6036
+ $scope.prepareData = function() {
5968
6037
  $scope.items = Array.from($scope.data, (data, index) => ({
5969
6038
  id: index + 1,
5970
6039
  height: Number($scope.rowHeight), // Default placeholder height
5971
6040
  offsetTop: index * Number($scope.rowHeight), // Approximate offset
5972
6041
  data: data
5973
6042
  }));
5974
-
6043
+
5975
6044
  $scope.totalContentHeight = $scope.items.length * Number($scope.rowHeight); // Initial placeholder height * number of items
5976
6045
  if ($scope.hasAppend) $scope.totalContentHeight += Number($scope.rowHeight);
5977
6046
  $scope.onScroll();
5978
6047
  };
5979
6048
 
5980
6049
  // ------------------------- On scroll -------------------------
5981
- $scope.onScroll = function () {
6050
+ $scope.onScroll = function() {
5982
6051
  const container = $element[0].getBoundingClientRect();
5983
6052
  const scrollTop = $element[0].scrollTop;
5984
6053
  const viewportHeight = container.height;
@@ -5986,20 +6055,20 @@ angular.module('niceElements')
5986
6055
  const startIndex = $scope.items.findIndex(item => item.offsetTop + item.height > scrollTop);
5987
6056
  let endIndex = $scope.items.findIndex(item => item.offsetTop > scrollTop + viewportHeight);
5988
6057
  if (endIndex == -1) endIndex = $scope.items.length - 1;
5989
-
6058
+
5990
6059
  $scope.visibleItems = $scope.items.slice(startIndex, endIndex + 1);
5991
6060
  };
5992
6061
 
5993
6062
  // ------------------------- Watch for changes from outside -------------------------
5994
6063
  $scope.$watchCollection('data', function () {
5995
- $timeout(function () {
6064
+ $timeout(function() {
5996
6065
  $scope.prepareData();
5997
6066
  });
5998
6067
  });
5999
6068
 
6000
- // ------------------------- Watch for element resize -------------------------
6001
- new ResizeObserver(function () {
6002
- $timeout(function () {
6069
+ // ------------------------- Watch for element resize -------------------------
6070
+ new ResizeObserver(function() {
6071
+ $timeout(function() {
6003
6072
  $scope.onScroll();
6004
6073
  });
6005
6074
  }).observe($element[0]);
@@ -6326,11 +6395,16 @@ angular.module('niceElements')
6326
6395
  return (el.scrollTop + el.clientHeight) >= (el.scrollHeight - tolerance);
6327
6396
  };
6328
6397
 
6329
- // Scroll Event Listener
6330
- element[0].addEventListener('scroll', () => {
6398
+ function onScroll() {
6331
6399
  if (isScrolledToBottom(element[0]) && !scope.$eval(attrs.niceInfiniteLoaderDisabled)) {
6332
6400
  scope.$eval(attrs.niceInfiniteLoader);
6333
6401
  }
6402
+ }
6403
+
6404
+ // Scroll Event Listener
6405
+ element.on('scroll', onScroll);
6406
+ scope.$on('$destroy', () => {
6407
+ element.off('scroll', onScroll);
6334
6408
  });
6335
6409
  }
6336
6410
  };
@@ -6432,7 +6506,7 @@ angular.module('niceElements')
6432
6506
  .service('NiceService', function ($rootScope) {
6433
6507
  const service = {
6434
6508
  name: "Nice elements",
6435
- version: "1.12.12",
6509
+ version: "1.13.0",
6436
6510
  getHeader: function () {
6437
6511
  return {};
6438
6512
  },
@@ -6511,7 +6585,7 @@ angular.module('niceElements')
6511
6585
  };
6512
6586
  });
6513
6587
 
6514
- angular.module('niceElements').run(['$templateCache', function ($templateCache) {
6588
+ angular.module('niceElements').run(['$templateCache', function($templateCache) {
6515
6589
  'use strict';
6516
6590
 
6517
6591
  $templateCache.put('src/components/nice-alert/nice-alert.html',
@@ -7421,6 +7495,27 @@ angular.module('niceElements').run(['$templateCache', function ($templateCache)
7421
7495
  );
7422
7496
 
7423
7497
 
7498
+ $templateCache.put('src/components/nice-options/nice-options.html',
7499
+ "<div class=\"nice-component nice-options\" ng-class=\"{ 'margin-bottom-0' : noMargin, 'nice-component-inline': isInline, 'nice-disabled': isDisabled }\" ng-form=\"formNiceOptions\">\n" +
7500
+ " <div class=\"row\">\n" +
7501
+ " \n" +
7502
+ " <nice-title text=\"title || niceTitle\" help=\"help\" required=\"required\" label-width=\"labelWidth\"></nice-title>\n" +
7503
+ "\n" +
7504
+ " \n" +
7505
+ " <div class=\"nice-field col-xs-12\" ng-class=\"[fieldWidth ? fieldWidth : 'col-sm-8']\">\n" +
7506
+ " <div class=\"nice-options-wrapper\">\n" +
7507
+ " <button ng-repeat=\"option in options\" type=\"button\" class=\"btn\" ng-click=\"selectOption(option)\" ng-disabled=\"isDisabled\" ng-class=\"{ 'btn-primary': isSelected(option), 'btn-default': !isSelected(option) }\" ng-transclude>\n" +
7508
+ " <nice-icon class=\"nice-options-wrapper-icon\" ng-if=\"option.icon\" icon=\"{{ option.icon }}\"></nice-icon>\n" +
7509
+ " <div class=\"nice-options-wrapper-title\">{{ option.title }}</div>\n" +
7510
+ " <div class=\"nice-options-wrapper-description\" ng-if=\"option.description\">{{ option.description }}</div>\n" +
7511
+ " </button>\n" +
7512
+ " </div>\n" +
7513
+ " </div>\n" +
7514
+ " </div>\n" +
7515
+ "</div>"
7516
+ );
7517
+
7518
+
7424
7519
  $templateCache.put('src/components/nice-percent/nice-percent.html',
7425
7520
  "<ng-form class=\"nice-component nice-input\" ng-class=\"{ 'margin-bottom-0' : noMargin, 'nice-component-inline': isInline }\" name=\"form\">\n" +
7426
7521
  " <div class=\"row\">\n" +
@@ -8825,6 +8920,13 @@ angular.module('niceElements').run(['$templateCache', function ($templateCache)
8825
8920
  " <path d=\"M14.3267 10.9481C14.1175 10.5991 14.2308 10.1469 14.5797 9.93748C14.9287 9.72809 15.3811 9.84093 15.5906 10.1898L14.3267 10.9481ZM20.0134 10.9483L17.8019 14.634C17.6687 14.8557 17.4289 14.9912 17.1703 14.9913C16.9114 14.9913 16.6714 14.8555 16.5382 14.6335L14.3267 10.9481L15.5906 10.1898L17.1706 12.8216L18.7487 10.1901L18.7911 10.1276C19.0146 9.82829 19.4329 9.74063 19.7601 9.93682C20.0874 10.1332 20.2077 10.5439 20.0489 10.882L20.0134 10.9483Z\"/>\n" +
8826
8921
  " </symbol>\n" +
8827
8922
  "\n" +
8923
+ " <symbol id=\"icon-options\" viewBox=\"0 0 24 24\">\n" +
8924
+ " <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M21 5H3C2.44772 5 2 5.44772 2 6V18C2 18.5523 2.44772 19 3 19H21C21.5523 19 22 18.5523 22 18V6C22 5.44772 21.5523 5 21 5ZM3 3C1.34315 3 0 4.34315 0 6V18C0 19.6569 1.34315 21 3 21H21C22.6569 21 24 19.6569 24 18V6C24 4.34315 22.6569 3 21 3H3Z\"/>\n" +
8925
+ " <path d=\"M4.5 8.5C4.5 7.67157 5.17157 7 6 7V7C6.82843 7 7.5 7.67157 7.5 8.5V15.5C7.5 16.3284 6.82843 17 6 17V17C5.17157 17 4.5 16.3284 4.5 15.5V8.5Z\"/>\n" +
8926
+ " <path d=\"M10.5 8.5C10.5 7.67157 11.1716 7 12 7V7C12.8284 7 13.5 7.67157 13.5 8.5V15.5C13.5 16.3284 12.8284 17 12 17V17C11.1716 17 10.5 16.3284 10.5 15.5V8.5Z\"/>\n" +
8927
+ " <path d=\"M16.5 8.5C16.5 7.67157 17.1716 7 18 7V7C18.8284 7 19.5 7.67157 19.5 8.5V15.5C19.5 16.3284 18.8284 17 18 17V17C17.1716 17 16.5 16.3284 16.5 15.5V8.5Z\"/>\n" +
8928
+ " </symbol>\n" +
8929
+ "\n" +
8828
8930
  " <symbol id=\"icon-seat\" viewBox=\"0 0 370 370\">\n" +
8829
8931
  " <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M31 261H339V300C339 329.823 314.823 354 285 354H85C55.1766 354 31 329.823 31 300V261ZM73.372 321C65.9937 316.906 61 309.036 61 300V291H309V300C309 309.036 304.006 316.906 296.628 321C293.183 322.911 289.219 324 285 324H85C80.7813 324 76.8167 322.911 73.372 321Z\"></path>\n" +
8830
8932
  " <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M339 291H249V227C249 202.147 269.147 182 294 182C318.853 182 339 202.147 339 227V291ZM309 227C309 218.716 302.284 212 294 212C285.716 212 279 218.716 279 227V261H309V227Z\"></path>\n" +