nice-elements 1.12.12 → 1.13.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nice-elements",
3
- "version": "1.12.12",
3
+ "version": "1.13.1",
4
4
  "description": "Nice elements used in olaii angular 1.x webapps.",
5
5
  "main": "dist/nice.js",
6
6
  "license": "MIT",
@@ -93,6 +93,7 @@ angular.module('niceElements')
93
93
  }
94
94
 
95
95
  const getFilter = function (item) {
96
+ if (!item) return;
96
97
  // Create filter for finding object by objValue with _.where()
97
98
  const filter = {};
98
99
  if (item.hasOwnProperty($scope.objKey))
@@ -33,7 +33,7 @@ angular.module('niceElements')
33
33
  objValue: '@', // Optional - default is 'value'
34
34
  objKey: '@?', // Optional - default is 'id'. Used only when returnOnlyKey=true.
35
35
  selectedIsKey: '@?',
36
- nullable: '@', // No selection is possible
36
+ nullable: '=', // No selection is possible
37
37
  required: '=', // Model cannot be NULL
38
38
  noMargin: '@', // margin-bottom: 0px
39
39
  multiple: '@', // Can select multiple items
@@ -66,7 +66,6 @@ angular.module('niceElements')
66
66
  if (!$scope.selectedText) { $scope.selectedText = gettextCatalog.getString("selected", null, "Nice"); }
67
67
  if (!$scope.addButtonFunction) { $scope.addButtonFunction = null; }
68
68
  if (!$scope.placement) { $scope.placement = "bottom-start"; }
69
- $scope.nullable = $scope.nullable === 'true' || $scope.nullable === true;
70
69
  $scope.noMargin = $scope.noMargin === 'true' || $scope.noMargin === true;
71
70
  $scope.multiple = $scope.multiple === 'true' || $scope.multiple === true;
72
71
  $scope.clearOnSelect = $scope.clearOnSelect === 'true' || $scope.clearOnSelect === true;
@@ -0,0 +1,25 @@
1
+ <div class="nice-component nice-options" ng-class="{ 'margin-bottom-0' : noMargin, 'nice-component-inline': isInline, 'nice-disabled': isDisabled }" ng-form="formNiceOptions">
2
+ <div class="row">
3
+ <!------------------------- Title ------------------------->
4
+ <nice-title text="title || niceTitle" help="help" required="required" label-width="labelWidth"></nice-title>
5
+
6
+ <!------------------------- Field ------------------------->
7
+ <div class="nice-field col-xs-12" ng-class="[fieldWidth ? fieldWidth : 'col-sm-8']">
8
+ <div class="nice-options-wrapper">
9
+ <button
10
+ ng-repeat="option in options"
11
+ type="button"
12
+ class="btn"
13
+ ng-click="selectOption(option)"
14
+ ng-disabled="isDisabled"
15
+ ng-class="{ 'btn-primary': isSelected(option), 'btn-default': !isSelected(option) }"
16
+ ng-transclude
17
+ >
18
+ <nice-icon class="nice-options-wrapper-icon" ng-if="option.icon" icon="{{ option.icon }}"></nice-icon>
19
+ <div class="nice-options-wrapper-title">{{ option.title }}</div>
20
+ <div class="nice-options-wrapper-description" ng-if="option.description">{{ option.description }}</div>
21
+ </button>
22
+ </div>
23
+ </div>
24
+ </div>
25
+ </div>
@@ -0,0 +1,68 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * @ngdoc directive
5
+ * @name niceElements.directive:niceOptions
6
+ * @description
7
+ * # niceOptions
8
+ */
9
+ angular.module('niceElements')
10
+ .directive('niceOptions', function () {
11
+ return {
12
+ templateUrl: 'src/components/nice-options/nice-options.html',
13
+ restrict: 'E',
14
+ transclude: true,
15
+ scope: {
16
+ model: '=',
17
+ niceTitle: '@',
18
+ isDisabled: '=',
19
+ fieldWidth: '@',
20
+ labelWidth: '@',
21
+ noMargin: '@',
22
+ onChange: '&?',
23
+ isInline: '=',
24
+ help: '@',
25
+ required: '=',
26
+ options: '=',
27
+ selectedIsKey: '=',
28
+ valueKey: "@"
29
+ },
30
+ controller: function ($scope, $timeout) {
31
+ if (!$scope.fieldWidth) $scope.fieldWidth = 'col-sm-8';
32
+ if (!$scope.labelWidth) $scope.labelWidth = 'col-sm-4';
33
+ if (!$scope.valueKey) $scope.valueKey = 'id';
34
+ $scope.noMargin = angular.isDefined($scope.noMargin);
35
+
36
+ // Check if selected
37
+ $scope.isSelected = function(option) {
38
+ if (!$scope.model) return false;
39
+ if ($scope.selectedIsKey) {
40
+ return $scope.model == option[$scope.valueKey];
41
+ } else {
42
+ return $scope.model[$scope.valueKey] == option[$scope.valueKey];
43
+ }
44
+ };
45
+
46
+ // Select option
47
+ $scope.selectOption = function(option) {
48
+ if ($scope.isSelected(option) && !$scope.required) {
49
+ $scope.model = null;
50
+ } else if ($scope.selectedIsKey) {
51
+ $scope.model = option[$scope.valueKey];
52
+ } else {
53
+ $scope.model = option;
54
+ }
55
+
56
+ $timeout(function () {
57
+ if ($scope.onChange) $scope.onChange({ model: $scope.model });
58
+ $scope.formNiceOptions.$setDirty();
59
+ });
60
+ };
61
+
62
+ // Select default
63
+ if (!$scope.model && $scope.options && $scope.required) {
64
+ $scope.selectOption($scope.options[0]);
65
+ }
66
+ }
67
+ };
68
+ });
@@ -0,0 +1,26 @@
1
+ .nice-options {
2
+ .nice-options-wrapper {
3
+ display: grid;
4
+ grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
5
+ gap: 3px;
6
+ padding: 3px;
7
+ border-radius: var(--nice-border-radius);
8
+ border: 1px solid var(--nice-border-color);
9
+
10
+ .btn {
11
+ display: flex;
12
+ flex-direction: column;
13
+ gap: 3px;
14
+
15
+ .nice-options-wrapper-icon {
16
+ height: 20px;
17
+ width: 20px;
18
+ }
19
+
20
+ .nice-options-wrapper-description {
21
+ font-style: italic;
22
+ font-size: 0.8em;
23
+ }
24
+ }
25
+ }
26
+ }
@@ -1206,6 +1206,13 @@
1206
1206
  <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" />
1207
1207
  </symbol>
1208
1208
 
1209
+ <symbol id="icon-options" viewBox="0 0 24 24">
1210
+ <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"/>
1211
+ <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"/>
1212
+ <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"/>
1213
+ <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"/>
1214
+ </symbol>
1215
+
1209
1216
  <symbol id="icon-seat" viewBox="0 0 370 370">
1210
1217
  <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>
1211
1218
  <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>
@@ -13,7 +13,9 @@
13
13
  <div class="text text-placeholder" ng-if="dragging" translate translate-group="Nice">Drop file here</div>
14
14
  <div class="error" ng-if="error">{{ error }}</div>
15
15
  </div>
16
- <img ng-if="imageSource" data-ng-src="{{ imageSource }}" />
16
+ <div ng-if="imageSource" ng-transclude>
17
+ <img data-ng-src="{{ imageSource }}" />
18
+ </div>
17
19
  </div>
18
20
  <input class="input-file" type="file" accept="{{ accept }}" ng-model="file" ng-required="required" ng-disabled="isDisabled || loading" />
19
21
  <nice-loader fulldiv="true" ng-if="loading"></nice-loader>
@@ -77,7 +77,7 @@
77
77
  }
78
78
  }
79
79
 
80
- img {
80
+ img, video {
81
81
  width: 100%;
82
82
  height: 100%;
83
83
  object-fit: contain;
@@ -17,11 +17,16 @@ angular.module('niceElements')
17
17
  return (el.scrollTop + el.clientHeight) >= (el.scrollHeight - tolerance);
18
18
  };
19
19
 
20
- // Scroll Event Listener
21
- element[0].addEventListener('scroll', () => {
20
+ function onScroll() {
22
21
  if (isScrolledToBottom(element[0]) && !scope.$eval(attrs.niceInfiniteLoaderDisabled)) {
23
22
  scope.$eval(attrs.niceInfiniteLoader);
24
23
  }
24
+ }
25
+
26
+ // Scroll Event Listener
27
+ element.on('scroll', onScroll);
28
+ scope.$on('$destroy', () => {
29
+ element.off('scroll', onScroll);
25
30
  });
26
31
  }
27
32
  };
@@ -8,9 +8,28 @@
8
8
  */
9
9
  angular.module('niceElements').filter('niceHighlight', function () {
10
10
  return function (value, highlightedText) {
11
- if (!value) return "";
11
+ if (!value || !highlightedText) return "";
12
12
  const regex = new RegExp(highlightedText, 'gmi');
13
- const newValue = String(value).replace(regex, "<span class='nice-highligh'>$&</span>");
13
+ const newValue = String(value).replace(regex, "<span class='nice-highlight'>$&</span>");
14
14
  return newValue;
15
15
  };
16
16
  });
17
+
18
+ angular.module('niceElements')
19
+ .filter('h', function ($sce, $sanitize) {
20
+ return function (text, phrase) {
21
+ if (!phrase || !text) return text;
22
+
23
+ // 1. Sanitize the original text to prevent XSS
24
+ let cleanText = $sanitize(text);
25
+
26
+ // 2. Create the case-insensitive global Regex
27
+ const regex = new RegExp('(' + phrase + ')', 'gi');
28
+
29
+ // 3. Replace matches with the h element
30
+ const highlighted = cleanText.replace(regex, '<h>$1</h>');
31
+
32
+ // 4. Trust the result so ng-bind-html renders it
33
+ return $sce.trustAsHtml(highlighted);
34
+ };
35
+ });
@@ -10,7 +10,7 @@ angular.module('niceElements')
10
10
  .service('NiceService', function ($rootScope) {
11
11
  const service = {
12
12
  name: "Nice elements",
13
- version: "1.12.12",
13
+ version: "1.13.1",
14
14
  getHeader: function () {
15
15
  return {};
16
16
  },
@@ -452,7 +452,7 @@ p.nice {
452
452
  }
453
453
  }
454
454
 
455
- .nice-highligh {
455
+ h, .nice-highlight {
456
456
  background: yellow;
457
457
  }
458
458
 
@@ -69,6 +69,7 @@
69
69
  @import "../components/nice-alert/nice-alert";
70
70
  @import "../components/nice-avatar/nice-avatar";
71
71
  @import "../components/nice-virtual-scroll/nice-virtual-scroll";
72
+ @import "../components/nice-options/nice-options";
72
73
 
73
74
  @import "../modals/nice-multilangual-modal/nice-multilangual-modal";
74
75