nice-elements 1.15.1 → 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 (44) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/CLAUDE.md +1 -0
  3. package/README.md +1 -1
  4. package/bower.json +1 -1
  5. package/dist/nice.js +573 -468
  6. package/dist/nice.min.js +1 -1
  7. package/dist/style.css +122 -104
  8. package/dist/style.css.map +1 -1
  9. package/dist/style.min.css +2 -2
  10. package/package.json +5 -6
  11. package/src/components/nice-calendar/nice-calendar.html +3 -4
  12. package/src/components/nice-calendar/nice-calendar.scss +0 -9
  13. package/src/components/nice-date/nice-date-picker.html +60 -0
  14. package/src/components/nice-date/nice-date.html +29 -86
  15. package/src/components/nice-date/nice-date.js +7 -35
  16. package/src/components/nice-date/nice-date.scss +6 -15
  17. package/src/components/nice-datetime-picker/nice-datetime-picker.html +1 -4
  18. package/src/components/nice-datetime-picker/nice-datetime-picker.scss +9 -12
  19. package/src/components/nice-datetimerange-picker/nice-datetimerange-picker.html +1 -3
  20. package/src/components/nice-datetimerange-picker-2/nice-datetimerange-picker-2.html +32 -30
  21. package/src/components/nice-datetimerange-picker-2/nice-datetimerange-picker-2.js +1 -33
  22. package/src/components/nice-datetimerange-picker-2/nice-datetimerange-picker-2.scss +7 -12
  23. package/src/components/nice-dropdown/nice-dropdown.html +42 -40
  24. package/src/components/nice-dropdown/nice-dropdown.js +52 -54
  25. package/src/components/nice-dropdown/nice-dropdown.scss +25 -4
  26. package/src/components/nice-dropdown-old/nice-dropdown-old.html +1 -1
  27. package/src/components/nice-dropdown-old/nice-dropdown-old.scss +8 -2
  28. package/src/components/nice-dtp/nice-dtp.html +7 -7
  29. package/src/components/nice-options/nice-options.scss +4 -0
  30. package/src/components/nice-popup/nice-popup.html +4 -4
  31. package/src/components/nice-popup/nice-popup.js +61 -75
  32. package/src/components/nice-popup/nice-popup.scss +10 -31
  33. package/src/components/nice-search/nice-search.html +0 -3
  34. package/src/components/nice-search2/nice-search2.html +22 -18
  35. package/src/components/nice-search2/nice-search2.js +1 -56
  36. package/src/components/nice-search2/nice-search2.scss +3 -2
  37. package/src/components/nice-svgs/nice-svgs.html +8 -0
  38. package/src/components/nice-time-picker/nice-time-picker.html +1 -3
  39. package/src/components/nice-time-picker/nice-time-picker.scss +0 -8
  40. package/src/directives/nice-tooltip/_nice-tooltip.scss +7 -28
  41. package/src/directives/nice-tooltip/nice-tooltip.js +16 -29
  42. package/src/services/nice-service.js +236 -1
  43. package/src/styles/_nice-anchored.scss +75 -0
  44. package/src/styles/_nice.scss +1 -0
@@ -1,44 +1,23 @@
1
+ // Positioning and arrow placement come from _nice-anchored.scss
2
+
3
+ // Single class on purpose: components can make the target a block (".nice-x .nice-popup-target")
4
+ .nice-popup-target {
5
+ display: inline-block;
6
+ }
7
+
1
8
  .nice-popup {
2
- .nice-popup-target {
3
- display: inline-block;
4
- }
5
9
 
6
- .nice-popup-arrow[data-hide] {
7
- visibility: hidden;
10
+ .nice-popup-arrow {
11
+ z-index: -1;
8
12
  }
9
13
 
10
- .nice-popup-arrow,
11
14
  .nice-popup-arrow::before {
12
15
  position: absolute;
13
16
  width: 8px;
14
17
  height: 8px;
15
- z-index: -1;
16
- }
17
-
18
- .nice-popup-arrow::before {
19
18
  content: '';
20
19
  transform: rotate(45deg);
21
20
  background: #ffffff;
22
21
  border: 1px solid $nice-border-color;
23
22
  }
24
-
25
- .nice-popup-content {
26
- z-index: 1;
27
- }
28
-
29
- .nice-popup-content[data-popper-placement^='top']>.nice-popup-arrow {
30
- bottom: -4px;
31
- }
32
-
33
- .nice-popup-content[data-popper-placement^='bottom']>.nice-popup-arrow {
34
- top: -4px;
35
- }
36
-
37
- .nice-popup-content[data-popper-placement^='left']>.nice-popup-arrow {
38
- right: -4px;
39
- }
40
-
41
- .nice-popup-content[data-popper-placement^='right']>.nice-popup-arrow {
42
- left: -4px;
43
- }
44
- }
23
+ }
@@ -9,15 +9,12 @@
9
9
  <input class="form-control" type="text" id="{{ id }}" ng-model="modelString" ng-keypress="keypress($event)" placeholder="{{ placeholder }}" ng-disabled="isDisabled" ng-change="updateSearch()" ng-required="required" tabindex="{{ tabIndex }}">
10
10
 
11
11
  <button type="button" class="btn input-group-addon" ng-click="search()" ng-if="!model" ng-disabled="isDisabled">
12
- <!-- <i ng-show="!loading" class="fa fa-search"></i>
13
- <i ng-show="loading" class="fa fa-refresh fa-spin"></i> -->
14
12
  <!-- <nice-icon ng-show="loading" icon="icon-loader" class="d-block nice-animation-spin"></nice-icon> -->
15
13
  <nice-icon ng-show="!loading" icon="icon-search"></nice-icon>
16
14
  <nice-loader ng-if="loading"></nice-loader>
17
15
  </button>
18
16
 
19
17
  <button type="button" class="btn input-group-addon" ng-click="remove()" ng-if="model" ng-disabled="isDisabled">
20
- <!-- <i ng-show="!loading" class="fa fa-remove"></i> -->
21
18
  <nice-icon ng-show="!loading" icon="icon-x"></nice-icon>
22
19
  </button>
23
20
  </div>
@@ -5,29 +5,33 @@
5
5
 
6
6
  <!------------------------- Field ------------------------->
7
7
  <div class="nice-field col-xs-12" ng-class="[fieldWidth ? fieldWidth : 'col-sm-8', { 'nice-disabled': isDisabled }]" click-outside="close()">
8
- <div class="nice-search-button input-group" ng-class="{ 'disabled': isDisabled }">
9
- <input class="form-control" type="text" id="{{ id }}" ng-model="model" placeholder="{{ placeholder }}" ng-disabled="isDisabled" ng-change="updateSearch()" ng-focus="onFocus()" ng-required="required" tabindex="{{ tabIndex }}">
8
+ <nice-popup trigger="manual" is-open="isOpen" placement="{{ placement }}" same-width="true">
9
+ <nice-popup-target>
10
+ <div class="nice-search-button input-group" ng-class="{ 'disabled': isDisabled }">
11
+ <input class="form-control" type="text" id="{{ id }}" ng-model="model" placeholder="{{ placeholder }}" ng-disabled="isDisabled" ng-change="updateSearch()" ng-focus="onFocus()" ng-required="required" tabindex="{{ tabIndex }}">
10
12
 
11
- <button type="button" class="btn input-group-addon" ng-disabled="isDisabled" ng-click="buttonClicked()">
12
- <nice-icon ng-show="!loading && model != ''" icon="icon-x"></nice-icon>
13
- <nice-icon ng-show="!loading && model == ''" icon="icon-search"></nice-icon>
14
- <nice-loader ng-if="loading"></nice-loader>
15
- </button>
16
- </div>
17
-
18
- <div class="nice-search-dropdown-wrapper">
19
- <div class="nice-search-dropdown" ng-if="showDropdown && isOpen">
20
- <div class="nice-search-row nice-search-row-loading" ng-if="loading && results.length == 0">
21
- <nice-loader ng-if="loading"></nice-loader>
13
+ <button type="button" class="btn input-group-addon" ng-disabled="isDisabled" ng-click="buttonClicked()">
14
+ <nice-icon ng-show="!loading && model != ''" icon="icon-x"></nice-icon>
15
+ <nice-icon ng-show="!loading && model == ''" icon="icon-search"></nice-icon>
16
+ <nice-loader ng-if="loading"></nice-loader>
17
+ </button>
22
18
  </div>
19
+ </nice-popup-target>
20
+
21
+ <nice-popup-content>
22
+ <div class="nice-search-dropdown" ng-if="showDropdown && isOpen">
23
+ <div class="nice-search-row nice-search-row-loading" ng-if="loading && results.length == 0">
24
+ <nice-loader ng-if="loading"></nice-loader>
25
+ </div>
23
26
 
24
- <div class="nice-search-row nice-search-row-empty" ng-if="!loading && results.length == 0" translate translate-context="Nice">No results found.</div>
27
+ <div class="nice-search-row nice-search-row-empty" ng-if="!loading && results.length == 0" translate translate-context="Nice">No results found.</div>
25
28
 
26
- <div ng-repeat="result in results" class="nice-search-row" ng-class="{'active': selectedIndex == $index}" ng-click="selectItem(result)">
27
- <ng-transclude>{{ result[keyForInputLabel] }}</ng-transclude>
29
+ <div ng-repeat="result in results" class="nice-search-row" ng-class="{'active': selectedIndex == $index}" ng-click="selectItem(result)">
30
+ <ng-transclude>{{ result[keyForInputLabel] }}</ng-transclude>
31
+ </div>
28
32
  </div>
29
- </div>
30
- </div>
33
+ </nice-popup-content>
34
+ </nice-popup>
31
35
  </div>
32
36
  </div>
33
37
  </ng-form>
@@ -33,7 +33,7 @@ angular.module('niceElements')
33
33
  isInline: '=',
34
34
  help: '@',
35
35
  required: '=',
36
- placement: '@', // Describes the preferred placement of the popper
36
+ placement: '@', // Preferred placement of the dropdown (nice-popup)
37
37
  },
38
38
  controller: function ($scope, $timeout, $element) {
39
39
  $scope.loading = false;
@@ -48,51 +48,6 @@ angular.module('niceElements')
48
48
  if (!$scope.model) $scope.model = "";
49
49
  if (!$scope.placement) { $scope.placement = "bottom-start"; }
50
50
 
51
- // Setup popper
52
- // https://popper.js.org/docs/v2/constructors/
53
- $scope.setupPopper = function () {
54
- const button = $element[0].getElementsByClassName('nice-search-button')[0];
55
- const tooltip = $element[0].getElementsByClassName('nice-search-dropdown-wrapper')[0];
56
- $scope.popper = Popper.createPopper(button, tooltip, {
57
- strategy: 'fixed',
58
- placement: $scope.placement,
59
- modifiers: [
60
- {
61
- name: 'offset',
62
- options: {
63
- offset: [0, 5],
64
- },
65
- },
66
- {
67
- name: "sameWidth",
68
- enabled: true,
69
- phase: "beforeWrite",
70
- requires: ["computeStyles"],
71
- fn: function (e) {
72
- const state = e.state;
73
- state.styles.popper.width = state.rects.reference.width + "px";
74
- },
75
- effect: function (e) {
76
- const state = e.state;
77
- state.elements.popper.style.width = state.elements.reference.offsetWidth + "px";
78
- }
79
- }
80
- ],
81
- });
82
- };
83
-
84
- const setupTimer = $timeout(function () {
85
- $scope.setupPopper();
86
- });
87
-
88
- // Popper adds scroll/resize listeners to window; remove them with the component
89
- $scope.$on('$destroy', function () {
90
- $timeout.cancel(setupTimer);
91
- if ($scope.popper) $scope.popper.destroy();
92
- $scope.popper = null;
93
- });
94
-
95
-
96
51
  // ------------------- On focus -------------------
97
52
  $scope.onFocus = function () {
98
53
  if ($scope.showDropdown && $scope.results.length == 0) {
@@ -115,22 +70,12 @@ angular.module('niceElements')
115
70
  // ------------------- On focus -------------------
116
71
  $scope.open = function () {
117
72
  $scope.isOpen = true;
118
- $timeout(function () {
119
- if ($scope.popper) $scope.popper.update();
120
- });
121
73
  };
122
74
 
123
75
 
124
76
  // ------------------- On blur -------------------
125
77
  $scope.close = function () {
126
78
  $scope.isOpen = false;
127
-
128
- // const input = $element[0].getElementsByTagName('input')[0];
129
- // if (input) input.blur();
130
-
131
- $timeout(function () {
132
- if ($scope.popper) $scope.popper.update();
133
- });
134
79
  };
135
80
 
136
81
 
@@ -14,8 +14,9 @@
14
14
  }
15
15
  }
16
16
 
17
- .nice-search-dropdown-wrapper {
18
- z-index: 999;
17
+ // Dropdown is a nice-popup as wide as the input
18
+ .nice-popup-target {
19
+ display: block;
19
20
  }
20
21
 
21
22
  .nice-search-dropdown {
@@ -245,6 +245,10 @@
245
245
  <path d="M23 12c0-3.037-1.232-5.789-3.222-7.778s-4.741-3.222-7.778-3.222-5.789 1.232-7.778 3.222-3.222 4.741-3.222 7.778 1.232 5.789 3.222 7.778 4.741 3.222 7.778 3.222 5.789-1.232 7.778-3.222 3.222-4.741 3.222-7.778zM21 12c0 2.486-1.006 4.734-2.636 6.364s-3.878 2.636-6.364 2.636-4.734-1.006-6.364-2.636-2.636-3.878-2.636-6.364 1.006-4.734 2.636-6.364 3.878-2.636 6.364-2.636 4.734 1.006 6.364 2.636 2.636 3.878 2.636 6.364z"></path>
246
246
  </symbol>
247
247
 
248
+ <symbol id="icon-dot" viewBox="0 0 24 24">
249
+ <path d="M12 6a6 6 0 1 1 0 12a6 6 0 1 1 0-12z"></path>
250
+ </symbol>
251
+
248
252
  <symbol id="icon-clipboard" viewBox="0 0 24 24">
249
253
  <path d="M7 5c0 0.552 0.225 1.053 0.586 1.414s0.862 0.586 1.414 0.586h6c0.552 0 1.053-0.225 1.414-0.586s0.586-0.862 0.586-1.414h1c0.276 0 0.525 0.111 0.707 0.293s0.293 0.431 0.293 0.707v14c0 0.276-0.111 0.525-0.293 0.707s-0.431 0.293-0.707 0.293h-12c-0.276 0-0.525-0.111-0.707-0.293s-0.293-0.431-0.293-0.707v-14c0-0.276 0.111-0.525 0.293-0.707s0.431-0.293 0.707-0.293zM9 1c-0.552 0-1.053 0.225-1.414 0.586s-0.586 0.862-0.586 1.414h-1c-0.828 0-1.58 0.337-2.121 0.879s-0.879 1.293-0.879 2.121v14c0 0.828 0.337 1.58 0.879 2.121s1.293 0.879 2.121 0.879h12c0.828 0 1.58-0.337 2.121-0.879s0.879-1.293 0.879-2.121v-14c0-0.828-0.337-1.58-0.879-2.121s-1.293-0.879-2.121-0.879h-1c0-0.552-0.225-1.053-0.586-1.414s-0.862-0.586-1.414-0.586zM9 3h6v2h-6z"></path>
250
254
  </symbol>
@@ -778,6 +782,10 @@
778
782
  </symbol>
779
783
 
780
784
  <symbol id="icon-plus" viewBox="0 0 24 24">
785
+ <path d="M10.5 5.5a1.5 1.5 0 0 1 3 0v5h5a1.5 1.5 0 0 1 0 3h-5v5a1.5 1.5 0 0 1-3 0v-5h-5a1.5 1.5 0 0 1 0-3h5z"></path>
786
+ </symbol>
787
+
788
+ <symbol id="icon-plus-2" viewBox="0 0 24 24">
781
789
  <path d="M5 13h6v6c0 0.552 0.448 1 1 1s1-0.448 1-1v-6h6c0.552 0 1-0.448 1-1s-0.448-1-1-1h-6v-6c0-0.552-0.448-1-1-1s-1 0.448-1 1v6h-6c-0.552 0-1 0.448-1 1s0.448 1 1 1z"></path>
782
790
  </symbol>
783
791
 
@@ -4,7 +4,7 @@
4
4
  <nice-title text="title || niceTitle" help="help" required="required" description="description" label-width="labelWidth"></nice-title>
5
5
 
6
6
  <!------------------------- Field ------------------------->
7
- <div class="nice-field col-xs-12" ng-class="fieldWidth ? fieldWidth : 'col-sm-8'">
7
+ <div class="nice-field col-xs-12" ng-class="fieldWidth ? fieldWidth : 'col-sm-8'" click-outside="close()" is-open="{{ open }}">
8
8
  <div class="input-group" ng-class="{
9
9
  'has-warning': !isDisabled && forma.$invalid && forma.$dirty,
10
10
  'disabled': isDisabled
@@ -39,6 +39,4 @@
39
39
  </div>
40
40
  </div>
41
41
  </div>
42
-
43
- <div class="nice-background" ng-click="close()" ng-if="open"></div>
44
42
  </div>
@@ -27,12 +27,4 @@
27
27
  }
28
28
  }
29
29
 
30
- .nice-background {
31
- position: fixed;
32
- top: 0;
33
- left: 0;
34
- width: 100%;
35
- z-index: 800;
36
- height: 100%;
37
- }
38
30
  }
@@ -2,9 +2,8 @@
2
2
  // cursor: help;
3
3
  }
4
4
 
5
+ // Positioning and arrow placement come from _nice-anchored.scss
5
6
  .nice-tooltip-window {
6
- display: none;
7
- position: relative;
8
7
  background: var(--nice-help-popup-bg);
9
8
  color: var(--nice-help-popup-color);
10
9
  max-width: 200px;
@@ -15,41 +14,21 @@
15
14
  font-weight: normal;
16
15
  text-transform: none;
17
16
 
18
- &[data-show] {
19
- display: block;
20
- }
21
-
22
- .nice-tooltip-window-arrow,
23
- .nice-tooltip-window-arrow::before {
24
- position: absolute;
25
- width: 8px;
26
- height: 8px;
27
- background: inherit;
17
+ &.nice-anchored-fallback {
18
+ z-index: 1100;
28
19
  }
29
20
 
30
21
  .nice-tooltip-window-arrow {
31
22
  visibility: hidden;
32
23
 
33
24
  &::before {
25
+ position: absolute;
26
+ width: 8px;
27
+ height: 8px;
28
+ background: var(--nice-help-popup-bg);
34
29
  visibility: visible;
35
30
  content: "";
36
31
  transform: rotate(45deg);
37
32
  }
38
33
  }
39
-
40
- &[data-popper-placement^="top"] > .nice-tooltip-window-arrow {
41
- bottom: -4px;
42
- }
43
-
44
- &[data-popper-placement^="bottom"] > .nice-tooltip-window-arrow {
45
- top: -4px;
46
- }
47
-
48
- &[data-popper-placement^="left"] > .nice-tooltip-window-arrow {
49
- right: -4px;
50
- }
51
-
52
- &[data-popper-placement^="right"] > .nice-tooltip-window-arrow {
53
- left: -4px;
54
- }
55
34
  }
@@ -5,24 +5,27 @@
5
5
  * @name niceElements.directive:niceTooltip
6
6
  * @description
7
7
  * # niceTooltip
8
+ * Positioned with NiceService.anchor() (native popover + CSS anchor positioning, Popper fallback).
8
9
  */
9
10
  angular.module('niceElements')
10
11
  .directive('niceTooltip', function () {
11
12
  return {
12
13
  restrict: 'A',
13
- controller: function ($scope, $element, $attrs, $injector) {
14
+ controller: function ($scope, $element, $attrs, $injector, NiceService) {
14
15
  const id = Math.random().toString(36).substring(7);
15
16
  const showEvents = ['mouseenter', 'focus'];
16
17
  const hideEvents = ['mouseleave', 'blur'];
17
- const placement = $attrs.niceTooltipPlacement || "top";
18
+ // "auto" variants → top variants (flips when there is no space)
19
+ const placement = ($attrs.niceTooltipPlacement || 'top').replace(/^auto/, 'top');
18
20
 
19
- // Create popper window
20
- $element.addClass("nice-tooltip");
21
+ // Create tooltip window
22
+ $element.addClass('nice-tooltip');
21
23
  const tooltipWindow = document.createElement('div');
22
24
  tooltipWindow.className = 'nice-tooltip-window';
23
25
  tooltipWindow.id = 'nice-tooltip-window-' + id;
26
+ tooltipWindow.setAttribute('role', 'tooltip');
24
27
 
25
- // Popper body. The attribute's {{ }} is interpolated by Angular, but the
28
+ // Tooltip body. The attribute's {{ }} is interpolated by Angular, but the
26
29
  // resulting text is never compiled, so user data can't run as a template.
27
30
  // Safe HTML is kept when the app loads ngSanitize; otherwise it's plain text.
28
31
  const content = document.createElement('div');
@@ -36,44 +39,28 @@ angular.module('niceElements')
36
39
  else content.textContent = value;
37
40
  });
38
41
 
39
- // Popper arrow
42
+ // Arrow
40
43
  const tooltipWindowArrow = document.createElement('div');
41
44
  tooltipWindowArrow.className = 'nice-tooltip-window-arrow';
42
- tooltipWindowArrow.setAttribute("data-popper-arrow", "");
43
45
  tooltipWindow.append(tooltipWindowArrow);
44
46
 
45
47
  // Add to body
46
48
  document.body.append(tooltipWindow);
47
49
 
48
- // Setup popper
49
- const popper = Popper.createPopper($element[0], tooltipWindow, {
50
+ const anchored = NiceService.anchor($element[0], tooltipWindow, {
50
51
  placement: placement,
51
- strategy: 'fixed',
52
- modifiers: [
53
- {
54
- name: 'offset',
55
- options: {
56
- offset: [0, 8],
57
- },
58
- },
59
- {
60
- name: 'arrow',
61
- options: {
62
- element: tooltipWindowArrow,
63
- padding: 3
64
- },
65
- },
66
- ],
52
+ offset: 8,
53
+ arrow: tooltipWindowArrow,
54
+ onEscape: hide
67
55
  });
68
56
 
69
57
  function show() {
70
58
  if ($attrs.niceTooltipDisabled == true || $attrs.niceTooltipDisabled == "true") return;
71
- tooltipWindow.setAttribute('data-show', '');
72
- popper.update();
59
+ anchored.open();
73
60
  }
74
61
 
75
62
  function hide() {
76
- tooltipWindow.removeAttribute('data-show');
63
+ anchored.close();
77
64
  }
78
65
 
79
66
  showEvents.forEach((event) => {
@@ -86,8 +73,8 @@ angular.module('niceElements')
86
73
 
87
74
  // On destroy
88
75
  $scope.$on('$destroy', function () {
76
+ anchored.destroy();
89
77
  tooltipWindow.remove();
90
- if (popper) popper.destroy();
91
78
  });
92
79
  }
93
80
  };