nice-elements 1.13.7 → 1.14.0
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 +22 -0
- package/README.md +1 -1
- package/bower.json +1 -1
- package/dist/nice.js +2760 -5123
- package/dist/nice.min.js +1 -1
- package/dist/style.css +413 -983
- package/dist/style.css.map +1 -59
- package/dist/style.min.css +2 -2
- package/package.json +6 -6
- package/src/components/nice-comment/nice-comment.js +11 -11
- package/src/components/nice-comment/nice-comment.scss +0 -2
- package/src/components/nice-date/nice-date.js +12 -2
- package/src/components/nice-datetimerange-picker-2/nice-datetimerange-picker-2.js +9 -2
- package/src/components/nice-dropdown/nice-dropdown.js +16 -15
- package/src/components/nice-help/nice-help.html +3 -4
- package/src/components/nice-help/nice-help.js +10 -37
- package/src/components/nice-help/nice-help.scss +59 -27
- package/src/components/nice-input/nice-input.html +11 -1
- package/src/components/nice-input/nice-input.js +38 -10
- package/src/components/nice-input/nice-input.scss +11 -0
- package/src/components/nice-notification/nice-notification.html +9 -4
- package/src/components/nice-notification/nice-notification.js +66 -46
- package/src/components/nice-notification/nice-notification.scss +97 -19
- package/src/components/nice-number/nice-number.html +35 -4
- package/src/components/nice-number/nice-number.js +40 -7
- package/src/components/nice-popup/nice-popup.js +10 -5
- package/src/components/nice-search2/nice-search2.js +15 -5
- package/src/components/nice-toggle/nice-toggle.html +18 -2
- package/src/components/nice-toggle/nice-toggle.js +4 -1
- package/src/components/nice-toggle/nice-toggle.scss +31 -0
- package/src/components/nice-view/_nice-view.scss +22 -0
- package/src/components/nice-virtual-scroll/nice-virtual-scroll.js +15 -3
- package/src/directives/nice-click-outside.js +24 -18
- package/src/directives/nice-tooltip/nice-tooltip.js +14 -4
- package/src/services/nice-service.js +14 -1
|
@@ -25,7 +25,8 @@ angular.module('niceElements')
|
|
|
25
25
|
|
|
26
26
|
// ------------------------- Prepare data -------------------------
|
|
27
27
|
$scope.prepareData = function() {
|
|
28
|
-
|
|
28
|
+
// data is often loaded asynchronously, so it can still be undefined/null here
|
|
29
|
+
$scope.items = Array.from($scope.data || [], (data, index) => ({
|
|
29
30
|
id: index + 1,
|
|
30
31
|
height: Number($scope.rowHeight), // Default placeholder height
|
|
31
32
|
offsetTop: index * Number($scope.rowHeight), // Approximate offset
|
|
@@ -39,6 +40,12 @@ angular.module('niceElements')
|
|
|
39
40
|
|
|
40
41
|
// ------------------------- On scroll -------------------------
|
|
41
42
|
$scope.onScroll = function() {
|
|
43
|
+
// Can run (e.g. from the ResizeObserver) before prepareData has built items
|
|
44
|
+
if (!$scope.items || $scope.items.length === 0) {
|
|
45
|
+
$scope.visibleItems = [];
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
42
49
|
const container = $element[0].getBoundingClientRect();
|
|
43
50
|
const scrollTop = $element[0].scrollTop;
|
|
44
51
|
const viewportHeight = container.height;
|
|
@@ -58,11 +65,16 @@ angular.module('niceElements')
|
|
|
58
65
|
});
|
|
59
66
|
|
|
60
67
|
// ------------------------- Watch for element resize -------------------------
|
|
61
|
-
new ResizeObserver(function() {
|
|
68
|
+
const resizeObserver = new ResizeObserver(function() {
|
|
62
69
|
$timeout(function() {
|
|
63
70
|
$scope.onScroll();
|
|
64
71
|
});
|
|
65
|
-
})
|
|
72
|
+
});
|
|
73
|
+
resizeObserver.observe($element[0]);
|
|
74
|
+
|
|
75
|
+
$scope.$on('$destroy', function () {
|
|
76
|
+
resizeObserver.disconnect();
|
|
77
|
+
});
|
|
66
78
|
|
|
67
79
|
// Initial render
|
|
68
80
|
$scope.prepareData();
|
|
@@ -18,12 +18,16 @@ angular.module('niceElements')
|
|
|
18
18
|
$scope.isOpen = value == 'true';
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
let eventHandler = null;
|
|
22
|
+
|
|
23
|
+
// Registered up front (not inside the timeout) so cleanup still happens
|
|
24
|
+
// when the element is destroyed before the listeners are attached.
|
|
25
|
+
const setupTimer = $timeout(function () {
|
|
22
26
|
// postpone linking to next digest to allow for unique id generation
|
|
23
27
|
const classList = (attr.outsideIfNot !== undefined) ? attr.outsideIfNot.split(/[ ,]+/) : [];
|
|
24
28
|
let fn;
|
|
25
29
|
|
|
26
|
-
function
|
|
30
|
+
eventHandler = function (e) {
|
|
27
31
|
if ($scope.isOpen) {
|
|
28
32
|
let i, element, r, id, classNames, l;
|
|
29
33
|
|
|
@@ -72,7 +76,7 @@ angular.module('niceElements')
|
|
|
72
76
|
fn($scope, { event: e });
|
|
73
77
|
});
|
|
74
78
|
}
|
|
75
|
-
}
|
|
79
|
+
};
|
|
76
80
|
|
|
77
81
|
|
|
78
82
|
// if the devices has a touchscreen, listen for this event
|
|
@@ -82,25 +86,27 @@ angular.module('niceElements')
|
|
|
82
86
|
|
|
83
87
|
// still listen for the click event even if there is touch to cater for touchscreen laptops
|
|
84
88
|
$document.on('click', eventHandler);
|
|
89
|
+
});
|
|
85
90
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
91
|
+
// when the scope is destroyed, clean up the documents event handlers as we don't want it hanging around
|
|
92
|
+
$scope.$on('$destroy', function () {
|
|
93
|
+
$timeout.cancel(setupTimer);
|
|
94
|
+
if (eventHandler) {
|
|
95
|
+
// off() is a no-op for events that were never bound, so no touch check needed
|
|
96
|
+
$document.off('touchstart', eventHandler);
|
|
92
97
|
$document.off('click', eventHandler);
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* @description Private function to attempt to figure out if we are on a touch device
|
|
97
|
-
* @private
|
|
98
|
-
**/
|
|
99
|
-
function _hasTouch() {
|
|
100
|
-
// works on most browsers, IE10/11 and Surface
|
|
101
|
-
return 'ontouchstart' in window || navigator.maxTouchPoints;
|
|
98
|
+
eventHandler = null;
|
|
102
99
|
}
|
|
103
100
|
});
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* @description Private function to attempt to figure out if we are on a touch device
|
|
104
|
+
* @private
|
|
105
|
+
**/
|
|
106
|
+
function _hasTouch() {
|
|
107
|
+
// works on most browsers, IE10/11 and Surface
|
|
108
|
+
return 'ontouchstart' in window || navigator.maxTouchPoints;
|
|
109
|
+
}
|
|
104
110
|
}
|
|
105
111
|
};
|
|
106
112
|
});
|
|
@@ -10,7 +10,7 @@ angular.module('niceElements')
|
|
|
10
10
|
.directive('niceTooltip', function () {
|
|
11
11
|
return {
|
|
12
12
|
restrict: 'A',
|
|
13
|
-
controller: function ($scope, $element, $attrs, $
|
|
13
|
+
controller: function ($scope, $element, $attrs, $injector) {
|
|
14
14
|
const id = Math.random().toString(36).substring(7);
|
|
15
15
|
const showEvents = ['mouseenter', 'focus'];
|
|
16
16
|
const hideEvents = ['mouseleave', 'blur'];
|
|
@@ -22,9 +22,19 @@ angular.module('niceElements')
|
|
|
22
22
|
tooltipWindow.className = 'nice-tooltip-window';
|
|
23
23
|
tooltipWindow.id = 'nice-tooltip-window-' + id;
|
|
24
24
|
|
|
25
|
-
// Popper body
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
// Popper body. The attribute's {{ }} is interpolated by Angular, but the
|
|
26
|
+
// resulting text is never compiled, so user data can't run as a template.
|
|
27
|
+
// Safe HTML is kept when the app loads ngSanitize; otherwise it's plain text.
|
|
28
|
+
const content = document.createElement('div');
|
|
29
|
+
content.className = 'nice-tooltip-body';
|
|
30
|
+
tooltipWindow.append(content);
|
|
31
|
+
|
|
32
|
+
const $sanitize = $injector.has('$sanitize') ? $injector.get('$sanitize') : null;
|
|
33
|
+
$attrs.$observe('niceTooltip', function (value) {
|
|
34
|
+
value = value == null ? '' : String(value);
|
|
35
|
+
if ($sanitize) content.innerHTML = $sanitize(value);
|
|
36
|
+
else content.textContent = value;
|
|
37
|
+
});
|
|
28
38
|
|
|
29
39
|
// Popper arrow
|
|
30
40
|
const tooltipWindowArrow = document.createElement('div');
|
|
@@ -10,12 +10,25 @@ angular.module('niceElements')
|
|
|
10
10
|
.service('NiceService', function ($rootScope) {
|
|
11
11
|
const service = {
|
|
12
12
|
name: "Nice elements",
|
|
13
|
-
version: "1.
|
|
13
|
+
version: "1.14.0",
|
|
14
14
|
getHeader: function () {
|
|
15
15
|
return {};
|
|
16
16
|
},
|
|
17
17
|
toast: function (message, type) {
|
|
18
18
|
$rootScope.$broadcast('toast', message, type);
|
|
19
|
+
},
|
|
20
|
+
// Check if value is a Decimal.js object (also Decimal.clone() instances)
|
|
21
|
+
isDecimal: function (value) {
|
|
22
|
+
return typeof Decimal !== 'undefined' && Decimal.isDecimal(value);
|
|
23
|
+
},
|
|
24
|
+
// Parse input value with Decimal constructor. Returns null for empty and undefined for invalid input (e.g. "-")
|
|
25
|
+
parseDecimal: function (value, DecimalConstructor) {
|
|
26
|
+
if (value === null || value === undefined || value === '') return null;
|
|
27
|
+
try {
|
|
28
|
+
return new DecimalConstructor(String(value).replace(',', '.'));
|
|
29
|
+
} catch (e) {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
19
32
|
}
|
|
20
33
|
};
|
|
21
34
|
|