nice-elements 1.12.4 → 1.12.6

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,17 @@
1
1
  # Changelog
2
2
 
3
+ ## v1.12.6 (15.7.2025)
4
+
5
+ - added validations to nice date input,
6
+ - added help to checkbox,
7
+ - added description prop to nice checkbox,
8
+ - added transclude to nice checkbox
9
+
10
+ ## v1.12.5 (11.6.2025)
11
+
12
+ - fixed nice date wrong start of week day
13
+ - added description to nice title
14
+
3
15
  ## v1.12.4 (15.5.2025)
4
16
 
5
17
  - added icon-x-o and icon-check-o,
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.4
3
+ # Nice elements v1.12.6
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.12.4",
3
+ "version": "1.12.6",
4
4
  "authors": [
5
5
  "Klemen Kastelic <klemen@olaii.com>"
6
6
  ],
package/dist/nice.js CHANGED
@@ -457,14 +457,17 @@ angular.module('niceElements')
457
457
  return {
458
458
  templateUrl: 'src/components/nice-checkbox/nice-checkbox.html',
459
459
  restrict: 'E',
460
+ transclude: true,
460
461
  scope: {
461
462
  model: '=',
462
463
  niceTitle: '@',
464
+ niceDescription: '@',
463
465
  title: '@',
464
466
  titleOnLeft: '=',
465
467
  noMargin: '@',
466
468
  clickDisabled: '@',
467
469
  onChange: '&?',
470
+ help: '@',
468
471
  isDisabled: '=',
469
472
  },
470
473
  controller: function ($scope) {
@@ -887,8 +890,8 @@ angular.module('niceElements')
887
890
  model: '=', // binding model
888
891
  date: '=?', // default: true, is date picker enabled?
889
892
  time: '=?', // default: false, is time picker enabled?
890
- minDate: '@', // default: undefined
891
- maxDate: '@', // default: undefined
893
+ minDate: '=', // default: undefined
894
+ maxDate: '=', // default: undefined
892
895
  niceTitle: '@',
893
896
  title: '@', // default: ''
894
897
  noMargin: '@', // default: false, if noMargin==true then entire directive can be injected inside other divs
@@ -903,9 +906,10 @@ angular.module('niceElements')
903
906
  placeholderDate: '@',
904
907
  placeholderTime: '@',
905
908
  },
906
- controller: function ($scope, $timeout, gettextCatalog) {
909
+ controller: function ($scope, $element, $timeout, gettextCatalog) {
907
910
  $scope.formatDate = "DD.MM.YYYY";
908
911
  $scope.formatTime = "HH:mm";
912
+ $scope.error = '';
909
913
  if ($scope.date === undefined) $scope.date = true;
910
914
  if ($scope.time === undefined) $scope.time = true;
911
915
  if (!$scope.placeholderDate) { $scope.placeholderDate = gettextCatalog.getString("••.••.••••", null, "Nice"); }
@@ -916,6 +920,12 @@ angular.module('niceElements')
916
920
  dateModel: angular.copy($scope.model || moment()),
917
921
  };
918
922
 
923
+ $scope.dateInput = null;
924
+ const timeInput = $element[0].getElementsByClassName("nice-time-input-field");
925
+ const dateInput = $element[0].getElementsByClassName("nice-date-input-field");
926
+ if (timeInput && timeInput[0]) $scope.dateInput = timeInput[0];
927
+ if (dateInput && dateInput[0]) $scope.dateInput = dateInput[0];
928
+
919
929
  $scope.dateChanged = function () {
920
930
  $timeout(function () {
921
931
  $scope.modelDate = $scope.inner.dateModel.format($scope.formatDate);
@@ -935,12 +945,25 @@ angular.module('niceElements')
935
945
  if (!$scope.date) $scope.modelDate = moment().format($scope.formatDate);
936
946
  const newModel = moment($scope.modelDate + " " + $scope.modelTime, $scope.formatDate + " " + $scope.formatTime).seconds(0).milliseconds(0);
937
947
  if (newModel.isValid()) {
938
- $scope.model = newModel;
939
- $scope.niceDateInputForm.$setValidity('validDate', true);
948
+ if ($scope.minDate && newModel.isBefore($scope.minDate)) {
949
+ // $scope.model = null;
950
+ $scope.niceDateInputForm.$setValidity('valid-date', false);
951
+ $scope.error = gettextCatalog.getString("Minimum date is {{date}}", { date: $scope.format($scope.minDate) }, "Nice");
952
+ } else if ($scope.maxDate && newModel.isAfter($scope.maxDate)) {
953
+ // $scope.model = null;
954
+ $scope.error = gettextCatalog.getString("Maximum date is {{date}}", { date: $scope.format($scope.maxDate) }, "Nice");
955
+ $scope.niceDateInputForm.$setValidity('valid-date', false);
956
+ } else {
957
+ $scope.model = newModel;
958
+ $scope.error = '';
959
+ $scope.niceDateInputForm.$setValidity('valid-date', null);
960
+ }
940
961
  } else {
941
- $scope.model = null;
942
- $scope.niceDateInputForm.$setValidity('validDate', false);
962
+ // $scope.model = null;
963
+ $scope.error = gettextCatalog.getString("Date is not valid", null, "Nice");
964
+ $scope.niceDateInputForm.$setValidity('valid-date', false);
943
965
  }
966
+ if ($scope.dateInput) $scope.dateInput.setCustomValidity($scope.error);
944
967
  if ($scope.onChange) $scope.onChange({ model: $scope.model });
945
968
  $scope.niceDateInputForm.$setDirty();
946
969
  };
@@ -948,6 +971,8 @@ angular.module('niceElements')
948
971
  // -------------------- Clear --------------------
949
972
  $scope.clear = function () {
950
973
  $scope.model = null;
974
+ $scope.error = '';
975
+ if ($scope.dateInput) $scope.dateInput.setCustomValidity($scope.error);
951
976
  if ($scope.onChange) $scope.onChange({ model: $scope.model });
952
977
  $scope.niceDateInputForm.$setDirty();
953
978
  };
@@ -964,26 +989,19 @@ angular.module('niceElements')
964
989
  };
965
990
  $scope.formatModel();
966
991
 
992
+ // -------------------- Format date --------------------
993
+ $scope.format = function (date) {
994
+ return moment(date).format($scope.formatDate + ($scope.time ? (" • " + $scope.formatTime) : ""));
995
+ };
996
+
967
997
  // -------------------- Date --------------------
968
998
  $scope.dateBlur = function () {
969
- const newDate = moment($scope.modelDate, $scope.formatDate);
970
- if (newDate.isValid()) {
971
- $scope.niceDateInputForm.$setValidity('validDate', true);
972
- $scope.handleChange();
973
- } else {
974
- $scope.niceDateInputForm.$setValidity('validDate', false);
975
- }
999
+ $scope.handleChange();
976
1000
  };
977
1001
 
978
1002
  // -------------------- Time --------------------
979
1003
  $scope.timeBlur = function () {
980
- const newTime = moment($scope.modelTime, $scope.formatTime);
981
- if (newTime.isValid()) {
982
- $scope.niceDateInputForm.$setValidity('validDate', true);
983
- $scope.handleChange();
984
- } else {
985
- $scope.niceDateInputForm.$setValidity('validDate', false);
986
- }
1004
+ $scope.handleChange();
987
1005
  };
988
1006
 
989
1007
  // -------------------- Watch model --------------------
@@ -1167,7 +1185,7 @@ angular.module('niceElements')
1167
1185
  { value: 9, name: gettextCatalog.getString("October", null, "Nice") },
1168
1186
  { value: 10, name: gettextCatalog.getString("November", null, "Nice") },
1169
1187
  { value: 11, name: gettextCatalog.getString("December", null, "Nice") }
1170
- ]
1188
+ ];
1171
1189
 
1172
1190
  if ($scope.maxDate) $scope.maxDate = moment($scope.maxDate);
1173
1191
  if ($scope.minDate) $scope.minDate = moment($scope.minDate);
@@ -1338,7 +1356,7 @@ angular.module('niceElements')
1338
1356
  // ------------------ Build month ------------------
1339
1357
  $scope._buildMonth = function () {
1340
1358
  let done = false;
1341
- const date = angular.copy($scope.innerDate.date).startOf("month").startOf('week');
1359
+ const date = angular.copy($scope.innerDate.date).startOf("month").startOf('week').isoWeekday(1);
1342
1360
  let monthIndex = date.month();
1343
1361
  let count = 0;
1344
1362
 
@@ -3852,6 +3870,7 @@ angular.module('niceElements')
3852
3870
  isDisabled: '=',
3853
3871
  type: '@',
3854
3872
  title: '@?',
3873
+ description: '@?',
3855
3874
  niceTitle: '@?',
3856
3875
  regex: '@?',
3857
3876
  regexRaw: '@?',
@@ -5587,6 +5606,7 @@ angular.module('niceElements')
5587
5606
  scope: {
5588
5607
  labelWidth: '=?',
5589
5608
  text: '=?',
5609
+ description: '=?',
5590
5610
  required: '=?',
5591
5611
  help: '=?'
5592
5612
  }
@@ -5667,6 +5687,7 @@ angular.module('niceElements')
5667
5687
  model: '=',
5668
5688
  niceTitle: '@',
5669
5689
  title: '@',
5690
+ description: '@?',
5670
5691
  isDisabled: '=',
5671
5692
  fieldWidth: '@',
5672
5693
  labelWidth: '@',
@@ -6258,7 +6279,7 @@ angular.module('niceElements')
6258
6279
  .service('NiceService', function ($rootScope) {
6259
6280
  const service = {
6260
6281
  name: "Nice elements",
6261
- version: "1.12.3",
6282
+ version: "1.12.5",
6262
6283
  getHeader: function () {
6263
6284
  return {};
6264
6285
  },
@@ -6474,7 +6495,11 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
6474
6495
  " <button type=\"button\" class=\"btn nice-checkbox-checkbox\" ng-disabled=\"isDisabled\">\n" +
6475
6496
  " <nice-icon class=\"nice-checkbox-check\" icon=\"icon-check\"></nice-icon>\n" +
6476
6497
  " </button>\n" +
6477
- " <div ng-if=\"title || niceTitle\" class=\"nice-checkbox-message\" ng-class=\"{ 'nice-disabled': isDisabled }\">{{ title || niceTitle }}</div>\n" +
6498
+ " <div class=\"nice-checkbox-info\" ng-transclude>\n" +
6499
+ " <nice-title text=\"title || niceTitle\" help=\"help\" required=\"required\" description=\"niceDescription\" label-width=\"col-xs-12\"></nice-title>\n" +
6500
+ " \n" +
6501
+ " \n" +
6502
+ " </div>\n" +
6478
6503
  "</div>"
6479
6504
  );
6480
6505
 
@@ -6518,56 +6543,63 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
6518
6543
 
6519
6544
 
6520
6545
  $templateCache.put('src/components/nice-date-input/nice-date-input.html',
6521
- "<div class=\"nice-component nice-date-input\" ng-form=\"niceDateInputForm\" ng-class=\"{ 'margin-bottom-0': noMargin, 'nice-component-inline': isInline, 'error': niceDateInputForm.$invalid, 'nice-date-input-no-date': !date }\">\n" +
6546
+ "<ng-form class=\"nice-component nice-date-input\" name=\"niceDateInputForm\" ng-class=\"{ 'margin-bottom-0': noMargin, 'nice-component-inline': isInline, 'error': niceDateInputForm.$invalid, 'nice-date-input-no-date': !date }\">\n" +
6522
6547
  " <div class=\"row\">\n" +
6523
6548
  " \n" +
6524
6549
  " <nice-title text=\"title || niceTitle\" help=\"help\" required=\"required\" label-width=\"labelWidth\"></nice-title>\n" +
6525
6550
  "\n" +
6526
6551
  " \n" +
6527
6552
  " <div class=\"nice-field col-xs-12\" ng-class=\"[fieldWidth ? fieldWidth : 'col-sm-8', { 'nice-disabled': isDisabled }]\">\n" +
6528
- " <div class=\"input-group nice-date-input\" ng-show=\"date\" ng-class=\"{ 'has-warning': !disabled && niceDateInputForm.$invalid && niceDateInputForm.$dirty }\">\n" +
6529
- " <input type=\"text\" class=\"form-control\" ng-model=\"modelDate\" placeholder=\"{{ placeholderDate }}\" ng-blur=\"dateBlur($event)\" ng-disabled=\"isDisabled\">\n" +
6530
- " <nice-popup placement=\"bottom\">\n" +
6531
- " <nice-popup-target>\n" +
6532
- " <span class=\"input-group-btns input-group-btn\">\n" +
6533
- " <button type=\"button\" class=\"btn btn-default btn-right\" ng-if=\"model && nullable\" tabindex=\"-1\" ng-disabled=\"isDisabled\" ng-click=\"clear()\">\n" +
6534
- " <nice-icon icon=\"icon-x\"></nice-icon>\n" +
6535
- " </button>\n" +
6553
+ " <div class=\"nice-date-field\">\n" +
6554
+ " <div class=\"input-group nice-date-input\" ng-show=\"date\" ng-class=\"{ 'has-warning': !disabled && niceDateInputForm.$invalid && niceDateInputForm.$dirty }\">\n" +
6555
+ " <input type=\"text\" class=\"form-control nice-date-input-field\" ng-model=\"modelDate\" placeholder=\"{{ placeholderDate }}\" ng-blur=\"dateBlur($event)\" ng-required=\"required\" ng-disabled=\"isDisabled\">\n" +
6556
+ " <nice-popup placement=\"bottom\">\n" +
6557
+ " <nice-popup-target>\n" +
6558
+ " <span class=\"input-group-btns input-group-btn\">\n" +
6559
+ " <button type=\"button\" class=\"btn btn-default btn-right\" ng-if=\"model && nullable\" tabindex=\"-1\" ng-disabled=\"isDisabled\" ng-click=\"clear()\">\n" +
6560
+ " <nice-icon icon=\"icon-x\"></nice-icon>\n" +
6561
+ " </button>\n" +
6562
+ "\n" +
6563
+ " <button type=\"button\" class=\"btn btn-default btn-right\" tabindex=\"-1\" ng-disabled=\"isDisabled\">\n" +
6564
+ " <nice-icon icon=\"icon-calendar\"></nice-icon>\n" +
6565
+ " </button>\n" +
6566
+ " </span>\n" +
6567
+ " </nice-popup-target>\n" +
6536
6568
  "\n" +
6537
- " <button type=\"button\" class=\"btn btn-default btn-right\" tabindex=\"-1\" ng-disabled=\"isDisabled\">\n" +
6538
- " <nice-icon icon=\"icon-calendar\"></nice-icon>\n" +
6539
- " </button>\n" +
6540
- " </span>\n" +
6541
- " </nice-popup-target>\n" +
6569
+ " <nice-popup-content>\n" +
6570
+ " <nice-date is-inline=\"true\" inline=\"true\" model=\"inner.dateModel\" on-change=\"dateChanged()\" no-margin=\"true\" min-date=\"minDate\" max-date=\"maxDate\" is-disabled=\"isDisabled\"></nice-date>\n" +
6571
+ " </nice-popup-content>\n" +
6572
+ " </nice-popup>\n" +
6573
+ " </div>\n" +
6542
6574
  "\n" +
6543
- " <nice-popup-content>\n" +
6544
- " <nice-date is-inline=\"true\" inline=\"true\" model=\"inner.dateModel\" on-change=\"dateChanged()\" no-margin=\"true\" is-disabled=\"isDisabled\"></nice-date>\n" +
6545
- " </nice-popup-content>\n" +
6546
- " </nice-popup>\n" +
6547
- " </div>\n" +
6548
- " <div class=\"input-group nice-time-input\" ng-show=\"time\" ng-class=\"{ 'has-warning': !disabled && niceDateInputForm.$invalid && niceDateInputForm.$dirty }\">\n" +
6549
- " <input type=\"text\" class=\"form-control\" ng-model=\"modelTime\" placeholder=\"{{ placeholderTime }}\" ng-blur=\"timeBlur($event)\" ng-disabled=\"isDisabled\">\n" +
6550
- " <nice-popup placement=\"bottom\">\n" +
6551
- " <nice-popup-target>\n" +
6552
- " <span class=\"input-group-btns input-group-btn\">\n" +
6553
- " <button type=\"button\" class=\"btn btn-default btn-right\" ng-if=\"model && nullable && !date\" tabindex=\"-1\" ng-disabled=\"isDisabled\" ng-click=\"clear()\">\n" +
6554
- " <nice-icon icon=\"icon-x\"></nice-icon>\n" +
6555
- " </button>\n" +
6575
+ " <div class=\"input-group nice-time-input\" ng-show=\"time\" ng-class=\"{ 'has-warning': !disabled && niceDateInputForm.$invalid && niceDateInputForm.$dirty }\">\n" +
6576
+ " <input type=\"text\" class=\"form-control nice-time-input-field\" ng-model=\"modelTime\" placeholder=\"{{ placeholderTime }}\" ng-blur=\"timeBlur($event)\" ng-required=\"required\" ng-disabled=\"isDisabled\">\n" +
6577
+ " <nice-popup placement=\"bottom\">\n" +
6578
+ " <nice-popup-target>\n" +
6579
+ " <span class=\"input-group-btns input-group-btn\">\n" +
6580
+ " <button type=\"button\" class=\"btn btn-default btn-right\" ng-if=\"model && nullable && !date\" tabindex=\"-1\" ng-disabled=\"isDisabled\" ng-click=\"clear()\">\n" +
6581
+ " <nice-icon icon=\"icon-x\"></nice-icon>\n" +
6582
+ " </button>\n" +
6583
+ "\n" +
6584
+ " <button type=\"button\" class=\"btn btn-default btn-right\" tabindex=\"-1\" ng-disabled=\"isDisabled\">\n" +
6585
+ " <nice-icon icon=\"icon-clock\"></nice-icon>\n" +
6586
+ " </button>\n" +
6587
+ " </span>\n" +
6588
+ " </nice-popup-target>\n" +
6556
6589
  "\n" +
6557
- " <button type=\"button\" class=\"btn btn-default btn-right\" tabindex=\"-1\" ng-disabled=\"isDisabled\">\n" +
6558
- " <nice-icon icon=\"icon-clock\"></nice-icon>\n" +
6559
- " </button>\n" +
6560
- " </span>\n" +
6561
- " </nice-popup-target>\n" +
6590
+ " <nice-popup-content>\n" +
6591
+ " <nice-date is-inline=\"true\" inline=\"true\" model=\"inner.timeModel\" on-change=\"timeChanged()\" time=\"true\" date=\"false\" no-margin=\"true\" is-disabled=\"isDisabled\"></nice-date>\n" +
6592
+ " </nice-popup-content>\n" +
6593
+ " </nice-popup>\n" +
6594
+ " </div>\n" +
6595
+ " </div>\n" +
6562
6596
  "\n" +
6563
- " <nice-popup-content>\n" +
6564
- " <nice-date is-inline=\"true\" inline=\"true\" model=\"inner.timeModel\" on-change=\"timeChanged()\" time=\"true\" date=\"false\" no-margin=\"true\" is-disabled=\"isDisabled\"></nice-date>\n" +
6565
- " </nice-popup-content>\n" +
6566
- " </nice-popup>\n" +
6597
+ " <div class=\"error-message\" ng-if=\"error\">\n" +
6598
+ " <div class=\"error-message\">{{ error }}</div>\n" +
6567
6599
  " </div>\n" +
6568
6600
  " </div>\n" +
6569
6601
  " </div>\n" +
6570
- "</div>"
6602
+ "</ng-form>"
6571
6603
  );
6572
6604
 
6573
6605
 
@@ -7089,7 +7121,7 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
7089
7121
  "<ng-form class=\"nice-component nice-input\" ng-class=\"{ 'margin-bottom-0' : noMargin, 'nice-component-inline': isInline }\" name=\"forma\">\n" +
7090
7122
  " <div class=\"row\">\n" +
7091
7123
  " \n" +
7092
- " <nice-title text=\"title || niceTitle\" help=\"help\" required=\"required\" label-width=\"labelWidth\"></nice-title>\n" +
7124
+ " <nice-title text=\"title || niceTitle\" help=\"help\" required=\"required\" description=\"description\" label-width=\"labelWidth\"></nice-title>\n" +
7093
7125
  "\n" +
7094
7126
  " \n" +
7095
7127
  " <div class=\"nice-field col-xs-12\" ng-class=\"fieldWidth ? fieldWidth : 'col-sm-8'\">\n" +
@@ -8797,7 +8829,10 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
8797
8829
 
8798
8830
  $templateCache.put('src/components/nice-title/nice-title.html',
8799
8831
  "<div class=\"nice-title col-xs-12\" ng-class=\"[labelWidth ? labelWidth : 'col-sm-4', {'nice-title-empty': !text && !help} ]\" ng-if=\"text\">\n" +
8800
- " <div class=\"nice-title-text\">{{ text }}<span class=\"nice-title-required\" ng-if=\"required\">*</span></div>\n" +
8832
+ " <div class=\"nice-title-inner\">\n" +
8833
+ " <div class=\"nice-title-text\">{{ text }}<span class=\"nice-title-required\" ng-if=\"required\">*</span></div>\n" +
8834
+ " <div class=\"nice-title-description\" ng-if=\"description\">{{ description }}</div>\n" +
8835
+ " </div>\n" +
8801
8836
  " <nice-help class=\"nice-title-help\" ng-if=\"help\" text=\"{{ help }}\"></nice-help>\n" +
8802
8837
  "</div>"
8803
8838
  );
@@ -8814,7 +8849,7 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
8814
8849
  "<div class=\"nice-component nice-toggle\" ng-class=\"{ 'margin-bottom-0': noMargin, 'title-right': titleRight, 'nice-component-inline': isInline, 'nice-component-block': isBlock, 'active': inverted ? !model : model }\" ng-form=\"formToggle\">\n" +
8815
8850
  " <div class=\"row\">\n" +
8816
8851
  " \n" +
8817
- " <nice-title text=\"title || niceTitle\" help=\"help\" required=\"required\" label-width=\"labelWidth\"></nice-title>\n" +
8852
+ " <nice-title text=\"title || niceTitle\" help=\"help\" required=\"required\" description=\"description\" label-width=\"labelWidth\"></nice-title>\n" +
8818
8853
  "\n" +
8819
8854
  " \n" +
8820
8855
  " <div class=\"nice-field col-xs-12\" ng-class=\"[fieldWidth ? fieldWidth : 'col-sm-8', { 'nice-disabled': isDisabled }]\">\n" +