nice-elements 1.13.8 → 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 +14 -0
- package/README.md +1 -1
- package/bower.json +1 -1
- package/dist/nice.js +217 -158
- package/dist/nice.min.js +1 -1
- package/dist/style.css +351 -996
- 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 +8 -1
- 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 +3 -0
- package/src/components/nice-input/nice-input.js +4 -4
- 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-popup/nice-popup.js +10 -5
- package/src/components/nice-search2/nice-search2.js +15 -5
- 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 +1 -1
|
@@ -1,31 +1,113 @@
|
|
|
1
|
-
.
|
|
1
|
+
// Stack container: newest on top, top-right corner. When a column fills the
|
|
2
|
+
// viewport height, older notifications wrap into a new column to the left.
|
|
3
|
+
.nice-notifications {
|
|
4
|
+
--nice-notification-top: 10px;
|
|
5
|
+
--nice-notification-spacing: 10px;
|
|
2
6
|
position: fixed;
|
|
7
|
+
top: var(--nice-notification-top);
|
|
3
8
|
right: 10px;
|
|
4
|
-
top: -100px;
|
|
5
9
|
z-index: 99999;
|
|
6
|
-
|
|
10
|
+
display: flex;
|
|
11
|
+
flex-direction: column;
|
|
12
|
+
flex-wrap: wrap-reverse;
|
|
13
|
+
align-items: flex-end;
|
|
14
|
+
align-content: flex-start;
|
|
15
|
+
column-gap: 10px;
|
|
16
|
+
max-height: calc(100vh - var(--nice-notification-top));
|
|
17
|
+
pointer-events: none; // clicks pass through the empty container area
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@keyframes nice-notification-in {
|
|
21
|
+
from {
|
|
22
|
+
grid-template-rows: minmax(0, 0fr);
|
|
23
|
+
margin-bottom: 0;
|
|
24
|
+
opacity: 0;
|
|
25
|
+
transform: translateX(40px) scale(0.96);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Slide out and fade, then collapse so the cards below close the gap
|
|
30
|
+
@keyframes nice-notification-out {
|
|
31
|
+
40% {
|
|
32
|
+
grid-template-rows: minmax(0, 1fr);
|
|
33
|
+
margin-bottom: var(--nice-notification-spacing, 10px);
|
|
34
|
+
opacity: 0;
|
|
35
|
+
transform: translateX(60px) scale(0.96);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
to {
|
|
39
|
+
grid-template-rows: minmax(0, 0fr);
|
|
40
|
+
margin-bottom: 0;
|
|
41
|
+
opacity: 0;
|
|
42
|
+
transform: translateX(60px) scale(0.96);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@keyframes nice-notification-fade-out {
|
|
47
|
+
to {
|
|
48
|
+
opacity: 0;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.notification {
|
|
53
|
+
// Single grid row animated between 0fr and 1fr: lets the card collapse/expand
|
|
54
|
+
// to its natural height so the cards below slide smoothly, without JS
|
|
55
|
+
display: grid;
|
|
56
|
+
grid-template-rows: minmax(0, 1fr);
|
|
57
|
+
overflow: hidden; // clip content while the row is collapsed
|
|
58
|
+
margin-bottom: var(--nice-notification-spacing, 10px);
|
|
59
|
+
pointer-events: auto;
|
|
7
60
|
border-radius: $border-radius-base;
|
|
8
61
|
cursor: pointer;
|
|
9
62
|
font-weight: normal;
|
|
10
63
|
min-width: 300px;
|
|
11
|
-
padding: 10px 15px;
|
|
12
64
|
color: $nice-notification-color;
|
|
13
65
|
background: $nice-notification-bg;
|
|
14
|
-
|
|
66
|
+
box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
|
|
67
|
+
animation: nice-notification-in 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
|
|
68
|
+
transition: opacity 0.2s ease;
|
|
15
69
|
|
|
70
|
+
// Leave. A keyframe animation (not a transition) so it also plays when the
|
|
71
|
+
// enter animation is interrupted. JS removes the element when it finishes,
|
|
72
|
+
// so the duration lives only here.
|
|
16
73
|
&.killed {
|
|
17
|
-
|
|
18
|
-
|
|
74
|
+
animation: nice-notification-out 0.4s ease forwards;
|
|
75
|
+
pointer-events: none;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
@media (prefers-reduced-motion: reduce) {
|
|
79
|
+
animation-name: none;
|
|
80
|
+
|
|
81
|
+
&.killed {
|
|
82
|
+
animation: nice-notification-fade-out 0.2s ease forwards;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.notification-inner {
|
|
87
|
+
min-height: 0; // required for the 0fr collapse
|
|
88
|
+
overflow: hidden;
|
|
89
|
+
display: flex;
|
|
90
|
+
align-items: center;
|
|
91
|
+
padding: 1rem;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Icon sits left of the title/message, aligned with the first line
|
|
95
|
+
.notification-icon {
|
|
96
|
+
flex: 0 0 auto;
|
|
97
|
+
width: 20px;
|
|
98
|
+
height: 20px;
|
|
99
|
+
margin-right: 0.5rem;
|
|
19
100
|
}
|
|
20
101
|
|
|
21
|
-
|
|
102
|
+
.notification-content {
|
|
103
|
+
flex: 1 1 auto;
|
|
104
|
+
min-width: 0;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.notification-title {
|
|
22
108
|
display: block;
|
|
23
|
-
margin: 10px 10px 0 10px;
|
|
24
|
-
padding: 0 0 5px 0;
|
|
25
109
|
text-align: left;
|
|
26
|
-
font-size:
|
|
27
|
-
font-style: normal;
|
|
28
|
-
color: white;
|
|
110
|
+
font-size: 1em;
|
|
29
111
|
font-weight: bold;
|
|
30
112
|
}
|
|
31
113
|
|
|
@@ -37,10 +119,6 @@
|
|
|
37
119
|
}
|
|
38
120
|
}
|
|
39
121
|
|
|
40
|
-
&>.message {
|
|
41
|
-
margin: 10px 10px 10px 10px;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
122
|
&.warning {
|
|
45
123
|
color: $nice-notification-warning-color;
|
|
46
124
|
background: $nice-notification-warning-bg;
|
|
@@ -61,7 +139,7 @@
|
|
|
61
139
|
background: $nice-notification-info-bg;
|
|
62
140
|
}
|
|
63
141
|
|
|
64
|
-
&:hover {
|
|
65
|
-
opacity: 0.
|
|
142
|
+
&:hover:not(.killed) {
|
|
143
|
+
opacity: 0.85;
|
|
66
144
|
}
|
|
67
145
|
}
|
|
@@ -59,8 +59,6 @@ angular.module('niceElements')
|
|
|
59
59
|
$scope.popper = Popper.createPopper(target, content, {
|
|
60
60
|
placement: $scope.placement,
|
|
61
61
|
strategy: $scope.strategy,
|
|
62
|
-
scroll: true,
|
|
63
|
-
resize: true,
|
|
64
62
|
modifiers: [
|
|
65
63
|
{
|
|
66
64
|
name: 'offset',
|
|
@@ -92,10 +90,17 @@ angular.module('niceElements')
|
|
|
92
90
|
});
|
|
93
91
|
};
|
|
94
92
|
|
|
95
|
-
$timeout(function () {
|
|
93
|
+
const setupTimer = $timeout(function () {
|
|
96
94
|
$scope.setupPopper();
|
|
97
95
|
});
|
|
98
96
|
|
|
97
|
+
// Popper adds scroll/resize listeners to window; remove them with the component
|
|
98
|
+
$scope.$on('$destroy', function () {
|
|
99
|
+
$timeout.cancel(setupTimer);
|
|
100
|
+
if ($scope.popper) $scope.popper.destroy();
|
|
101
|
+
$scope.popper = null;
|
|
102
|
+
});
|
|
103
|
+
|
|
99
104
|
// -----------------------------------Open -----------------------------------
|
|
100
105
|
$scope.toggle = function () {
|
|
101
106
|
if ($scope.isOpen) {
|
|
@@ -111,11 +116,11 @@ angular.module('niceElements')
|
|
|
111
116
|
};
|
|
112
117
|
|
|
113
118
|
$scope.open = function () {
|
|
114
|
-
$scope.popper.update();
|
|
119
|
+
if ($scope.popper) $scope.popper.update();
|
|
115
120
|
$scope.isOpen = true;
|
|
116
121
|
if ($scope.onChange) $scope.onChange($scope.isOpen);
|
|
117
122
|
$timeout(function () {
|
|
118
|
-
$scope.popper.update();
|
|
123
|
+
if ($scope.popper) $scope.popper.update();
|
|
119
124
|
});
|
|
120
125
|
};
|
|
121
126
|
}
|
|
@@ -80,10 +80,17 @@ angular.module('niceElements')
|
|
|
80
80
|
});
|
|
81
81
|
};
|
|
82
82
|
|
|
83
|
-
$timeout(function () {
|
|
83
|
+
const setupTimer = $timeout(function () {
|
|
84
84
|
$scope.setupPopper();
|
|
85
85
|
});
|
|
86
86
|
|
|
87
|
+
// Popper adds scroll/resize listeners to window; remove them with the component
|
|
88
|
+
$scope.$on('$destroy', function () {
|
|
89
|
+
$timeout.cancel(setupTimer);
|
|
90
|
+
if ($scope.popper) $scope.popper.destroy();
|
|
91
|
+
$scope.popper = null;
|
|
92
|
+
});
|
|
93
|
+
|
|
87
94
|
|
|
88
95
|
// ------------------- On focus -------------------
|
|
89
96
|
$scope.onFocus = function () {
|
|
@@ -121,7 +128,7 @@ angular.module('niceElements')
|
|
|
121
128
|
// if (input) input.blur();
|
|
122
129
|
|
|
123
130
|
$timeout(function () {
|
|
124
|
-
$scope.popper.update();
|
|
131
|
+
if ($scope.popper) $scope.popper.update();
|
|
125
132
|
});
|
|
126
133
|
};
|
|
127
134
|
|
|
@@ -220,8 +227,9 @@ angular.module('niceElements')
|
|
|
220
227
|
};
|
|
221
228
|
|
|
222
229
|
|
|
223
|
-
// ----------------------------------- Watch for keydown
|
|
224
|
-
|
|
230
|
+
// ----------------------------------- Watch for keydown -----------------------------------
|
|
231
|
+
// keydown only: Enter also fires keypress, which used to select the item twice
|
|
232
|
+
$element.bind("keydown", function (event) {
|
|
225
233
|
// Arrow Up
|
|
226
234
|
if (event.keyCode == 38) {
|
|
227
235
|
event.preventDefault();
|
|
@@ -252,7 +260,9 @@ angular.module('niceElements')
|
|
|
252
260
|
if (event.keyCode == 13) {
|
|
253
261
|
event.preventDefault();
|
|
254
262
|
$timeout(function () {
|
|
255
|
-
|
|
263
|
+
// Only select a result that exists (no results → no onSelect(undefined))
|
|
264
|
+
const item = $scope.results ? $scope.results[$scope.selectedIndex] : undefined;
|
|
265
|
+
if (item !== undefined) $scope.selectItem(item);
|
|
256
266
|
});
|
|
257
267
|
}
|
|
258
268
|
|
|
@@ -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');
|