nice-elements 1.8.4 → 1.8.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 +12 -0
- package/README.md +2 -1
- package/bower.json +1 -1
- package/dist/nice.js +202 -146
- package/dist/nice.min.js +1 -1
- package/dist/style.css +35 -1
- package/dist/style.css.map +3 -2
- package/dist/style.min.css +2 -2
- package/package.json +1 -1
- package/src/components/nice-dropdown/nice-dropdown.html +10 -9
- package/src/components/nice-dropdown/nice-dropdown.js +68 -51
- package/src/components/nice-dropdown/nice-dropdown.scss +12 -2
- package/src/components/nice-pill/nice-pill.html +4 -0
- package/src/components/nice-pill/nice-pill.js +29 -0
- package/src/components/nice-pill/nice-pill.scss +26 -0
- package/src/services/nice-service.js +1 -1
- package/src/styles/_nice.scss +2 -1
|
@@ -48,6 +48,7 @@ angular.module('niceElements')
|
|
|
48
48
|
enableLoadMore: '@' // Enable load more
|
|
49
49
|
},
|
|
50
50
|
controller: function ($scope, $http, $element, $timeout, gettextCatalog, NiceService) {
|
|
51
|
+
$scope.id = Math.random().toString(36).substring(7);
|
|
51
52
|
if (!$scope.dropdownDistance) { $scope.dropdownDistance = 5; }
|
|
52
53
|
if (!$scope.objValue) { $scope.objValue = 'value'; }
|
|
53
54
|
if (!$scope.objKey) { $scope.objKey = 'id'; }
|
|
@@ -64,13 +65,17 @@ angular.module('niceElements')
|
|
|
64
65
|
$scope.clearOnSelect = $scope.clearOnSelect === 'true' || $scope.clearOnSelect === true;
|
|
65
66
|
$scope.isOpen = false;
|
|
66
67
|
$scope.selected = null;
|
|
67
|
-
$scope.selectedIndex = 0;
|
|
68
|
+
// $scope.selectedIndex = 0;
|
|
68
69
|
$scope.popper = null;
|
|
69
70
|
|
|
70
71
|
$scope.internal = {
|
|
71
72
|
search: ""
|
|
72
73
|
};
|
|
73
74
|
|
|
75
|
+
if ($scope.list) {
|
|
76
|
+
$scope.originalList = angular.copy($scope.list);
|
|
77
|
+
}
|
|
78
|
+
|
|
74
79
|
// Setup popper
|
|
75
80
|
// https://popper.js.org/docs/v2/constructors/
|
|
76
81
|
$scope.setupPopper = function () {
|
|
@@ -125,6 +130,7 @@ angular.module('niceElements')
|
|
|
125
130
|
|
|
126
131
|
$scope.open = function () {
|
|
127
132
|
$scope.popper.update();
|
|
133
|
+
if ($scope.filterFunction) $scope.internalList = $scope.filterFunction($scope.originalList);
|
|
128
134
|
$timeout(function () {
|
|
129
135
|
$scope.isOpen = true;
|
|
130
136
|
$timeout(function () {
|
|
@@ -200,6 +206,13 @@ angular.module('niceElements')
|
|
|
200
206
|
};
|
|
201
207
|
|
|
202
208
|
|
|
209
|
+
$scope.handleNewInternalList = function (items) {
|
|
210
|
+
$scope.originalList = angular.copy(items);
|
|
211
|
+
if ($scope.filterFunction) $scope.internalList = $scope.filterFunction($scope.originalList);
|
|
212
|
+
else $scope.internalList = items;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
|
|
203
216
|
// ----------------------------------- Scroll to hover -----------------------------------
|
|
204
217
|
$scope.scrollToHover = function (notSmooth) {
|
|
205
218
|
var dropdownMenu = $element[0].getElementsByClassName("nice-dropdown-menu")[0];
|
|
@@ -218,10 +231,10 @@ angular.module('niceElements')
|
|
|
218
231
|
|
|
219
232
|
// ----------------------------------- Search -----------------------------------
|
|
220
233
|
$scope.handleSearch = function () {
|
|
234
|
+
if (!$scope.searchFunction) return;
|
|
221
235
|
$scope.loading = true;
|
|
222
236
|
$scope.searchFunction($scope.internal.search).then(function (response) {
|
|
223
|
-
|
|
224
|
-
else $scope.internalList = response;
|
|
237
|
+
$scope.handleNewInternalList(response);
|
|
225
238
|
$scope.loading = false;
|
|
226
239
|
$scope.handleDefault();
|
|
227
240
|
}, function (error) {
|
|
@@ -230,6 +243,11 @@ angular.module('niceElements')
|
|
|
230
243
|
});
|
|
231
244
|
};
|
|
232
245
|
|
|
246
|
+
$scope.clearSearch = function () {
|
|
247
|
+
$scope.internal.search = "";
|
|
248
|
+
$scope.handleSearch();
|
|
249
|
+
}
|
|
250
|
+
|
|
233
251
|
|
|
234
252
|
// ----------------------------------- Item clicked -----------------------------------
|
|
235
253
|
$scope.handleSelected = function (item, index) {
|
|
@@ -323,8 +341,7 @@ angular.module('niceElements')
|
|
|
323
341
|
|
|
324
342
|
// ----------------------------------- Watch for list change -----------------------------------
|
|
325
343
|
$scope.$watchCollection('list', function (value_new, value_old) {
|
|
326
|
-
|
|
327
|
-
else $scope.internalList = angular.copy($scope.list);
|
|
344
|
+
$scope.handleNewInternalList(angular.copy($scope.list));
|
|
328
345
|
$scope.handleDefault();
|
|
329
346
|
});
|
|
330
347
|
|
|
@@ -347,7 +364,7 @@ angular.module('niceElements')
|
|
|
347
364
|
if (i[$scope.objKey] == s) {
|
|
348
365
|
i._selected = true;
|
|
349
366
|
// $scope.selected.push(i);
|
|
350
|
-
$scope.selectedIndex = index;
|
|
367
|
+
// $scope.selectedIndex = index;
|
|
351
368
|
}
|
|
352
369
|
});
|
|
353
370
|
} else {
|
|
@@ -355,7 +372,7 @@ angular.module('niceElements')
|
|
|
355
372
|
if ($scope.selected != null && i[$scope.objKey] == $scope.selected) {
|
|
356
373
|
i._selected = true;
|
|
357
374
|
$scope.selected = i;
|
|
358
|
-
$scope.selectedIndex = index;
|
|
375
|
+
// $scope.selectedIndex = index;
|
|
359
376
|
$scope.scrollToHover();
|
|
360
377
|
}
|
|
361
378
|
}
|
|
@@ -367,7 +384,7 @@ angular.module('niceElements')
|
|
|
367
384
|
if (i[$scope.objKey] == s[$scope.objKey]) {
|
|
368
385
|
i._selected = true;
|
|
369
386
|
// $scope.selected.push(i);
|
|
370
|
-
$scope.selectedIndex = index;
|
|
387
|
+
// $scope.selectedIndex = index;
|
|
371
388
|
}
|
|
372
389
|
});
|
|
373
390
|
} else {
|
|
@@ -375,7 +392,7 @@ angular.module('niceElements')
|
|
|
375
392
|
if ($scope.selected != null && i[$scope.objKey] == $scope.selected[$scope.objKey]) {
|
|
376
393
|
i._selected = true;
|
|
377
394
|
$scope.selected = i;
|
|
378
|
-
$scope.selectedIndex = index;
|
|
395
|
+
// $scope.selectedIndex = index;
|
|
379
396
|
$scope.scrollToHover();
|
|
380
397
|
}
|
|
381
398
|
}
|
|
@@ -389,48 +406,48 @@ angular.module('niceElements')
|
|
|
389
406
|
}
|
|
390
407
|
|
|
391
408
|
// ----------------------------------- Watch for keydown and keypress -----------------------------------
|
|
392
|
-
$element.bind("keydown keypress", function (event) {
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
});
|
|
409
|
+
// $element.bind("keydown keypress", function (event) {
|
|
410
|
+
// // Arrow Up
|
|
411
|
+
// if (event.keyCode == 38) {
|
|
412
|
+
// event.preventDefault();
|
|
413
|
+
// $timeout(function () {
|
|
414
|
+
// if ($scope.selectedIndex > 0) {
|
|
415
|
+
// $scope.selectedIndex -= 1;
|
|
416
|
+
// $timeout(function () {
|
|
417
|
+
// $scope.scrollToHover();
|
|
418
|
+
// });
|
|
419
|
+
// }
|
|
420
|
+
// });
|
|
421
|
+
// }
|
|
422
|
+
|
|
423
|
+
// // Arrow Down
|
|
424
|
+
// if (event.keyCode == 40) {
|
|
425
|
+
// event.preventDefault();
|
|
426
|
+
// $timeout(function () {
|
|
427
|
+
// if ($scope.internalList && $scope.selectedIndex < $scope.internalList.length - 1) {
|
|
428
|
+
// $scope.selectedIndex += 1;
|
|
429
|
+
// $timeout(function () {
|
|
430
|
+
// $scope.scrollToHover();
|
|
431
|
+
// });
|
|
432
|
+
// }
|
|
433
|
+
// });
|
|
434
|
+
// }
|
|
435
|
+
|
|
436
|
+
// // Enter
|
|
437
|
+
// if (event.keyCode == 13) {
|
|
438
|
+
// event.preventDefault();
|
|
439
|
+
// $timeout(function () {
|
|
440
|
+
// $scope.handleSelected($scope.internalList[$scope.selectedIndex], $scope.selectedIndex);
|
|
441
|
+
// });
|
|
442
|
+
// }
|
|
443
|
+
|
|
444
|
+
// // Escape
|
|
445
|
+
// if (event.keyCode == 27) {
|
|
446
|
+
// $timeout(function () {
|
|
447
|
+
// $scope.close();
|
|
448
|
+
// });
|
|
449
|
+
// }
|
|
450
|
+
// });
|
|
434
451
|
|
|
435
452
|
$scope.handleDefault();
|
|
436
453
|
|
|
@@ -87,6 +87,10 @@
|
|
|
87
87
|
width: 16px;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
.icon-trash {
|
|
91
|
+
color: var(--nice-danger-color);
|
|
92
|
+
}
|
|
93
|
+
|
|
90
94
|
.count {
|
|
91
95
|
position: absolute;
|
|
92
96
|
top: 50%;
|
|
@@ -111,7 +115,6 @@
|
|
|
111
115
|
padding: 0;
|
|
112
116
|
margin: 0;
|
|
113
117
|
|
|
114
|
-
|
|
115
118
|
.nice-dropdown-item {
|
|
116
119
|
padding: 10px;
|
|
117
120
|
position: relative;
|
|
@@ -119,6 +122,11 @@
|
|
|
119
122
|
display: flex;
|
|
120
123
|
align-items: center;
|
|
121
124
|
|
|
125
|
+
border: 0 none;
|
|
126
|
+
background: transparent;
|
|
127
|
+
text-align: left;
|
|
128
|
+
width: 100%;
|
|
129
|
+
|
|
122
130
|
.choice-checkbox {
|
|
123
131
|
transition: all 0.2s;
|
|
124
132
|
background: $nice-choice-bg;
|
|
@@ -138,7 +146,9 @@
|
|
|
138
146
|
}
|
|
139
147
|
|
|
140
148
|
&:hover,
|
|
141
|
-
&.hover
|
|
149
|
+
&.hover,
|
|
150
|
+
&:focus,
|
|
151
|
+
&.focus {
|
|
142
152
|
background: $nice-hover-color;
|
|
143
153
|
}
|
|
144
154
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @ngdoc directive
|
|
5
|
+
* @name niceElements.directive:nicePill
|
|
6
|
+
* @description
|
|
7
|
+
* # nicePill
|
|
8
|
+
*/
|
|
9
|
+
angular.module('niceElements')
|
|
10
|
+
.directive('nicePill', function () {
|
|
11
|
+
return {
|
|
12
|
+
templateUrl: 'src/components/nice-pill/nice-pill.html',
|
|
13
|
+
restrict: 'E',
|
|
14
|
+
transclude: true,
|
|
15
|
+
scope: {
|
|
16
|
+
model: '=',
|
|
17
|
+
valueKey: '@',
|
|
18
|
+
canDelete: '@',
|
|
19
|
+
onDelete: '=?',
|
|
20
|
+
},
|
|
21
|
+
controller: function ($scope) {
|
|
22
|
+
if (!$scope.valueKey) $scope.valueKey = "value";
|
|
23
|
+
|
|
24
|
+
$scope.handleDelete = function () {
|
|
25
|
+
$scope.onDelete($scope.model)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
.nice-pills {
|
|
2
|
+
display: flex;
|
|
3
|
+
gap: 0.2rem;
|
|
4
|
+
flex-wrap: wrap;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.nice-pill {
|
|
8
|
+
background: var(--nice-primary-color);
|
|
9
|
+
color: white;
|
|
10
|
+
border-radius: 1rem;
|
|
11
|
+
padding: 2px 8px;
|
|
12
|
+
font-size: 0.8em;
|
|
13
|
+
position: relative;
|
|
14
|
+
|
|
15
|
+
display: flex;
|
|
16
|
+
align-items: center;
|
|
17
|
+
gap: 0.2rem;
|
|
18
|
+
|
|
19
|
+
.nice-pill-remove {
|
|
20
|
+
margin: 0;
|
|
21
|
+
padding: 0;
|
|
22
|
+
min-height: auto;
|
|
23
|
+
border: 0 none;
|
|
24
|
+
color: white;
|
|
25
|
+
}
|
|
26
|
+
}
|
package/src/styles/_nice.scss
CHANGED
|
@@ -55,4 +55,5 @@
|
|
|
55
55
|
@import "../components/nice-icon/nice-icon";
|
|
56
56
|
@import "../components/nice-toast/nice-toast";
|
|
57
57
|
@import "../components/nice-date-input/nice-date-input.scss";
|
|
58
|
-
@import "../components/nice-wrapper/nice-wrapper.scss";
|
|
58
|
+
@import "../components/nice-wrapper/nice-wrapper.scss";
|
|
59
|
+
@import "../components/nice-pill/nice-pill.scss";
|