nice-elements 1.16.0 → 1.16.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,15 @@
1
1
  # Changelog
2
2
 
3
+ ## v1.16.1 (30.11.2026)
4
+
5
+ - fixed nice search dropdown position (sits under the input),
6
+ - nice search dropdown closes on click outside,
7
+ - nice search updates results also when refresh-function returns a native promise,
8
+ - fixed nice search2 on-select (accepts an expression like on-select="fn(model)" or a function reference),
9
+ - fixed nice search2 model binding inside nice popup,
10
+ - nice notification classes are prefixed with nice-,
11
+ - added max-width to nice notification, cards align left
12
+
3
13
  ## v1.16.0 (27.11.2026)
4
14
 
5
15
  - removed font awesome, all icons are now nice icon (added icon-dot, bolder icon-plus),
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.16.0
3
+ # Nice elements v1.16.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
 
package/bower.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nice-elements",
3
- "version": "1.16.0",
3
+ "version": "1.16.1",
4
4
  "authors": [
5
5
  "Klemen Kastelic <klemen@olaii.com>"
6
6
  ],
package/dist/nice.js CHANGED
@@ -5567,19 +5567,12 @@ angular.module('niceElements')
5567
5567
  //scope.$apply();
5568
5568
  };
5569
5569
 
5570
- // Close the dropdown if clicked outside
5571
- const onClick = function (event) {
5572
- const isClickedElementChildOfPopup = element.find(event.target).length > 0;
5573
-
5574
- if (isClickedElementChildOfPopup) return;
5575
-
5570
+ // Close the dropdown (called by click-outside in the template)
5571
+ scope.closeDropdown = function () {
5576
5572
  scope.results = [];
5577
5573
  scope.noResults = false;
5578
- scope.$apply();
5579
5574
  };
5580
5575
 
5581
- angular.element(element).on('click', onClick);
5582
-
5583
5576
  // Keyboard up/down on search results
5584
5577
  const onKeyDown = function (event) {
5585
5578
  if ((event.keyCode == 38 || event.keyCode == 40 || event.keyCode == 13 || event.keyCode == 27) && scope.results && scope.results.length > 0) {
@@ -5611,7 +5604,6 @@ angular.module('niceElements')
5611
5604
  angular.element(element).on('keydown', onKeyDown);
5612
5605
 
5613
5606
  scope.$on('$destroy', function () {
5614
- angular.element(element).off('click', onClick);
5615
5607
  angular.element(element).off('keydown', onKeyDown);
5616
5608
  });
5617
5609
 
@@ -5664,10 +5656,15 @@ angular.module('niceElements')
5664
5656
  }
5665
5657
  $scope.requests = $scope.requests + 1;
5666
5658
  const requestNumber = angular.copy($scope.requests);
5659
+ // $timeout so the view updates also when refreshFunction returns a native Promise
5667
5660
  $scope.refreshFunction($scope.modelString).then(function (response) {
5668
- updateList(response, requestNumber);
5661
+ $timeout(function () {
5662
+ updateList(response, requestNumber);
5663
+ });
5669
5664
  }, function (error) {
5670
- $scope.loading = false;
5665
+ $timeout(function () {
5666
+ $scope.loading = false;
5667
+ });
5671
5668
  });
5672
5669
  // Why was this here?
5673
5670
  // $scope.model = $scope.modelString;
@@ -5737,7 +5734,7 @@ angular.module('niceElements')
5737
5734
  labelWidth: '@',
5738
5735
  refreshFunction: '=',
5739
5736
  refreshSelectedCallback: '=',
5740
- onSelect: '=',
5737
+ onSelect: '&?',
5741
5738
  onChange: '&?',
5742
5739
  noMargin: '@',
5743
5740
  tabIndex: '@',
@@ -5761,6 +5758,14 @@ angular.module('niceElements')
5761
5758
  if (!$scope.model) $scope.model = "";
5762
5759
  if (!$scope.placement) { $scope.placement = "bottom-start"; }
5763
5760
 
5761
+ // ------------------- Model accessor -------------------
5762
+ // Input lives inside nice-popup's transcluded (child) scope, so a plain ng-model="model"
5763
+ // would write to the child scope only. Bind through a getter/setter instead.
5764
+ $scope.modelAccessor = function (value) {
5765
+ if (arguments.length) $scope.model = value;
5766
+ return $scope.model;
5767
+ };
5768
+
5764
5769
  // ------------------- On focus -------------------
5765
5770
  $scope.onFocus = function () {
5766
5771
  if ($scope.showDropdown && $scope.results.length == 0) {
@@ -5864,7 +5869,10 @@ angular.module('niceElements')
5864
5869
  // ------------------------ Select item ------------------------
5865
5870
  $scope.selectItem = function (item) {
5866
5871
  if ($scope.onSelect) {
5867
- $scope.onSelect(item);
5872
+ // Supports on-select="fn(model)" (expression) and on-select="fn" (function reference):
5873
+ // the expression form is evaluated directly, the reference form returns the function to call.
5874
+ const result = $scope.onSelect({ model: item });
5875
+ if (angular.isFunction(result)) result(item);
5868
5876
  $scope.clear();
5869
5877
  $scope.close();
5870
5878
  }
@@ -7199,7 +7207,7 @@ angular.module('niceElements')
7199
7207
 
7200
7208
  const service = {
7201
7209
  name: "Nice elements",
7202
- version: "1.16.0",
7210
+ version: "1.16.1",
7203
7211
  getHeader: function () {
7204
7212
  return {};
7205
7213
  },
@@ -8341,12 +8349,12 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
8341
8349
 
8342
8350
 
8343
8351
  $templateCache.put('src/components/nice-notification/nice-notification.html',
8344
- "<div class=\"notification\" ng-class=\"{ 'has-icon': icon }\">\n" +
8345
- " <div class=\"notification-inner\">\n" +
8346
- " <nice-icon ng-if=\"icon\" class=\"notification-icon\" icon=\"{{ icon }}\"></nice-icon>\n" +
8347
- " <div class=\"notification-content\">\n" +
8348
- " <div class=\"notification-title\" ng-show=\"title\" ng-bind-html=\"title\"></div>\n" +
8349
- " <div class=\"notification-message\" ng-bind-html=\"message\"></div>\n" +
8352
+ "<div class=\"nice-notification\" ng-class=\"{ 'has-icon': icon }\">\n" +
8353
+ " <div class=\"nice-notification-inner\">\n" +
8354
+ " <nice-icon ng-if=\"icon\" class=\"nice-notification-icon\" icon=\"{{ icon }}\"></nice-icon>\n" +
8355
+ " <div class=\"nice-notification-content\">\n" +
8356
+ " <div class=\"nice-notification-title\" ng-show=\"title\" ng-bind-html=\"title\"></div>\n" +
8357
+ " <div class=\"nice-notification-message\" ng-bind-html=\"message\"></div>\n" +
8350
8358
  " </div>\n" +
8351
8359
  " </div>\n" +
8352
8360
  "</div>\n"
@@ -8531,33 +8539,31 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
8531
8539
  "\n" +
8532
8540
  " \n" +
8533
8541
  " <div class=\"nice-field col-xs-12\" ng-class=\"[fieldWidth ? fieldWidth : 'col-sm-8', { 'nice-disabled': isDisabled }]\">\n" +
8534
- " <div class=\"input-group\" ng-class=\"{ 'disabled': isDisabled }\">\n" +
8535
- " <input class=\"form-control\" type=\"text\" id=\"{{ id }}\" ng-model=\"modelString\" ng-keypress=\"keypress($event)\" placeholder=\"{{ placeholder }}\" ng-disabled=\"isDisabled\" ng-change=\"updateSearch()\" ng-required=\"required\" tabindex=\"{{ tabIndex }}\">\n" +
8542
+ " <div class=\"nice-search-field\" click-outside=\"closeDropdown()\" is-open=\"{{ results.length > 0 || noResults }}\">\n" +
8543
+ " <div class=\"input-group\" ng-class=\"{ 'disabled': isDisabled }\">\n" +
8544
+ " <input class=\"form-control\" type=\"text\" id=\"{{ id }}\" ng-model=\"modelString\" ng-keypress=\"keypress($event)\" placeholder=\"{{ placeholder }}\" ng-disabled=\"isDisabled\" ng-change=\"updateSearch()\" ng-required=\"required\" tabindex=\"{{ tabIndex }}\">\n" +
8536
8545
  "\n" +
8537
- " <button type=\"button\" class=\"btn input-group-addon\" ng-click=\"search()\" ng-if=\"!model\" ng-disabled=\"isDisabled\">\n" +
8538
- " \n" +
8539
- " <nice-icon ng-show=\"!loading\" icon=\"icon-search\"></nice-icon>\n" +
8540
- " <nice-loader ng-if=\"loading\"></nice-loader>\n" +
8541
- " </button>\n" +
8546
+ " <button type=\"button\" class=\"btn input-group-addon\" ng-click=\"search()\" ng-if=\"!model\" ng-disabled=\"isDisabled\">\n" +
8547
+ " \n" +
8548
+ " <nice-icon ng-show=\"!loading\" icon=\"icon-search\"></nice-icon>\n" +
8549
+ " <nice-loader ng-if=\"loading\"></nice-loader>\n" +
8550
+ " </button>\n" +
8542
8551
  "\n" +
8543
- " <button type=\"button\" class=\"btn input-group-addon\" ng-click=\"remove()\" ng-if=\"model\" ng-disabled=\"isDisabled\">\n" +
8544
- " <nice-icon ng-show=\"!loading\" icon=\"icon-x\"></nice-icon>\n" +
8545
- " </button>\n" +
8546
- " </div>\n" +
8547
- " </div>\n" +
8548
- " </div>\n" +
8552
+ " <button type=\"button\" class=\"btn input-group-addon\" ng-click=\"remove()\" ng-if=\"model\" ng-disabled=\"isDisabled\">\n" +
8553
+ " <nice-icon ng-show=\"!loading\" icon=\"icon-x\"></nice-icon>\n" +
8554
+ " </button>\n" +
8555
+ " </div>\n" +
8549
8556
  "\n" +
8550
- " <div class=\"row\" ng-if=\"noResults || results.length\">\n" +
8551
- " <div ng-class=\"labelWidth ? labelWidth : 'col-sm-4'\" ng-if=\"title\"></div>\n" +
8552
- " <div class=\"nice-field col-xs-12\" ng-class=\"fieldWidth ? fieldWidth : 'col-sm-8'\">\n" +
8553
- " <div class=\"nice-dropdown-empty\" ng-if=\"noResults\">\n" +
8554
- " <div class=\"nice-search-row\" translate translate-context=\"Nice\">No results found.</div>\n" +
8555
- " </div>\n" +
8557
+ " \n" +
8558
+ " <div class=\"nice-dropdown-empty\" ng-if=\"noResults\">\n" +
8559
+ " <div class=\"nice-search-row\" translate translate-context=\"Nice\">No results found.</div>\n" +
8560
+ " </div>\n" +
8556
8561
  "\n" +
8557
- " <div class=\"nice-dropdown\" ng-if=\"results.length\">\n" +
8558
- " <div ng-repeat=\"result in results\" class=\"nice-search-row\" ng-class=\"{'active': selectedIndex == $index}\" ng-click=\"selectRow(result)\">\n" +
8559
- " <span class=\"text-bold\" ng-if=\"!hasRowTemplate\">{{ result[keyForInputLabel] }}</span>\n" +
8560
- " <div ng-if=\"hasRowTemplate\" nice-search-row-transclude></div>\n" +
8562
+ " <div class=\"nice-dropdown\" ng-if=\"results.length\">\n" +
8563
+ " <div ng-repeat=\"result in results\" class=\"nice-search-row\" ng-class=\"{'active': selectedIndex == $index}\" ng-click=\"selectRow(result)\">\n" +
8564
+ " <span class=\"text-bold\" ng-if=\"!hasRowTemplate\">{{ result[keyForInputLabel] }}</span>\n" +
8565
+ " <div ng-if=\"hasRowTemplate\" nice-search-row-transclude></div>\n" +
8566
+ " </div>\n" +
8561
8567
  " </div>\n" +
8562
8568
  " </div>\n" +
8563
8569
  " </div>\n" +
@@ -8578,7 +8584,7 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
8578
8584
  " <nice-popup trigger=\"manual\" is-open=\"isOpen\" placement=\"{{ placement }}\" same-width=\"true\">\n" +
8579
8585
  " <nice-popup-target>\n" +
8580
8586
  " <div class=\"nice-search-button input-group\" ng-class=\"{ 'disabled': isDisabled }\">\n" +
8581
- " <input class=\"form-control\" type=\"text\" id=\"{{ id }}\" ng-model=\"model\" placeholder=\"{{ placeholder }}\" ng-disabled=\"isDisabled\" ng-change=\"updateSearch()\" ng-focus=\"onFocus()\" ng-required=\"required\" tabindex=\"{{ tabIndex }}\">\n" +
8587
+ " <input class=\"form-control\" type=\"text\" id=\"{{ id }}\" ng-model=\"modelAccessor\" ng-model-options=\"{ getterSetter: true }\" placeholder=\"{{ placeholder }}\" ng-disabled=\"isDisabled\" ng-change=\"updateSearch()\" ng-focus=\"onFocus()\" ng-required=\"required\" tabindex=\"{{ tabIndex }}\">\n" +
8582
8588
  "\n" +
8583
8589
  " <button type=\"button\" class=\"btn input-group-addon\" ng-disabled=\"isDisabled\" ng-click=\"buttonClicked()\">\n" +
8584
8590
  " <nice-icon ng-show=\"!loading && model != ''\" icon=\"icon-x\"></nice-icon>\n" +