nice-elements 1.15.0 → 1.16.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/.claude/launch.json +11 -0
- package/CHANGELOG.md +24 -0
- package/CLAUDE.md +1 -0
- package/README.md +1 -1
- package/bower.json +1 -1
- package/dist/nice.js +688 -495
- package/dist/nice.min.js +1 -1
- package/dist/style.css +140 -114
- 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 +7 -4
- package/src/components/nice-calendar/nice-calendar.scss +0 -9
- package/src/components/nice-checkbox/nice-checkbox.html +10 -4
- package/src/components/nice-checkbox/nice-checkbox.js +1 -0
- package/src/components/nice-checkbox/nice-checkbox.scss +7 -0
- package/src/components/nice-choice/nice-choice.js +11 -0
- package/src/components/nice-date/nice-date-picker.html +60 -0
- package/src/components/nice-date/nice-date.html +29 -77
- package/src/components/nice-date/nice-date.js +54 -35
- package/src/components/nice-date/nice-date.scss +7 -15
- package/src/components/nice-date-input/nice-date-input.js +1 -1
- package/src/components/nice-date-range/nice-date-range.html +1 -1
- package/src/components/nice-datetime-picker/nice-datetime-picker.html +4 -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 +64 -57
- package/src/components/nice-dropdown/nice-dropdown.scss +25 -15
- 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-options/nice-options.scss +4 -0
- package/src/components/nice-percent/nice-percent.js +10 -3
- 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 +0 -3
- package/src/components/nice-search/nice-search.js +8 -14
- package/src/components/nice-search2/nice-search2.html +22 -18
- package/src/components/nice-search2/nice-search2.js +2 -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/components/nice-toggle/nice-toggle.html +3 -0
- package/src/components/nice-upload/nice-upload.html +1 -1
- package/src/components/nice-yesno/nice-yesno.html +3 -0
- 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-common.scss +17 -0
- package/src/styles/_nice.scss +1 -0
|
@@ -50,7 +50,10 @@ angular.module('niceElements')
|
|
|
50
50
|
return Number(new Decimal(String(number)).toFixed(decimals, 4));
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
-
if (
|
|
53
|
+
if ($scope.model === null && $scope.required) {
|
|
54
|
+
// Required and empty: keep the field empty so ng-required marks it invalid
|
|
55
|
+
$scope.internalModel = "";
|
|
56
|
+
} else if (angular.isDefined($scope.model)) {
|
|
54
57
|
$scope.internalModel = roundN((angular.copy($scope.model) * 100), 6);
|
|
55
58
|
} else {
|
|
56
59
|
$scope.internalModel = "0";
|
|
@@ -63,7 +66,8 @@ angular.module('niceElements')
|
|
|
63
66
|
if (parseFloat($scope.internalModel) > 100) $scope.internalModel = 100;
|
|
64
67
|
$scope.model = roundN(parseFloat($scope.internalModel) / 100, 6);
|
|
65
68
|
} else {
|
|
66
|
-
|
|
69
|
+
// Cleared field: null when required (so the form is invalid), otherwise 0
|
|
70
|
+
$scope.model = $scope.required ? null : 0;
|
|
67
71
|
}
|
|
68
72
|
if ($scope.onChange) $scope.onChange({ model: $scope.model });
|
|
69
73
|
};
|
|
@@ -85,11 +89,14 @@ angular.module('niceElements')
|
|
|
85
89
|
$scope.$watch('model', function (value_new, value_old) {
|
|
86
90
|
if (value_new) {
|
|
87
91
|
$scope.internalModel = roundN(angular.copy($scope.model) * 100, 6);
|
|
92
|
+
} else if (value_new === null && $scope.required) {
|
|
93
|
+
$scope.internalModel = "";
|
|
88
94
|
}
|
|
89
95
|
});
|
|
90
96
|
|
|
91
97
|
$scope.$watch('internalModel', function (value_new, value_old) {
|
|
92
|
-
|
|
98
|
+
// Empty field falls back to 0, unless required (then it stays empty and invalid)
|
|
99
|
+
if (!$scope.internalModel && !$scope.required) {
|
|
93
100
|
$scope.internalModel = "0";
|
|
94
101
|
}
|
|
95
102
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
<div class="nice-popup" click-outside="
|
|
2
|
-
<div class="nice-popup-target" ng-transclude="target" ng-click="
|
|
1
|
+
<div class="nice-popup" click-outside="clickedOutside()">
|
|
2
|
+
<div class="nice-popup-target" ng-transclude="target" ng-click="targetClicked()"></div>
|
|
3
3
|
<div class="nice-popup-content">
|
|
4
|
-
<div class="nice-popup-arrow"
|
|
4
|
+
<div class="nice-popup-arrow" ng-show="isOpen && showArrow"></div>
|
|
5
5
|
<div ng-transclude="content" ng-if="isOpen"></div>
|
|
6
6
|
</div>
|
|
7
|
-
</div>
|
|
7
|
+
</div>
|
|
@@ -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
|
+
}
|
|
@@ -9,15 +9,12 @@
|
|
|
9
9
|
<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
10
|
|
|
11
11
|
<button type="button" class="btn input-group-addon" ng-click="search()" ng-if="!model" ng-disabled="isDisabled">
|
|
12
|
-
<!-- <i ng-show="!loading" class="fa fa-search"></i>
|
|
13
|
-
<i ng-show="loading" class="fa fa-refresh fa-spin"></i> -->
|
|
14
12
|
<!-- <nice-icon ng-show="loading" icon="icon-loader" class="d-block nice-animation-spin"></nice-icon> -->
|
|
15
13
|
<nice-icon ng-show="!loading" icon="icon-search"></nice-icon>
|
|
16
14
|
<nice-loader ng-if="loading"></nice-loader>
|
|
17
15
|
</button>
|
|
18
16
|
|
|
19
17
|
<button type="button" class="btn input-group-addon" ng-click="remove()" ng-if="model" ng-disabled="isDisabled">
|
|
20
|
-
<!-- <i ng-show="!loading" class="fa fa-remove"></i> -->
|
|
21
18
|
<nice-icon ng-show="!loading" icon="icon-x"></nice-icon>
|
|
22
19
|
</button>
|
|
23
20
|
</div>
|
|
@@ -43,7 +43,6 @@ angular.module('niceElements')
|
|
|
43
43
|
if (!attrs.placeholder) { attrs.placeholder = ''; }
|
|
44
44
|
if (!attrs.fieldWidth) { attrs.fieldWidth = 'col-sm-8'; }
|
|
45
45
|
if (!attrs.labelWidth) { attrs.labelWidth = 'col-sm-4'; }
|
|
46
|
-
if (!attrs.setText) { attrs.setText = ''; }
|
|
47
46
|
|
|
48
47
|
attrs.required = attrs.required === 'true' || attrs.required === true;
|
|
49
48
|
attrs.hideValid = attrs.hideValid === 'true' || attrs.hideValid === true;
|
|
@@ -69,8 +68,9 @@ angular.module('niceElements')
|
|
|
69
68
|
});
|
|
70
69
|
|
|
71
70
|
// Set default text
|
|
71
|
+
// (skip when set-text is not used, so the label of a preset model below is kept)
|
|
72
72
|
scope.$watch("setText", function () {
|
|
73
|
-
scope.modelString = scope.setText;
|
|
73
|
+
if (angular.isDefined(scope.setText)) scope.modelString = scope.setText;
|
|
74
74
|
});
|
|
75
75
|
|
|
76
76
|
// Check if object is defined
|
|
@@ -81,18 +81,12 @@ angular.module('niceElements')
|
|
|
81
81
|
scope.modelString = scope.model;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
scope.$watch('model', function (newValue) {
|
|
91
|
-
if (scope.model && scope.model.id) {
|
|
92
|
-
setValid(true);
|
|
93
|
-
} else {
|
|
94
|
-
setValid(false);
|
|
95
|
-
}
|
|
84
|
+
// When required, an object (with id) has to be selected. Also re-check when
|
|
85
|
+
// `required` changes, so turning it off clears the error.
|
|
86
|
+
scope.$watchGroup(['model', 'required'], function () {
|
|
87
|
+
if (!scope.form) return;
|
|
88
|
+
const hasObject = !!(scope.model && scope.model.id);
|
|
89
|
+
scope.form.$setValidity('objectSelected', !scope.required || hasObject);
|
|
96
90
|
});
|
|
97
91
|
|
|
98
92
|
scope.selectRow = function (obj) {
|
|
@@ -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="model" 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>
|
|
@@ -32,7 +32,8 @@ angular.module('niceElements')
|
|
|
32
32
|
debounceTime: '@',
|
|
33
33
|
isInline: '=',
|
|
34
34
|
help: '@',
|
|
35
|
-
|
|
35
|
+
required: '=',
|
|
36
|
+
placement: '@', // Preferred placement of the dropdown (nice-popup)
|
|
36
37
|
},
|
|
37
38
|
controller: function ($scope, $timeout, $element) {
|
|
38
39
|
$scope.loading = false;
|
|
@@ -47,51 +48,6 @@ angular.module('niceElements')
|
|
|
47
48
|
if (!$scope.model) $scope.model = "";
|
|
48
49
|
if (!$scope.placement) { $scope.placement = "bottom-start"; }
|
|
49
50
|
|
|
50
|
-
// Setup popper
|
|
51
|
-
// https://popper.js.org/docs/v2/constructors/
|
|
52
|
-
$scope.setupPopper = function () {
|
|
53
|
-
const button = $element[0].getElementsByClassName('nice-search-button')[0];
|
|
54
|
-
const tooltip = $element[0].getElementsByClassName('nice-search-dropdown-wrapper')[0];
|
|
55
|
-
$scope.popper = Popper.createPopper(button, tooltip, {
|
|
56
|
-
strategy: 'fixed',
|
|
57
|
-
placement: $scope.placement,
|
|
58
|
-
modifiers: [
|
|
59
|
-
{
|
|
60
|
-
name: 'offset',
|
|
61
|
-
options: {
|
|
62
|
-
offset: [0, 5],
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
name: "sameWidth",
|
|
67
|
-
enabled: true,
|
|
68
|
-
phase: "beforeWrite",
|
|
69
|
-
requires: ["computeStyles"],
|
|
70
|
-
fn: function (e) {
|
|
71
|
-
const state = e.state;
|
|
72
|
-
state.styles.popper.width = state.rects.reference.width + "px";
|
|
73
|
-
},
|
|
74
|
-
effect: function (e) {
|
|
75
|
-
const state = e.state;
|
|
76
|
-
state.elements.popper.style.width = state.elements.reference.offsetWidth + "px";
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
],
|
|
80
|
-
});
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
const setupTimer = $timeout(function () {
|
|
84
|
-
$scope.setupPopper();
|
|
85
|
-
});
|
|
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
|
-
|
|
94
|
-
|
|
95
51
|
// ------------------- On focus -------------------
|
|
96
52
|
$scope.onFocus = function () {
|
|
97
53
|
if ($scope.showDropdown && $scope.results.length == 0) {
|
|
@@ -114,22 +70,12 @@ angular.module('niceElements')
|
|
|
114
70
|
// ------------------- On focus -------------------
|
|
115
71
|
$scope.open = function () {
|
|
116
72
|
$scope.isOpen = true;
|
|
117
|
-
$timeout(function () {
|
|
118
|
-
if ($scope.popper) $scope.popper.update();
|
|
119
|
-
});
|
|
120
73
|
};
|
|
121
74
|
|
|
122
75
|
|
|
123
76
|
// ------------------- On blur -------------------
|
|
124
77
|
$scope.close = function () {
|
|
125
78
|
$scope.isOpen = false;
|
|
126
|
-
|
|
127
|
-
// const input = $element[0].getElementsByTagName('input')[0];
|
|
128
|
-
// if (input) input.blur();
|
|
129
|
-
|
|
130
|
-
$timeout(function () {
|
|
131
|
-
if ($scope.popper) $scope.popper.update();
|
|
132
|
-
});
|
|
133
79
|
};
|
|
134
80
|
|
|
135
81
|
|
|
@@ -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>
|
|
@@ -18,6 +18,9 @@
|
|
|
18
18
|
|
|
19
19
|
<!------------------------- Field ------------------------->
|
|
20
20
|
<div class="nice-field col-xs-12" ng-class="[fieldWidth ? fieldWidth : 'col-sm-8', { 'nice-disabled': isDisabled }]">
|
|
21
|
+
<!-- Only for form validation (toggle must be on when required) -->
|
|
22
|
+
<input type="checkbox" class="hidden-input" ng-model="model" ng-required="required" tabindex="-1" />
|
|
23
|
+
|
|
21
24
|
<button type="button" class="nice-toggle-field" ng-click="toggle()" ng-disabled="isDisabled">
|
|
22
25
|
<div class="nice-toggle-field-handle">
|
|
23
26
|
<nice-icon ng-if="showIcons && model" icon="icon-check"></nice-icon>
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
</button>
|
|
26
26
|
|
|
27
27
|
<!-- Input file -->
|
|
28
|
-
<input class="input-file" type="file" accept="{{ accept }}" ng-model="file" ng-required="required" ng-disabled="isDisabled || loading" />
|
|
28
|
+
<input class="input-file" type="file" accept="{{ accept }}" ng-model="file" ng-required="required && !model" ng-disabled="isDisabled || loading" />
|
|
29
29
|
|
|
30
30
|
<!-- Loading -->
|
|
31
31
|
<div class="nice-upload-loading" ng-if="loading">
|
|
@@ -5,6 +5,9 @@
|
|
|
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
|
+
<!-- Only for form validation (yes or no has to be chosen when required) -->
|
|
9
|
+
<input class="hidden-input" ng-model="model" ng-required="required" tabindex="-1" />
|
|
10
|
+
|
|
8
11
|
<div class="yesno-wrapper noselect">
|
|
9
12
|
<button type="button" class="yesno-yes-bg" ng-click="switch()" tabindex="-1" ng-disabled="isDisabled">{{ yes }}</button>
|
|
10
13
|
<button type="button" class="yesno-no-bg" ng-click="switch()" tabindex="-1" ng-disabled="isDisabled">{{ no }}</button>
|
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
// cursor: help;
|
|
3
3
|
}
|
|
4
4
|
|
|
5
|
+
// Positioning and arrow placement come from _nice-anchored.scss
|
|
5
6
|
.nice-tooltip-window {
|
|
6
|
-
display: none;
|
|
7
|
-
position: relative;
|
|
8
7
|
background: var(--nice-help-popup-bg);
|
|
9
8
|
color: var(--nice-help-popup-color);
|
|
10
9
|
max-width: 200px;
|
|
@@ -15,41 +14,21 @@
|
|
|
15
14
|
font-weight: normal;
|
|
16
15
|
text-transform: none;
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.nice-tooltip-window-arrow,
|
|
23
|
-
.nice-tooltip-window-arrow::before {
|
|
24
|
-
position: absolute;
|
|
25
|
-
width: 8px;
|
|
26
|
-
height: 8px;
|
|
27
|
-
background: inherit;
|
|
17
|
+
&.nice-anchored-fallback {
|
|
18
|
+
z-index: 1100;
|
|
28
19
|
}
|
|
29
20
|
|
|
30
21
|
.nice-tooltip-window-arrow {
|
|
31
22
|
visibility: hidden;
|
|
32
23
|
|
|
33
24
|
&::before {
|
|
25
|
+
position: absolute;
|
|
26
|
+
width: 8px;
|
|
27
|
+
height: 8px;
|
|
28
|
+
background: var(--nice-help-popup-bg);
|
|
34
29
|
visibility: visible;
|
|
35
30
|
content: "";
|
|
36
31
|
transform: rotate(45deg);
|
|
37
32
|
}
|
|
38
33
|
}
|
|
39
|
-
|
|
40
|
-
&[data-popper-placement^="top"] > .nice-tooltip-window-arrow {
|
|
41
|
-
bottom: -4px;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
&[data-popper-placement^="bottom"] > .nice-tooltip-window-arrow {
|
|
45
|
-
top: -4px;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
&[data-popper-placement^="left"] > .nice-tooltip-window-arrow {
|
|
49
|
-
right: -4px;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
&[data-popper-placement^="right"] > .nice-tooltip-window-arrow {
|
|
53
|
-
left: -4px;
|
|
54
|
-
}
|
|
55
34
|
}
|