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.
Files changed (57) hide show
  1. package/.claude/launch.json +11 -0
  2. package/CHANGELOG.md +24 -0
  3. package/CLAUDE.md +1 -0
  4. package/README.md +1 -1
  5. package/bower.json +1 -1
  6. package/dist/nice.js +688 -495
  7. package/dist/nice.min.js +1 -1
  8. package/dist/style.css +140 -114
  9. package/dist/style.css.map +1 -1
  10. package/dist/style.min.css +2 -2
  11. package/package.json +5 -6
  12. package/src/components/nice-calendar/nice-calendar.html +7 -4
  13. package/src/components/nice-calendar/nice-calendar.scss +0 -9
  14. package/src/components/nice-checkbox/nice-checkbox.html +10 -4
  15. package/src/components/nice-checkbox/nice-checkbox.js +1 -0
  16. package/src/components/nice-checkbox/nice-checkbox.scss +7 -0
  17. package/src/components/nice-choice/nice-choice.js +11 -0
  18. package/src/components/nice-date/nice-date-picker.html +60 -0
  19. package/src/components/nice-date/nice-date.html +29 -77
  20. package/src/components/nice-date/nice-date.js +54 -35
  21. package/src/components/nice-date/nice-date.scss +7 -15
  22. package/src/components/nice-date-input/nice-date-input.js +1 -1
  23. package/src/components/nice-date-range/nice-date-range.html +1 -1
  24. package/src/components/nice-datetime-picker/nice-datetime-picker.html +4 -4
  25. package/src/components/nice-datetime-picker/nice-datetime-picker.scss +9 -12
  26. package/src/components/nice-datetimerange-picker/nice-datetimerange-picker.html +1 -3
  27. package/src/components/nice-datetimerange-picker-2/nice-datetimerange-picker-2.html +32 -30
  28. package/src/components/nice-datetimerange-picker-2/nice-datetimerange-picker-2.js +1 -33
  29. package/src/components/nice-datetimerange-picker-2/nice-datetimerange-picker-2.scss +7 -12
  30. package/src/components/nice-dropdown/nice-dropdown.html +42 -40
  31. package/src/components/nice-dropdown/nice-dropdown.js +64 -57
  32. package/src/components/nice-dropdown/nice-dropdown.scss +25 -15
  33. package/src/components/nice-dropdown-old/nice-dropdown-old.html +1 -1
  34. package/src/components/nice-dropdown-old/nice-dropdown-old.scss +8 -2
  35. package/src/components/nice-dtp/nice-dtp.html +7 -7
  36. package/src/components/nice-options/nice-options.scss +4 -0
  37. package/src/components/nice-percent/nice-percent.js +10 -3
  38. package/src/components/nice-popup/nice-popup.html +4 -4
  39. package/src/components/nice-popup/nice-popup.js +61 -75
  40. package/src/components/nice-popup/nice-popup.scss +10 -31
  41. package/src/components/nice-search/nice-search.html +0 -3
  42. package/src/components/nice-search/nice-search.js +8 -14
  43. package/src/components/nice-search2/nice-search2.html +22 -18
  44. package/src/components/nice-search2/nice-search2.js +2 -56
  45. package/src/components/nice-search2/nice-search2.scss +3 -2
  46. package/src/components/nice-svgs/nice-svgs.html +8 -0
  47. package/src/components/nice-time-picker/nice-time-picker.html +1 -3
  48. package/src/components/nice-time-picker/nice-time-picker.scss +0 -8
  49. package/src/components/nice-toggle/nice-toggle.html +3 -0
  50. package/src/components/nice-upload/nice-upload.html +1 -1
  51. package/src/components/nice-yesno/nice-yesno.html +3 -0
  52. package/src/directives/nice-tooltip/_nice-tooltip.scss +7 -28
  53. package/src/directives/nice-tooltip/nice-tooltip.js +16 -29
  54. package/src/services/nice-service.js +236 -1
  55. package/src/styles/_nice-anchored.scss +75 -0
  56. package/src/styles/_nice-common.scss +17 -0
  57. package/src/styles/_nice.scss +1 -0
@@ -1,45 +1,47 @@
1
1
  <div class="nice-component nice-datetimerange-picker-2" ng-form="formDateRangePicker" ng-class="{ 'margin-bottom-0': noMargin, 'nice-component-inline': isInline }">
2
- <div class="nice-dtp-background" ng-click="close()" ng-if="isOpen"></div>
3
-
4
2
  <div class="row">
5
3
  <!------------------------- Title ------------------------->
6
4
  <nice-title text="title || niceTitle" help="help" required="required" description="description" label-width="labelWidth"></nice-title>
7
5
 
8
6
  <!------------------------- Field ------------------------->
9
- <div class="nice-field col-xs-12" ng-class="[fieldWidth ? fieldWidth : 'col-sm-8', { 'nice-disabled': isDisabled }]">
10
- <div class="nice-daterange-picker-button input-group" ng-class="{ 'open': isOpen }" ng-click="open()">
11
- <input type="text" class="form-control" value="{{ modelFormat }}" readonly="readonly" ng-disabled="isDisabled" />
12
- <!-- <div class="form-control" title="{{ modelFormat }}">{{ modelFormat }}</div> -->
13
- <button type="button" class="btn input-group-addon" ng-disabled="isDisabled">
14
- <nice-icon icon="icon-calendar"></nice-icon>
15
- </button>
16
- </div>
7
+ <div class="nice-field col-xs-12" ng-class="[fieldWidth ? fieldWidth : 'col-sm-8', { 'nice-disabled': isDisabled }]" click-outside="isOpen && close()">
8
+ <nice-popup trigger="manual" is-open="isOpen" placement="{{ placement }}" on-change="isOpen || close()">
9
+ <nice-popup-target>
10
+ <div class="nice-daterange-picker-button input-group" ng-class="{ 'open': isOpen }" ng-click="open()">
11
+ <input type="text" class="form-control" value="{{ modelFormat }}" readonly="readonly" ng-disabled="isDisabled" />
12
+ <!-- <div class="form-control" title="{{ modelFormat }}">{{ modelFormat }}</div> -->
13
+ <button type="button" class="btn input-group-addon" ng-disabled="isDisabled">
14
+ <nice-icon icon="icon-calendar"></nice-icon>
15
+ </button>
16
+ </div>
17
+ </nice-popup-target>
17
18
 
18
- <div class="nice-daterange-picker-wrapper">
19
- <div class="dtp-wrapper" ng-if="isOpen">
20
- <div class="dtp-buttons-left">
21
- <div class="dtp-buttons-top">
22
- <a class="btn btn-primary btn-block" ng-click="selectToday()" translate translate-context="Nice">Last 24 hours</a>
23
- <a class="btn btn-primary btn-block" ng-click="selectLastNDays(7)" translate translate-context="Nice">Last 7 days</a>
24
- <a class="btn btn-primary btn-block" ng-click="selectLastMonth()" translate translate-context="Nice">Last month</a>
25
- <a class="btn btn-primary btn-block" ng-click="selectThisMonth()" translate translate-context="Nice">This month</a>
26
- </div>
19
+ <nice-popup-content>
20
+ <div class="dtp-wrapper">
21
+ <div class="dtp-buttons-left">
22
+ <div class="dtp-buttons-top">
23
+ <a class="btn btn-primary btn-block" ng-click="selectToday()" translate translate-context="Nice">Last 24 hours</a>
24
+ <a class="btn btn-primary btn-block" ng-click="selectLastNDays(7)" translate translate-context="Nice">Last 7 days</a>
25
+ <a class="btn btn-primary btn-block" ng-click="selectLastMonth()" translate translate-context="Nice">Last month</a>
26
+ <a class="btn btn-primary btn-block" ng-click="selectThisMonth()" translate translate-context="Nice">This month</a>
27
+ </div>
27
28
 
28
- <div class="dtp-buttons-bottom">
29
- <a class="btn btn-danger btn-block" ng-click="close()" translate translate-context="Nice">Cancel</a>
30
- <a class="btn btn-success btn-block" ng-click="confirm()" translate translate-context="Nice">OK</a>
29
+ <div class="dtp-buttons-bottom">
30
+ <a class="btn btn-danger btn-block" ng-click="close()" translate translate-context="Nice">Cancel</a>
31
+ <a class="btn btn-success btn-block" ng-click="confirm()" translate translate-context="Nice">OK</a>
32
+ </div>
31
33
  </div>
32
- </div>
33
34
 
34
- <div class="dtp-left">
35
- <nice-date model="model.innerStartDate" next-date="model.innerEndDate" is-inline="true" no-margin="true" inline="true" time="time" min-date="minDate" max-date="maxDate" on-change="dateChanged(model)"></nice-date>
36
- </div>
35
+ <div class="dtp-left">
36
+ <nice-date model="model.innerStartDate" next-date="model.innerEndDate" is-inline="true" no-margin="true" inline="true" time="time" min-date="minDate" max-date="maxDate" on-change="dateChanged(model)"></nice-date>
37
+ </div>
37
38
 
38
- <div class="dtp-right">
39
- <nice-date model="model.innerEndDate" next-date="model.innerStartDate" is-inline="true" no-margin="true" inline="true" time="time" min-date="minDate" max-date="maxDate" on-change="dateChanged(model)"></nice-date>
39
+ <div class="dtp-right">
40
+ <nice-date model="model.innerEndDate" next-date="model.innerStartDate" is-inline="true" no-margin="true" inline="true" time="time" min-date="minDate" max-date="maxDate" on-change="dateChanged(model)"></nice-date>
41
+ </div>
40
42
  </div>
41
- </div>
42
- </div>
43
+ </nice-popup-content>
44
+ </nice-popup>
43
45
  </div>
44
46
  </div>
45
47
  </div>
@@ -28,7 +28,7 @@ angular.module('niceElements')
28
28
  isInline: '=',
29
29
  onChange: '&?',
30
30
  required: '=',
31
- placement: '@', // Describes the preferred placement of the popper
31
+ placement: '@', // Preferred placement of the dropdown (nice-popup)
32
32
  },
33
33
  templateUrl: 'src/components/nice-datetimerange-picker-2/nice-datetimerange-picker-2.html',
34
34
  controller: function ($element, $timeout, $scope) {
@@ -64,37 +64,6 @@ angular.module('niceElements')
64
64
  }
65
65
 
66
66
 
67
- // Setup popper
68
- // https://popper.js.org/docs/v2/constructors/
69
- $scope.setupPopper = function () {
70
- const button = $element[0].getElementsByClassName('nice-daterange-picker-button')[0];
71
- const tooltip = $element[0].getElementsByClassName('nice-daterange-picker-wrapper')[0];
72
- $scope.popper = Popper.createPopper(button, tooltip, {
73
- strategy: 'fixed',
74
- placement: $scope.placement,
75
- modifiers: [
76
- {
77
- name: 'offset',
78
- options: {
79
- offset: [0, 5],
80
- },
81
- }
82
- ],
83
- });
84
- };
85
-
86
- const setupTimer = $timeout(function () {
87
- $scope.setupPopper();
88
- });
89
-
90
- // Popper adds scroll/resize listeners to window; remove them with the component
91
- $scope.$on('$destroy', function () {
92
- $timeout.cancel(setupTimer);
93
- if ($scope.popper) $scope.popper.destroy();
94
- $scope.popper = null;
95
- });
96
-
97
-
98
67
  $scope.format = function () {
99
68
  $scope.modelFormat = $scope.startDate.format($scope.formatString) + " - " + $scope.endDate.format($scope.formatString);
100
69
  };
@@ -103,7 +72,6 @@ angular.module('niceElements')
103
72
  $scope.open = function () {
104
73
  if (!$scope.isDisabled) {
105
74
  $scope.isOpen = true;
106
- if ($scope.popper) $scope.popper.update();
107
75
  }
108
76
  };
109
77
 
@@ -10,10 +10,14 @@
10
10
  &.open {}
11
11
  }
12
12
 
13
- .nice-daterange-picker-wrapper {
14
- z-index: 900;
13
+ // Dropdown is a nice-popup
14
+ .nice-popup-target {
15
+ display: block;
16
+ }
17
+
18
+ .nice-popup-content {
15
19
  width: 700px;
16
- max-width: 80%;
20
+ max-width: 80vw;
17
21
  }
18
22
 
19
23
  .dtp-wrapper {
@@ -73,15 +77,6 @@
73
77
  }
74
78
 
75
79
 
76
- .nice-dtp-background {
77
- position: fixed;
78
- top: 0;
79
- left: 0;
80
- width: 100%;
81
- z-index: 800;
82
- height: 100%;
83
- }
84
-
85
80
  .btn {
86
81
  border-radius: $nice-border-radius;
87
82
  }
@@ -6,50 +6,52 @@
6
6
  <!------------------------- Field ------------------------->
7
7
  <div class="nice-field col-xs-12" ng-class="[ fieldWidth ? fieldWidth : 'col-sm-8', { 'open': isOpen, 'nice-disabled': isDisabled || emptyList } ]" click-outside="close()" is-open="{{ isOpen }}">
8
8
  <div class="nice-field-wrapper">
9
- <!------------------------- Button ------------------------->
10
- <button type="button" class="btn btn-dropdown" type="button" ng-ref="dropdown-button" ng-click="toggle()" ng-disabled="isDisabled || emptyList" aria-expanded="{{ isOpen }}" aria-haspopup="true" aria-controls="menu" id="nice-dropdown-{{ id }}">
11
- <input class="hidden-input" ng-model="model" ng-required="required" ng-disabled="disabled" tabindex="-1" />
12
- <div class="btn-dropdown-inside" ng-transclude="button" ng-if="selected != null">
13
- <span ng-if="!multiple">{{ selected[objValue] }}</span>
14
- <span ng-if="multiple" class="multiple-selected" ng-class="{ 'has-more': selected.length > maxSelectedShown }">
15
- <span ng-if="selected.length > 0" class="multiple-selected-values"><span ng-repeat="item in selected | limitTo: maxSelectedShown">{{ item[objValue] }}{{ $last ? '' : ', ' }}</span></span>
16
- <span ng-if="selected.length > maxSelectedShown" class="multiple-selected-more">+{{ selected.length - maxSelectedShown }} {{ moreText }}</span>
17
- <span ng-if="selected.length == 0" class="not-selected">{{ nullableText }}</span>
18
- </span>
19
- </div>
9
+ <!------------------------- Button + menu ------------------------->
10
+ <nice-popup trigger="manual" is-open="isOpen" placement="{{ placement }}" offset-distance="{{ dropdownDistance }}" same-width="true">
11
+ <nice-popup-target>
12
+ <button type="button" class="btn btn-dropdown" type="button" ng-ref="dropdown-button" ng-click="toggle()" ng-disabled="isDisabled || emptyList" aria-expanded="{{ isOpen }}" aria-haspopup="true" aria-controls="menu" id="nice-dropdown-{{ id }}">
13
+ <input class="hidden-input" ng-model="model" ng-required="required" ng-disabled="disabled" tabindex="-1" />
14
+ <div class="btn-dropdown-inside" ng-transclude="button" ng-if="selected != null">
15
+ <span ng-if="!multiple">{{ selected[objValue] }}</span>
16
+ <span ng-if="multiple" class="multiple-selected" ng-class="{ 'has-more': selected.length > maxSelectedShown }">
17
+ <span ng-if="selected.length > 0" class="multiple-selected-values"><span ng-repeat="item in selected | limitTo: maxSelectedShown">{{ item[objValue] }}{{ $last ? '' : ', ' }}</span></span>
18
+ <span ng-if="selected.length > maxSelectedShown" class="multiple-selected-more">+{{ selected.length - maxSelectedShown }} {{ moreText }}</span>
19
+ <span ng-if="selected.length == 0" class="not-selected">{{ nullableText }}</span>
20
+ </span>
21
+ </div>
20
22
 
21
- <div class="not-selected" ng-if="selected == null">{{ selectText }}</div>
22
-
23
- <span class="caret" ng-show="!loading"></span>
24
- <nice-loader ng-if="loading"></nice-loader>
25
- </button>
23
+ <div class="not-selected" ng-if="selected == null">{{ selectText }}</div>
26
24
 
25
+ <span class="caret" ng-show="!loading"></span>
26
+ <nice-loader ng-if="loading"></nice-loader>
27
+ </button>
28
+ </nice-popup-target>
27
29
 
28
- <!------------------------- Dropdown menu ------------------------->
29
- <div class="nice-dropdown-menu-wrapper">
30
- <div class="nice-dropdown-menu" ng-if="isOpen">
31
- <div class="search-bar" ng-if="!noSearch && searchFunction">
32
- <input class="search-bar-input" ng-model="internal.search" ng-model-options="{ debounce: 500 }" ng-change="handleSearch()" placeholder="{{ searchText }}" />
33
- <div class="count" ng-if="internalList && internalList._metadata && enableLoadMore">{{ internalList.length }}/{{ internalList._metadata.count }}</div>
34
- <nice-icon ng-if="!internal.search" class="icon" icon="icon-search"></nice-icon>
35
- <nice-icon ng-if="internal.search" class="icon" icon="icon-x" ng-click="clearSearch()"></nice-icon>
36
- </div>
37
- <div class="nice-dropdown-actions" ng-if="multiple">
38
- <button type="button" class="btn btn-default btn-sm" ng-click="selectAll()" translate translate-context="Nice">All</button>
39
- <button type="button" class="btn btn-default btn-sm" ng-click="selectNone()">{{ nullableText }}</button>
40
- </div>
41
- <div class="nice-dropdown-items" aria-labelledby="nice-dropdown-{{ id }}" role="listbox">
42
- <div role="none" type="button" class="nice-no-data" ng-if="internalList && internalList.length == 0">{{ noDataText }}</div>
43
- <button type="button" role="option" class="nice-dropdown-item null-item" ng-if="!multiple && nullable && internalList.length != 0" ng-click="handleSelected(null, -1)" ng-disabled="isDisabled">
44
- {{ nullableText }}
45
- </button>
46
- <button type="button" role="option" class="nice-dropdown-item" ng-repeat="item in internalList" ng-click="handleSelected(item, $index)" ng-class="{ 'selected': item._selected }" ng-disabled="isDisabled">
47
- <div class="choice-checkbox" ng-if="multiple" role="menuitemcheckbox"><i class="fa fa-check"></i></div>
48
- <div class="choice-option" ng-transclude="option" ng-class="{ 'multiple-item': multiple }">{{ item[objValue] }}</div>
49
- </button>
30
+ <nice-popup-content>
31
+ <div class="nice-dropdown-menu" ng-if="isOpen">
32
+ <div class="search-bar" ng-if="!noSearch && searchFunction">
33
+ <input class="search-bar-input" ng-model="internal.search" ng-model-options="{ debounce: 500 }" ng-change="handleSearch()" placeholder="{{ searchText }}" />
34
+ <div class="count" ng-if="internalList && internalList._metadata && enableLoadMore">{{ internalList.length }}/{{ internalList._metadata.count }}</div>
35
+ <nice-icon ng-if="!internal.search" class="icon" icon="icon-search"></nice-icon>
36
+ <nice-icon ng-if="internal.search" class="icon" icon="icon-x" ng-click="clearSearch()"></nice-icon>
37
+ </div>
38
+ <div class="nice-dropdown-actions" ng-if="multiple">
39
+ <button type="button" class="btn btn-default btn-sm" ng-click="selectAll()" translate translate-context="Nice">All</button>
40
+ <button type="button" class="btn btn-default btn-sm" ng-click="selectNone()">{{ nullableText }}</button>
41
+ </div>
42
+ <div class="nice-dropdown-items" aria-labelledby="nice-dropdown-{{ id }}" role="listbox">
43
+ <div role="none" type="button" class="nice-no-data" ng-if="internalList && internalList.length == 0">{{ noDataText }}</div>
44
+ <button type="button" role="option" class="nice-dropdown-item null-item" ng-if="!multiple && nullable && internalList.length != 0" ng-click="handleSelected(null, -1)" ng-disabled="isDisabled">
45
+ {{ nullableText }}
46
+ </button>
47
+ <button type="button" role="option" class="nice-dropdown-item" ng-repeat="item in internalList" ng-click="handleSelected(item, $index)" ng-class="{ 'selected': item._selected }" ng-disabled="isDisabled">
48
+ <div class="choice-checkbox" ng-if="multiple" role="menuitemcheckbox"><nice-icon icon="icon-check"></nice-icon></div>
49
+ <div class="choice-option" ng-transclude="option" ng-class="{ 'multiple-item': multiple }">{{ item[objValue] }}</div>
50
+ </button>
51
+ </div>
50
52
  </div>
51
- </div>
52
- </div>
53
+ </nice-popup-content>
54
+ </nice-popup>
53
55
 
54
56
 
55
57
  <!------------------------- Add button ------------------------->
@@ -51,12 +51,13 @@ angular.module('niceElements')
51
51
  dropdownDistance: '@',
52
52
  searchFunction: '=?',
53
53
  filterFunction: '=?',
54
+ selectedFunction: '=?', // Loads selected options missing from the list: function(keys) → promise of objects
54
55
  isInline: '=',
55
56
  clearOnSelect: '@',
56
57
  enableLoadMore: '@', // Enable load more
57
- placement: '@', // Describes the preferred placement of the popper
58
+ placement: '@', // Preferred placement of the menu
58
59
  },
59
- controller: function ($scope, $attrs, $http, $element, $timeout, gettextCatalog, NiceService) {
60
+ controller: function ($scope, $attrs, $http, $q, $element, $timeout, gettextCatalog, NiceService) {
60
61
  NiceService.bindFlag($scope, $attrs, 'selectedIsKey');
61
62
  NiceService.bindFlag($scope, $attrs, 'enableLoadMore');
62
63
 
@@ -81,7 +82,6 @@ angular.module('niceElements')
81
82
  $scope.isOpen = false;
82
83
  $scope.selected = null;
83
84
  // $scope.selectedIndex = 0;
84
- $scope.popper = null;
85
85
 
86
86
  $scope.internal = {
87
87
  search: ""
@@ -91,52 +91,9 @@ angular.module('niceElements')
91
91
  $scope.originalList = angular.copy($scope.list);
92
92
  }
93
93
 
94
- // Setup popper
95
- // https://popper.js.org/docs/v2/constructors/
96
- $scope.setupPopper = function () {
97
- const button = $element[0].getElementsByClassName('btn-dropdown')[0];
98
- const tooltip = $element[0].getElementsByClassName('nice-dropdown-menu-wrapper')[0];
99
- $scope.popper = Popper.createPopper(button, tooltip, {
100
- strategy: 'fixed',
101
- placement: $scope.placement,
102
- modifiers: [
103
- {
104
- name: 'offset',
105
- options: {
106
- offset: [0, $scope.dropdownDistance],
107
- },
108
- },
109
- {
110
- name: "sameWidth",
111
- enabled: true,
112
- phase: "beforeWrite",
113
- requires: ["computeStyles"],
114
- fn: function (e) {
115
- const state = e.state;
116
- let width = state.rects.reference.width;
117
- if (width < 200) width = 200;
118
- state.styles.popper.width = width + "px";
119
- },
120
- effect: function (e) {
121
- const state = e.state;
122
- let width = state.elements.reference.width;
123
- if (width < 200) width = 200;
124
- state.elements.popper.style.width = width + "px";
125
- }
126
- }
127
- ],
128
- });
129
- };
130
-
131
- const setupTimer = $timeout(function () {
132
- $scope.setupPopper();
133
- });
134
-
135
- // Popper adds scroll/resize listeners to window; remove them with the component
136
- $scope.$on('$destroy', function () {
137
- $timeout.cancel(setupTimer);
138
- if ($scope.popper) $scope.popper.destroy();
139
- $scope.popper = null;
94
+ // The menu is a nice-popup (positioning, Escape); on-close fires on every close
95
+ $scope.$watch('isOpen', function (isOpen, wasOpen) {
96
+ if (wasOpen && !isOpen && $scope.onClose) $scope.onClose();
140
97
  });
141
98
 
142
99
 
@@ -151,18 +108,13 @@ angular.module('niceElements')
151
108
 
152
109
  $scope.close = function () {
153
110
  $scope.isOpen = false;
154
- if ($scope.onClose) $scope.onClose();
155
111
  };
156
112
 
157
113
  $scope.open = function () {
158
- if ($scope.popper) $scope.popper.update();
159
114
  if ($scope.filterFunction) $scope.internalList = $scope.filterFunction($scope.originalList, $scope.model);
160
115
  $timeout(function () {
161
116
  $scope.isOpen = true;
162
117
  if ($scope.onOpen) $scope.onOpen();
163
- $timeout(function () {
164
- if ($scope.popper) $scope.popper.update();
165
- });
166
118
  });
167
119
  $timeout(function () {
168
120
  $scope.focusInput();
@@ -408,10 +360,17 @@ angular.module('niceElements')
408
360
  $scope.handleModelChange();
409
361
  });
410
362
 
363
+ // Options seen so far by key (lists, search results, loaded with selected-function),
364
+ // so selected keys keep their label when they are not in the current list
365
+ const knownItems = {};
366
+ // Keys already passed to selected-function (load each one only once)
367
+ const requestedKeys = {};
368
+
411
369
  $scope.handleModelChange = function () {
412
370
  $scope.selected = angular.copy($scope.model);
413
371
  angular.forEach($scope.internalList, function (i, index) {
414
372
  i._selected = false;
373
+ knownItems[i[$scope.objKey]] = i;
415
374
 
416
375
  if ($scope.selectedIsKey) {
417
376
  // Not object
@@ -457,12 +416,60 @@ angular.module('niceElements')
457
416
  }
458
417
  });
459
418
 
419
+ // Selected keys that are not in the list are still raw keys here
420
+ if ($scope.selectedIsKey && $scope.selected != null) {
421
+ if ($scope.multiple) $scope.selected = $scope.selected.map($scope.resolveKey);
422
+ else $scope.selected = $scope.resolveKey($scope.selected);
423
+ $scope.loadMissingSelected();
424
+ }
425
+
460
426
  // Handle required
461
- $timeout(function () {
462
- if ($scope.formDropdown) $scope.formDropdown.$setValidity('required', !(!$scope.selected && $scope.required));
463
- });
427
+ $timeout($scope.checkRequired);
464
428
  }
465
429
 
430
+ // ----------------------------------- Selected keys missing from the list -----------------------------------
431
+ // Turn a selected key into an option: one from the list, one seen before,
432
+ // or a placeholder that shows the key (until selected-function loads it)
433
+ $scope.resolveKey = function (key) {
434
+ if (angular.isObject(key)) return key; // already an option from the list
435
+ if (knownItems[key]) return knownItems[key];
436
+ const placeholder = { _missing: true };
437
+ placeholder[$scope.objKey] = key;
438
+ placeholder[$scope.objValue] = String(key);
439
+ return placeholder;
440
+ };
441
+
442
+ // Ask selected-function for the options of placeholder keys, then show them
443
+ $scope.loadMissingSelected = function () {
444
+ if (!$scope.selectedFunction) return;
445
+ const selected = $scope.multiple ? $scope.selected : [$scope.selected];
446
+ const keys = selected.filter(function (s) {
447
+ return s._missing && !requestedKeys[s[$scope.objKey]];
448
+ }).map(function (s) {
449
+ return s[$scope.objKey];
450
+ });
451
+ if (keys.length == 0) return;
452
+
453
+ keys.forEach(function (key) { requestedKeys[key] = true; });
454
+ $q.when($scope.selectedFunction(keys)).then(function (items) {
455
+ angular.forEach(items, function (item) {
456
+ knownItems[item[$scope.objKey]] = item;
457
+ });
458
+ $scope.handleModelChange();
459
+ });
460
+ };
461
+
462
+ // ----------------------------------- Required -----------------------------------
463
+ // Form is invalid when required and nothing is selected
464
+ $scope.checkRequired = function () {
465
+ if ($scope.formDropdown) $scope.formDropdown.$setValidity('required', !(!$scope.selected && $scope.required));
466
+ };
467
+
468
+ // Re-check when required is turned on/off
469
+ $scope.$watch('required', function () {
470
+ $scope.checkRequired();
471
+ });
472
+
466
473
  // ----------------------------------- Watch for keydown and keypress -----------------------------------
467
474
  // $element.bind("keydown keypress", function (event) {
468
475
  // // Arrow Up
@@ -7,17 +7,6 @@
7
7
  position: fixed !important;
8
8
  }
9
9
 
10
- .hidden-input {
11
- height: 0;
12
- width: 100%;
13
- position: absolute;
14
- bottom: 0;
15
- left: 0;
16
- padding: 0;
17
- background: transparent;
18
- opacity: 0;
19
- }
20
-
21
10
  .open {
22
11
  .btn-dropdown {
23
12
  background: $nice-focus-bg !important;
@@ -43,8 +32,23 @@
43
32
  }
44
33
  }
45
34
 
46
- .nice-dropdown-menu-wrapper {
47
- z-index: 1000;
35
+ // Menu is a nice-popup, as wide as the button but at least 200px.
36
+ // The <nice-popup> element is the flex item next to the add button.
37
+ nice-popup {
38
+ flex-grow: 1;
39
+ min-width: 0;
40
+ }
41
+
42
+ .nice-popup-target {
43
+ display: block;
44
+
45
+ .btn-dropdown {
46
+ width: 100%;
47
+ }
48
+ }
49
+
50
+ .nice-popup-content {
51
+ min-width: 200px;
48
52
  }
49
53
 
50
54
  .nice-dropdown-menu {
@@ -149,14 +153,20 @@
149
153
  transition: all 0.2s;
150
154
  background: $nice-choice-bg;
151
155
  color: $nice-choice-bg;
152
- line-height: 22px;
153
156
  width: 25px;
154
157
  height: 25px;
155
158
  border: 1px solid $nice-border-color;
156
159
  margin-right: 1rem;
157
160
  border-radius: $nice-border-radius;
158
- text-align: center;
161
+ display: flex;
162
+ align-items: center;
163
+ justify-content: center;
159
164
  flex-shrink: 0;
165
+
166
+ .nice-icon {
167
+ width: 16px;
168
+ height: 16px;
169
+ }
160
170
  }
161
171
 
162
172
  .choice-option {
@@ -25,7 +25,7 @@
25
25
  <ul id="{{id}}" class="dropdown-menu" role="menu">
26
26
  <li id="{{id}}-{{$index}}" ng-repeat="item in internalList" ng-click="clicked(item)">
27
27
  <a href>
28
- <span class="choice-checkbox" ng-if="multiple" ng-class="{ 'selected' : isItemSelected(item) }"><i class="fa fa-check"></i></span>
28
+ <span class="choice-checkbox" ng-if="multiple" ng-class="{ 'selected' : isItemSelected(item) }"><nice-icon icon="icon-check"></nice-icon></span>
29
29
  <span ng-if="item.color_hex_code" class="dropdown-color" ng-style="{'background': item.color_hex_code}"></span>
30
30
  <span ng-class="{'multiple-item': multiple}">{{ getLabel(item) }}</span>
31
31
  <!--<span ng-if="showTax && item.value">{{ item.value * 100 }}%</span>-->
@@ -43,13 +43,19 @@
43
43
 
44
44
  background: $nice-choice-bg;
45
45
  color: $nice-choice-bg;
46
- line-height: 22px;
47
46
  width: 25px;
48
47
  height: 25px;
49
48
  border: 2px solid $nice-border-color;
50
49
  position: absolute;
51
50
  border-radius: 2px;
52
- text-align: center;
51
+ display: flex;
52
+ align-items: center;
53
+ justify-content: center;
54
+
55
+ .nice-icon {
56
+ width: 16px;
57
+ height: 16px;
58
+ }
53
59
 
54
60
  &.selected {
55
61
  border-color: $nice-choice-selected-bg;
@@ -4,27 +4,27 @@
4
4
  <div class="dtp-date-view">
5
5
  <div class="dtp-header" ng-if="!inline">
6
6
  <div class="dtp-actual-day">{{actualDay}}</div>
7
- <div class="dtp-close" ng-if="!inline"><a href="javascript:void(0);" ng-click="onCloseClick()"><i class="fa fa-close"></i></div>
7
+ <div class="dtp-close" ng-if="!inline"><a href="javascript:void(0);" ng-click="onCloseClick()"><nice-icon icon="icon-x"></nice-icon></a></div>
8
8
  </div>
9
9
  <div class="dtp-date" ng-if="!inline" ng-class="{'hidden': !showDateHeader}">
10
10
  <div>
11
11
  <div class="left center p10">
12
- <a href="javascript:void(0);" class="dtp-select-month-before" ng-click="onMonthBeforeClick()" ng-class="{'disabled': !btnMonthBeforeEnabled}"><i class="fa fa-chevron-left"></i></a>
12
+ <a href="javascript:void(0);" class="dtp-select-month-before" ng-click="onMonthBeforeClick()" ng-class="{'disabled': !btnMonthBeforeEnabled}"><nice-icon icon="icon-chevron-left"></nice-icon></a>
13
13
  </div>
14
14
  <div class="dtp-actual-month p80" ng-click="initDate()">{{actualMonth}}</div>
15
15
  <div class="right center p10">
16
- <a href="javascript:void(0);" class="dtp-select-month-after" ng-click="onMonthAfterClick()" ng-class="{'disabled': !btnMonthAfterEnabled}"><i class="fa fa-chevron-right"></i></a>
16
+ <a href="javascript:void(0);" class="dtp-select-month-after" ng-click="onMonthAfterClick()" ng-class="{'disabled': !btnMonthAfterEnabled}"><nice-icon icon="icon-chevron-right"></nice-icon></a>
17
17
  </div>
18
18
  <div class="clearfix"></div>
19
19
  </div>
20
20
  <div class="dtp-actual-num" ng-click="initDate()">{{actualNum}}</div>
21
21
  <div>
22
22
  <div class="left center p10">
23
- <a href="javascript:void(0);" class="dtp-select-year-before" ng-click="onYearBeforeClick()" ng-class="{'disabled': !btnYearBeforeEnabled}""><i class=" fa fa-chevron-left"></i></a>
23
+ <a href="javascript:void(0);" class="dtp-select-year-before" ng-click="onYearBeforeClick()" ng-class="{'disabled': !btnYearBeforeEnabled}"><nice-icon icon="icon-chevron-left"></nice-icon></a>
24
24
  </div>
25
25
  <div class="dtp-actual-year p80" ng-click="initDate()">{{actualYear}}</div>
26
26
  <div class="right center p10">
27
- <a href="javascript:void(0);" class="dtp-select-year-after" ng-click="onYearAfterClick()" ng-class="{'disabled': !btnYearAfterEnabled}"><i class="fa fa-chevron-right"></i></a>
27
+ <a href="javascript:void(0);" class="dtp-select-year-after" ng-click="onYearAfterClick()" ng-class="{'disabled': !btnYearAfterEnabled}"><nice-icon icon="icon-chevron-right"></nice-icon></a>
28
28
  </div>
29
29
  <div class="clearfix"></div>
30
30
  </div>
@@ -38,11 +38,11 @@
38
38
  <div class="dtp-picker-calendar" ng-class="{'hidden': !showCalendar}">
39
39
  <div>
40
40
  <div ng-if="inline" class="left center p10">
41
- <a href="javascript:void(0);" class="dtp-select-month-before" ng-click="onMonthBeforeClick()" ng-class="{'disabled': !btnMonthBeforeEnabled}"><i class="fa fa-chevron-left"></i></a>
41
+ <a href="javascript:void(0);" class="dtp-select-month-before" ng-click="onMonthBeforeClick()" ng-class="{'disabled': !btnMonthBeforeEnabled}"><nice-icon icon="icon-chevron-left"></nice-icon></a>
42
42
  </div>
43
43
  <div class="dtp-picker-month" ng-class="{'p80': inline}">{{monthAndYear}}</div>
44
44
  <div class="right center p10" ng-if="inline">
45
- <a href="javascript:void(0);" class="dtp-select-month-after" ng-click="onMonthAfterClick()" ng-class="{'disabled': !btnMonthAfterEnabled}"><i class="fa fa-chevron-right"></i></a>
45
+ <a href="javascript:void(0);" class="dtp-select-month-after" ng-click="onMonthAfterClick()" ng-class="{'disabled': !btnMonthAfterEnabled}"><nice-icon icon="icon-chevron-right"></nice-icon></a>
46
46
  </div>
47
47
  </div>
48
48
 
@@ -11,6 +11,10 @@
11
11
  display: flex;
12
12
  flex-direction: column;
13
13
  gap: 3px;
14
+ // Text wraps inside the cell (.btn is nowrap), also in transcluded content
15
+ white-space: normal;
16
+ overflow-wrap: anywhere;
17
+ min-width: 0;
14
18
 
15
19
  .nice-options-wrapper-icon {
16
20
  height: 20px;