nice-elements 1.4.11 → 1.6.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 (51) hide show
  1. package/.vscode/settings.json +3 -0
  2. package/CHANGELOG.md +28 -0
  3. package/README.md +48 -1
  4. package/bower.json +1 -1
  5. package/dist/nice.js +1262 -106
  6. package/dist/nice.min.js +1 -1
  7. package/dist/style.css +989 -66
  8. package/dist/style.css.map +7 -2
  9. package/dist/style.min.css +2 -2
  10. package/package.json +1 -1
  11. package/src/components/nice-calendar/nice-calendar.html +10 -37
  12. package/src/components/nice-calendar/nice-calendar.scss +25 -24
  13. package/src/components/nice-checkbox/nice-checkbox.html +2 -2
  14. package/src/components/nice-checkbox/nice-checkbox.scss +5 -4
  15. package/src/components/nice-choice/nice-choice.html +1 -1
  16. package/src/components/nice-choice/nice-choice.scss +22 -22
  17. package/src/components/nice-date/nice-date.html +14 -34
  18. package/src/components/nice-date/nice-date.scss +41 -17
  19. package/src/components/nice-datetimerange-picker/nice-datetimerange-picker.html +4 -34
  20. package/src/components/nice-datetimerange-picker-2/nice-datetimerange-picker-2.scss +18 -14
  21. package/src/components/nice-dropdown/nice-dropdown.js +5 -0
  22. package/src/components/nice-dropdown/nice-dropdown.scss +5 -4
  23. package/src/components/nice-dropdown-old/nice-dropdown-old.scss +27 -26
  24. package/src/components/nice-icon/nice-icon.html +3 -0
  25. package/src/components/nice-icon/nice-icon.js +18 -0
  26. package/src/components/nice-icon/nice-icon.scss +6 -0
  27. package/src/components/nice-number/nice-number.html +2 -2
  28. package/src/components/nice-number/nice-number.scss +9 -0
  29. package/src/components/nice-popup/nice-popup.html +7 -0
  30. package/src/components/nice-popup/nice-popup.js +123 -0
  31. package/src/components/nice-popup/nice-popup.scss +44 -0
  32. package/src/components/nice-quantity/nice-quantity.html +3 -10
  33. package/src/components/nice-quantity/nice-quantity.scss +17 -10
  34. package/src/components/nice-search2/nice-search2.html +2 -12
  35. package/src/components/nice-search2/nice-search2.js +34 -27
  36. package/src/components/nice-svgs/nice-svgs.html +1153 -0
  37. package/src/components/nice-svgs/nice-svgs.js +16 -0
  38. package/src/components/nice-toast/nice-toast.html +3 -0
  39. package/src/components/nice-toast/nice-toast.js +57 -0
  40. package/src/components/nice-toast/nice-toast.scss +75 -0
  41. package/src/components/nice-tooltip/nice-tooltip.js +9 -6
  42. package/src/components/nice-upload/nice-upload.html +4 -5
  43. package/src/components/nice-upload/nice-upload.js +73 -41
  44. package/src/components/nice-upload/nice-upload.scss +32 -13
  45. package/src/components/nice-yesno/nice-yesno.html +1 -1
  46. package/src/components/nice-yesno/nice-yesno.scss +23 -15
  47. package/src/styles/_nice-buttons.scss +335 -0
  48. package/src/styles/_nice-common.scss +84 -47
  49. package/src/styles/_nice-spacing.scss +58 -0
  50. package/src/styles/_nice.scss +6 -1
  51. package/src/styles/_variables.scss +81 -3
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * @ngdoc directive
5
+ * @name niceElements.directive:niceSvgs
6
+ * @description
7
+ * # niceSvgs
8
+ */
9
+ angular.module('niceElements')
10
+ .directive('niceSvgs', function () {
11
+ return {
12
+ templateUrl: 'src/components/nice-svgs/nice-svgs.html',
13
+ restrict: 'E',
14
+ transclude: true
15
+ };
16
+ });
@@ -0,0 +1,3 @@
1
+ <div class="nice-toasts" ng-class="position">
2
+ <div class="nice-toast" ng-class="toast.type" ng-repeat="toast in toasts">{{ toast.message }}</div>
3
+ </div>
@@ -0,0 +1,57 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * @ngdoc directive
5
+ * @name niceElements.directive:niceToast
6
+ * @description
7
+ * # niceToast
8
+ */
9
+ angular.module('niceElements')
10
+ .directive("niceToast", function () {
11
+ return {
12
+ restrict: "E",
13
+ templateUrl: "src/components/nice-toast/nice-toast.html",
14
+ scope: {
15
+ position: '@',
16
+ timeoutTime: '@',
17
+ },
18
+ controller: function ($scope, $timeout) {
19
+ if (!$scope.position) $scope.position = "bottom center";
20
+ if (!$scope.timeoutTime) $scope.timeoutTime = 2000;
21
+ $scope.toasts = [];
22
+
23
+ // -------------------------- Watch for events --------------------------
24
+ $scope.$on('toast', function (e, message, type) {
25
+ $scope.createToast(message, type);
26
+ });
27
+
28
+
29
+ // -------------------------- Create toast --------------------------
30
+ $scope.createToast = function (message, type) {
31
+ // Create new toast
32
+ var toast = {
33
+ id: Math.random().toString(36).replace(/[^a-z]+/g, '').substr(2, 10),
34
+ message: message,
35
+ type: type || "default"
36
+ };
37
+
38
+ // Append toast
39
+ $scope.toasts.push(toast);
40
+
41
+ // Remove after some time
42
+ $timeout(function () {
43
+ $scope.removeToast(toast);
44
+ }, $scope.timeoutTime);
45
+ };
46
+
47
+
48
+ // -------------------------- Remove toast --------------------------
49
+ $scope.removeToast = function (toast) {
50
+ var toastIndex = $scope.toasts.findIndex(function (a) { return a.id == toast.id })
51
+ if (toastIndex >= 0) {
52
+ $scope.toasts.splice(toastIndex, 1);
53
+ }
54
+ }
55
+ }
56
+ };
57
+ });
@@ -0,0 +1,75 @@
1
+ .nice-toasts {
2
+ z-index: 9999999;
3
+ position: fixed;
4
+
5
+ display: flex;
6
+ flex-direction: column;
7
+ align-items: center;
8
+
9
+ gap: 0.5rem;
10
+ padding: 1rem;
11
+
12
+ &.top {
13
+ top: $nice-navbar-height;
14
+ }
15
+
16
+ &.bottom {
17
+ bottom: 0;
18
+ flex-direction: column-reverse;
19
+ }
20
+
21
+ &.center {
22
+ right: 50%;
23
+ transform: translateX(50%);
24
+ }
25
+
26
+ &.left {
27
+ left: 0;
28
+ align-items: flex-start;
29
+ }
30
+
31
+ &.right {
32
+ right: 0;
33
+ align-items: flex-end;
34
+ }
35
+
36
+ .nice-toast {
37
+ background: $nice-hover-color;
38
+ padding: 0.3rem 1.2rem;
39
+ border-radius: 30px;
40
+ font-size: 0.8em;
41
+ font-weight: bold;
42
+ box-shadow: 0 0 30px rgba(0, 0, 0, 0.05);
43
+ max-width: 500px;
44
+
45
+ &.success {
46
+ color: white;
47
+ background: $nice-notification-success-bg;
48
+ }
49
+
50
+ &.error {
51
+ color: white;
52
+ background: $nice-notification-danger-color-bg;
53
+ }
54
+ }
55
+ }
56
+
57
+ .toast-enter-active {
58
+ animation: bounce-in .5s;
59
+ }
60
+
61
+ .toast-leave-active {
62
+ animation: bounce-in .5s reverse;
63
+ }
64
+
65
+ @keyframes bounce-in {
66
+ from {
67
+ transform: translateY(100%);
68
+ opacity: 1;
69
+ }
70
+
71
+ to {
72
+ transform: translateY(0);
73
+ opacity: 1;
74
+ }
75
+ }
@@ -7,14 +7,17 @@
7
7
  * # niceTooltip
8
8
  */
9
9
  angular.module('niceElements')
10
- .directive('niceTooltip', function() {
10
+ .directive('niceTooltip', function () {
11
11
  return {
12
12
  restrict: 'EA',
13
- link: function(scope, element, attrs) {
14
- var html = element.html();
13
+ link: function (scope, element, attrs) {
15
14
  element.addClass("nice-tooltip");
16
- html = html + "<span class='nice-tooltip-window'>" + attrs.niceTooltip + "</span>"
17
- element.html(html);
18
- }
15
+
16
+ var tooltipWindow = document.createElement('span')
17
+ tooltipWindow.className = 'nice-tooltip-window';
18
+ tooltipWindow.innerHTML = attrs.niceTooltip;
19
+
20
+ element.append(tooltipWindow);
21
+ }
19
22
  };
20
23
  });
@@ -9,15 +9,14 @@
9
9
  <!------------------------- Field ------------------------->
10
10
  <div class="nice-field col-xs-12" ng-class="[fieldWidth ? fieldWidth : 'col-sm-8', { 'nice-disabled': isDisabled }]">
11
11
  <input class="input-file" type="file" accept="{{ accept }}" ng-model="file" ng-disabled="isDisabled" />
12
- <div class="input-area">
12
+ <div class="input-area" ng-class="{ 'dragging': dragging || draggingGlobal }">
13
13
  <div class="middle-text" ng-if="!imageSource && !loading">
14
- <div class="text">{{ text }}</div>
14
+ <div class="text text-placeholder" ng-if="!dragging">{{ text }}</div>
15
+ <div class="text text-placeholder" ng-if="dragging" translate translate-group="Nice">Drop file here</div>
15
16
  <div class="error" ng-if="error">{{ error }}</div>
16
17
  </div>
17
18
  <img ng-if="imageSource" data-ng-src="{{ imageSource }}" />
18
- </div>
19
- <div class="loading" ng-if="loading">
20
- <nice-loader></nice-loader>
19
+ <nice-loader fulldiv="true" ng-if="loading"></nice-loader>
21
20
  </div>
22
21
  </div>
23
22
  </div>
@@ -6,8 +6,8 @@
6
6
  * @description
7
7
  * # niceUpload
8
8
  */
9
- angular.module('niceElements')
10
- .directive('niceUpload', function ($timeout, gettextCatalog) {
9
+ angular.module('niceElements')
10
+ .directive('niceUpload', function ($timeout, gettextCatalog) {
11
11
  return {
12
12
  restrict: 'E',
13
13
  replace: true,
@@ -30,7 +30,7 @@
30
30
  help: '@'
31
31
  },
32
32
 
33
- link: function(scope, element, attrs){
33
+ link: function (scope, element, attrs) {
34
34
  if (!attrs.title) { attrs.title = ''; }
35
35
  if (!attrs.text) { attrs.text = gettextCatalog.getString('Click to upload file', null, 'Nice'); }
36
36
  if (!attrs.fieldWidth) { attrs.fieldWidth = 'col-sm-8'; }
@@ -38,17 +38,46 @@
38
38
  attrs.noMargin = angular.isDefined(attrs.noMargin);
39
39
  var maxImageSize = 1000000; // 1MB
40
40
 
41
- element.bind("change", function (changeEvent) {
41
+ scope.startDragging = function () { $timeout(function () { scope.dragging = true; }); }
42
+ scope.endDragging = function () { $timeout(function () { scope.dragging = false; }); }
43
+ scope.startDraggingGlobal = function () { $timeout(function () { scope.draggingGlobal = true; }); }
44
+ scope.endDraggingGlobal = function () { $timeout(function () { scope.dragging = false; scope.draggingGlobal = false; }); }
45
+
46
+ scope.dragging = false;
47
+ scope.draggingGlobal = false;
48
+ var inputElement = element[0].querySelector(".input-file");
49
+ // document.addEventListener("dragenter", scope.startDraggingGlobal);
50
+ // document.addEventListener("drop", scope.endDraggingGlobal);
51
+ // document.addEventListener("dragend", scope.endDraggingGlobal);
52
+ // document.addEventListener("mouseleave", scope.endDraggingGlobal);
53
+ // document.addEventListener("dragleave", scope.endDragging);
54
+ inputElement.addEventListener("dragenter", scope.startDragging);
55
+ inputElement.addEventListener("dragleave", scope.endDragging);
56
+ inputElement.addEventListener("dragend", scope.endDraggingGlobal);
57
+ inputElement.addEventListener("drop", scope.endDraggingGlobal);
58
+
59
+ scope.$on('$destroy', function () {
60
+ // document.removeEventListener("dragenter", scope.startDraggingGlobal);
61
+ // document.removeEventListener("drop", scope.endDraggingGlobal);
62
+ // document.removeEventListener("dragend", scope.endDraggingGlobal);
63
+ // document.removeEventListener("mouseleave", scope.endDraggingGlobal);
64
+ // document.removeEventListener("dragleave", scope.endDraggingGlobal);
65
+ inputElement.removeEventListener("dragenter", scope.startDragging);
66
+ inputElement.removeEventListener("dragleave", scope.endDragging);
67
+ inputElement.removeEventListener("dragend", scope.endDraggingGlobal);
68
+ inputElement.removeEventListener("drop", scope.endDraggingGlobal);
69
+ });
42
70
 
71
+
72
+ element.bind("change", function (changeEvent) {
43
73
  if (scope.callbackUrl != undefined) {
44
74
  scope.callbackUrl(URL.createObjectURL(changeEvent.target.files[0]));
45
75
  }
46
76
 
47
77
  $timeout(function () {
48
- var inputObj = changeEvent.target;
49
-
50
78
  scope.loading = true;
51
79
  scope.error = null;
80
+ var inputObj = changeEvent.target;
52
81
  var reader = new FileReader();
53
82
 
54
83
  if (inputObj.files) {
@@ -56,44 +85,47 @@
56
85
  var fileSize = inputObj.files[0].size; // in bytes
57
86
 
58
87
  reader.onload = function (event) {
59
- $timeout(function(){
88
+ $timeout(function () {
60
89
  // file size must be smaller than 1MB.
61
- if (fileSize <= maxImageSize) {
62
- if (scope.callbackFunction != undefined) {
63
- scope.loading = false;
64
- scope.imageSource = null;
65
- scope.callbackFunction(event.target.result);
66
- scope.text = inputObj.files[0].name;
67
- scope.form.$setDirty();
68
- }
90
+ if (fileSize > maxImageSize) {
91
+ scope.error = gettextCatalog.getString("File must be smaller than 1MB", null, "Nice");
92
+ scope.loading = false;
93
+ scope.imageSource = null;
94
+ return;
95
+ }
69
96
 
70
- if(scope.callbackFile != undefined){
97
+ if (scope.callbackFunction != undefined) {
98
+ scope.loading = false;
99
+ scope.imageSource = null;
100
+ scope.callbackFunction(event.target.result);
101
+ scope.text = inputObj.files[0].name;
102
+ scope.form.$setDirty();
103
+ }
104
+
105
+ if (scope.callbackFile != undefined) {
106
+ scope.loading = false;
107
+ scope.text = inputObj.files[0].name;
108
+ scope.callbackFile(inputObj.files[0]);
109
+ scope.form.$setDirty();
110
+ }
111
+
112
+ if (scope.uploadFunction != undefined) {
113
+ scope.uploadFunction(inputObj.files[0]).then(function (response) {
71
114
  scope.loading = false;
72
- scope.text = inputObj.files[0].name;
73
- scope.callbackFile(inputObj.files[0]);
115
+ scope.imageSource = event.target.result;
116
+ scope.model = response.data.url;
74
117
  scope.form.$setDirty();
75
- }
76
-
77
- if (scope.uploadFunction != undefined) {
78
- scope.uploadFunction(inputObj.files[0]).then(function (response) {
79
- scope.loading = false;
80
- scope.imageSource = event.target.result;
81
- scope.model = response.data.url;
82
- scope.form.$setDirty();
83
- }, function (error) {
84
- // Handle upload function error
85
- scope.error = error;
86
- scope.loading = false;
87
- scope.imageSource = null;
88
- });
89
- } else {
90
- // console.error("No upload function set!");
91
- }
118
+ }, function (error) {
119
+ // Handle upload function error
120
+ scope.error = error;
121
+ scope.loading = false;
122
+ scope.imageSource = null;
123
+ });
92
124
  } else {
93
- // Handle file too big error
94
- scope.error = gettextCatalog.getString("File must be smaller than 1MB", null, "Nice");
95
- scope.loading = false;
96
- scope.imageSource = null;
125
+ // console.error("No upload function set!");
126
+ if (event.target.result.substring(0, 10) == "data:image") {
127
+ scope.imageSource = event.target.result;
128
+ }
97
129
  }
98
130
  });
99
131
  };
@@ -114,8 +146,8 @@
114
146
  });
115
147
  },
116
148
 
117
- controller: function($scope) {
118
- $scope.$watch("model", function(value){
149
+ controller: function ($scope) {
150
+ $scope.$watch("model", function (value) {
119
151
  $scope.imageSource = angular.copy($scope.model);
120
152
  });
121
153
  }
@@ -1,8 +1,16 @@
1
1
  .nice-upload {
2
2
  display: block;
3
- overflow: hidden;
3
+ // overflow: hidden;
4
4
 
5
- input{
5
+ .nice-field {
6
+ &:focus-within {
7
+ .input-area {
8
+ @extend .nice-focus;
9
+ }
10
+ }
11
+ }
12
+
13
+ input {
6
14
  position: absolute;
7
15
  top: 0;
8
16
  left: 0;
@@ -17,7 +25,7 @@
17
25
  }
18
26
  }
19
27
 
20
- .input-area{
28
+ .input-area {
21
29
  border-radius: $nice-border-radius;
22
30
  width: 100%;
23
31
  height: 150px;
@@ -28,32 +36,43 @@
28
36
  display: table;
29
37
  padding: 15px;
30
38
 
31
- .middle-text{
32
- display: table-cell;
33
- vertical-align: middle;
34
- text-align: center;
39
+ &.dragging {
40
+ outline: 2px dashed var(--nice-primary-color);
41
+ outline-offset: -7px;
42
+ }
43
+
44
+ .middle-text {
45
+ display: flex;
46
+ align-items: center;
47
+ justify-content: center;
48
+ flex-direction: column;
49
+ height: 100%;
50
+
51
+ .text-placeholder {
52
+ font-size: 0.9em;
53
+ opacity: 0.6;
54
+ }
35
55
 
36
- .error{
56
+ .error {
37
57
  color: $nice-danger-color;
38
- margin-top: 10px;
39
58
  }
40
59
  }
41
60
 
42
- img{
61
+ img {
43
62
  max-width: 100%;
44
63
  max-height: 148px;
45
64
  }
46
65
  }
47
66
 
48
- .loading{
67
+ .loading {
49
68
  position: absolute;
50
69
  width: 100%;
51
70
  height: 100%;
52
71
  top: 0;
53
72
  left: 0;
54
- background-color: rgba(255,255,255,0.50);
73
+ background-color: rgba(255, 255, 255, 0.50);
55
74
 
56
- .nice-loader{
75
+ .nice-loader {
57
76
  position: absolute;
58
77
  top: 50%;
59
78
  left: 50%;
@@ -11,7 +11,7 @@
11
11
  <div class="yesno-wrapper noselect" ng-class="{ 'disabled': isDisabled }">
12
12
  <div class="yesno-yes-bg" ng-click="switch()">{{ yes }}</div>
13
13
  <div class="yesno-no-bg" ng-click="switch()">{{ no }}</div>
14
- <div class="yesno-button" ng-class="buttonClass" ng-click="switch()">{{ state }}</div>
14
+ <button class="yesno-button btn btn-primary" ng-class="buttonClass" ng-click="switch()">{{ state }}</button>
15
15
  </div>
16
16
  </div>
17
17
  </div>
@@ -1,15 +1,17 @@
1
- .nice-yesno{
2
- .disabled{
1
+ .nice-yesno {
2
+ .disabled {
3
3
  background-color: $nice-yesno-disabled-bg;
4
4
  opacity: 0.65;
5
5
  border: $nice-yesno-disabled-border;
6
6
 
7
- .yesno-yes-bg, .yesno-no-bg, .yesno-button{
7
+ .yesno-yes-bg,
8
+ .yesno-no-bg,
9
+ .yesno-button {
8
10
  cursor: not-allowed !important;
9
11
  }
10
12
  }
11
13
 
12
- .yesno-wrapper{
14
+ .yesno-wrapper {
13
15
  background: $nice-yesno-bg;
14
16
  border: 1px solid $nice-border-color;
15
17
  color: $nice-font-color;
@@ -18,13 +20,17 @@
18
20
  height: 34px;
19
21
  position: relative;
20
22
 
21
- .yesno-yes-bg, .yesno-no-bg, .yesno-button {
23
+ .yesno-yes-bg,
24
+ .yesno-no-bg,
25
+ .yesno-button {
22
26
  text-align: center;
23
27
  line-height: 34px;
28
+ min-height: unset;
24
29
  cursor: pointer;
25
30
  }
26
31
 
27
- .yesno-yes-bg, .yesno-no-bg {
32
+ .yesno-yes-bg,
33
+ .yesno-no-bg {
28
34
  opacity: 0.8;
29
35
  height: 100%;
30
36
  position: absolute;
@@ -32,50 +38,52 @@
32
38
  bottom: 0;
33
39
  }
34
40
 
35
- .yesno-no-bg{
41
+ .yesno-no-bg {
36
42
  left: 50%;
37
43
  right: 0;
38
44
  }
39
- .yesno-yes-bg{
45
+
46
+ .yesno-yes-bg {
40
47
  left: 0;
41
48
  right: 50%;
42
49
  }
43
50
 
44
- .yesno-button{
51
+ .yesno-button {
45
52
  transition: all 0.5s;
46
53
  background-color: $nice-yesno-slider-bg;
47
54
  border-radius: $nice-border-radius-small;
48
55
  color: white;
49
56
  position: absolute;
50
57
  line-height: 28px;
58
+ padding: 0;
51
59
  top: 2px;
52
60
  left: 2px;
53
61
  right: 50%;
54
62
 
55
- &:hover{
63
+ &:hover {
56
64
  background-color: darken($nice-yesno-slider-bg, 5%);
57
65
  }
58
66
  }
59
67
 
60
- .yesno-button-no{
68
+ .yesno-button-no {
61
69
  left: 50%;
62
70
  top: 2px;
63
71
  bottom: 2px;
64
72
  right: 2px;
65
73
  }
66
74
 
67
- .yesno-button-yes{
75
+ .yesno-button-yes {
68
76
  left: 2px;
69
77
  top: 2px;
70
78
  bottom: 2px;
71
79
  right: 50%;
72
80
  }
73
81
 
74
- &.true{
75
- .yesno-button{
82
+ &.true {
83
+ .yesno-button {
76
84
  right: 2px;
77
85
  left: 50%;
78
86
  }
79
87
  }
80
88
  }
81
- }
89
+ }