nice-elements 1.13.7 → 1.14.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 (35) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +1 -1
  3. package/bower.json +1 -1
  4. package/dist/nice.js +2760 -5123
  5. package/dist/nice.min.js +1 -1
  6. package/dist/style.css +413 -983
  7. package/dist/style.css.map +1 -59
  8. package/dist/style.min.css +2 -2
  9. package/package.json +6 -6
  10. package/src/components/nice-comment/nice-comment.js +11 -11
  11. package/src/components/nice-comment/nice-comment.scss +0 -2
  12. package/src/components/nice-date/nice-date.js +12 -2
  13. package/src/components/nice-datetimerange-picker-2/nice-datetimerange-picker-2.js +9 -2
  14. package/src/components/nice-dropdown/nice-dropdown.js +16 -15
  15. package/src/components/nice-help/nice-help.html +3 -4
  16. package/src/components/nice-help/nice-help.js +10 -37
  17. package/src/components/nice-help/nice-help.scss +59 -27
  18. package/src/components/nice-input/nice-input.html +11 -1
  19. package/src/components/nice-input/nice-input.js +38 -10
  20. package/src/components/nice-input/nice-input.scss +11 -0
  21. package/src/components/nice-notification/nice-notification.html +9 -4
  22. package/src/components/nice-notification/nice-notification.js +66 -46
  23. package/src/components/nice-notification/nice-notification.scss +97 -19
  24. package/src/components/nice-number/nice-number.html +35 -4
  25. package/src/components/nice-number/nice-number.js +40 -7
  26. package/src/components/nice-popup/nice-popup.js +10 -5
  27. package/src/components/nice-search2/nice-search2.js +15 -5
  28. package/src/components/nice-toggle/nice-toggle.html +18 -2
  29. package/src/components/nice-toggle/nice-toggle.js +4 -1
  30. package/src/components/nice-toggle/nice-toggle.scss +31 -0
  31. package/src/components/nice-view/_nice-view.scss +22 -0
  32. package/src/components/nice-virtual-scroll/nice-virtual-scroll.js +15 -3
  33. package/src/directives/nice-click-outside.js +24 -18
  34. package/src/directives/nice-tooltip/nice-tooltip.js +14 -4
  35. package/src/services/nice-service.js +14 -1
@@ -10,12 +10,35 @@ angular.module('niceElements')
10
10
  .factory('NiceNotification', function ($timeout, $http, $compile, $templateCache, $rootScope, $sce) {
11
11
 
12
12
  let startTop = 10;
13
- let startRight = 10;
14
13
  let verticalSpacing = 10;
15
- let horizontalSpacing = 10;
16
14
  let delay = 5000;
17
15
 
18
- const messageElements = [];
16
+ // Default icon per type (primary has none). Override with notify.config({ icons: { ... } })
17
+ const icons = {
18
+ success: 'icon-check-circle',
19
+ error: 'icon-alert-triangle',
20
+ warning: 'icon-alert-circle',
21
+ info: 'icon-info',
22
+ };
23
+
24
+ // All notifications live in one fixed container; CSS (flexbox) does the stacking
25
+ let container = null;
26
+
27
+ const applyConfig = function () {
28
+ if (!container) return;
29
+ container.style.setProperty('--nice-notification-top', startTop + 'px');
30
+ container.style.setProperty('--nice-notification-spacing', verticalSpacing + 'px');
31
+ };
32
+
33
+ const getContainer = function () {
34
+ if (!container || !document.body.contains(container)) {
35
+ container = document.createElement('div');
36
+ container.className = 'nice-notifications';
37
+ applyConfig();
38
+ document.body.appendChild(container);
39
+ }
40
+ return container;
41
+ };
19
42
 
20
43
  const notify = function (args, t) {
21
44
 
@@ -33,6 +56,8 @@ angular.module('niceElements')
33
56
  scope.message = $sce.trustAsHtml(args.message);
34
57
  scope.title = $sce.trustAsHtml(args.title);
35
58
  scope.t = args.type.substr(0, 1);
59
+ // icon: undefined → type default, false/null/'' → no icon, string → that icon id
60
+ scope.icon = angular.isUndefined(args.icon) ? icons[args.type] : args.icon;
36
61
  scope.delay = args.delay;
37
62
 
38
63
  if (typeof args.scope === 'object') {
@@ -41,54 +66,42 @@ angular.module('niceElements')
41
66
  }
42
67
  }
43
68
 
44
- const reposite = function () {
45
- let j = 0;
46
- let k = 0;
47
- let lastTop = startTop;
48
- let top = 0;
49
- // const lastRight = startRight;
50
- for (let i = messageElements.length - 1; i >= 0; i--) {
51
- const element = messageElements[i];
52
- const elHeight = parseInt(element[0].offsetHeight);
53
- const elWidth = parseInt(element[0].offsetWidth);
54
- if ((top + elHeight) > window.innerHeight) {
55
- lastTop = startTop;
56
- k++;
57
- j = 0;
58
- }
59
- top = lastTop + (j === 0 ? 0 : verticalSpacing);
60
- const right = startRight + (k * (horizontalSpacing + elWidth));
61
-
62
- element.css('top', top + 'px');
63
- element.css('right', right + 'px');
64
-
65
- lastTop = top + elHeight;
66
- j++;
67
- }
68
- };
69
-
70
69
  const templateElement = $compile(template)(scope);
71
70
  templateElement.addClass(args.type);
72
- templateElement.bind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd click', function (e) {
73
- e = e.originalEvent || e;
74
- if (e.type === 'click' || (e.propertyName === 'opacity' && e.elapsedTime >= 0.4)) {
75
- templateElement.remove();
76
- messageElements.splice(messageElements.indexOf(templateElement), 1);
77
- reposite();
78
- }
79
- });
80
71
 
81
- $timeout(function () {
72
+ let closed = false;
73
+ let closeTimer = null;
74
+
75
+ // Single exit path: safe to call any number of times (click + timer)
76
+ const close = function () {
77
+ if (closed) return;
78
+ closed = true;
79
+ if (closeTimer) $timeout.cancel(closeTimer);
80
+
81
+ // Mark as closed; the leave animation is defined entirely in CSS (.killed).
82
+ // Remove the element once whatever CSS animations it has are done
83
+ // (resolves right away if there are none, e.g. a custom template).
84
+ const el = templateElement[0];
82
85
  templateElement.addClass('killed');
83
- templateElement.remove();
84
- messageElements.splice(messageElements.indexOf(templateElement), 1);
85
- reposite();
86
- }, args.delay);
86
+ const running = el.getAnimations ? el.getAnimations() : [];
87
+ // An interrupted enter animation rejects its promise; treat that as done
88
+ // so it doesn't cut the leave transitions short.
89
+ Promise.all(running.map(function (a) { return a.finished.catch(angular.noop); }))
90
+ .then(function () {
91
+ templateElement.remove();
92
+ scope.$destroy();
93
+ });
94
+ };
87
95
 
88
- angular.element(document.getElementsByTagName('body')).append(templateElement);
89
- messageElements.push(templateElement);
96
+ templateElement.on('click', close);
90
97
 
91
- $timeout(reposite);
98
+ // Newest on top; the CSS enter animation runs on insertion
99
+ const list = getContainer();
100
+ list.insertBefore(templateElement[0], list.firstChild);
101
+
102
+ if (args.delay > 0) {
103
+ closeTimer = $timeout(close, args.delay);
104
+ }
92
105
 
93
106
  }).error(function (data) {
94
107
  throw new Error('Template (' + args.template + ') could not be loaded. ' + data);
@@ -98,6 +111,13 @@ angular.module('niceElements')
98
111
  notify.config = function (args) {
99
112
  startTop = args.top ? args.top : startTop;
100
113
  verticalSpacing = args.verticalSpacing ? args.verticalSpacing : verticalSpacing;
114
+ applyConfig();
115
+ if (args.icons) {
116
+ // Use 'primary' as the key for the default type
117
+ angular.forEach(args.icons, function (icon, type) {
118
+ icons[type === 'primary' ? '' : type] = icon;
119
+ });
120
+ }
101
121
  };
102
122
 
103
123
  notify.primary = function (args) {
@@ -122,4 +142,4 @@ angular.module('niceElements')
122
142
 
123
143
 
124
144
  return notify;
125
- });
145
+ });
@@ -1,31 +1,113 @@
1
- .notification {
1
+ // Stack container: newest on top, top-right corner. When a column fills the
2
+ // viewport height, older notifications wrap into a new column to the left.
3
+ .nice-notifications {
4
+ --nice-notification-top: 10px;
5
+ --nice-notification-spacing: 10px;
2
6
  position: fixed;
7
+ top: var(--nice-notification-top);
3
8
  right: 10px;
4
- top: -100px;
5
9
  z-index: 99999;
6
- //box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.3);
10
+ display: flex;
11
+ flex-direction: column;
12
+ flex-wrap: wrap-reverse;
13
+ align-items: flex-end;
14
+ align-content: flex-start;
15
+ column-gap: 10px;
16
+ max-height: calc(100vh - var(--nice-notification-top));
17
+ pointer-events: none; // clicks pass through the empty container area
18
+ }
19
+
20
+ @keyframes nice-notification-in {
21
+ from {
22
+ grid-template-rows: minmax(0, 0fr);
23
+ margin-bottom: 0;
24
+ opacity: 0;
25
+ transform: translateX(40px) scale(0.96);
26
+ }
27
+ }
28
+
29
+ // Slide out and fade, then collapse so the cards below close the gap
30
+ @keyframes nice-notification-out {
31
+ 40% {
32
+ grid-template-rows: minmax(0, 1fr);
33
+ margin-bottom: var(--nice-notification-spacing, 10px);
34
+ opacity: 0;
35
+ transform: translateX(60px) scale(0.96);
36
+ }
37
+
38
+ to {
39
+ grid-template-rows: minmax(0, 0fr);
40
+ margin-bottom: 0;
41
+ opacity: 0;
42
+ transform: translateX(60px) scale(0.96);
43
+ }
44
+ }
45
+
46
+ @keyframes nice-notification-fade-out {
47
+ to {
48
+ opacity: 0;
49
+ }
50
+ }
51
+
52
+ .notification {
53
+ // Single grid row animated between 0fr and 1fr: lets the card collapse/expand
54
+ // to its natural height so the cards below slide smoothly, without JS
55
+ display: grid;
56
+ grid-template-rows: minmax(0, 1fr);
57
+ overflow: hidden; // clip content while the row is collapsed
58
+ margin-bottom: var(--nice-notification-spacing, 10px);
59
+ pointer-events: auto;
7
60
  border-radius: $border-radius-base;
8
61
  cursor: pointer;
9
62
  font-weight: normal;
10
63
  min-width: 300px;
11
- padding: 10px 15px;
12
64
  color: $nice-notification-color;
13
65
  background: $nice-notification-bg;
14
- transform: all 0.5s ease;
66
+ box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
67
+ animation: nice-notification-in 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
68
+ transition: opacity 0.2s ease;
15
69
 
70
+ // Leave. A keyframe animation (not a transition) so it also plays when the
71
+ // enter animation is interrupted. JS removes the element when it finishes,
72
+ // so the duration lives only here.
16
73
  &.killed {
17
- opacity: 0;
18
- transform: opacity 0.5s ease;
74
+ animation: nice-notification-out 0.4s ease forwards;
75
+ pointer-events: none;
76
+ }
77
+
78
+ @media (prefers-reduced-motion: reduce) {
79
+ animation-name: none;
80
+
81
+ &.killed {
82
+ animation: nice-notification-fade-out 0.2s ease forwards;
83
+ }
84
+ }
85
+
86
+ .notification-inner {
87
+ min-height: 0; // required for the 0fr collapse
88
+ overflow: hidden;
89
+ display: flex;
90
+ align-items: center;
91
+ padding: 1rem;
92
+ }
93
+
94
+ // Icon sits left of the title/message, aligned with the first line
95
+ .notification-icon {
96
+ flex: 0 0 auto;
97
+ width: 20px;
98
+ height: 20px;
99
+ margin-right: 0.5rem;
19
100
  }
20
101
 
21
- &>h3 {
102
+ .notification-content {
103
+ flex: 1 1 auto;
104
+ min-width: 0;
105
+ }
106
+
107
+ .notification-title {
22
108
  display: block;
23
- margin: 10px 10px 0 10px;
24
- padding: 0 0 5px 0;
25
109
  text-align: left;
26
- font-size: $font-size-large;
27
- font-style: normal;
28
- color: white;
110
+ font-size: 1em;
29
111
  font-weight: bold;
30
112
  }
31
113
 
@@ -37,10 +119,6 @@
37
119
  }
38
120
  }
39
121
 
40
- &>.message {
41
- margin: 10px 10px 10px 10px;
42
- }
43
-
44
122
  &.warning {
45
123
  color: $nice-notification-warning-color;
46
124
  background: $nice-notification-warning-bg;
@@ -61,7 +139,7 @@
61
139
  background: $nice-notification-info-bg;
62
140
  }
63
141
 
64
- &:hover {
65
- opacity: 0.7;
142
+ &:hover:not(.killed) {
143
+ opacity: 0.85;
66
144
  }
67
145
  }
@@ -1,4 +1,11 @@
1
- <div class="nice-component nice-number" ng-form="niceNumberForm" ng-class="{ 'margin-bottom-0' : noMargin, 'nice-component-inline': isInline }">
1
+ <div
2
+ class="nice-component nice-number"
3
+ ng-form="niceNumberForm"
4
+ ng-class="[{
5
+ 'margin-bottom-0' : noMargin,
6
+ 'nice-component-inline': isInline
7
+ }]"
8
+ >
2
9
  <div ng-class="{'row' : !disableRow}">
3
10
  <!------------------------- Title ------------------------->
4
11
  <nice-title text="title || niceTitle" help="help" required="required" description="description" label-width="labelWidth"></nice-title>
@@ -7,15 +14,39 @@
7
14
  <div class="nice-field col-xs-12" ng-class="[fieldWidth ? fieldWidth : 'col-sm-8', { 'nice-disabled': isDisabled }]">
8
15
  <div class="input-group" ng-class="{'has-warning': !isDisabled && niceNumberForm.$invalid && niceNumberForm.$dirty}">
9
16
  <span class="input-group-btn">
10
- <button type="button" class="btn btn-default btn-left" ng-disabled="!canSubtract || isDisabled" ng-click="subtract()" tabindex="-1">
17
+ <!-- Subtract -->
18
+ <button
19
+ type="button"
20
+ class="btn btn-default btn-left"
21
+ ng-disabled="!canSubtract || isDisabled"
22
+ ng-click="subtract()"
23
+ tabindex="-1
24
+ ">
11
25
  <nice-icon icon="icon-minus"></nice-icon>
12
26
  </button>
13
27
  </span>
14
28
 
15
- <input type="number" step="{{ step }}" ng-change="inputChanged()" class="form-control" max="{{ max }}" min="{{ min }}" ng-disabled="isDisabled" ng-model="model" />
29
+ <!-- Value -->
30
+ <input
31
+ type="number"
32
+ step="{{ step }}"
33
+ ng-change="inputChanged()"
34
+ class="form-control"
35
+ max="{{ max }}"
36
+ min="{{ min }}"
37
+ ng-disabled="isDisabled"
38
+ ng-model="internal.value"
39
+ />
16
40
 
17
41
  <span class="input-group-btn">
18
- <button type="button" class="btn btn-default btn-right" ng-disabled="!canAdd || isDisabled" ng-click="add()" tabindex="-1">
42
+ <!-- Add -->
43
+ <button
44
+ type="button"
45
+ class="btn btn-default btn-right"
46
+ ng-disabled="!canAdd || isDisabled"
47
+ ng-click="add()"
48
+ tabindex="-1"
49
+ >
19
50
  <nice-icon icon="icon-plus"></nice-icon>
20
51
  </button>
21
52
  </span>
@@ -36,7 +36,7 @@ angular.module('niceElements')
36
36
  onChange: '&?'
37
37
  },
38
38
 
39
- controller: function ($scope, $timeout) {
39
+ controller: function ($scope, $timeout, NiceService) {
40
40
  $scope.canAdd = true;
41
41
  $scope.canSubtract = true;
42
42
  $scope.preventZero = $scope.preventZero == "true";
@@ -75,8 +75,13 @@ angular.module('niceElements')
75
75
  if ($scope.innerStep == "any") $scope.innerStep = 1; // Fix step any
76
76
  if (Number.isNaN($scope.innerStep)) $scope.innerStep = 1; // Fix step any
77
77
 
78
+ // Decimal.js model is kept as Decimal (same constructor), input works with number
79
+ $scope.decimalConstructor = NiceService.isDecimal($scope.model) ? $scope.model.constructor : null;
80
+
78
81
  // Check if number is defined
79
- if (!$scope.model) {
82
+ if ($scope.decimalConstructor) {
83
+ // Keep Decimal
84
+ } else if (!$scope.model) {
80
85
  $scope.model = $scope.defaultValue;
81
86
  } else {
82
87
  if (parseFloat($scope.model)) {
@@ -126,14 +131,42 @@ angular.module('niceElements')
126
131
  });
127
132
 
128
133
 
134
+ // Input model. <input type="number"> needs a number, so Decimal model is converted.
135
+ const toInternal = function (value) {
136
+ return NiceService.isDecimal(value) ? value.toNumber() : value;
137
+ };
138
+
139
+ const setModel = function (value) {
140
+ if ($scope.decimalConstructor && value != null && !NiceService.isDecimal(value)) {
141
+ value = new $scope.decimalConstructor(value);
142
+ }
143
+ $scope.model = value;
144
+ };
145
+
146
+ $scope.internal = {
147
+ value: toInternal($scope.model)
148
+ };
149
+
150
+
129
151
  // On input change
130
152
  $scope.inputChanged = function () {
153
+ setModel($scope.internal.value);
131
154
  $scope.check();
132
155
  };
133
156
 
134
157
 
135
- // Watch for model change
136
- $scope.$watch("model", function (oldModel, newModel) {
158
+ // Watch for model change. Decimal is watched by value, because parent can replace it with new equal object.
159
+ $scope.$watch(function () {
160
+ return NiceService.isDecimal($scope.model) ? $scope.model.toString() : $scope.model;
161
+ }, function (oldModel, newModel) {
162
+ if (NiceService.isDecimal($scope.model)) {
163
+ $scope.decimalConstructor = $scope.model.constructor;
164
+ } else if ($scope.model != null) {
165
+ $scope.decimalConstructor = null; // Parent switched to plain value
166
+ }
167
+ if (toInternal($scope.model) !== $scope.internal.value) {
168
+ $scope.internal.value = toInternal($scope.model);
169
+ }
137
170
  $scope.check();
138
171
  if ($scope.onChange && oldModel != newModel) {
139
172
  $timeout(function () {
@@ -148,11 +181,11 @@ angular.module('niceElements')
148
181
  const result = new Decimal($scope.model != undefined ? $scope.model : $scope.defaultValue).plus($scope.innerStep).toNumber(); //.toFixed($scope.decimals);
149
182
  if ($scope.max) {
150
183
  if (result <= parseFloat($scope.max)) {
151
- $scope.model = result;
184
+ setModel(result);
152
185
  $scope.niceNumberForm.$setDirty();
153
186
  }
154
187
  } else {
155
- $scope.model = result;
188
+ setModel(result);
156
189
  $scope.niceNumberForm.$setDirty();
157
190
  }
158
191
  $scope.check();
@@ -163,7 +196,7 @@ angular.module('niceElements')
163
196
  $scope.subtract = function () {
164
197
  const result = new Decimal($scope.model != undefined ? $scope.model : $scope.defaultValue).minus($scope.innerStep).toNumber();
165
198
  if (result >= Number($scope.min)) {
166
- $scope.model = result;
199
+ setModel(result);
167
200
  $scope.niceNumberForm.$setDirty();
168
201
  }
169
202
  $scope.check();
@@ -59,8 +59,6 @@ angular.module('niceElements')
59
59
  $scope.popper = Popper.createPopper(target, content, {
60
60
  placement: $scope.placement,
61
61
  strategy: $scope.strategy,
62
- scroll: true,
63
- resize: true,
64
62
  modifiers: [
65
63
  {
66
64
  name: 'offset',
@@ -92,10 +90,17 @@ angular.module('niceElements')
92
90
  });
93
91
  };
94
92
 
95
- $timeout(function () {
93
+ const setupTimer = $timeout(function () {
96
94
  $scope.setupPopper();
97
95
  });
98
96
 
97
+ // Popper adds scroll/resize listeners to window; remove them with the component
98
+ $scope.$on('$destroy', function () {
99
+ $timeout.cancel(setupTimer);
100
+ if ($scope.popper) $scope.popper.destroy();
101
+ $scope.popper = null;
102
+ });
103
+
99
104
  // -----------------------------------Open -----------------------------------
100
105
  $scope.toggle = function () {
101
106
  if ($scope.isOpen) {
@@ -111,11 +116,11 @@ angular.module('niceElements')
111
116
  };
112
117
 
113
118
  $scope.open = function () {
114
- $scope.popper.update();
119
+ if ($scope.popper) $scope.popper.update();
115
120
  $scope.isOpen = true;
116
121
  if ($scope.onChange) $scope.onChange($scope.isOpen);
117
122
  $timeout(function () {
118
- $scope.popper.update();
123
+ if ($scope.popper) $scope.popper.update();
119
124
  });
120
125
  };
121
126
  }
@@ -80,10 +80,17 @@ angular.module('niceElements')
80
80
  });
81
81
  };
82
82
 
83
- $timeout(function () {
83
+ const setupTimer = $timeout(function () {
84
84
  $scope.setupPopper();
85
85
  });
86
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
+
87
94
 
88
95
  // ------------------- On focus -------------------
89
96
  $scope.onFocus = function () {
@@ -121,7 +128,7 @@ angular.module('niceElements')
121
128
  // if (input) input.blur();
122
129
 
123
130
  $timeout(function () {
124
- $scope.popper.update();
131
+ if ($scope.popper) $scope.popper.update();
125
132
  });
126
133
  };
127
134
 
@@ -220,8 +227,9 @@ angular.module('niceElements')
220
227
  };
221
228
 
222
229
 
223
- // ----------------------------------- Watch for keydown and keypress -----------------------------------
224
- $element.bind("keydown keypress", function (event) {
230
+ // ----------------------------------- Watch for keydown -----------------------------------
231
+ // keydown only: Enter also fires keypress, which used to select the item twice
232
+ $element.bind("keydown", function (event) {
225
233
  // Arrow Up
226
234
  if (event.keyCode == 38) {
227
235
  event.preventDefault();
@@ -252,7 +260,9 @@ angular.module('niceElements')
252
260
  if (event.keyCode == 13) {
253
261
  event.preventDefault();
254
262
  $timeout(function () {
255
- $scope.selectItem($scope.results[$scope.selectedIndex], $scope.selectedIndex);
263
+ // Only select a result that exists (no results → no onSelect(undefined))
264
+ const item = $scope.results ? $scope.results[$scope.selectedIndex] : undefined;
265
+ if (item !== undefined) $scope.selectItem(item);
256
266
  });
257
267
  }
258
268
 
@@ -1,4 +1,17 @@
1
- <div class="nice-component nice-toggle" ng-class="{ 'margin-bottom-0': noMargin, 'title-right': titleRight, 'nice-component-inline': isInline, 'nice-component-block': isBlock, 'active': inverted ? !model : model }" ng-form="formToggle">
1
+ <div
2
+ class="nice-component nice-toggle"
3
+ ng-class="[
4
+ 'nice-toggle-' + type,
5
+ {
6
+ 'margin-bottom-0': noMargin,
7
+ 'title-right': titleRight,
8
+ 'nice-component-inline': isInline,
9
+ 'nice-component-block': isBlock,
10
+ 'active': inverted ? !model : model
11
+ }
12
+ ]"
13
+ ng-form="formToggle"
14
+ >
2
15
  <div class="row">
3
16
  <!------------------------- Title ------------------------->
4
17
  <nice-title text="title || niceTitle" help="help" required="required" description="description" description="description" label-width="labelWidth"></nice-title>
@@ -6,7 +19,10 @@
6
19
  <!------------------------- Field ------------------------->
7
20
  <div class="nice-field col-xs-12" ng-class="[fieldWidth ? fieldWidth : 'col-sm-8', { 'nice-disabled': isDisabled }]">
8
21
  <button type="button" class="nice-toggle-field" ng-click="toggle()" ng-disabled="isDisabled">
9
- <div class="nice-toggle-field-handle">{{ state }}</div>
22
+ <div class="nice-toggle-field-handle">
23
+ <nice-icon ng-if="showIcons && model" icon="icon-check"></nice-icon>
24
+ <nice-icon ng-if="showIcons && !model" icon="icon-x"></nice-icon>
25
+ </div>
10
26
  </button>
11
27
  </div>
12
28
  </div>
@@ -26,12 +26,15 @@ angular.module('niceElements')
26
26
  titleRight: '=',
27
27
  help: '@',
28
28
  required: '=',
29
- inverted: '='
29
+ inverted: '=',
30
+ showIcons: '=',
31
+ type: '@?'
30
32
  },
31
33
  controller: function ($scope, $timeout) {
32
34
  if (!$scope.title) { $scope.title = ''; }
33
35
  if (!$scope.fieldWidth) { $scope.fieldWidth = 'col-sm-8'; }
34
36
  if (!$scope.labelWidth) { $scope.labelWidth = 'col-sm-4'; }
37
+ if (!$scope.type) { $scope.type = 'default'; }
35
38
  if (!angular.isDefined($scope.model)) $scope.model = false;
36
39
 
37
40
  // ------------------------- Switch -------------------------
@@ -96,6 +96,17 @@
96
96
  background: var(--nice-border-color);
97
97
  border-radius: 50%;
98
98
  transition: all 0.3s ease-in-out;
99
+
100
+ display: flex;
101
+ flex-direction: column;
102
+ justify-content: center;
103
+ align-items: center;
104
+
105
+ .nice-icon {
106
+ color: var(--nice-input-bg);
107
+ height: 14px;
108
+ width: 14px;
109
+ }
99
110
  }
100
111
  }
101
112
 
@@ -106,7 +117,27 @@
106
117
  .nice-toggle-field-handle {
107
118
  background: var(--nice-input-bg);
108
119
  left: calc(100% - 22px);
120
+
121
+ .nice-icon {
122
+ color: var(--nice-primary-color);
123
+ }
109
124
  }
125
+
126
+ }
127
+
128
+ &.nice-toggle-success {
129
+ .nice-toggle-field { background: var(--nice-success-color); }
130
+ .nice-toggle-field-handle { .nice-icon { color: var(--nice-success-color); }}
131
+ }
132
+
133
+ &.nice-toggle-danger {
134
+ .nice-toggle-field { background: var(--nice-danger-color); }
135
+ .nice-toggle-field-handle { .nice-icon { color: var(--nice-danger-color); }}
136
+ }
137
+
138
+ &.nice-toggle-warning {
139
+ .nice-toggle-field { background: var(--nice-warning-color); }
140
+ .nice-toggle-field-handle { .nice-icon { color: var(--nice-warning-color); }}
110
141
  }
111
142
  }
112
143
 
@@ -16,8 +16,15 @@
16
16
  }
17
17
  }
18
18
 
19
+ // Header / footer borders are driven by the body scroll position
20
+ timeline-scope: --nice-view-scroll;
21
+
19
22
  .nice-view-header {
20
23
  flex-shrink: 0;
24
+ border-bottom: 1px solid transparent;
25
+ animation: nice-view-header-border linear both;
26
+ animation-timeline: --nice-view-scroll;
27
+ animation-range: 0 1rem;
21
28
  padding: var(--nice-view-padding);
22
29
  padding-bottom: calc(var(--nice-view-padding) / 2);
23
30
 
@@ -48,11 +55,16 @@
48
55
  .nice-view-body {
49
56
  flex-grow: 1;
50
57
  overflow: auto;
58
+ scroll-timeline: --nice-view-scroll block;
51
59
  padding: var(--nice-view-padding);
52
60
  }
53
61
 
54
62
  .nice-view-footer {
55
63
  flex-shrink: 0;
64
+ border-top: 1px solid transparent;
65
+ animation: nice-view-footer-border linear both;
66
+ animation-timeline: --nice-view-scroll;
67
+ animation-range: calc(100% - 1rem) 100%;
56
68
  padding: var(--nice-view-padding);
57
69
  padding-top: calc(var(--nice-view-padding) / 2);
58
70
  }
@@ -61,3 +73,13 @@
61
73
  --nice-view-padding: 1rem;
62
74
  }
63
75
  }
76
+
77
+ @keyframes nice-view-header-border {
78
+ from { border-bottom-color: transparent; }
79
+ to { border-bottom-color: var(--nice-border-color); }
80
+ }
81
+
82
+ @keyframes nice-view-footer-border {
83
+ from { border-top-color: var(--nice-border-color); }
84
+ to { border-top-color: transparent; }
85
+ }