nice-elements 1.16.0 → 1.16.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 +14 -0
- package/README.md +1 -1
- package/bower.json +1 -1
- package/dist/nice.js +57 -45
- package/dist/nice.min.js +1 -1
- package/dist/style.css +23 -22
- package/dist/style.css.map +1 -1
- package/dist/style.min.css +2 -2
- package/package.json +1 -1
- package/src/components/nice-notification/nice-notification.html +6 -6
- package/src/components/nice-notification/nice-notification.scss +7 -6
- package/src/components/nice-search/nice-search.html +21 -23
- package/src/components/nice-search/nice-search.js +9 -12
- package/src/components/nice-search/nice-search.scss +9 -10
- package/src/components/nice-search2/nice-search2.html +1 -1
- package/src/components/nice-search2/nice-search2.js +13 -2
- package/src/directives/nice-click-outside.js +6 -0
- package/src/services/nice-service.js +1 -1
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
<div class="notification" ng-class="{ 'has-icon': icon }">
|
|
2
|
-
<div class="notification-inner">
|
|
3
|
-
<nice-icon ng-if="icon" class="notification-icon" icon="{{ icon }}"></nice-icon>
|
|
4
|
-
<div class="notification-content">
|
|
5
|
-
<div class="notification-title" ng-show="title" ng-bind-html="title"></div>
|
|
6
|
-
<div class="notification-message" ng-bind-html="message"></div>
|
|
1
|
+
<div class="nice-notification" ng-class="{ 'has-icon': icon }">
|
|
2
|
+
<div class="nice-notification-inner">
|
|
3
|
+
<nice-icon ng-if="icon" class="nice-notification-icon" icon="{{ icon }}"></nice-icon>
|
|
4
|
+
<div class="nice-notification-content">
|
|
5
|
+
<div class="nice-notification-title" ng-show="title" ng-bind-html="title"></div>
|
|
6
|
+
<div class="nice-notification-message" ng-bind-html="message"></div>
|
|
7
7
|
</div>
|
|
8
8
|
</div>
|
|
9
9
|
</div>
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
display: flex;
|
|
11
11
|
flex-direction: column;
|
|
12
12
|
flex-wrap: wrap-reverse;
|
|
13
|
-
align-items: flex-
|
|
13
|
+
align-items: flex-start;
|
|
14
14
|
align-content: flex-start;
|
|
15
15
|
column-gap: 10px;
|
|
16
16
|
max-height: calc(100vh - var(--nice-notification-top));
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
.notification {
|
|
52
|
+
.nice-notification {
|
|
53
53
|
// Single grid row animated between 0fr and 1fr: lets the card collapse/expand
|
|
54
54
|
// to its natural height so the cards below slide smoothly, without JS
|
|
55
55
|
display: grid;
|
|
@@ -60,6 +60,7 @@
|
|
|
60
60
|
border-radius: $border-radius-base;
|
|
61
61
|
cursor: pointer;
|
|
62
62
|
font-weight: normal;
|
|
63
|
+
max-width: 500px;
|
|
63
64
|
min-width: 300px;
|
|
64
65
|
color: $nice-notification-color;
|
|
65
66
|
background: $nice-notification-bg;
|
|
@@ -83,7 +84,7 @@
|
|
|
83
84
|
}
|
|
84
85
|
}
|
|
85
86
|
|
|
86
|
-
.notification-inner {
|
|
87
|
+
.nice-notification-inner {
|
|
87
88
|
min-height: 0; // required for the 0fr collapse
|
|
88
89
|
overflow: hidden;
|
|
89
90
|
display: flex;
|
|
@@ -92,7 +93,7 @@
|
|
|
92
93
|
}
|
|
93
94
|
|
|
94
95
|
// Icon sits left of the title/message, aligned with the first line
|
|
95
|
-
.notification-icon {
|
|
96
|
+
.nice-notification-icon {
|
|
96
97
|
flex: 0 0 auto;
|
|
97
98
|
width: 20px;
|
|
98
99
|
height: 20px;
|
|
@@ -100,12 +101,12 @@
|
|
|
100
101
|
flex-shrink: 0;
|
|
101
102
|
}
|
|
102
103
|
|
|
103
|
-
.notification-content {
|
|
104
|
+
.nice-notification-content {
|
|
104
105
|
flex: 1 1 auto;
|
|
105
106
|
min-width: 0;
|
|
106
107
|
}
|
|
107
108
|
|
|
108
|
-
.notification-title {
|
|
109
|
+
.nice-notification-title {
|
|
109
110
|
display: block;
|
|
110
111
|
text-align: left;
|
|
111
112
|
font-size: 1em;
|
|
@@ -5,33 +5,31 @@
|
|
|
5
5
|
|
|
6
6
|
<!------------------------- Field ------------------------->
|
|
7
7
|
<div class="nice-field col-xs-12" ng-class="[fieldWidth ? fieldWidth : 'col-sm-8', { 'nice-disabled': isDisabled }]">
|
|
8
|
-
<div class="
|
|
9
|
-
<
|
|
8
|
+
<div class="nice-search-field" click-outside="closeDropdown()" is-open="{{ results.length > 0 || noResults }}">
|
|
9
|
+
<div class="input-group" ng-class="{ 'disabled': isDisabled }">
|
|
10
|
+
<input class="form-control" type="text" id="{{ id }}" ng-model="modelString" ng-keypress="keypress($event)" placeholder="{{ placeholder }}" ng-disabled="isDisabled" ng-change="updateSearch()" ng-required="required" tabindex="{{ tabIndex }}">
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
<button type="button" class="btn input-group-addon" ng-click="search()" ng-if="!model" ng-disabled="isDisabled">
|
|
13
|
+
<!-- <nice-icon ng-show="loading" icon="icon-loader" class="d-block nice-animation-spin"></nice-icon> -->
|
|
14
|
+
<nice-icon ng-show="!loading" icon="icon-search"></nice-icon>
|
|
15
|
+
<nice-loader ng-if="loading"></nice-loader>
|
|
16
|
+
</button>
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
</div>
|
|
22
|
-
</div>
|
|
18
|
+
<button type="button" class="btn input-group-addon" ng-click="remove()" ng-if="model" ng-disabled="isDisabled">
|
|
19
|
+
<nice-icon ng-show="!loading" icon="icon-x"></nice-icon>
|
|
20
|
+
</button>
|
|
21
|
+
</div>
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
<div class="nice-search-row" translate translate-context="Nice">No results found.</div>
|
|
29
|
-
</div>
|
|
23
|
+
<!------------------------- Dropdown ------------------------->
|
|
24
|
+
<div class="nice-dropdown-empty" ng-if="noResults">
|
|
25
|
+
<div class="nice-search-row" translate translate-context="Nice">No results found.</div>
|
|
26
|
+
</div>
|
|
30
27
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
<div class="nice-dropdown" ng-if="results.length">
|
|
29
|
+
<div ng-repeat="result in results" class="nice-search-row" ng-class="{'active': selectedIndex == $index}" ng-click="selectRow(result)">
|
|
30
|
+
<span class="text-bold" ng-if="!hasRowTemplate">{{ result[keyForInputLabel] }}</span>
|
|
31
|
+
<div ng-if="hasRowTemplate" nice-search-row-transclude></div>
|
|
32
|
+
</div>
|
|
35
33
|
</div>
|
|
36
34
|
</div>
|
|
37
35
|
</div>
|
|
@@ -119,19 +119,12 @@ angular.module('niceElements')
|
|
|
119
119
|
//scope.$apply();
|
|
120
120
|
};
|
|
121
121
|
|
|
122
|
-
// Close the dropdown
|
|
123
|
-
|
|
124
|
-
const isClickedElementChildOfPopup = element.find(event.target).length > 0;
|
|
125
|
-
|
|
126
|
-
if (isClickedElementChildOfPopup) return;
|
|
127
|
-
|
|
122
|
+
// Close the dropdown (called by click-outside in the template)
|
|
123
|
+
scope.closeDropdown = function () {
|
|
128
124
|
scope.results = [];
|
|
129
125
|
scope.noResults = false;
|
|
130
|
-
scope.$apply();
|
|
131
126
|
};
|
|
132
127
|
|
|
133
|
-
angular.element(element).on('click', onClick);
|
|
134
|
-
|
|
135
128
|
// Keyboard up/down on search results
|
|
136
129
|
const onKeyDown = function (event) {
|
|
137
130
|
if ((event.keyCode == 38 || event.keyCode == 40 || event.keyCode == 13 || event.keyCode == 27) && scope.results && scope.results.length > 0) {
|
|
@@ -163,7 +156,6 @@ angular.module('niceElements')
|
|
|
163
156
|
angular.element(element).on('keydown', onKeyDown);
|
|
164
157
|
|
|
165
158
|
scope.$on('$destroy', function () {
|
|
166
|
-
angular.element(element).off('click', onClick);
|
|
167
159
|
angular.element(element).off('keydown', onKeyDown);
|
|
168
160
|
});
|
|
169
161
|
|
|
@@ -216,10 +208,15 @@ angular.module('niceElements')
|
|
|
216
208
|
}
|
|
217
209
|
$scope.requests = $scope.requests + 1;
|
|
218
210
|
const requestNumber = angular.copy($scope.requests);
|
|
211
|
+
// $timeout so the view updates also when refreshFunction returns a native Promise
|
|
219
212
|
$scope.refreshFunction($scope.modelString).then(function (response) {
|
|
220
|
-
|
|
213
|
+
$timeout(function () {
|
|
214
|
+
updateList(response, requestNumber);
|
|
215
|
+
});
|
|
221
216
|
}, function (error) {
|
|
222
|
-
$
|
|
217
|
+
$timeout(function () {
|
|
218
|
+
$scope.loading = false;
|
|
219
|
+
});
|
|
223
220
|
});
|
|
224
221
|
// Why was this here?
|
|
225
222
|
// $scope.model = $scope.modelString;
|
|
@@ -24,13 +24,19 @@
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
// Positioning parent of the dropdown (wraps the input)
|
|
28
|
+
.nice-search-field {
|
|
29
|
+
position: relative;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Dropdown sits right under the input, same width
|
|
27
33
|
.nice-dropdown {
|
|
28
34
|
position: absolute;
|
|
29
35
|
z-index: 999;
|
|
30
|
-
|
|
36
|
+
top: 100%;
|
|
31
37
|
left: 0;
|
|
32
|
-
|
|
33
|
-
|
|
38
|
+
right: 0;
|
|
39
|
+
margin-top: 4px;
|
|
34
40
|
max-height: 300px;
|
|
35
41
|
background-color: white;
|
|
36
42
|
border-radius: $nice-border-radius;
|
|
@@ -40,10 +46,6 @@
|
|
|
40
46
|
-webkit-box-shadow: 0 0 1px rgba(0, 0, 0, 0.175);
|
|
41
47
|
box-shadow: 0 0 1px rgba(0, 0, 0, 0.175);
|
|
42
48
|
|
|
43
|
-
top: -13px;
|
|
44
|
-
margin: 15px;
|
|
45
|
-
right: 0;
|
|
46
|
-
|
|
47
49
|
.nice-search-row {
|
|
48
50
|
padding: 10px 15px;
|
|
49
51
|
z-index: 1000;
|
|
@@ -79,9 +81,6 @@
|
|
|
79
81
|
|
|
80
82
|
.nice-dropdown-empty {
|
|
81
83
|
@extend .nice-dropdown;
|
|
82
|
-
top: -13px;
|
|
83
|
-
margin: 15px;
|
|
84
|
-
right: 0;
|
|
85
84
|
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
|
|
86
85
|
|
|
87
86
|
.nice-search-row {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
<nice-popup trigger="manual" is-open="isOpen" placement="{{ placement }}" same-width="true">
|
|
9
9
|
<nice-popup-target>
|
|
10
10
|
<div class="nice-search-button input-group" ng-class="{ 'disabled': isDisabled }">
|
|
11
|
-
<input class="form-control" type="text" id="{{ id }}" ng-model="model" placeholder="{{ placeholder }}" ng-disabled="isDisabled" ng-change="updateSearch()" ng-focus="onFocus()" ng-required="required" tabindex="{{ tabIndex }}">
|
|
11
|
+
<input class="form-control" type="text" id="{{ id }}" ng-model="modelAccessor" ng-model-options="{ getterSetter: true }" placeholder="{{ placeholder }}" ng-disabled="isDisabled" ng-change="updateSearch()" ng-focus="onFocus()" ng-required="required" tabindex="{{ tabIndex }}">
|
|
12
12
|
|
|
13
13
|
<button type="button" class="btn input-group-addon" ng-disabled="isDisabled" ng-click="buttonClicked()">
|
|
14
14
|
<nice-icon ng-show="!loading && model != ''" icon="icon-x"></nice-icon>
|
|
@@ -24,7 +24,7 @@ angular.module('niceElements')
|
|
|
24
24
|
labelWidth: '@',
|
|
25
25
|
refreshFunction: '=',
|
|
26
26
|
refreshSelectedCallback: '=',
|
|
27
|
-
onSelect: '
|
|
27
|
+
onSelect: '&?',
|
|
28
28
|
onChange: '&?',
|
|
29
29
|
noMargin: '@',
|
|
30
30
|
tabIndex: '@',
|
|
@@ -48,6 +48,14 @@ angular.module('niceElements')
|
|
|
48
48
|
if (!$scope.model) $scope.model = "";
|
|
49
49
|
if (!$scope.placement) { $scope.placement = "bottom-start"; }
|
|
50
50
|
|
|
51
|
+
// ------------------- Model accessor -------------------
|
|
52
|
+
// Input lives inside nice-popup's transcluded (child) scope, so a plain ng-model="model"
|
|
53
|
+
// would write to the child scope only. Bind through a getter/setter instead.
|
|
54
|
+
$scope.modelAccessor = function (value) {
|
|
55
|
+
if (arguments.length) $scope.model = value;
|
|
56
|
+
return $scope.model;
|
|
57
|
+
};
|
|
58
|
+
|
|
51
59
|
// ------------------- On focus -------------------
|
|
52
60
|
$scope.onFocus = function () {
|
|
53
61
|
if ($scope.showDropdown && $scope.results.length == 0) {
|
|
@@ -151,7 +159,10 @@ angular.module('niceElements')
|
|
|
151
159
|
// ------------------------ Select item ------------------------
|
|
152
160
|
$scope.selectItem = function (item) {
|
|
153
161
|
if ($scope.onSelect) {
|
|
154
|
-
|
|
162
|
+
// Supports on-select="fn(model)" (expression) and on-select="fn" (function reference):
|
|
163
|
+
// the expression form is evaluated directly, the reference form returns the function to call.
|
|
164
|
+
const result = $scope.onSelect({ model: item });
|
|
165
|
+
if (angular.isFunction(result)) result(item);
|
|
155
166
|
$scope.clear();
|
|
156
167
|
$scope.close();
|
|
157
168
|
}
|
|
@@ -36,6 +36,12 @@ angular.module('niceElements')
|
|
|
36
36
|
return;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
// the click removed its own target (e.g. a re-rendered ng-repeat calendar day),
|
|
40
|
+
// so we can't tell where it was - treat it as an inside click
|
|
41
|
+
if (!document.documentElement.contains(e.target)) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
39
45
|
// loop through the available elements, looking for classes in the class list that might match and so will eat
|
|
40
46
|
for (element = e.target; element; element = element.parentNode) {
|
|
41
47
|
// check if the element is the same element the directive is attached to and exit if so (props @CosticaPuntaru)
|