nice-elements 1.12.6 → 1.12.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nice-elements",
3
- "version": "1.12.6",
3
+ "version": "1.12.7",
4
4
  "description": "Nice elements used in olaii angular 1.x webapps.",
5
5
  "main": "dist/nice.js",
6
6
  "license": "MIT",
@@ -0,0 +1 @@
1
+ <canvas class="nice-avatar"></canvas>
@@ -0,0 +1,122 @@
1
+
2
+ /**
3
+ * @ngdoc directive
4
+ * @name niceElements.directive:niceAvatar
5
+ * @description
6
+ * # niceAvatar
7
+ */
8
+ angular.module('niceElements')
9
+ .directive('niceAvatar', function () {
10
+ return {
11
+ templateUrl: 'src/components/nice-avatar/nice-avatar.html',
12
+ restrict: 'E',
13
+ replace: true,
14
+ scope: {
15
+ text: '@?',
16
+ },
17
+ controller: function ($scope, $element, $timeout) {
18
+ /**
19
+ * Handles the generation process when the button is clicked or on initial load.
20
+ */
21
+ function generateAndDraw() {
22
+
23
+ // Get references to DOM elements
24
+ const avatarCanvas = $element[0];
25
+ const ctx = avatarCanvas.getContext('2d');
26
+
27
+ /**
28
+ * Simple Pseudo-Random Number Generator (PRNG) using a seed.
29
+ * This ensures that for the same seed, the sequence of "random" numbers is identical.
30
+ * Based on a common LCG (Linear Congenital Generator) algorithm.
31
+ * @param {number} seed - The initial seed value.
32
+ * @returns {function(): number} A function that generates the next pseudo-random number (0-1).
33
+ */
34
+ function createSeededRandom(seed) {
35
+ // Use a simple string hashing for the initial seed if it's a string
36
+ let currentSeed = typeof seed === 'string' ? hashString(seed) : seed;
37
+
38
+ // LCG parameters
39
+ const a = 1103515245;
40
+ const c = 12345;
41
+ const m = 2 ** 31; // Modulus (a large prime number or power of 2)
42
+
43
+ return function () {
44
+ currentSeed = (a * currentSeed + c) % m;
45
+ return currentSeed / m; // Normalize to a value between 0 and 1
46
+ };
47
+ }
48
+
49
+ /**
50
+ * Simple string hashing function to convert a string seed into a number.
51
+ * @param {string} str - The string to hash.
52
+ * @returns {number} A numerical hash value.
53
+ */
54
+ function hashString(str) {
55
+ let hash = 0;
56
+ for (let i = 0; i < str.length; i++) {
57
+ const char = str.charCodeAt(i);
58
+ hash = ((hash << 5) - hash) + char; // Bitwise operations for speed
59
+ hash |= 0; // Convert to 32bit integer
60
+ }
61
+ return Math.abs(hash); // Ensure positive hash
62
+ }
63
+
64
+ /**
65
+ * Generates a random color in HSL format based on the seeded random number generator.
66
+ * HSL (Hue, Saturation, Lightness) is good for generating visually distinct colors.
67
+ * @param {function(): number} randomFunc - The seeded random number generator function.
68
+ * @returns {string} An HSL color string (e.g., "hsl(120, 70%, 50%)").
69
+ */
70
+ function generateRandomColor(randomFunc) {
71
+ const hue = Math.floor(randomFunc() * 360); // Hue: 0-359 degrees
72
+ const saturation = Math.floor(randomFunc() * 30) + 60; // Saturation: 60-90% (avoiding dull/overly vibrant)
73
+ const lightness = Math.floor(randomFunc() * 20) + 40; // Lightness: 40-60% (avoiding too dark/light)
74
+ return `hsl(${hue}, ${saturation}%, ${lightness}%)`;
75
+ }
76
+
77
+ /**
78
+ * Draws a linear gradient avatar on the canvas.
79
+ * @param {string} seed - The seed string for deterministic generation.
80
+ */
81
+ function drawAvatar(seed) {
82
+ const size = avatarCanvas.width; // Canvas is square
83
+ const seededRandom = createSeededRandom(seed);
84
+
85
+ // Generate two deterministic colors based on the seed
86
+ const color1 = generateRandomColor(seededRandom);
87
+ const color2 = generateRandomColor(seededRandom);
88
+
89
+ // Create a linear gradient
90
+ // The angle of the gradient can also be made deterministic
91
+ const angle = seededRandom() * Math.PI * 2; // Random angle from 0 to 2*PI radians
92
+
93
+ // Calculate start and end points for the gradient based on the angle
94
+ const startX = size / 2 + Math.cos(angle) * size / 2;
95
+ const startY = size / 2 + Math.sin(angle) * size / 2;
96
+ const endX = size / 2 + Math.cos(angle + Math.PI) * size / 2; // Opposite direction
97
+ const endY = size / 2 + Math.sin(angle + Math.PI) * size / 2;
98
+
99
+ const gradient = ctx.createLinearGradient(startX, startY, endX, endY);
100
+ gradient.addColorStop(0, color1);
101
+ gradient.addColorStop(1, color2);
102
+
103
+ // Fill the canvas with the gradient
104
+ ctx.clearRect(0, 0, size, size); // Clear previous drawing
105
+ ctx.fillStyle = gradient;
106
+ ctx.fillRect(0, 0, size, size);
107
+ }
108
+
109
+ const seed = $scope.text;
110
+ drawAvatar(seed);
111
+ }
112
+
113
+ $timeout(function () {
114
+ generateAndDraw();
115
+ });
116
+
117
+ $scope.$watch('text', function () {
118
+ generateAndDraw();
119
+ });
120
+ }
121
+ };
122
+ });
@@ -0,0 +1,5 @@
1
+ .nice-avatar {
2
+ height: 50px;
3
+ width: 50px;
4
+ border-radius: 50%;
5
+ }
@@ -116,12 +116,12 @@ angular.module('niceElements')
116
116
  $scope.close = function () {
117
117
  $scope.isOpen = false;
118
118
 
119
- const input = $element[0].getElementsByTagName('input')[0];
120
- if (input) input.blur();
119
+ // const input = $element[0].getElementsByTagName('input')[0];
120
+ // if (input) input.blur();
121
121
 
122
122
  $timeout(function () {
123
123
  $scope.popper.update();
124
- })
124
+ });
125
125
  };
126
126
 
127
127
 
@@ -172,7 +172,7 @@ angular.module('niceElements')
172
172
  $scope.buttonClicked = function () {
173
173
  if (!$scope.loading && $scope.model != '') $scope.clear();
174
174
  if (!$scope.loading && $scope.model == '') $scope.onFocus();
175
- }
175
+ };
176
176
 
177
177
  // ------------------------ If search button is clicked set focus or make request ------------------------
178
178
  $scope.search = function () {
@@ -263,5 +263,5 @@ angular.module('niceElements')
263
263
  }
264
264
  });
265
265
  }
266
- }
266
+ };
267
267
  });
@@ -1168,6 +1168,41 @@
1168
1168
  <path d="M25.2931 11.293L15.0001 21.586L10.7071 17.293C10.3161 16.902 9.68312 16.902 9.29312 17.293C8.90312 17.684 8.90212 18.317 9.29312 18.707L14.2931 23.707C14.6841 24.098 15.3171 24.098 15.7071 23.707L26.7071 12.707C27.0981 12.316 27.0981 11.683 26.7071 11.293C26.3161 10.903 25.6831 10.902 25.2931 11.293V11.293Z" />
1169
1169
  </symbol>
1170
1170
 
1171
+ <symbol id="icon-input-quantity" viewBox="0 0 24 24">
1172
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M21 5H3C2.44772 5 2 5.44772 2 6V18C2 18.5523 2.44772 19 3 19H21C21.5523 19 22 18.5523 22 18V6C22 5.44772 21.5523 5 21 5ZM3 3C1.34315 3 0 4.34315 0 6V18C0 19.6569 1.34315 21 3 21H21C22.6569 21 24 19.6569 24 18V6C24 4.34315 22.6569 3 21 3H3Z" />
1173
+ <path d="M11.9986 16.1758C11.3267 16.1732 10.7486 16.0078 10.2642 15.6797C9.78243 15.3516 9.41133 14.8763 9.15092 14.2539C8.89311 13.6315 8.7655 12.8828 8.76811 12.0078C8.76811 11.1354 8.89701 10.3919 9.15482 9.77734C9.41524 9.16276 9.78633 8.69531 10.2681 8.375C10.7525 8.05208 11.3293 7.89062 11.9986 7.89062C12.6678 7.89062 13.2434 8.05208 13.7251 8.375C14.2095 8.69792 14.5819 9.16667 14.8423 9.78125C15.1027 10.3932 15.2316 11.1354 15.229 12.0078C15.229 12.8854 15.0988 13.6354 14.8384 14.2578C14.5806 14.8802 14.2108 15.3555 13.729 15.6836C13.2473 16.0117 12.6704 16.1758 11.9986 16.1758ZM11.9986 14.7734C12.4569 14.7734 12.8228 14.543 13.0962 14.082C13.3697 13.6211 13.5051 12.9297 13.5025 12.0078C13.5025 11.401 13.44 10.8958 13.315 10.4922C13.1926 10.0885 13.0181 9.78516 12.7915 9.58203C12.5676 9.37891 12.3033 9.27734 11.9986 9.27734C11.5428 9.27734 11.1783 9.50521 10.9048 9.96094C10.6314 10.4167 10.4934 11.099 10.4908 12.0078C10.4908 12.6224 10.552 13.1354 10.6744 13.5469C10.7994 13.9557 10.9751 14.263 11.2017 14.4688C11.4283 14.6719 11.6939 14.7734 11.9986 14.7734Z" />
1174
+ <path d="M17.25 12.25H18.75V13.75C18.75 13.888 18.862 14 19 14C19.138 14 19.25 13.888 19.25 13.75V12.25H20.75C20.888 12.25 21 12.138 21 12C21 11.862 20.888 11.75 20.75 11.75H19.25V10.25C19.25 10.112 19.138 10 19 10C18.862 10 18.75 10.112 18.75 10.25V11.75H17.25C17.112 11.75 17 11.862 17 12C17 12.138 17.112 12.25 17.25 12.25Z" />
1175
+ <path d="M3.25 12.25H6.75C6.888 12.25 7 12.1492 7 12.025C7 11.9008 6.888 11.8 6.75 11.8H3.25C3.112 11.8 3 11.9008 3 12.025C3 12.1492 3.112 12.25 3.25 12.25Z" />
1176
+ </symbol>
1177
+
1178
+ <symbol id="icon-input-percent" viewBox="0 0 24 24">
1179
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M21 5H3C2.44772 5 2 5.44772 2 6V18C2 18.5523 2.44772 19 3 19H21C21.5523 19 22 18.5523 22 18V6C22 5.44772 21.5523 5 21 5ZM3 3C1.34315 3 0 4.34315 0 6V18C0 19.6569 1.34315 21 3 21H21C22.6569 21 24 19.6569 24 18V6C24 4.34315 22.6569 3 21 3H3Z" />
1180
+ <path d="M8.02734 14.5V14.0781C8.02734 13.7578 8.09505 13.4635 8.23047 13.1953C8.36849 12.9245 8.56771 12.7083 8.82812 12.5469C9.09115 12.3828 9.41146 12.3008 9.78906 12.3008C10.1719 12.3008 10.4935 12.3815 10.7539 12.543C11.0169 12.7044 11.2148 12.9206 11.3477 13.1914C11.4831 13.4596 11.5508 13.7552 11.5508 14.0781V14.5C11.5508 14.8203 11.4831 15.1159 11.3477 15.3867C11.2122 15.6549 11.013 15.8698 10.75 16.0312C10.487 16.1953 10.1667 16.2773 9.78906 16.2773C9.40625 16.2773 9.08464 16.1953 8.82422 16.0312C8.5638 15.8698 8.36589 15.6549 8.23047 15.3867C8.09505 15.1159 8.02734 14.8203 8.02734 14.5ZM9.16406 14.0781V14.5C9.16406 14.6849 9.20833 14.8594 9.29688 15.0234C9.38802 15.1875 9.55208 15.2695 9.78906 15.2695C10.026 15.2695 10.1875 15.1888 10.2734 15.0273C10.362 14.8659 10.4063 14.6901 10.4063 14.5V14.0781C10.4063 13.888 10.3646 13.7109 10.2812 13.5469C10.1979 13.3828 10.0339 13.3008 9.78906 13.3008C9.55469 13.3008 9.39193 13.3828 9.30078 13.5469C9.20964 13.7109 9.16406 13.888 9.16406 14.0781ZM3.92188 9.92188V9.5C3.92188 9.17708 3.99089 8.88151 4.12891 8.61328C4.26693 8.34245 4.46615 8.1263 4.72656 7.96484C4.98958 7.80339 5.30729 7.72266 5.67969 7.72266C6.0651 7.72266 6.38802 7.80339 6.64844 7.96484C6.90885 8.1263 7.10677 8.34245 7.24219 8.61328C7.3776 8.88151 7.44531 9.17708 7.44531 9.5V9.92188C7.44531 10.2448 7.3763 10.5404 7.23828 10.8086C7.10286 11.0768 6.90365 11.2917 6.64062 11.4531C6.38021 11.612 6.0599 11.6914 5.67969 11.6914C5.29948 11.6914 4.97786 11.6107 4.71484 11.4492C4.45443 11.2852 4.25651 11.0703 4.12109 10.8047C3.98828 10.5365 3.92188 10.2422 3.92188 9.92188ZM5.06641 9.5V9.92188C5.06641 10.112 5.11068 10.2878 5.19922 10.4492C5.29036 10.6107 5.45052 10.6914 5.67969 10.6914C5.91927 10.6914 6.08203 10.6107 6.16797 10.4492C6.25651 10.2878 6.30078 10.112 6.30078 9.92188V9.5C6.30078 9.3099 6.25911 9.13281 6.17578 8.96875C6.09245 8.80469 5.92708 8.72266 5.67969 8.72266C5.44792 8.72266 5.28776 8.80599 5.19922 8.97266C5.11068 9.13932 5.06641 9.3151 5.06641 9.5ZM4.4375 16L9.9375 8H10.9609L5.46094 16H4.4375Z" />
1181
+ </symbol>
1182
+
1183
+ <symbol id="icon-input-number" viewBox="0 0 24 24">
1184
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M21 5H3C2.44772 5 2 5.44772 2 6V18C2 18.5523 2.44772 19 3 19H21C21.5523 19 22 18.5523 22 18V6C22 5.44772 21.5523 5 21 5ZM3 3C1.34315 3 0 4.34315 0 6V18C0 19.6569 1.34315 21 3 21H21C22.6569 21 24 19.6569 24 18V6C24 4.34315 22.6569 3 21 3H3Z" />
1185
+ <path d="M9.03027 16V14.7812L11.8779 12.1445C12.1201 11.9102 12.3232 11.6992 12.4873 11.5117C12.654 11.3242 12.7803 11.1406 12.8662 10.9609C12.9521 10.7786 12.9951 10.582 12.9951 10.3711C12.9951 10.1367 12.9417 9.9349 12.835 9.76563C12.7282 9.59375 12.5824 9.46224 12.3975 9.37109C12.2126 9.27734 12.0029 9.23047 11.7686 9.23047C11.5238 9.23047 11.3102 9.27995 11.1279 9.37891C10.9456 9.47786 10.805 9.61979 10.7061 9.80469C10.6071 9.98958 10.5576 10.2096 10.5576 10.4648H8.95215C8.95215 9.94141 9.07064 9.48698 9.30762 9.10156C9.5446 8.71615 9.87663 8.41797 10.3037 8.20703C10.7308 7.99609 11.223 7.89062 11.7803 7.89062C12.3532 7.89062 12.8519 7.99219 13.2764 8.19531C13.7035 8.39583 14.0355 8.67448 14.2725 9.03125C14.5094 9.38802 14.6279 9.79688 14.6279 10.2578C14.6279 10.5599 14.568 10.8581 14.4482 11.1523C14.3311 11.4466 14.1214 11.7734 13.8193 12.1328C13.5173 12.4896 13.0915 12.918 12.542 13.418L11.374 14.5625V14.6172H14.7334V16H9.03027Z" />
1186
+ <path d="M7.12891 8V16H5.4375V9.60547H5.39062L3.55859 10.7539V9.25391L5.53906 8H7.12891Z" />
1187
+ </symbol>
1188
+
1189
+ <symbol id="icon-input-text" viewBox="0 0 24 24">
1190
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M21 5H3C2.44772 5 2 5.44772 2 6V18C2 18.5523 2.44772 19 3 19H21C21.5523 19 22 18.5523 22 18V6C22 5.44772 21.5523 5 21 5ZM3 3C1.34315 3 0 4.34315 0 6V18C0 19.6569 1.34315 21 3 21H21C22.6569 21 24 19.6569 24 18V6C24 4.34315 22.6569 3 21 3H3Z" />
1191
+ <path d="M11.9238 16V8H15.127C15.7155 8 16.2064 8.08724 16.5996 8.26172C16.9928 8.4362 17.2884 8.67839 17.4863 8.98828C17.6842 9.29557 17.7832 9.64974 17.7832 10.0508C17.7832 10.3633 17.7207 10.638 17.5957 10.875C17.4707 11.1094 17.2988 11.3021 17.0801 11.4531C16.8639 11.6016 16.6165 11.707 16.3379 11.7695V11.8477C16.6426 11.8607 16.9277 11.9466 17.1934 12.1055C17.4616 12.2643 17.679 12.487 17.8457 12.7734C18.0124 13.0573 18.0957 13.3958 18.0957 13.7891C18.0957 14.2135 17.9902 14.5924 17.7793 14.9258C17.571 15.2565 17.2624 15.5182 16.8535 15.7109C16.4447 15.9036 15.9408 16 15.3418 16H11.9238ZM13.6152 14.6172H14.9941C15.4655 14.6172 15.8092 14.5273 16.0254 14.3477C16.2415 14.1654 16.3496 13.9232 16.3496 13.6211C16.3496 13.3997 16.2962 13.2044 16.1895 13.0352C16.0827 12.8659 15.9303 12.7331 15.7324 12.6367C15.5371 12.5404 15.304 12.4922 15.0332 12.4922H13.6152V14.6172ZM13.6152 11.3477H14.8691C15.1009 11.3477 15.3066 11.3073 15.4863 11.2266C15.6686 11.1432 15.8118 11.026 15.916 10.875C16.0228 10.724 16.0762 10.543 16.0762 10.332C16.0762 10.043 15.9733 9.8099 15.7676 9.63281C15.5645 9.45573 15.2754 9.36719 14.9004 9.36719H13.6152V11.3477Z" />
1192
+ <path d="M5.07422 16H3.26172L6.02344 8H8.20312L10.9609 16H9.14844L7.14453 9.82813H7.08203L5.07422 16ZM4.96094 12.8555H9.24219V14.1758H4.96094V12.8555Z" />
1193
+ </symbol>
1194
+
1195
+ <symbol id="icon-input" viewBox="0 0 24 24">
1196
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M21 5H3C2.44772 5 2 5.44772 2 6V18C2 18.5523 2.44772 19 3 19H21C21.5523 19 22 18.5523 22 18V6C22 5.44772 21.5523 5 21 5ZM3 3C1.34315 3 0 4.34315 0 6V18C0 19.6569 1.34315 21 3 21H21C22.6569 21 24 19.6569 24 18V6C24 4.34315 22.6569 3 21 3H3Z" />
1197
+ <path d="M7 17H5L5 7H7L7 17Z" />
1198
+ </symbol>
1199
+
1200
+ <symbol id="icon-dropdown" viewBox="0 0 24 24">
1201
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M21 5H3C2.44772 5 2 5.44772 2 6V18C2 18.5523 2.44772 19 3 19H21C21.5523 19 22 18.5523 22 18V6C22 5.44772 21.5523 5 21 5ZM3 3C1.34315 3 0 4.34315 0 6V18C0 19.6569 1.34315 21 3 21H21C22.6569 21 24 19.6569 24 18V6C24 4.34315 22.6569 3 21 3H3Z" />
1202
+ <path d="M14.3267 10.9481C14.1175 10.5991 14.2308 10.1469 14.5797 9.93748C14.9287 9.72809 15.3811 9.84093 15.5906 10.1898L14.3267 10.9481ZM20.0134 10.9483L17.8019 14.634C17.6687 14.8557 17.4289 14.9912 17.1703 14.9913C16.9114 14.9913 16.6714 14.8555 16.5382 14.6335L14.3267 10.9481L15.5906 10.1898L17.1706 12.8216L18.7487 10.1901L18.7911 10.1276C19.0146 9.82829 19.4329 9.74063 19.7601 9.93682C20.0874 10.1332 20.2077 10.5439 20.0489 10.882L20.0134 10.9483Z" />
1203
+ </symbol>
1204
+
1205
+
1171
1206
  <symbol id="icon-seat" viewBox="0 0 370 370">
1172
1207
  <path fill-rule="evenodd" clip-rule="evenodd" d="M31 261H339V300C339 329.823 314.823 354 285 354H85C55.1766 354 31 329.823 31 300V261ZM73.372 321C65.9937 316.906 61 309.036 61 300V291H309V300C309 309.036 304.006 316.906 296.628 321C293.183 322.911 289.219 324 285 324H85C80.7813 324 76.8167 322.911 73.372 321Z"></path>
1173
1208
  <path fill-rule="evenodd" clip-rule="evenodd" d="M339 291H249V227C249 202.147 269.147 182 294 182C318.853 182 339 202.147 339 227V291ZM309 227C309 218.716 302.284 212 294 212C285.716 212 279 218.716 279 227V261H309V227Z"></path>
@@ -34,6 +34,7 @@
34
34
 
35
35
  .nice-view-header-title {
36
36
  font-size: 2em;
37
+ font-weight: medium;
37
38
  line-height: 1;
38
39
  }
39
40
 
@@ -10,7 +10,7 @@ angular.module('niceElements')
10
10
  .service('NiceService', function ($rootScope) {
11
11
  const service = {
12
12
  name: "Nice elements",
13
- version: "1.12.6",
13
+ version: "1.12.7",
14
14
  getHeader: function () {
15
15
  return {};
16
16
  },
@@ -67,5 +67,6 @@
67
67
  @import "../components/nice-table/nice-table";
68
68
  @import "../components/nice-view/nice-view";
69
69
  @import "../components/nice-alert/nice-alert";
70
+ @import "../components/nice-avatar/nice-avatar";
70
71
  @import "../components/nice-virtual-scroll/nice-virtual-scroll";
71
72
  @import "../modals/nice-multilangual-modal/nice-multilangual-modal";
@@ -1,5 +1,5 @@
1
1
  // ---------- Fonts ----------
2
- $nice-font-family: "Roboto", "Helvetica Neue", Helvetica, Arial, sans-serif !default;
2
+ $nice-font-family: "Inter",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji" !default;
3
3
  $nice-font-weight: normal !default;
4
4
  $nice-font-color: #404040 !default;
5
5