nice-elements 1.10.16 → 1.11.1

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,16 @@
1
1
  # Changelog
2
2
 
3
+ ## v1.11.1 (17.1.2025)
4
+
5
+ - added autocomplete to nice-input,
6
+ - fixed nice slot niceTitle
7
+
8
+ ## v1.11.0 (11.12.2024)
9
+
10
+ - created nice virtual scroll component,
11
+ - fixed nice number step any bug,
12
+ - fixed nice dropdown nullable text color,
13
+
3
14
  ## v1.10.16 (4.11.2024)
4
15
 
5
16
  - added placement prop to nice date, dropdown, daterangepricer, help and search2,
@@ -25,7 +36,7 @@
25
36
 
26
37
  - worked on nice tooltip,
27
38
  - create nice tooltip example page,
28
- - changed nice-choice inline margin
39
+ - changed nice-choice inline margin
29
40
 
30
41
  ## v1.10.12 (20.10.2024)
31
42
 
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.10.16
3
+ # Nice elements v1.11.1
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
 
@@ -49,6 +49,9 @@ Nice elements is an AngularJS v1.5.8 module that contains nice form elements lik
49
49
  - nice-toggle
50
50
  - nice-no-data
51
51
  - nice-table
52
+ - nice-view
53
+ - nice-virtual-scroll
54
+ - nice-on-scroll
52
55
  - ~~nice-datetime-picker~~ (DEPREACATED)
53
56
  - ~~nice-datetimerange-picker~~ (DEPREACATED)
54
57
  - ~~nice-dtp~~ (DEPREACATED)
package/bower.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nice-elements",
3
- "version": "1.10.16",
3
+ "version": "1.11.1",
4
4
  "authors": ["Klemen Kastelic <klemen@olaii.com>"],
5
5
  "description": "Nice elements",
6
6
  "keywords": [],
package/dist/nice.js CHANGED
@@ -3809,6 +3809,7 @@ angular.module('niceElements')
3809
3809
  positiveOnly: '=?', // Allow only positive numbers in the input
3810
3810
  multilanguage: '=?', // Multiple languages object
3811
3811
  multilanguageField: '@?', // Multiple languages field name
3812
+ autocomplete: "@?"
3812
3813
  },
3813
3814
 
3814
3815
  link: function (scope, element, attrs) {
@@ -4267,7 +4268,7 @@ angular.module('niceElements')
4267
4268
 
4268
4269
  controller: function ($scope, $timeout) {
4269
4270
  $scope.canAdd = true;
4270
- $scope.canSubstract = true;
4271
+ $scope.canSubtract = true;
4271
4272
  $scope.preventZero = $scope.preventZero == "true";
4272
4273
 
4273
4274
  // Link form object with valid object
@@ -4300,7 +4301,9 @@ angular.module('niceElements')
4300
4301
  // Fix step
4301
4302
  if (!$scope.step) $scope.step = 1;
4302
4303
  else $scope.step = parseFloat($scope.step);
4303
-
4304
+ $scope.innerStep = angular.copy($scope.step);
4305
+ if ($scope.innerStep == "any") $scope.innerStep = 1; // Fix step any
4306
+ if (Number.isNaN($scope.innerStep)) $scope.innerStep = 1; // Fix step any
4304
4307
 
4305
4308
  // Check if number is defined
4306
4309
  if (!$scope.model) {
@@ -4324,10 +4327,10 @@ angular.module('niceElements')
4324
4327
  }
4325
4328
 
4326
4329
  if ($scope.min && parseFloat($scope.model) <= $scope.min) {
4327
- $scope.canSubstract = false;
4330
+ $scope.canSubtract = false;
4328
4331
  // $scope.model = $scope.min;
4329
4332
  } else {
4330
- $scope.canSubstract = true;
4333
+ $scope.canSubtract = true;
4331
4334
  }
4332
4335
 
4333
4336
  if ($scope.max && parseFloat($scope.model) >= $scope.max) {
@@ -4365,14 +4368,14 @@ angular.module('niceElements')
4365
4368
  if ($scope.onChange && oldModel != newModel) {
4366
4369
  $timeout(function () {
4367
4370
  $scope.onChange({ model: $scope.model });
4368
- })
4371
+ });
4369
4372
  }
4370
4373
  });
4371
4374
 
4372
4375
 
4373
4376
  // Add to the value
4374
4377
  $scope.add = function () {
4375
- const result = new Decimal($scope.model != undefined ? $scope.model : $scope.defaultValue).plus($scope.step).toNumber(); //.toFixed($scope.decimals);
4378
+ const result = new Decimal($scope.model != undefined ? $scope.model : $scope.defaultValue).plus($scope.innerStep).toNumber(); //.toFixed($scope.decimals);
4376
4379
  if ($scope.max) {
4377
4380
  if (result <= parseFloat($scope.max)) {
4378
4381
  $scope.model = result;
@@ -4388,7 +4391,7 @@ angular.module('niceElements')
4388
4391
 
4389
4392
  // Subtract to the value
4390
4393
  $scope.subtract = function () {
4391
- const result = new Decimal($scope.model != undefined ? $scope.model : $scope.defaultValue).minus($scope.step).toNumber();
4394
+ const result = new Decimal($scope.model != undefined ? $scope.model : $scope.defaultValue).minus($scope.innerStep).toNumber();
4392
4395
  if (result >= Number($scope.min)) {
4393
4396
  $scope.model = result;
4394
4397
  $scope.niceNumberForm.$setDirty();
@@ -4401,6 +4404,24 @@ angular.module('niceElements')
4401
4404
 
4402
4405
  'use strict';
4403
4406
 
4407
+ /**
4408
+ * @ngdoc directive
4409
+ * @name niceElements.directive:niceOnScroll
4410
+ * @description
4411
+ * # niceOnScroll
4412
+ */
4413
+ angular.module('niceElements').directive('niceOnScroll', function() {
4414
+ return {
4415
+ restrict: 'A',
4416
+ link: function(scope, element, attrs) {
4417
+ element.on('scroll', function() {
4418
+ scope.$apply(attrs.niceOnScroll);
4419
+ });
4420
+ }
4421
+ };
4422
+ });
4423
+ 'use strict';
4424
+
4404
4425
  /**
4405
4426
  * @ngdoc directive
4406
4427
  * @name niceElements.directive:nicePercent
@@ -5301,7 +5322,7 @@ angular.module('niceElements')
5301
5322
  link: function postLink(scope, element, attrs) {
5302
5323
  if (!attrs.fieldWidth) { attrs.fieldWidth = 'col-sm-8'; }
5303
5324
  if (!attrs.labelWidth) { attrs.labelWidth = 'col-sm-4'; }
5304
- if (!attrs.title) { attrs.title = ' '; }
5325
+ if (!attrs.niceTitle) { attrs.niceTitle = ' '; }
5305
5326
  }
5306
5327
  };
5307
5328
  });
@@ -5886,6 +5907,77 @@ angular.module('niceElements')
5886
5907
 
5887
5908
  'use strict';
5888
5909
 
5910
+ /**
5911
+ * @ngdoc directive
5912
+ * @name niceElements.directive:niceVirtualScroll
5913
+ * @description
5914
+ * # niceVirtualScroll
5915
+ */
5916
+ angular.module('niceElements')
5917
+ .directive('niceVirtualScroll', function () {
5918
+ return {
5919
+ templateUrl: 'src/components/nice-virtual-scroll/nice-virtual-scroll.html',
5920
+ restrict: 'E',
5921
+ transclude: {
5922
+ 'append': '?niceVirtualScrollAppend',
5923
+ },
5924
+ replace: true,
5925
+ scope: {
5926
+ data: "=",
5927
+ rowHeight: "@"
5928
+ },
5929
+ controller: function ($scope, $element, $timeout, $transclude) {
5930
+ $scope.hasAppend = $transclude.isSlotFilled('append');
5931
+ if (!$scope.rowHeight) $scope.rowHeight = 50;
5932
+
5933
+ // ------------------------- Prepare data -------------------------
5934
+ $scope.prepareData = function() {
5935
+ $scope.items = Array.from($scope.data, (data, index) => ({
5936
+ id: index + 1,
5937
+ height: Number($scope.rowHeight), // Default placeholder height
5938
+ offsetTop: index * Number($scope.rowHeight), // Approximate offset
5939
+ data: data
5940
+ }));
5941
+
5942
+ $scope.totalContentHeight = $scope.items.length * Number($scope.rowHeight); // Initial placeholder height * number of items
5943
+ if ($scope.hasAppend) $scope.totalContentHeight += Number($scope.rowHeight);
5944
+ $scope.onScroll();
5945
+ };
5946
+
5947
+ // ------------------------- On scroll -------------------------
5948
+ $scope.onScroll = function() {
5949
+ const container = $element[0].getBoundingClientRect();
5950
+ const scrollTop = $element[0].scrollTop;
5951
+ const viewportHeight = container.height;
5952
+
5953
+ const startIndex = $scope.items.findIndex(item => item.offsetTop + item.height > scrollTop);
5954
+ let endIndex = $scope.items.findIndex(item => item.offsetTop > scrollTop + viewportHeight);
5955
+ if (endIndex == -1) endIndex = $scope.items.length - 1;
5956
+
5957
+ $scope.visibleItems = $scope.items.slice(startIndex, endIndex + 1);
5958
+ };
5959
+
5960
+ // ------------------------- Watch for changes from outside -------------------------
5961
+ $scope.$watchCollection('data', function () {
5962
+ $timeout(function() {
5963
+ $scope.prepareData();
5964
+ });
5965
+ });
5966
+
5967
+ // ------------------------- Watch for element resize -------------------------
5968
+ new ResizeObserver(function() {
5969
+ $timeout(function() {
5970
+ $scope.onScroll();
5971
+ });
5972
+ }).observe($element[0]);
5973
+
5974
+ // Initial render
5975
+ $scope.prepareData();
5976
+ }
5977
+ };
5978
+ });
5979
+ 'use strict';
5980
+
5889
5981
  /**
5890
5982
  * @ngdoc directive
5891
5983
  * @name niceElements.directive:niceWrapper
@@ -6088,7 +6180,7 @@ angular.module('niceElements')
6088
6180
  .service('NiceService', function ($rootScope) {
6089
6181
  const service = {
6090
6182
  name: "Nice elements",
6091
- version: "1.10.15",
6183
+ version: "1.11.0",
6092
6184
  getHeader: function () {
6093
6185
  return {};
6094
6186
  },
@@ -6658,7 +6750,7 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
6658
6750
  "<span ng-if=\"multiple\">\n" +
6659
6751
  "<span ng-if=\"selected.length > 1\">{{ selected.length }} {{ selectedText }}</span>\n" +
6660
6752
  "<span ng-if=\"selected.length == 1\">{{ selected[0][objValue] }}</span>\n" +
6661
- "<span ng-if=\"selected.length == 0\">{{ nullableText }}</span>\n" +
6753
+ "<span ng-if=\"selected.length == 0\" class=\"not-selected\">{{ nullableText }}</span>\n" +
6662
6754
  "</span>\n" +
6663
6755
  "</div>\n" +
6664
6756
  "<div class=\"not-selected\" ng-if=\"selected == null\">{{ selectText }}</div>\n" +
@@ -6824,8 +6916,8 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
6824
6916
  " 'nice-disabled': isDisabled\r" +
6825
6917
  "\n" +
6826
6918
  " }\">\n" +
6827
- "<textarea ng-if=\"textArea\" class=\"form-control\" ng-model=\"$parent.internalModel\" id=\"{{ id }}\" tabindex=\"{{ tabIndex }}\" placeholder=\"{{ placeholder }}\" rows=\"{{textAreaLines}}\" max=\"{{ max }}\" min=\"{{ min }}\" ng-minlength=\"minlength\" ng-maxlength=\"maxlength\" ng-required=\"required\" ng-pattern=\"regexexp\" ng-disabled=\"isDisabled\"></textarea>\n" +
6828
- "<input ng-if=\"!textArea\" class=\"form-control\" type=\"{{ internalType }}\" inputmode=\"{{ inputMode }}\" ng-model=\"$parent.internalModel\" name=\"{{ name }}\" id=\"{{ id }}\" tabindex=\"{{ tabIndex }}\" placeholder=\"{{ placeholder }}\" max=\"{{ max }}\" min=\"{{ min }}\" ng-minlength=\"minlength\" ng-maxlength=\"maxlength\" ng-required=\"required\" ng-keypress=\"keypress($event)\" ng-pattern=\"regexexp\" ng-disabled=\"isDisabled\">\n" +
6919
+ "<textarea ng-if=\"textArea\" class=\"form-control\" ng-model=\"$parent.internalModel\" id=\"{{ id }}\" tabindex=\"{{ tabIndex }}\" placeholder=\"{{ placeholder }}\" rows=\"{{textAreaLines}}\" max=\"{{ max }}\" min=\"{{ min }}\" autocomplete=\"{{ autocomplete }}\" ng-minlength=\"minlength\" ng-maxlength=\"maxlength\" ng-required=\"required\" ng-pattern=\"regexexp\" ng-disabled=\"isDisabled\"></textarea>\n" +
6920
+ "<input ng-if=\"!textArea\" class=\"form-control\" type=\"{{ internalType }}\" inputmode=\"{{ inputMode }}\" ng-model=\"$parent.internalModel\" name=\"{{ name }}\" id=\"{{ id }}\" tabindex=\"{{ tabIndex }}\" placeholder=\"{{ placeholder }}\" max=\"{{ max }}\" min=\"{{ min }}\" autocomplete=\"{{ autocomplete }}\" ng-minlength=\"minlength\" ng-maxlength=\"maxlength\" ng-required=\"required\" ng-keypress=\"keypress($event)\" ng-pattern=\"regexexp\" ng-disabled=\"isDisabled\">\n" +
6829
6921
  "<div class=\"input-group-addon\" ng-if=\"symbol\">{{ symbol }}</div>\n" +
6830
6922
  "<button type=\"button\" class=\"input-group-btn\" ng-if=\"multilanguageField\" ng-click=\"openMultilanguage()\">\n" +
6831
6923
  "<nice-icon icon=\"icon-translate\"></nice-icon>\n" +
@@ -6901,7 +6993,7 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
6901
6993
  "<div class=\"nice-field col-xs-12\" ng-class=\"[fieldWidth ? fieldWidth : 'col-sm-8', { 'nice-disabled': isDisabled }]\">\n" +
6902
6994
  "<div class=\"input-group\" ng-class=\"{'has-warning': !isDisabled && niceNumberForm.$invalid && niceNumberForm.$dirty}\">\n" +
6903
6995
  "<span class=\"input-group-btn\">\n" +
6904
- "<button type=\"button\" class=\"btn btn-default btn-left\" ng-disabled=\"!canSubstract || isDisabled\" ng-click=\"subtract()\" tabindex=\"-1\">\n" +
6996
+ "<button type=\"button\" class=\"btn btn-default btn-left\" ng-disabled=\"!canSubtract || isDisabled\" ng-click=\"subtract()\" tabindex=\"-1\">\n" +
6905
6997
  "<nice-icon icon=\"icon-minus\"></nice-icon>\n" +
6906
6998
  "</button>\n" +
6907
6999
  "</span>\n" +
@@ -8234,6 +8326,18 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
8234
8326
  );
8235
8327
 
8236
8328
 
8329
+ $templateCache.put('src/components/nice-virtual-scroll/nice-virtual-scroll.html',
8330
+ "<div class=\"nice-virtual-scroll\" nice-on-scroll=\"onScroll()\">\n" +
8331
+ "<div class=\"nice-virtual-scroll-content\" ng-style=\"{ height: totalContentHeight + 'px' }\">\n" +
8332
+ "<div class=\"nice-virtual-scroll-item\" ng-repeat=\"item in visibleItems track by $index\" ng-style=\"{ top: item.offsetTop + 'px', height: item.height + 'px' }\">\n" +
8333
+ "<ng-transclude item=\"item\">{{ item.data }}</ng-transclude>\n" +
8334
+ "</div>\n" +
8335
+ "<div class=\"nice-virtual-scroll-append\" ng-if=\"hasAppend\" ng-style=\"{ height: rowHeight + 'px' }\" ng-transclude=\"append\"></div>\n" +
8336
+ "</div>\n" +
8337
+ "</div>"
8338
+ );
8339
+
8340
+
8237
8341
  $templateCache.put('src/components/nice-wrapper/nice-wrapper.html',
8238
8342
  "<div class=\"nice-wrapper\" ng-class=\"{ 'collapsable': collapsable, 'has-header': hasHeader, 'has-footer': hasFooter, 'nice-wrapper-sticky-footer': stickyFooter, 'nice-wrapper-sticky-header': stickyHeader }\">\n" +
8239
8343
  "<div class=\"nice-wrapper-header\" ng-if=\"hasHeader\" ng-click=\"toggle()\">\n" +