nice-elements 1.13.0 → 1.13.2

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,18 @@
1
1
  # Changelog
2
2
 
3
+ ## v1.13.2 (3.4.2026)
4
+
5
+ - added clear button to nice upload,
6
+ - fixed nice upload no files error
7
+
8
+ ## v1.13.1 (30.3.2026)
9
+
10
+ - added transclude to nice upload,
11
+ - worked on nice choice no item error,
12
+ - worked on nice upload example,
13
+ - worked on nice highlight,
14
+ - worked on nice dropdown nullable prop
15
+
3
16
  ## v1.13.0 (20.1.2026)
4
17
 
5
18
  - created nice options component
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.13.0
3
+ # Nice elements v1.13.2
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.13.0",
3
+ "version": "1.13.2",
4
4
  "authors": [
5
5
  "Klemen Kastelic <klemen@olaii.com>"
6
6
  ],
package/dist/nice.js CHANGED
@@ -701,6 +701,7 @@ angular.module('niceElements')
701
701
  }
702
702
 
703
703
  const getFilter = function (item) {
704
+ if (!item) return;
704
705
  // Create filter for finding object by objValue with _.where()
705
706
  const filter = {};
706
707
  if (item.hasOwnProperty($scope.objKey))
@@ -2478,7 +2479,7 @@ angular.module('niceElements')
2478
2479
  objValue: '@', // Optional - default is 'value'
2479
2480
  objKey: '@?', // Optional - default is 'id'. Used only when returnOnlyKey=true.
2480
2481
  selectedIsKey: '@?',
2481
- nullable: '@', // No selection is possible
2482
+ nullable: '=', // No selection is possible
2482
2483
  required: '=', // Model cannot be NULL
2483
2484
  noMargin: '@', // margin-bottom: 0px
2484
2485
  multiple: '@', // Can select multiple items
@@ -2511,7 +2512,6 @@ angular.module('niceElements')
2511
2512
  if (!$scope.selectedText) { $scope.selectedText = gettextCatalog.getString("selected", null, "Nice"); }
2512
2513
  if (!$scope.addButtonFunction) { $scope.addButtonFunction = null; }
2513
2514
  if (!$scope.placement) { $scope.placement = "bottom-start"; }
2514
- $scope.nullable = $scope.nullable === 'true' || $scope.nullable === true;
2515
2515
  $scope.noMargin = $scope.noMargin === 'true' || $scope.noMargin === true;
2516
2516
  $scope.multiple = $scope.multiple === 'true' || $scope.multiple === true;
2517
2517
  $scope.clearOnSelect = $scope.clearOnSelect === 'true' || $scope.clearOnSelect === true;
@@ -5846,6 +5846,7 @@ angular.module('niceElements')
5846
5846
  callbackUrl: '=',
5847
5847
  isDisabled: '=',
5848
5848
  isInline: '=',
5849
+ hideClear: '=',
5849
5850
  help: '@',
5850
5851
  maxFileSize: '@',
5851
5852
  required: '=',
@@ -5896,73 +5897,71 @@ angular.module('niceElements')
5896
5897
  }
5897
5898
 
5898
5899
  $timeout(function () {
5899
- scope.loading = true;
5900
- scope.error = null;
5901
5900
  const inputObj = changeEvent.target;
5902
5901
  const reader = new FileReader();
5902
+ if (!inputObj.files || !inputObj.files[0]) return;
5903
+ scope.loading = true;
5904
+ scope.error = null;
5903
5905
 
5904
- if (inputObj.files) {
5905
- try {
5906
- const fileSize = inputObj.files[0].size; // in bytes
5906
+ try {
5907
+ const fileSize = inputObj.files[0].size; // in bytes
5907
5908
 
5908
- reader.onload = function (event) {
5909
- $timeout(function () {
5910
- // file size must be smaller than XMB.
5911
- if (fileSize > (scope.maxFileSize * 1000000)) {
5912
- scope.error = gettextCatalog.getString("File must be smaller than {{size}}MB", { size: scope.maxFileSize }, "Nice");
5913
- scope.loading = false;
5914
- scope.imageSource = null;
5915
- return;
5916
- }
5909
+ reader.onload = function (event) {
5910
+ $timeout(function () {
5911
+ // file size must be smaller than XMB.
5912
+ if (fileSize > (scope.maxFileSize * 1000000)) {
5913
+ scope.error = gettextCatalog.getString("File must be smaller than {{size}}MB", { size: scope.maxFileSize }, "Nice");
5914
+ scope.loading = false;
5915
+ scope.imageSource = null;
5916
+ return;
5917
+ }
5917
5918
 
5918
- if (scope.callbackFunction != undefined) {
5919
- scope.loading = false;
5920
- scope.imageSource = null;
5921
- scope.callbackFunction(event.target.result);
5922
- scope.text = inputObj.files[0].name;
5923
- scope.form.$setDirty();
5924
- }
5919
+ if (scope.callbackFunction != undefined) {
5920
+ scope.loading = false;
5921
+ scope.imageSource = null;
5922
+ scope.callbackFunction(event.target.result);
5923
+ scope.text = inputObj.files[0].name;
5924
+ scope.form.$setDirty();
5925
+ }
5926
+
5927
+ if (scope.callbackFile != undefined) {
5928
+ scope.loading = false;
5929
+ scope.text = inputObj.files[0].name;
5930
+ scope.callbackFile(inputObj.files[0]);
5931
+ scope.form.$setDirty();
5932
+ }
5925
5933
 
5926
- if (scope.callbackFile != undefined) {
5934
+ if (scope.uploadFunction != undefined) {
5935
+ scope.uploadFunction(inputObj.files[0]).then(function (response) {
5927
5936
  scope.loading = false;
5928
- scope.text = inputObj.files[0].name;
5929
- scope.callbackFile(inputObj.files[0]);
5937
+ scope.imageSource = event.target.result;
5938
+ if (response.data && response.data.url) scope.model = response.data.url;
5939
+ if (response.file) scope.model = response.data.url;
5930
5940
  scope.form.$setDirty();
5941
+ }, function (error) {
5942
+ // Handle upload function error
5943
+ scope.error = error;
5944
+ scope.loading = false;
5945
+ scope.imageSource = null;
5946
+ });
5947
+ } else {
5948
+ // console.error("No upload function set!");
5949
+ if (event.target.result.substring(0, 10) == "data:image") {
5950
+ scope.imageSource = event.target.result;
5931
5951
  }
5952
+ }
5953
+ });
5954
+ };
5932
5955
 
5933
- if (scope.uploadFunction != undefined) {
5934
- scope.uploadFunction(inputObj.files[0]).then(function (response) {
5935
- scope.loading = false;
5936
- scope.imageSource = event.target.result;
5937
- if (response.data && response.data.url) scope.model = response.data.url;
5938
- if (response.file) scope.model = response.data.url;
5939
- scope.form.$setDirty();
5940
- }, function (error) {
5941
- // Handle upload function error
5942
- scope.error = error;
5943
- scope.loading = false;
5944
- scope.imageSource = null;
5945
- });
5946
- } else {
5947
- // console.error("No upload function set!");
5948
- if (event.target.result.substring(0, 10) == "data:image") {
5949
- scope.imageSource = event.target.result;
5950
- }
5951
- }
5952
- });
5953
- };
5954
-
5955
- } catch (err) {
5956
- // Handle try catch
5957
- scope.error = gettextCatalog.getString("Something went wrong", null, "Nice");
5958
- scope.loading = false;
5959
- scope.imageSource = null;
5960
- }
5961
-
5962
- // when the file is read it triggers the onload event above.
5963
- reader.readAsDataURL(inputObj.files[0]);
5964
-
5956
+ } catch (err) {
5957
+ // Handle try catch
5958
+ scope.error = gettextCatalog.getString("Something went wrong", null, "Nice");
5959
+ scope.loading = false;
5960
+ scope.imageSource = null;
5965
5961
  }
5962
+
5963
+ // when the file is read it triggers the onload event above.
5964
+ reader.readAsDataURL(inputObj.files[0]);
5966
5965
  });
5967
5966
 
5968
5967
  });
@@ -5972,6 +5971,16 @@ angular.module('niceElements')
5972
5971
  $scope.$watch("model", function (value) {
5973
5972
  $scope.imageSource = angular.copy($scope.model);
5974
5973
  });
5974
+
5975
+ $scope.clear = function () {
5976
+ $scope.model = null;
5977
+ $scope.imageSource = null;
5978
+ $scope.form.$setDirty();
5979
+ $scope.text = gettextCatalog.getString('Click to upload file', null, 'Nice');
5980
+ if ($scope.callbackFunction) $scope.callbackFunction(null);
5981
+ if ($scope.callbackFile) $scope.callbackFile(null);
5982
+ if ($scope.callbackUrl) $scope.callbackUrl(null);
5983
+ };
5975
5984
  }
5976
5985
 
5977
5986
  };
@@ -6263,13 +6272,32 @@ angular.module('niceElements').filter('niceDate', function () {
6263
6272
  */
6264
6273
  angular.module('niceElements').filter('niceHighlight', function () {
6265
6274
  return function (value, highlightedText) {
6266
- if (!value) return "";
6275
+ if (!value || !highlightedText) return "";
6267
6276
  const regex = new RegExp(highlightedText, 'gmi');
6268
- const newValue = String(value).replace(regex, "<span class='nice-highligh'>$&</span>");
6277
+ const newValue = String(value).replace(regex, "<span class='nice-highlight'>$&</span>");
6269
6278
  return newValue;
6270
6279
  };
6271
6280
  });
6272
6281
 
6282
+ angular.module('niceElements')
6283
+ .filter('h', function ($sce, $sanitize) {
6284
+ return function (text, phrase) {
6285
+ if (!phrase || !text) return text;
6286
+
6287
+ // 1. Sanitize the original text to prevent XSS
6288
+ let cleanText = $sanitize(text);
6289
+
6290
+ // 2. Create the case-insensitive global Regex
6291
+ const regex = new RegExp('(' + phrase + ')', 'gi');
6292
+
6293
+ // 3. Replace matches with the h element
6294
+ const highlighted = cleanText.replace(regex, '<h>$1</h>');
6295
+
6296
+ // 4. Trust the result so ng-bind-html renders it
6297
+ return $sce.trustAsHtml(highlighted);
6298
+ };
6299
+ });
6300
+
6273
6301
  'use strict';
6274
6302
 
6275
6303
  /**
@@ -6506,7 +6534,7 @@ angular.module('niceElements')
6506
6534
  .service('NiceService', function ($rootScope) {
6507
6535
  const service = {
6508
6536
  name: "Nice elements",
6509
- version: "1.13.0",
6537
+ version: "1.13.2",
6510
6538
  getHeader: function () {
6511
6539
  return {};
6512
6540
  },
@@ -9192,8 +9220,13 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
9192
9220
  " <div class=\"text text-placeholder\" ng-if=\"dragging\" translate translate-group=\"Nice\">Drop file here</div>\n" +
9193
9221
  " <div class=\"error\" ng-if=\"error\">{{ error }}</div>\n" +
9194
9222
  " </div>\n" +
9195
- " <img ng-if=\"imageSource\" data-ng-src=\"{{ imageSource }}\">\n" +
9223
+ " <div ng-if=\"imageSource\" ng-transclude>\n" +
9224
+ " <img data-ng-src=\"{{ imageSource }}\">\n" +
9225
+ " </div>\n" +
9196
9226
  " </div>\n" +
9227
+ " <button type=\"button\" ng-click=\"clear()\" ng-if=\"imageSource && !loading && !hideClear\" class=\"btn btn-primary nice-upload-clear-button\">\n" +
9228
+ " <nice-icon icon=\"icon-x\"></nice-icon>\n" +
9229
+ " </button>\n" +
9197
9230
  " <input class=\"input-file\" type=\"file\" accept=\"{{ accept }}\" ng-model=\"file\" ng-required=\"required\" ng-disabled=\"isDisabled || loading\">\n" +
9198
9231
  " <nice-loader fulldiv=\"true\" ng-if=\"loading\"></nice-loader>\n" +
9199
9232
  " </div>\n" +