nice-elements 1.15.1 → 1.16.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/CHANGELOG.md +24 -0
- package/CLAUDE.md +1 -0
- package/README.md +1 -1
- package/bower.json +1 -1
- package/dist/nice.js +620 -509
- package/dist/nice.min.js +1 -1
- package/dist/style.css +145 -126
- package/dist/style.css.map +1 -1
- package/dist/style.min.css +2 -2
- package/package.json +5 -6
- package/src/components/nice-calendar/nice-calendar.html +3 -4
- package/src/components/nice-calendar/nice-calendar.scss +0 -9
- package/src/components/nice-date/nice-date-picker.html +60 -0
- package/src/components/nice-date/nice-date.html +29 -86
- package/src/components/nice-date/nice-date.js +7 -35
- package/src/components/nice-date/nice-date.scss +6 -15
- package/src/components/nice-datetime-picker/nice-datetime-picker.html +1 -4
- package/src/components/nice-datetime-picker/nice-datetime-picker.scss +9 -12
- package/src/components/nice-datetimerange-picker/nice-datetimerange-picker.html +1 -3
- package/src/components/nice-datetimerange-picker-2/nice-datetimerange-picker-2.html +32 -30
- package/src/components/nice-datetimerange-picker-2/nice-datetimerange-picker-2.js +1 -33
- package/src/components/nice-datetimerange-picker-2/nice-datetimerange-picker-2.scss +7 -12
- package/src/components/nice-dropdown/nice-dropdown.html +42 -40
- package/src/components/nice-dropdown/nice-dropdown.js +52 -54
- package/src/components/nice-dropdown/nice-dropdown.scss +25 -4
- package/src/components/nice-dropdown-old/nice-dropdown-old.html +1 -1
- package/src/components/nice-dropdown-old/nice-dropdown-old.scss +8 -2
- package/src/components/nice-dtp/nice-dtp.html +7 -7
- package/src/components/nice-notification/nice-notification.html +6 -6
- package/src/components/nice-notification/nice-notification.scss +7 -6
- package/src/components/nice-options/nice-options.scss +4 -0
- package/src/components/nice-popup/nice-popup.html +4 -4
- package/src/components/nice-popup/nice-popup.js +61 -75
- package/src/components/nice-popup/nice-popup.scss +10 -31
- package/src/components/nice-search/nice-search.html +21 -26
- 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 +22 -18
- package/src/components/nice-search2/nice-search2.js +12 -56
- package/src/components/nice-search2/nice-search2.scss +3 -2
- package/src/components/nice-svgs/nice-svgs.html +8 -0
- package/src/components/nice-time-picker/nice-time-picker.html +1 -3
- package/src/components/nice-time-picker/nice-time-picker.scss +0 -8
- package/src/directives/nice-tooltip/_nice-tooltip.scss +7 -28
- package/src/directives/nice-tooltip/nice-tooltip.js +16 -29
- package/src/services/nice-service.js +236 -1
- package/src/styles/_nice-anchored.scss +75 -0
- package/src/styles/_nice.scss +1 -0
|
@@ -5,6 +5,12 @@
|
|
|
5
5
|
* @name niceElements.directive:nicePopup
|
|
6
6
|
* @description
|
|
7
7
|
* # nicePopup
|
|
8
|
+
* Shows content next to a target. Positioned with NiceService.anchor()
|
|
9
|
+
* (native popover + CSS anchor positioning, Popper fallback).
|
|
10
|
+
*
|
|
11
|
+
* trigger="click" (default): clicking the target toggles it, clicking outside closes it.
|
|
12
|
+
* trigger="manual": the parent opens and closes it through is-open.
|
|
13
|
+
* Escape always closes it (also in "manual", is-open is set to false).
|
|
8
14
|
*/
|
|
9
15
|
angular.module('niceElements')
|
|
10
16
|
.directive('nicePopup', function () {
|
|
@@ -16,92 +22,69 @@ angular.module('niceElements')
|
|
|
16
22
|
'content': '?nicePopupContent'
|
|
17
23
|
},
|
|
18
24
|
scope: {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
25
|
+
isOpen: '=?', // two-way open state
|
|
26
|
+
trigger: '@', // "click" (default) or "manual"
|
|
27
|
+
offsetDistance: '@', // gap in px between the target and the content
|
|
28
|
+
offsetSkidding: '@', // shift in px along the target
|
|
29
|
+
placement: '@', // preferred placement, e.g. "bottom-start"
|
|
30
|
+
strategy: '@', // Popper strategy (fallback only)
|
|
23
31
|
showArrow: '@',
|
|
32
|
+
sameWidth: '@', // content as wide as the target
|
|
24
33
|
onChange: '&?',
|
|
25
34
|
},
|
|
26
|
-
controller: function ($scope, $element, $timeout) {
|
|
27
|
-
$scope
|
|
28
|
-
|
|
29
|
-
if (!$scope.
|
|
30
|
-
if (!$scope.
|
|
31
|
-
if (!$scope.offsetSkidding) { $scope.offsetSkidding = 0; }
|
|
35
|
+
controller: function ($scope, $element, $attrs, $timeout, NiceService) {
|
|
36
|
+
NiceService.bindFlag($scope, $attrs, 'showArrow');
|
|
37
|
+
NiceService.bindFlag($scope, $attrs, 'sameWidth');
|
|
38
|
+
if (!$scope.isOpen) { $scope.isOpen = false; }
|
|
39
|
+
if (!$scope.trigger) { $scope.trigger = "click"; }
|
|
32
40
|
if (!$scope.placement) { $scope.placement = "auto"; }
|
|
33
|
-
if (!$scope.
|
|
41
|
+
if (!$scope.offsetDistance) { $scope.offsetDistance = $scope.showArrow ? 8 : 5; }
|
|
42
|
+
if (!$scope.offsetSkidding) { $scope.offsetSkidding = 0; }
|
|
34
43
|
|
|
35
|
-
// Placements
|
|
36
|
-
//
|
|
37
|
-
// 'auto',
|
|
38
|
-
// 'auto-start',
|
|
39
|
-
// 'auto-end',
|
|
40
|
-
// 'top',
|
|
41
|
-
// 'top-start',
|
|
42
|
-
// 'top-end',
|
|
43
|
-
// 'bottom',
|
|
44
|
-
// 'bottom-start',
|
|
45
|
-
// 'bottom-end',
|
|
46
|
-
// 'right',
|
|
47
|
-
// 'right-start',
|
|
48
|
-
// 'right-end',
|
|
49
|
-
// 'left',
|
|
50
|
-
// 'left-start',
|
|
51
|
-
// 'left-end'
|
|
52
|
-
// ]
|
|
44
|
+
// Placements: auto, auto-start, auto-end, top, top-start, top-end, bottom, bottom-start,
|
|
45
|
+
// bottom-end, right, right-start, right-end, left, left-start, left-end
|
|
53
46
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
47
|
+
let anchored = null;
|
|
48
|
+
|
|
49
|
+
// Template is in the DOM after the first digest
|
|
50
|
+
const setupTimer = $timeout(function () {
|
|
57
51
|
const target = $element[0].getElementsByClassName('nice-popup-target')[0];
|
|
58
52
|
const content = $element[0].getElementsByClassName('nice-popup-content')[0];
|
|
59
|
-
|
|
53
|
+
const arrow = $element[0].getElementsByClassName('nice-popup-arrow')[0];
|
|
54
|
+
anchored = NiceService.anchor(target, content, {
|
|
60
55
|
placement: $scope.placement,
|
|
56
|
+
offset: parseInt($scope.offsetDistance),
|
|
57
|
+
skidding: parseInt($scope.offsetSkidding),
|
|
58
|
+
sameWidth: $scope.sameWidth,
|
|
61
59
|
strategy: $scope.strategy,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
offset: [$scope.offsetSkidding, $scope.offsetDistance],
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
name: 'arrow',
|
|
71
|
-
options: {
|
|
72
|
-
padding: 5, // 5px from the edges of the popper
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
// {
|
|
76
|
-
// name: "sameWidth",
|
|
77
|
-
// enabled: true,
|
|
78
|
-
// phase: "beforeWrite",
|
|
79
|
-
// requires: ["computeStyles"],
|
|
80
|
-
// fn: function (e) {
|
|
81
|
-
// var state = e.state;
|
|
82
|
-
// state.styles.popper.width = state.rects.reference.width + "px";
|
|
83
|
-
// },
|
|
84
|
-
// effect: function (e) {
|
|
85
|
-
// var state = e.state;
|
|
86
|
-
// state.elements.popper.style.width = state.elements.reference.offsetWidth + "px";
|
|
87
|
-
// }
|
|
88
|
-
// }
|
|
89
|
-
],
|
|
60
|
+
arrow: arrow,
|
|
61
|
+
onEscape: function () {
|
|
62
|
+
$timeout(function () { $scope.close(); });
|
|
63
|
+
}
|
|
90
64
|
});
|
|
91
|
-
|
|
65
|
+
if ($scope.isOpen) anchored.open();
|
|
66
|
+
});
|
|
92
67
|
|
|
93
|
-
|
|
94
|
-
|
|
68
|
+
// Show or hide the content when the state changes
|
|
69
|
+
$scope.$watch('isOpen', function (isOpen, wasOpen) {
|
|
70
|
+
if (!anchored) return;
|
|
71
|
+
if (isOpen) {
|
|
72
|
+
anchored.open();
|
|
73
|
+
// Content is rendered with ng-if, update once it's there
|
|
74
|
+
$timeout(function () { if (anchored) anchored.update(); });
|
|
75
|
+
} else {
|
|
76
|
+
anchored.close();
|
|
77
|
+
}
|
|
78
|
+
if (isOpen !== wasOpen && $scope.onChange) $scope.onChange({ isOpen: isOpen });
|
|
95
79
|
});
|
|
96
80
|
|
|
97
|
-
// Popper adds scroll/resize listeners to window; remove them with the component
|
|
98
81
|
$scope.$on('$destroy', function () {
|
|
99
82
|
$timeout.cancel(setupTimer);
|
|
100
|
-
if (
|
|
101
|
-
|
|
83
|
+
if (anchored) anchored.destroy();
|
|
84
|
+
anchored = null;
|
|
102
85
|
});
|
|
103
86
|
|
|
104
|
-
// -----------------------------------Open -----------------------------------
|
|
87
|
+
// ----------------------------------- Open -----------------------------------
|
|
105
88
|
$scope.toggle = function () {
|
|
106
89
|
if ($scope.isOpen) {
|
|
107
90
|
$scope.close();
|
|
@@ -112,17 +95,20 @@ angular.module('niceElements')
|
|
|
112
95
|
|
|
113
96
|
$scope.close = function () {
|
|
114
97
|
$scope.isOpen = false;
|
|
115
|
-
if ($scope.onChange) $scope.onChange({ isOpen: $scope.isOpen });
|
|
116
98
|
};
|
|
117
99
|
|
|
118
100
|
$scope.open = function () {
|
|
119
|
-
if ($scope.popper) $scope.popper.update();
|
|
120
101
|
$scope.isOpen = true;
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
// Click on target / outside only does something in "click" mode
|
|
105
|
+
$scope.targetClicked = function () {
|
|
106
|
+
if ($scope.trigger != 'manual') $scope.toggle();
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
$scope.clickedOutside = function () {
|
|
110
|
+
if ($scope.trigger != 'manual') $scope.close();
|
|
125
111
|
};
|
|
126
112
|
}
|
|
127
113
|
};
|
|
128
|
-
});
|
|
114
|
+
});
|
|
@@ -1,44 +1,23 @@
|
|
|
1
|
+
// Positioning and arrow placement come from _nice-anchored.scss
|
|
2
|
+
|
|
3
|
+
// Single class on purpose: components can make the target a block (".nice-x .nice-popup-target")
|
|
4
|
+
.nice-popup-target {
|
|
5
|
+
display: inline-block;
|
|
6
|
+
}
|
|
7
|
+
|
|
1
8
|
.nice-popup {
|
|
2
|
-
.nice-popup-target {
|
|
3
|
-
display: inline-block;
|
|
4
|
-
}
|
|
5
9
|
|
|
6
|
-
.nice-popup-arrow
|
|
7
|
-
|
|
10
|
+
.nice-popup-arrow {
|
|
11
|
+
z-index: -1;
|
|
8
12
|
}
|
|
9
13
|
|
|
10
|
-
.nice-popup-arrow,
|
|
11
14
|
.nice-popup-arrow::before {
|
|
12
15
|
position: absolute;
|
|
13
16
|
width: 8px;
|
|
14
17
|
height: 8px;
|
|
15
|
-
z-index: -1;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.nice-popup-arrow::before {
|
|
19
18
|
content: '';
|
|
20
19
|
transform: rotate(45deg);
|
|
21
20
|
background: #ffffff;
|
|
22
21
|
border: 1px solid $nice-border-color;
|
|
23
22
|
}
|
|
24
|
-
|
|
25
|
-
.nice-popup-content {
|
|
26
|
-
z-index: 1;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.nice-popup-content[data-popper-placement^='top']>.nice-popup-arrow {
|
|
30
|
-
bottom: -4px;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.nice-popup-content[data-popper-placement^='bottom']>.nice-popup-arrow {
|
|
34
|
-
top: -4px;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.nice-popup-content[data-popper-placement^='left']>.nice-popup-arrow {
|
|
38
|
-
right: -4px;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
.nice-popup-content[data-popper-placement^='right']>.nice-popup-arrow {
|
|
42
|
-
left: -4px;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
23
|
+
}
|
|
@@ -5,36 +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
|
-
|
|
16
|
-
<nice-loader ng-if="loading"></nice-loader>
|
|
17
|
-
</button>
|
|
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>
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
</
|
|
23
|
-
</div>
|
|
24
|
-
</div>
|
|
25
|
-
</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>
|
|
26
22
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
<div class="nice-search-row" translate translate-context="Nice">No results found.</div>
|
|
32
|
-
</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>
|
|
33
27
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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>
|
|
38
33
|
</div>
|
|
39
34
|
</div>
|
|
40
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 {
|
|
@@ -5,29 +5,33 @@
|
|
|
5
5
|
|
|
6
6
|
<!------------------------- Field ------------------------->
|
|
7
7
|
<div class="nice-field col-xs-12" ng-class="[fieldWidth ? fieldWidth : 'col-sm-8', { 'nice-disabled': isDisabled }]" click-outside="close()">
|
|
8
|
-
<
|
|
9
|
-
<
|
|
8
|
+
<nice-popup trigger="manual" is-open="isOpen" placement="{{ placement }}" same-width="true">
|
|
9
|
+
<nice-popup-target>
|
|
10
|
+
<div class="nice-search-button input-group" ng-class="{ 'disabled': isDisabled }">
|
|
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 }}">
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
</div>
|
|
17
|
-
|
|
18
|
-
<div class="nice-search-dropdown-wrapper">
|
|
19
|
-
<div class="nice-search-dropdown" ng-if="showDropdown && isOpen">
|
|
20
|
-
<div class="nice-search-row nice-search-row-loading" ng-if="loading && results.length == 0">
|
|
21
|
-
<nice-loader ng-if="loading"></nice-loader>
|
|
13
|
+
<button type="button" class="btn input-group-addon" ng-disabled="isDisabled" ng-click="buttonClicked()">
|
|
14
|
+
<nice-icon ng-show="!loading && model != ''" icon="icon-x"></nice-icon>
|
|
15
|
+
<nice-icon ng-show="!loading && model == ''" icon="icon-search"></nice-icon>
|
|
16
|
+
<nice-loader ng-if="loading"></nice-loader>
|
|
17
|
+
</button>
|
|
22
18
|
</div>
|
|
19
|
+
</nice-popup-target>
|
|
20
|
+
|
|
21
|
+
<nice-popup-content>
|
|
22
|
+
<div class="nice-search-dropdown" ng-if="showDropdown && isOpen">
|
|
23
|
+
<div class="nice-search-row nice-search-row-loading" ng-if="loading && results.length == 0">
|
|
24
|
+
<nice-loader ng-if="loading"></nice-loader>
|
|
25
|
+
</div>
|
|
23
26
|
|
|
24
|
-
|
|
27
|
+
<div class="nice-search-row nice-search-row-empty" ng-if="!loading && results.length == 0" translate translate-context="Nice">No results found.</div>
|
|
25
28
|
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
<div ng-repeat="result in results" class="nice-search-row" ng-class="{'active': selectedIndex == $index}" ng-click="selectItem(result)">
|
|
30
|
+
<ng-transclude>{{ result[keyForInputLabel] }}</ng-transclude>
|
|
31
|
+
</div>
|
|
28
32
|
</div>
|
|
29
|
-
</
|
|
30
|
-
</
|
|
33
|
+
</nice-popup-content>
|
|
34
|
+
</nice-popup>
|
|
31
35
|
</div>
|
|
32
36
|
</div>
|
|
33
37
|
</ng-form>
|
|
@@ -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: '@',
|
|
@@ -33,7 +33,7 @@ angular.module('niceElements')
|
|
|
33
33
|
isInline: '=',
|
|
34
34
|
help: '@',
|
|
35
35
|
required: '=',
|
|
36
|
-
placement: '@', //
|
|
36
|
+
placement: '@', // Preferred placement of the dropdown (nice-popup)
|
|
37
37
|
},
|
|
38
38
|
controller: function ($scope, $timeout, $element) {
|
|
39
39
|
$scope.loading = false;
|
|
@@ -48,51 +48,14 @@ angular.module('niceElements')
|
|
|
48
48
|
if (!$scope.model) $scope.model = "";
|
|
49
49
|
if (!$scope.placement) { $scope.placement = "bottom-start"; }
|
|
50
50
|
|
|
51
|
-
//
|
|
52
|
-
//
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
$scope.
|
|
57
|
-
strategy: 'fixed',
|
|
58
|
-
placement: $scope.placement,
|
|
59
|
-
modifiers: [
|
|
60
|
-
{
|
|
61
|
-
name: 'offset',
|
|
62
|
-
options: {
|
|
63
|
-
offset: [0, 5],
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
name: "sameWidth",
|
|
68
|
-
enabled: true,
|
|
69
|
-
phase: "beforeWrite",
|
|
70
|
-
requires: ["computeStyles"],
|
|
71
|
-
fn: function (e) {
|
|
72
|
-
const state = e.state;
|
|
73
|
-
state.styles.popper.width = state.rects.reference.width + "px";
|
|
74
|
-
},
|
|
75
|
-
effect: function (e) {
|
|
76
|
-
const state = e.state;
|
|
77
|
-
state.elements.popper.style.width = state.elements.reference.offsetWidth + "px";
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
],
|
|
81
|
-
});
|
|
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;
|
|
82
57
|
};
|
|
83
58
|
|
|
84
|
-
const setupTimer = $timeout(function () {
|
|
85
|
-
$scope.setupPopper();
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
// Popper adds scroll/resize listeners to window; remove them with the component
|
|
89
|
-
$scope.$on('$destroy', function () {
|
|
90
|
-
$timeout.cancel(setupTimer);
|
|
91
|
-
if ($scope.popper) $scope.popper.destroy();
|
|
92
|
-
$scope.popper = null;
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
|
|
96
59
|
// ------------------- On focus -------------------
|
|
97
60
|
$scope.onFocus = function () {
|
|
98
61
|
if ($scope.showDropdown && $scope.results.length == 0) {
|
|
@@ -115,22 +78,12 @@ angular.module('niceElements')
|
|
|
115
78
|
// ------------------- On focus -------------------
|
|
116
79
|
$scope.open = function () {
|
|
117
80
|
$scope.isOpen = true;
|
|
118
|
-
$timeout(function () {
|
|
119
|
-
if ($scope.popper) $scope.popper.update();
|
|
120
|
-
});
|
|
121
81
|
};
|
|
122
82
|
|
|
123
83
|
|
|
124
84
|
// ------------------- On blur -------------------
|
|
125
85
|
$scope.close = function () {
|
|
126
86
|
$scope.isOpen = false;
|
|
127
|
-
|
|
128
|
-
// const input = $element[0].getElementsByTagName('input')[0];
|
|
129
|
-
// if (input) input.blur();
|
|
130
|
-
|
|
131
|
-
$timeout(function () {
|
|
132
|
-
if ($scope.popper) $scope.popper.update();
|
|
133
|
-
});
|
|
134
87
|
};
|
|
135
88
|
|
|
136
89
|
|
|
@@ -206,7 +159,10 @@ angular.module('niceElements')
|
|
|
206
159
|
// ------------------------ Select item ------------------------
|
|
207
160
|
$scope.selectItem = function (item) {
|
|
208
161
|
if ($scope.onSelect) {
|
|
209
|
-
|
|
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);
|
|
210
166
|
$scope.clear();
|
|
211
167
|
$scope.close();
|
|
212
168
|
}
|
|
@@ -245,6 +245,10 @@
|
|
|
245
245
|
<path d="M23 12c0-3.037-1.232-5.789-3.222-7.778s-4.741-3.222-7.778-3.222-5.789 1.232-7.778 3.222-3.222 4.741-3.222 7.778 1.232 5.789 3.222 7.778 4.741 3.222 7.778 3.222 5.789-1.232 7.778-3.222 3.222-4.741 3.222-7.778zM21 12c0 2.486-1.006 4.734-2.636 6.364s-3.878 2.636-6.364 2.636-4.734-1.006-6.364-2.636-2.636-3.878-2.636-6.364 1.006-4.734 2.636-6.364 3.878-2.636 6.364-2.636 4.734 1.006 6.364 2.636 2.636 3.878 2.636 6.364z"></path>
|
|
246
246
|
</symbol>
|
|
247
247
|
|
|
248
|
+
<symbol id="icon-dot" viewBox="0 0 24 24">
|
|
249
|
+
<path d="M12 6a6 6 0 1 1 0 12a6 6 0 1 1 0-12z"></path>
|
|
250
|
+
</symbol>
|
|
251
|
+
|
|
248
252
|
<symbol id="icon-clipboard" viewBox="0 0 24 24">
|
|
249
253
|
<path d="M7 5c0 0.552 0.225 1.053 0.586 1.414s0.862 0.586 1.414 0.586h6c0.552 0 1.053-0.225 1.414-0.586s0.586-0.862 0.586-1.414h1c0.276 0 0.525 0.111 0.707 0.293s0.293 0.431 0.293 0.707v14c0 0.276-0.111 0.525-0.293 0.707s-0.431 0.293-0.707 0.293h-12c-0.276 0-0.525-0.111-0.707-0.293s-0.293-0.431-0.293-0.707v-14c0-0.276 0.111-0.525 0.293-0.707s0.431-0.293 0.707-0.293zM9 1c-0.552 0-1.053 0.225-1.414 0.586s-0.586 0.862-0.586 1.414h-1c-0.828 0-1.58 0.337-2.121 0.879s-0.879 1.293-0.879 2.121v14c0 0.828 0.337 1.58 0.879 2.121s1.293 0.879 2.121 0.879h12c0.828 0 1.58-0.337 2.121-0.879s0.879-1.293 0.879-2.121v-14c0-0.828-0.337-1.58-0.879-2.121s-1.293-0.879-2.121-0.879h-1c0-0.552-0.225-1.053-0.586-1.414s-0.862-0.586-1.414-0.586zM9 3h6v2h-6z"></path>
|
|
250
254
|
</symbol>
|
|
@@ -778,6 +782,10 @@
|
|
|
778
782
|
</symbol>
|
|
779
783
|
|
|
780
784
|
<symbol id="icon-plus" viewBox="0 0 24 24">
|
|
785
|
+
<path d="M10.5 5.5a1.5 1.5 0 0 1 3 0v5h5a1.5 1.5 0 0 1 0 3h-5v5a1.5 1.5 0 0 1-3 0v-5h-5a1.5 1.5 0 0 1 0-3h5z"></path>
|
|
786
|
+
</symbol>
|
|
787
|
+
|
|
788
|
+
<symbol id="icon-plus-2" viewBox="0 0 24 24">
|
|
781
789
|
<path d="M5 13h6v6c0 0.552 0.448 1 1 1s1-0.448 1-1v-6h6c0.552 0 1-0.448 1-1s-0.448-1-1-1h-6v-6c0-0.552-0.448-1-1-1s-1 0.448-1 1v6h-6c-0.552 0-1 0.448-1 1s0.448 1 1 1z"></path>
|
|
782
790
|
</symbol>
|
|
783
791
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<nice-title text="title || niceTitle" help="help" required="required" description="description" label-width="labelWidth"></nice-title>
|
|
5
5
|
|
|
6
6
|
<!------------------------- Field ------------------------->
|
|
7
|
-
<div class="nice-field col-xs-12" ng-class="fieldWidth ? fieldWidth : 'col-sm-8'">
|
|
7
|
+
<div class="nice-field col-xs-12" ng-class="fieldWidth ? fieldWidth : 'col-sm-8'" click-outside="close()" is-open="{{ open }}">
|
|
8
8
|
<div class="input-group" ng-class="{
|
|
9
9
|
'has-warning': !isDisabled && forma.$invalid && forma.$dirty,
|
|
10
10
|
'disabled': isDisabled
|
|
@@ -39,6 +39,4 @@
|
|
|
39
39
|
</div>
|
|
40
40
|
</div>
|
|
41
41
|
</div>
|
|
42
|
-
|
|
43
|
-
<div class="nice-background" ng-click="close()" ng-if="open"></div>
|
|
44
42
|
</div>
|