@ngx-stoui/core 12.1.5 → 13.0.1
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/esm2020/index.mjs +18 -0
- package/esm2020/lib/abstract-and-interfaces/keyPress.enum.mjs +140 -0
- package/esm2020/lib/sto-directives/context-menu.directive.mjs +35 -0
- package/esm2020/lib/sto-directives/date-form-field-click.directive.mjs +45 -0
- package/esm2020/lib/sto-directives/directives.module.mjs +56 -0
- package/esm2020/lib/sto-directives/index.mjs +7 -0
- package/esm2020/lib/sto-directives/menu-overlay.directive.mjs +47 -0
- package/esm2020/lib/sto-directives/quick-keys.directive.mjs +78 -0
- package/esm2020/lib/sto-directives/sto-grid.directive.mjs +106 -0
- package/esm2020/lib/sto-directives/sto-select-text-on-focus.directive.mjs +58 -0
- package/esm2020/lib/sto-pipes/currency-format.pipe.mjs +35 -0
- package/esm2020/lib/sto-pipes/date-format.pipe.mjs +47 -0
- package/esm2020/lib/sto-pipes/keys.pipe.mjs +27 -0
- package/esm2020/lib/sto-pipes/number-format.pipe.mjs +78 -0
- package/esm2020/lib/sto-pipes/sto-pipes.module.mjs +51 -0
- package/esm2020/lib/sto-pipes/with-unit.mjs +43 -0
- package/esm2020/lib/sto-pipes/yes-no.mjs +21 -0
- package/esm2020/lib/sto-user-preference/sto-user-preference.component.mjs +45 -0
- package/esm2020/lib/sto-user-preference/sto-user-preference.module.mjs +27 -0
- package/esm2020/lib/sto-user-preference/sto-user-preference.service.mjs +39 -0
- package/esm2020/ngx-stoui-core.mjs +5 -0
- package/fesm2015/ngx-stoui-core.mjs +926 -0
- package/fesm2015/ngx-stoui-core.mjs.map +1 -0
- package/{fesm2015/ngx-stoui-core.js → fesm2020/ngx-stoui-core.mjs} +69 -72
- package/fesm2020/ngx-stoui-core.mjs.map +1 -0
- package/ngx-stoui.css +136 -137
- package/package.json +21 -8
- package/style/grid.scss +6 -2
- package/style/sto-dialog.scss +1 -1
- package/style/theme/_appheader.scss +1 -1
- package/style/theme/_card.scss +1 -1
- package/style/theme/_colors.scss +1 -1
- package/style/theme/_datatable.scss +1 -1
- package/style/theme/_drawer.scss +1 -1
- package/style/theme/_filterpanel.scss +1 -1
- package/style/theme/_input-overrides.scss +1 -1
- package/style/theme/_message-panel.scss +1 -1
- package/style/theme/_sto-indicators.scss +1 -1
- package/style/theme/_theme-variables.scss +1 -1
- package/style/theme/_theme.scss +1 -1
- package/style/theme/_typography.scss +1 -1
- package/style/theme.scss +1 -1
- package/bundles/ngx-stoui-core.umd.js +0 -1350
- package/bundles/ngx-stoui-core.umd.js.map +0 -1
- package/esm2015/index.js +0 -18
- package/esm2015/index.js.map +0 -1
- package/esm2015/lib/abstract-and-interfaces/keyPress.enum.js +0 -140
- package/esm2015/lib/abstract-and-interfaces/keyPress.enum.js.map +0 -1
- package/esm2015/lib/sto-directives/context-menu.directive.js +0 -35
- package/esm2015/lib/sto-directives/context-menu.directive.js.map +0 -1
- package/esm2015/lib/sto-directives/date-form-field-click.directive.js +0 -45
- package/esm2015/lib/sto-directives/date-form-field-click.directive.js.map +0 -1
- package/esm2015/lib/sto-directives/directives.module.js +0 -56
- package/esm2015/lib/sto-directives/directives.module.js.map +0 -1
- package/esm2015/lib/sto-directives/index.js +0 -7
- package/esm2015/lib/sto-directives/index.js.map +0 -1
- package/esm2015/lib/sto-directives/menu-overlay.directive.js +0 -47
- package/esm2015/lib/sto-directives/menu-overlay.directive.js.map +0 -1
- package/esm2015/lib/sto-directives/quick-keys.directive.js +0 -78
- package/esm2015/lib/sto-directives/quick-keys.directive.js.map +0 -1
- package/esm2015/lib/sto-directives/sto-grid.directive.js +0 -106
- package/esm2015/lib/sto-directives/sto-grid.directive.js.map +0 -1
- package/esm2015/lib/sto-directives/sto-select-text-on-focus.directive.js +0 -58
- package/esm2015/lib/sto-directives/sto-select-text-on-focus.directive.js.map +0 -1
- package/esm2015/lib/sto-pipes/currency-format.pipe.js +0 -35
- package/esm2015/lib/sto-pipes/currency-format.pipe.js.map +0 -1
- package/esm2015/lib/sto-pipes/date-format.pipe.js +0 -47
- package/esm2015/lib/sto-pipes/date-format.pipe.js.map +0 -1
- package/esm2015/lib/sto-pipes/keys.pipe.js +0 -27
- package/esm2015/lib/sto-pipes/keys.pipe.js.map +0 -1
- package/esm2015/lib/sto-pipes/number-format.pipe.js +0 -78
- package/esm2015/lib/sto-pipes/number-format.pipe.js.map +0 -1
- package/esm2015/lib/sto-pipes/sto-pipes.module.js +0 -51
- package/esm2015/lib/sto-pipes/sto-pipes.module.js.map +0 -1
- package/esm2015/lib/sto-pipes/with-unit.js +0 -43
- package/esm2015/lib/sto-pipes/with-unit.js.map +0 -1
- package/esm2015/lib/sto-pipes/yes-no.js +0 -21
- package/esm2015/lib/sto-pipes/yes-no.js.map +0 -1
- package/esm2015/lib/sto-user-preference/sto-user-preference.component.js +0 -48
- package/esm2015/lib/sto-user-preference/sto-user-preference.component.js.map +0 -1
- package/esm2015/lib/sto-user-preference/sto-user-preference.module.js +0 -27
- package/esm2015/lib/sto-user-preference/sto-user-preference.module.js.map +0 -1
- package/esm2015/lib/sto-user-preference/sto-user-preference.service.js +0 -39
- package/esm2015/lib/sto-user-preference/sto-user-preference.service.js.map +0 -1
- package/esm2015/ngx-stoui-core.js +0 -5
- package/esm2015/ngx-stoui-core.js.map +0 -1
- package/fesm2015/ngx-stoui-core.js.map +0 -1
|
@@ -0,0 +1,926 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { EventEmitter, Directive, Input, Output, HostListener, ContentChildren, Injectable, Optional, HostBinding, ElementRef, Host, NgModule, Pipe, Component } from '@angular/core';
|
|
3
|
+
import * as i4 from '@angular/common';
|
|
4
|
+
import { CommonModule } from '@angular/common';
|
|
5
|
+
import { MatInput } from '@angular/material/input';
|
|
6
|
+
import { Subject, BehaviorSubject, fromEvent } from 'rxjs';
|
|
7
|
+
import { takeUntil, switchMap, take } from 'rxjs/operators';
|
|
8
|
+
import { LayoutModule } from '@angular/cdk/layout';
|
|
9
|
+
import * as i1 from '@angular/material/menu';
|
|
10
|
+
import { format } from 'date-fns';
|
|
11
|
+
import * as i1$1 from '@angular/forms';
|
|
12
|
+
import { ReactiveFormsModule, FormsModule } from '@angular/forms';
|
|
13
|
+
import * as i3 from '@angular/material/expansion';
|
|
14
|
+
import { MatExpansionModule } from '@angular/material/expansion';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
MIT License
|
|
18
|
+
|
|
19
|
+
Copyright (c) 2017 Nathan Friend
|
|
20
|
+
|
|
21
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
22
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
23
|
+
in the Software without restriction, including without limitation the rights
|
|
24
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
25
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
26
|
+
furnished to do so, subject to the following conditions:
|
|
27
|
+
|
|
28
|
+
The above copyright notice and this permission notice shall be included in all
|
|
29
|
+
copies or substantial portions of the Software.
|
|
30
|
+
|
|
31
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
32
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
33
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
34
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
35
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
36
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
37
|
+
SOFTWARE. **/
|
|
38
|
+
var Key;
|
|
39
|
+
(function (Key) {
|
|
40
|
+
Key[Key["Backspace"] = 8] = "Backspace";
|
|
41
|
+
Key[Key["Tab"] = 9] = "Tab";
|
|
42
|
+
Key[Key["Enter"] = 13] = "Enter";
|
|
43
|
+
Key[Key["Shift"] = 16] = "Shift";
|
|
44
|
+
Key[Key["Ctrl"] = 17] = "Ctrl";
|
|
45
|
+
Key[Key["Alt"] = 18] = "Alt";
|
|
46
|
+
Key[Key["PauseBreak"] = 19] = "PauseBreak";
|
|
47
|
+
Key[Key["CapsLock"] = 20] = "CapsLock";
|
|
48
|
+
Key[Key["Escape"] = 27] = "Escape";
|
|
49
|
+
Key[Key["Space"] = 32] = "Space";
|
|
50
|
+
Key[Key["PageUp"] = 33] = "PageUp";
|
|
51
|
+
Key[Key["PageDown"] = 34] = "PageDown";
|
|
52
|
+
Key[Key["End"] = 35] = "End";
|
|
53
|
+
Key[Key["Home"] = 36] = "Home";
|
|
54
|
+
Key[Key["LeftArrow"] = 37] = "LeftArrow";
|
|
55
|
+
Key[Key["UpArrow"] = 38] = "UpArrow";
|
|
56
|
+
Key[Key["RightArrow"] = 39] = "RightArrow";
|
|
57
|
+
Key[Key["DownArrow"] = 40] = "DownArrow";
|
|
58
|
+
Key[Key["Insert"] = 45] = "Insert";
|
|
59
|
+
Key[Key["Delete"] = 46] = "Delete";
|
|
60
|
+
Key[Key["Zero"] = 48] = "Zero";
|
|
61
|
+
Key[Key["ClosedParen"] = 48] = "ClosedParen";
|
|
62
|
+
Key[Key["One"] = 49] = "One";
|
|
63
|
+
Key[Key["ExclamationMark"] = 49] = "ExclamationMark";
|
|
64
|
+
Key[Key["Two"] = 50] = "Two";
|
|
65
|
+
Key[Key["AtSign"] = 50] = "AtSign";
|
|
66
|
+
Key[Key["Three"] = 51] = "Three";
|
|
67
|
+
Key[Key["PoundSign"] = 51] = "PoundSign";
|
|
68
|
+
Key[Key["Hash"] = 51] = "Hash";
|
|
69
|
+
Key[Key["Four"] = 52] = "Four";
|
|
70
|
+
Key[Key["DollarSign"] = 52] = "DollarSign";
|
|
71
|
+
Key[Key["Five"] = 53] = "Five";
|
|
72
|
+
Key[Key["PercentSign"] = 53] = "PercentSign";
|
|
73
|
+
Key[Key["Six"] = 54] = "Six";
|
|
74
|
+
Key[Key["Caret"] = 54] = "Caret";
|
|
75
|
+
Key[Key["Hat"] = 54] = "Hat";
|
|
76
|
+
Key[Key["Seven"] = 55] = "Seven";
|
|
77
|
+
Key[Key["Ampersand"] = 55] = "Ampersand";
|
|
78
|
+
Key[Key["Eight"] = 56] = "Eight";
|
|
79
|
+
Key[Key["Star"] = 56] = "Star";
|
|
80
|
+
Key[Key["Asterik"] = 56] = "Asterik";
|
|
81
|
+
Key[Key["Nine"] = 57] = "Nine";
|
|
82
|
+
Key[Key["OpenParen"] = 57] = "OpenParen";
|
|
83
|
+
Key[Key["A"] = 65] = "A";
|
|
84
|
+
Key[Key["B"] = 66] = "B";
|
|
85
|
+
Key[Key["C"] = 67] = "C";
|
|
86
|
+
Key[Key["D"] = 68] = "D";
|
|
87
|
+
Key[Key["E"] = 69] = "E";
|
|
88
|
+
Key[Key["F"] = 70] = "F";
|
|
89
|
+
Key[Key["G"] = 71] = "G";
|
|
90
|
+
Key[Key["H"] = 72] = "H";
|
|
91
|
+
Key[Key["I"] = 73] = "I";
|
|
92
|
+
Key[Key["J"] = 74] = "J";
|
|
93
|
+
Key[Key["K"] = 75] = "K";
|
|
94
|
+
Key[Key["L"] = 76] = "L";
|
|
95
|
+
Key[Key["M"] = 77] = "M";
|
|
96
|
+
Key[Key["N"] = 78] = "N";
|
|
97
|
+
Key[Key["O"] = 79] = "O";
|
|
98
|
+
Key[Key["P"] = 80] = "P";
|
|
99
|
+
Key[Key["Q"] = 81] = "Q";
|
|
100
|
+
Key[Key["R"] = 82] = "R";
|
|
101
|
+
Key[Key["S"] = 83] = "S";
|
|
102
|
+
Key[Key["T"] = 84] = "T";
|
|
103
|
+
Key[Key["U"] = 85] = "U";
|
|
104
|
+
Key[Key["V"] = 86] = "V";
|
|
105
|
+
Key[Key["W"] = 87] = "W";
|
|
106
|
+
Key[Key["X"] = 88] = "X";
|
|
107
|
+
Key[Key["Y"] = 89] = "Y";
|
|
108
|
+
Key[Key["Z"] = 90] = "Z";
|
|
109
|
+
Key[Key["LeftWindowKey"] = 91] = "LeftWindowKey";
|
|
110
|
+
Key[Key["RightWindowKey"] = 92] = "RightWindowKey";
|
|
111
|
+
Key[Key["SelectKey"] = 93] = "SelectKey";
|
|
112
|
+
Key[Key["Numpad0"] = 96] = "Numpad0";
|
|
113
|
+
Key[Key["Numpad1"] = 97] = "Numpad1";
|
|
114
|
+
Key[Key["Numpad2"] = 98] = "Numpad2";
|
|
115
|
+
Key[Key["Numpad3"] = 99] = "Numpad3";
|
|
116
|
+
Key[Key["Numpad4"] = 100] = "Numpad4";
|
|
117
|
+
Key[Key["Numpad5"] = 101] = "Numpad5";
|
|
118
|
+
Key[Key["Numpad6"] = 102] = "Numpad6";
|
|
119
|
+
Key[Key["Numpad7"] = 103] = "Numpad7";
|
|
120
|
+
Key[Key["Numpad8"] = 104] = "Numpad8";
|
|
121
|
+
Key[Key["Numpad9"] = 105] = "Numpad9";
|
|
122
|
+
Key[Key["Multiply"] = 106] = "Multiply";
|
|
123
|
+
Key[Key["Add"] = 107] = "Add";
|
|
124
|
+
Key[Key["Subtract"] = 109] = "Subtract";
|
|
125
|
+
Key[Key["DecimalPoint"] = 110] = "DecimalPoint";
|
|
126
|
+
Key[Key["Divide"] = 111] = "Divide";
|
|
127
|
+
Key[Key["F1"] = 112] = "F1";
|
|
128
|
+
Key[Key["F2"] = 113] = "F2";
|
|
129
|
+
Key[Key["F3"] = 114] = "F3";
|
|
130
|
+
Key[Key["F4"] = 115] = "F4";
|
|
131
|
+
Key[Key["F5"] = 116] = "F5";
|
|
132
|
+
Key[Key["F6"] = 117] = "F6";
|
|
133
|
+
Key[Key["F7"] = 118] = "F7";
|
|
134
|
+
Key[Key["F8"] = 119] = "F8";
|
|
135
|
+
Key[Key["F9"] = 120] = "F9";
|
|
136
|
+
Key[Key["F10"] = 121] = "F10";
|
|
137
|
+
Key[Key["F11"] = 122] = "F11";
|
|
138
|
+
Key[Key["F12"] = 123] = "F12";
|
|
139
|
+
Key[Key["NumLock"] = 144] = "NumLock";
|
|
140
|
+
Key[Key["ScrollLock"] = 145] = "ScrollLock";
|
|
141
|
+
Key[Key["SemiColon"] = 186] = "SemiColon";
|
|
142
|
+
Key[Key["Equals"] = 187] = "Equals";
|
|
143
|
+
Key[Key["Comma"] = 188] = "Comma";
|
|
144
|
+
Key[Key["Dash"] = 189] = "Dash";
|
|
145
|
+
Key[Key["Period"] = 190] = "Period";
|
|
146
|
+
Key[Key["UnderScore"] = 189] = "UnderScore";
|
|
147
|
+
Key[Key["PlusSign"] = 187] = "PlusSign";
|
|
148
|
+
Key[Key["ForwardSlash"] = 191] = "ForwardSlash";
|
|
149
|
+
Key[Key["Tilde"] = 192] = "Tilde";
|
|
150
|
+
Key[Key["GraveAccent"] = 192] = "GraveAccent";
|
|
151
|
+
Key[Key["OpenBracket"] = 219] = "OpenBracket";
|
|
152
|
+
Key[Key["ClosedBracket"] = 221] = "ClosedBracket";
|
|
153
|
+
Key[Key["Quote"] = 222] = "Quote";
|
|
154
|
+
})(Key || (Key = {}));
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* QuickKeysDirective is used to implement shortcut keys on DOM elements, e.g to submit or reset a form on enter/escape
|
|
158
|
+
* <form quickKeys (quickSubmit)="save()" (quickCancel)="reset()">
|
|
159
|
+
*/
|
|
160
|
+
class QuickKeysDirective {
|
|
161
|
+
constructor() {
|
|
162
|
+
/**
|
|
163
|
+
* Emits when ctrl + enter is clicked in combination
|
|
164
|
+
* <form (quickSubmit)="save()">
|
|
165
|
+
*/
|
|
166
|
+
this.quickSubmit = new EventEmitter();
|
|
167
|
+
/**
|
|
168
|
+
* Emits when escape is clicked
|
|
169
|
+
* <form (quickCancel)="cancel()">
|
|
170
|
+
*/
|
|
171
|
+
this.quickCancel = new EventEmitter();
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Listens on the host element for any keyup events
|
|
175
|
+
* @param e
|
|
176
|
+
*/
|
|
177
|
+
onKeyUp(e) {
|
|
178
|
+
if (this.formGroup) {
|
|
179
|
+
this.handleFormKeys(e);
|
|
180
|
+
}
|
|
181
|
+
this.handleGenericKeydown(e);
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Handler for generic keydowns, such as cancel events to close drawers
|
|
185
|
+
* @param e
|
|
186
|
+
* void
|
|
187
|
+
*/
|
|
188
|
+
handleGenericKeydown(e) {
|
|
189
|
+
// Shortcuts that are useful outside of forms
|
|
190
|
+
if (e.keyCode === Key.Escape) {
|
|
191
|
+
this.quickCancel.emit();
|
|
192
|
+
}
|
|
193
|
+
if (!this.formGroup && e.keyCode === Key.Enter && e.ctrlKey) {
|
|
194
|
+
this.quickSubmit.emit();
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Handler for form specific shortcuts, such as saving the form
|
|
199
|
+
* @param e
|
|
200
|
+
*/
|
|
201
|
+
handleFormKeys(e) {
|
|
202
|
+
if (this.formGroup.pristine) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
if (e.keyCode === Key.Enter && e.ctrlKey) {
|
|
206
|
+
this.quickSubmit.emit();
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
QuickKeysDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: QuickKeysDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
211
|
+
QuickKeysDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.2", type: QuickKeysDirective, selector: "[stoQuickKeys]", inputs: { quickKeys: "quickKeys", formGroup: "formGroup" }, outputs: { quickSubmit: "quickSubmit", quickCancel: "quickCancel" }, host: { listeners: { "keyup": "onKeyUp($event)" } }, ngImport: i0 });
|
|
212
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: QuickKeysDirective, decorators: [{
|
|
213
|
+
type: Directive,
|
|
214
|
+
args: [{
|
|
215
|
+
selector: '[stoQuickKeys]'
|
|
216
|
+
}]
|
|
217
|
+
}], propDecorators: { quickKeys: [{
|
|
218
|
+
type: Input
|
|
219
|
+
}], formGroup: [{
|
|
220
|
+
type: Input
|
|
221
|
+
}], quickSubmit: [{
|
|
222
|
+
type: Output
|
|
223
|
+
}], quickCancel: [{
|
|
224
|
+
type: Output
|
|
225
|
+
}], onKeyUp: [{
|
|
226
|
+
type: HostListener,
|
|
227
|
+
args: ['keyup', ['$event']]
|
|
228
|
+
}] } });
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Directive that can be placed on mat-form-fields that contains a mat-datepicker.
|
|
232
|
+
* This directive has two tasks:
|
|
233
|
+
* Clicking anywhere on the mat-form-field will open the datepicker dialog
|
|
234
|
+
* When the datepicker is closed in any manner, we shift focus back to the datepicker input
|
|
235
|
+
*/
|
|
236
|
+
class DateFormFieldClickDirective {
|
|
237
|
+
constructor() {
|
|
238
|
+
this.destroy$ = new Subject();
|
|
239
|
+
}
|
|
240
|
+
clickEvent() {
|
|
241
|
+
this.stoDateFormFieldClick.open();
|
|
242
|
+
}
|
|
243
|
+
ngOnInit() {
|
|
244
|
+
this.stoDateFormFieldClick.closedStream
|
|
245
|
+
.pipe(takeUntil(this.destroy$)).subscribe(() => this.inputs.first.focus());
|
|
246
|
+
}
|
|
247
|
+
ngOnDestroy() {
|
|
248
|
+
this.destroy$.next(true);
|
|
249
|
+
this.destroy$.complete();
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
DateFormFieldClickDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: DateFormFieldClickDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
253
|
+
DateFormFieldClickDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.2", type: DateFormFieldClickDirective, selector: "[stoDateFormFieldClick]", inputs: { stoDateFormFieldClick: "stoDateFormFieldClick" }, host: { listeners: { "click": "clickEvent()" } }, queries: [{ propertyName: "inputs", predicate: MatInput }], ngImport: i0 });
|
|
254
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: DateFormFieldClickDirective, decorators: [{
|
|
255
|
+
type: Directive,
|
|
256
|
+
args: [{
|
|
257
|
+
selector: '[stoDateFormFieldClick]'
|
|
258
|
+
}]
|
|
259
|
+
}], propDecorators: { inputs: [{
|
|
260
|
+
type: ContentChildren,
|
|
261
|
+
args: [MatInput]
|
|
262
|
+
}], stoDateFormFieldClick: [{
|
|
263
|
+
type: Input
|
|
264
|
+
}], clickEvent: [{
|
|
265
|
+
type: HostListener,
|
|
266
|
+
args: ['click']
|
|
267
|
+
}] } });
|
|
268
|
+
|
|
269
|
+
const preferenceKey = 'TOPS_IM:UserPreferences';
|
|
270
|
+
class StoUserPreferenceService {
|
|
271
|
+
constructor() {
|
|
272
|
+
this.hasSelectTextOnFocusEnabled = new BehaviorSubject(true);
|
|
273
|
+
this.default = {
|
|
274
|
+
hasSelectTextOnFocusEnabled: true
|
|
275
|
+
};
|
|
276
|
+
let sessionPreferences = {};
|
|
277
|
+
const sessionPreferencesString = this.getPreferences();
|
|
278
|
+
try {
|
|
279
|
+
sessionPreferences = JSON.parse(sessionPreferencesString);
|
|
280
|
+
}
|
|
281
|
+
catch (e) {
|
|
282
|
+
console.error('Unable to parse the preferences from local storage. Loading default');
|
|
283
|
+
}
|
|
284
|
+
this.preferences = Object.assign(Object.assign({}, this.default), sessionPreferences);
|
|
285
|
+
this.setHasSelectTextOnFocusEnabled(this.preferences.hasSelectTextOnFocusEnabled);
|
|
286
|
+
}
|
|
287
|
+
setHasSelectTextOnFocusEnabled(value) {
|
|
288
|
+
this.hasSelectTextOnFocusEnabled.next(value);
|
|
289
|
+
this.preferences.hasSelectTextOnFocusEnabled = value;
|
|
290
|
+
this.setPreferences(this.preferences);
|
|
291
|
+
}
|
|
292
|
+
getPreferences() {
|
|
293
|
+
return sessionStorage.getItem(preferenceKey) || '{}';
|
|
294
|
+
}
|
|
295
|
+
setPreferences(value) {
|
|
296
|
+
sessionStorage.setItem(preferenceKey, JSON.stringify(value));
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
StoUserPreferenceService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: StoUserPreferenceService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
300
|
+
StoUserPreferenceService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: StoUserPreferenceService });
|
|
301
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: StoUserPreferenceService, decorators: [{
|
|
302
|
+
type: Injectable
|
|
303
|
+
}], ctorParameters: function () { return []; } });
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* stoSelectTextOnFocus listens for input focus events, and selects the contents of the input
|
|
307
|
+
* A user service is established in {@link StoUserPreferenceService} that allows a user to toggle this feature
|
|
308
|
+
*/
|
|
309
|
+
class StoSelectTextOnFocusDirective {
|
|
310
|
+
constructor(elementRef, userPreferenceService) {
|
|
311
|
+
this.elementRef = elementRef;
|
|
312
|
+
this.userPreferenceService = userPreferenceService;
|
|
313
|
+
this.destroyed$ = new Subject();
|
|
314
|
+
this._el = this.elementRef.nativeElement;
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Listens for focus events on the host (input) element, and focuses if applicable
|
|
318
|
+
*/
|
|
319
|
+
onFocus() {
|
|
320
|
+
if (this._hasSelectTextOnFocusEnabled && this._el.readOnly === false) {
|
|
321
|
+
this._el.select();
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Subscribes to changes in {@link StoUserPreferenceService}, and binds the variable accordingly.
|
|
326
|
+
*/
|
|
327
|
+
ngOnInit() {
|
|
328
|
+
if (this.userPreferenceService) {
|
|
329
|
+
this.userPreferenceService.hasSelectTextOnFocusEnabled
|
|
330
|
+
.pipe(takeUntil(this.destroyed$)).subscribe((hasSelectTextOnFocusEnabled) => {
|
|
331
|
+
this._hasSelectTextOnFocusEnabled = hasSelectTextOnFocusEnabled;
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
ngOnDestroy() {
|
|
336
|
+
this.destroyed$.next(true);
|
|
337
|
+
this.destroyed$.complete();
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
StoSelectTextOnFocusDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: StoSelectTextOnFocusDirective, deps: [{ token: i0.ElementRef }, { token: StoUserPreferenceService, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
|
|
341
|
+
StoSelectTextOnFocusDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.2", type: StoSelectTextOnFocusDirective, selector: "[stoSelectTextOnFocus]", host: { listeners: { "focus": "onFocus()", "dblclick": "onFocus()" } }, ngImport: i0 });
|
|
342
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: StoSelectTextOnFocusDirective, decorators: [{
|
|
343
|
+
type: Directive,
|
|
344
|
+
args: [{
|
|
345
|
+
selector: '[stoSelectTextOnFocus]'
|
|
346
|
+
}]
|
|
347
|
+
}], ctorParameters: function () {
|
|
348
|
+
return [{ type: i0.ElementRef }, { type: StoUserPreferenceService, decorators: [{
|
|
349
|
+
type: Optional
|
|
350
|
+
}] }];
|
|
351
|
+
}, propDecorators: { onFocus: [{
|
|
352
|
+
type: HostListener,
|
|
353
|
+
args: ['focus']
|
|
354
|
+
}, {
|
|
355
|
+
type: HostListener,
|
|
356
|
+
args: ['dblclick']
|
|
357
|
+
}] } });
|
|
358
|
+
|
|
359
|
+
const getClass = (width, small = 400, large = 800) => {
|
|
360
|
+
let cols = 1;
|
|
361
|
+
if (width > small) {
|
|
362
|
+
cols += 1;
|
|
363
|
+
}
|
|
364
|
+
if (width > large) {
|
|
365
|
+
cols += 2;
|
|
366
|
+
}
|
|
367
|
+
return `sto-f-grid--${cols}`;
|
|
368
|
+
};
|
|
369
|
+
const ALL_GRIDS = ['sto-f-grid--1', 'sto-f-grid--2', 'sto-f-grid--4', 'sto-f-grid--6'];
|
|
370
|
+
class StoGridSpacerDirective {
|
|
371
|
+
constructor() {
|
|
372
|
+
this.useClass = true;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
StoGridSpacerDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: StoGridSpacerDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
376
|
+
StoGridSpacerDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.2", type: StoGridSpacerDirective, selector: "[stoGridSpacer]", host: { properties: { "class.sto-f-grid__col": "this.useClass", "class.sto-f-grid__col--spacer": "this.useClass" } }, ngImport: i0 });
|
|
377
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: StoGridSpacerDirective, decorators: [{
|
|
378
|
+
type: Directive,
|
|
379
|
+
args: [{ selector: '[stoGridSpacer]' }]
|
|
380
|
+
}], propDecorators: { useClass: [{
|
|
381
|
+
type: HostBinding,
|
|
382
|
+
args: ['class.sto-f-grid__col']
|
|
383
|
+
}, {
|
|
384
|
+
type: HostBinding,
|
|
385
|
+
args: ['class.sto-f-grid__col--spacer']
|
|
386
|
+
}] } });
|
|
387
|
+
class StoGridColumnDirective {
|
|
388
|
+
constructor() {
|
|
389
|
+
this.useClass = true;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
StoGridColumnDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: StoGridColumnDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
393
|
+
StoGridColumnDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.2", type: StoGridColumnDirective, selector: "[stoGridColumn]", inputs: { stoGridColumnDouble: "stoGridColumnDouble" }, host: { properties: { "class.sto-f-grid__col": "this.useClass", "class.sto-f-grid__col--2": "this.stoGridColumnDouble" } }, ngImport: i0 });
|
|
394
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: StoGridColumnDirective, decorators: [{
|
|
395
|
+
type: Directive,
|
|
396
|
+
args: [{ selector: '[stoGridColumn]' }]
|
|
397
|
+
}], propDecorators: { useClass: [{
|
|
398
|
+
type: HostBinding,
|
|
399
|
+
args: ['class.sto-f-grid__col']
|
|
400
|
+
}], stoGridColumnDouble: [{
|
|
401
|
+
type: HostBinding,
|
|
402
|
+
args: ['class.sto-f-grid__col--2']
|
|
403
|
+
}, {
|
|
404
|
+
type: Input
|
|
405
|
+
}] } });
|
|
406
|
+
class StoGridDirective {
|
|
407
|
+
constructor(elRef) {
|
|
408
|
+
this.elRef = elRef;
|
|
409
|
+
this.maxWidth = 1000;
|
|
410
|
+
this.minWidth = 250;
|
|
411
|
+
this.baseClass = true;
|
|
412
|
+
}
|
|
413
|
+
ngAfterViewInit() {
|
|
414
|
+
const el = this.elRef.nativeElement;
|
|
415
|
+
this.observer = new ResizeObserver(entries => {
|
|
416
|
+
for (const entry of entries) {
|
|
417
|
+
const cr = entry.contentRect;
|
|
418
|
+
const { width } = cr;
|
|
419
|
+
const breakpoints = this.breakpoints || { 2: 400, 4: 800 };
|
|
420
|
+
const gridType = getClass(width, breakpoints[2], breakpoints[4]);
|
|
421
|
+
if (!el.classList.contains(gridType)) {
|
|
422
|
+
el.classList.remove(...ALL_GRIDS);
|
|
423
|
+
el.classList.add(gridType);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
});
|
|
427
|
+
this.observer.observe(this.elRef.nativeElement);
|
|
428
|
+
}
|
|
429
|
+
ngOnDestroy() {
|
|
430
|
+
if (this.observer) {
|
|
431
|
+
this.observer.disconnect();
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
StoGridDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: StoGridDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
436
|
+
StoGridDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.2", type: StoGridDirective, selector: "[stoGrid]", inputs: { maxWidth: "maxWidth", minWidth: "minWidth", breakpoints: "breakpoints" }, host: { properties: { "style.max-width.px": "this.maxWidth", "style.min-width.px": "this.minWidth", "class.sto-f-grid": "this.baseClass" } }, queries: [{ propertyName: "columns", predicate: StoGridColumnDirective, read: ElementRef }], exportAs: ["stoGrid"], ngImport: i0 });
|
|
437
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: StoGridDirective, decorators: [{
|
|
438
|
+
type: Directive,
|
|
439
|
+
args: [{
|
|
440
|
+
selector: '[stoGrid]',
|
|
441
|
+
exportAs: 'stoGrid'
|
|
442
|
+
}]
|
|
443
|
+
}], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { maxWidth: [{
|
|
444
|
+
type: HostBinding,
|
|
445
|
+
args: ['style.max-width.px']
|
|
446
|
+
}, {
|
|
447
|
+
type: Input
|
|
448
|
+
}], minWidth: [{
|
|
449
|
+
type: HostBinding,
|
|
450
|
+
args: ['style.min-width.px']
|
|
451
|
+
}, {
|
|
452
|
+
type: Input
|
|
453
|
+
}], baseClass: [{
|
|
454
|
+
type: HostBinding,
|
|
455
|
+
args: ['class.sto-f-grid']
|
|
456
|
+
}], columns: [{
|
|
457
|
+
type: ContentChildren,
|
|
458
|
+
args: [StoGridColumnDirective, { read: ElementRef }]
|
|
459
|
+
}], breakpoints: [{
|
|
460
|
+
type: Input
|
|
461
|
+
}] } });
|
|
462
|
+
|
|
463
|
+
class MenuOverlayDirective {
|
|
464
|
+
constructor(trigger, el) {
|
|
465
|
+
this.trigger = trigger;
|
|
466
|
+
this.left = 0;
|
|
467
|
+
this.top = 0;
|
|
468
|
+
this.menu = trigger.menu;
|
|
469
|
+
this.trigger.menuOpened.pipe(switchMap(() => fromEvent(document, 'click')
|
|
470
|
+
.pipe(take(1)))).subscribe(() => {
|
|
471
|
+
this.trigger.closeMenu();
|
|
472
|
+
});
|
|
473
|
+
this.setStyle(el.nativeElement);
|
|
474
|
+
}
|
|
475
|
+
updatePosition(event) {
|
|
476
|
+
this.left = event.x;
|
|
477
|
+
this.top = event.y;
|
|
478
|
+
}
|
|
479
|
+
setStyle(element) {
|
|
480
|
+
element.style.overflow = 'hidden';
|
|
481
|
+
element.style.position = 'fixed';
|
|
482
|
+
element.style.height = '1px';
|
|
483
|
+
element.style.width = '1px';
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
MenuOverlayDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: MenuOverlayDirective, deps: [{ token: i1.MatMenuTrigger, host: true }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
487
|
+
MenuOverlayDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.2", type: MenuOverlayDirective, selector: "[stoMenuOverlay]", host: { properties: { "style.left.px": "this.left", "style.top.px": "this.top" } }, exportAs: ["stoMenuOverlay"], ngImport: i0 });
|
|
488
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: MenuOverlayDirective, decorators: [{
|
|
489
|
+
type: Directive,
|
|
490
|
+
args: [{
|
|
491
|
+
selector: '[stoMenuOverlay]',
|
|
492
|
+
exportAs: 'stoMenuOverlay'
|
|
493
|
+
}]
|
|
494
|
+
}], ctorParameters: function () {
|
|
495
|
+
return [{ type: i1.MatMenuTrigger, decorators: [{
|
|
496
|
+
type: Host
|
|
497
|
+
}] }, { type: i0.ElementRef }];
|
|
498
|
+
}, propDecorators: { left: [{
|
|
499
|
+
type: HostBinding,
|
|
500
|
+
args: ['style.left.px']
|
|
501
|
+
}], top: [{
|
|
502
|
+
type: HostBinding,
|
|
503
|
+
args: ['style.top.px']
|
|
504
|
+
}] } });
|
|
505
|
+
|
|
506
|
+
class ContextMenuDirective {
|
|
507
|
+
contextMenu(event) {
|
|
508
|
+
event.preventDefault();
|
|
509
|
+
if (this.menuTrigger.menuOpen) {
|
|
510
|
+
this.menuTrigger.closeMenu();
|
|
511
|
+
}
|
|
512
|
+
this.overlayDirective.updatePosition(event);
|
|
513
|
+
setTimeout(() => {
|
|
514
|
+
this.menuTrigger.menuData = this.menuContext;
|
|
515
|
+
this.menuTrigger.openMenu();
|
|
516
|
+
}, 150);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
ContextMenuDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: ContextMenuDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
520
|
+
ContextMenuDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.2", type: ContextMenuDirective, selector: "[stoContextMenu]", inputs: { menuTrigger: "menuTrigger", overlayDirective: "overlayDirective", menuContext: "menuContext" }, host: { listeners: { "contextmenu": "contextMenu($event)" } }, ngImport: i0 });
|
|
521
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: ContextMenuDirective, decorators: [{
|
|
522
|
+
type: Directive,
|
|
523
|
+
args: [{
|
|
524
|
+
selector: '[stoContextMenu]'
|
|
525
|
+
}]
|
|
526
|
+
}], propDecorators: { menuTrigger: [{
|
|
527
|
+
type: Input
|
|
528
|
+
}], overlayDirective: [{
|
|
529
|
+
type: Input
|
|
530
|
+
}], menuContext: [{
|
|
531
|
+
type: Input
|
|
532
|
+
}], contextMenu: [{
|
|
533
|
+
type: HostListener,
|
|
534
|
+
args: ['contextmenu', ['$event']]
|
|
535
|
+
}] } });
|
|
536
|
+
|
|
537
|
+
class StoDirectivesModule {
|
|
538
|
+
}
|
|
539
|
+
StoDirectivesModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: StoDirectivesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
540
|
+
StoDirectivesModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: StoDirectivesModule, declarations: [QuickKeysDirective,
|
|
541
|
+
DateFormFieldClickDirective,
|
|
542
|
+
StoSelectTextOnFocusDirective,
|
|
543
|
+
StoGridDirective,
|
|
544
|
+
StoGridColumnDirective,
|
|
545
|
+
StoGridSpacerDirective,
|
|
546
|
+
MenuOverlayDirective,
|
|
547
|
+
ContextMenuDirective], imports: [CommonModule, LayoutModule], exports: [QuickKeysDirective,
|
|
548
|
+
DateFormFieldClickDirective,
|
|
549
|
+
StoSelectTextOnFocusDirective,
|
|
550
|
+
StoGridDirective,
|
|
551
|
+
StoGridColumnDirective,
|
|
552
|
+
StoGridSpacerDirective,
|
|
553
|
+
MenuOverlayDirective,
|
|
554
|
+
ContextMenuDirective] });
|
|
555
|
+
StoDirectivesModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: StoDirectivesModule, imports: [[CommonModule, LayoutModule]] });
|
|
556
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: StoDirectivesModule, decorators: [{
|
|
557
|
+
type: NgModule,
|
|
558
|
+
args: [{
|
|
559
|
+
imports: [CommonModule, LayoutModule],
|
|
560
|
+
declarations: [
|
|
561
|
+
QuickKeysDirective,
|
|
562
|
+
DateFormFieldClickDirective,
|
|
563
|
+
StoSelectTextOnFocusDirective,
|
|
564
|
+
StoGridDirective,
|
|
565
|
+
StoGridColumnDirective,
|
|
566
|
+
StoGridSpacerDirective,
|
|
567
|
+
MenuOverlayDirective,
|
|
568
|
+
ContextMenuDirective
|
|
569
|
+
],
|
|
570
|
+
exports: [
|
|
571
|
+
QuickKeysDirective,
|
|
572
|
+
DateFormFieldClickDirective,
|
|
573
|
+
StoSelectTextOnFocusDirective,
|
|
574
|
+
StoGridDirective,
|
|
575
|
+
StoGridColumnDirective,
|
|
576
|
+
StoGridSpacerDirective,
|
|
577
|
+
MenuOverlayDirective,
|
|
578
|
+
ContextMenuDirective
|
|
579
|
+
]
|
|
580
|
+
}]
|
|
581
|
+
}] });
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* Formats numbers to use our standard formatting (d ddd,ddd)
|
|
585
|
+
*
|
|
586
|
+
* @example
|
|
587
|
+
*
|
|
588
|
+
* {{ 1234,32 | numberFormat }} -> 1 234,320
|
|
589
|
+
* {{ 1234,32 | numberFormat:'M3' }} -> 1 234,320 M3
|
|
590
|
+
* {{ -1234,32 | numberFormat:'M3':true }} -> 1 234,320 M3
|
|
591
|
+
* {{ 1234,32 | numberFormat:'M3':false:false }} -> 1 234 M3
|
|
592
|
+
* {{ 1234,32 | numberFormat:'M3':false:true:5 }} -> 1 234,32000 M3
|
|
593
|
+
*/
|
|
594
|
+
class NumberFormatPipe {
|
|
595
|
+
transform(value, unit = '', abs, appendDecimals = true, numberOfDecimals = 3) {
|
|
596
|
+
if (value !== 0 && !value) {
|
|
597
|
+
return '';
|
|
598
|
+
}
|
|
599
|
+
if (typeof value === 'string') {
|
|
600
|
+
const newValue = parseFloat(value);
|
|
601
|
+
if (isNaN(newValue)) {
|
|
602
|
+
return null;
|
|
603
|
+
}
|
|
604
|
+
value = newValue;
|
|
605
|
+
}
|
|
606
|
+
if (abs) {
|
|
607
|
+
value = Math.abs(value);
|
|
608
|
+
}
|
|
609
|
+
// We absolute the value to ensure that the rounding rules is always away from zero.
|
|
610
|
+
// 1.5 => 2 and -1.5 => -2
|
|
611
|
+
const isNegativeNumber = value < 0;
|
|
612
|
+
value = Math.abs(value);
|
|
613
|
+
if (!appendDecimals) {
|
|
614
|
+
value = Math.round(value);
|
|
615
|
+
}
|
|
616
|
+
if (!isNaN(value) && appendDecimals) {
|
|
617
|
+
value = parseFloat(this.toFixed(value, numberOfDecimals));
|
|
618
|
+
}
|
|
619
|
+
// Turn negative numbers back, but only if value is not -0
|
|
620
|
+
// eslint-disable-next-line no-compare-neg-zero
|
|
621
|
+
if (isNegativeNumber && value !== -0) {
|
|
622
|
+
value = value * -1;
|
|
623
|
+
}
|
|
624
|
+
const localized = this.prettyPrintValue(value, appendDecimals, numberOfDecimals);
|
|
625
|
+
return localized.replace(/,/g, ' ').replace('.', ',') + `${unit ? ' ' + unit : ''}`;
|
|
626
|
+
}
|
|
627
|
+
prettyPrintValue(value, appendDecimals, numberOfDecimals) {
|
|
628
|
+
const intlOptions = { minimumFractionDigits: numberOfDecimals, maximumFractionDigits: numberOfDecimals };
|
|
629
|
+
const intl = new Intl.NumberFormat('en-US', intlOptions).format(value);
|
|
630
|
+
const split = intl.split('.');
|
|
631
|
+
let localized = split[0];
|
|
632
|
+
if (appendDecimals) {
|
|
633
|
+
const decimals = split.length === 2 ? split[1] : '';
|
|
634
|
+
split[1] = decimals.padEnd(numberOfDecimals, '0');
|
|
635
|
+
localized = split.join('.');
|
|
636
|
+
}
|
|
637
|
+
return localized;
|
|
638
|
+
}
|
|
639
|
+
// Normal toFixed has some issues: https://stackoverflow.com/questions/10015027/javascript-tofixed-not-rounding
|
|
640
|
+
toFixed(num, precision) {
|
|
641
|
+
// This method also has some issues - namely, it's unable to parse negative numbers with huge floating points
|
|
642
|
+
// -8.185452315956354e-12 becomes NaN
|
|
643
|
+
let returnValue = (+(Math.round(+(num + 'e' + precision)) + 'e' + -precision));
|
|
644
|
+
if (isNaN(returnValue)) {
|
|
645
|
+
returnValue = parseFloat(num.toFixed(precision));
|
|
646
|
+
}
|
|
647
|
+
return returnValue.toFixed(precision);
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
NumberFormatPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: NumberFormatPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
651
|
+
NumberFormatPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: NumberFormatPipe, name: "numberFormat" });
|
|
652
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: NumberFormatPipe, decorators: [{
|
|
653
|
+
type: Pipe,
|
|
654
|
+
args: [{
|
|
655
|
+
name: 'numberFormat'
|
|
656
|
+
}]
|
|
657
|
+
}] });
|
|
658
|
+
|
|
659
|
+
/**
|
|
660
|
+
* Pipe used to transform numbers to a currency format
|
|
661
|
+
*
|
|
662
|
+
* @example
|
|
663
|
+
*
|
|
664
|
+
* <span>{{ 5000.5824 | currentFormat:'$':3 }}</span>
|
|
665
|
+
* Results in
|
|
666
|
+
* <span>5 000,582 $</span>
|
|
667
|
+
*/
|
|
668
|
+
class CurrencyFormatPipe {
|
|
669
|
+
transform(value, unit = '', maximumFractionDigits = 3) {
|
|
670
|
+
if (!value) {
|
|
671
|
+
return null;
|
|
672
|
+
}
|
|
673
|
+
if (typeof value === 'string') {
|
|
674
|
+
value = parseFloat(value);
|
|
675
|
+
if (isNaN(value)) {
|
|
676
|
+
return '';
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
const intl = new Intl.NumberFormat('en-US', { maximumFractionDigits }).format(value);
|
|
680
|
+
return intl.replace(/,/g, ' ').replace('.', ',') + ` ${unit}`;
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
CurrencyFormatPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: CurrencyFormatPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
684
|
+
CurrencyFormatPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: CurrencyFormatPipe, name: "currencyFormat" });
|
|
685
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: CurrencyFormatPipe, decorators: [{
|
|
686
|
+
type: Pipe,
|
|
687
|
+
args: [{
|
|
688
|
+
name: 'currencyFormat'
|
|
689
|
+
}]
|
|
690
|
+
}] });
|
|
691
|
+
|
|
692
|
+
/**
|
|
693
|
+
* Transforms an Object to an Array.
|
|
694
|
+
*
|
|
695
|
+
* @example
|
|
696
|
+
*
|
|
697
|
+
* public obj = {a: 1, b: 2, c: 3};
|
|
698
|
+
* <span *ngFor="let key of obj | keys "> {{ obj[key] }}, </span> -> 1, 2, 3,
|
|
699
|
+
*/
|
|
700
|
+
class KeysPipe {
|
|
701
|
+
transform(value) {
|
|
702
|
+
if (value) {
|
|
703
|
+
return Object.keys(value);
|
|
704
|
+
}
|
|
705
|
+
return [];
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
KeysPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: KeysPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
709
|
+
KeysPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: KeysPipe, name: "keys" });
|
|
710
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: KeysPipe, decorators: [{
|
|
711
|
+
type: Pipe,
|
|
712
|
+
args: [{
|
|
713
|
+
name: 'keys'
|
|
714
|
+
}]
|
|
715
|
+
}] });
|
|
716
|
+
|
|
717
|
+
/**
|
|
718
|
+
* Pipe used to transform dates, based on our default formats.
|
|
719
|
+
*
|
|
720
|
+
* @example
|
|
721
|
+
*
|
|
722
|
+
* public date = "2018-08-27 14:00:30"
|
|
723
|
+
* <span>{{ date | dateFormat }}</span> -> Aug 27, 2018
|
|
724
|
+
* <span>{{ date | dateFormat:'long' }}</span> -> Monday Aug 27, 2018
|
|
725
|
+
*/
|
|
726
|
+
class DateFormatPipe {
|
|
727
|
+
transform(value, format$1) {
|
|
728
|
+
if (!value) {
|
|
729
|
+
return null;
|
|
730
|
+
}
|
|
731
|
+
if (typeof value === 'string') {
|
|
732
|
+
value = new Date(value);
|
|
733
|
+
}
|
|
734
|
+
switch (format$1) {
|
|
735
|
+
case 'long':
|
|
736
|
+
return format(value, 'EEEE MMM d, yyyy');
|
|
737
|
+
case 'short':
|
|
738
|
+
return format(value, 'yyyy-MM-dd');
|
|
739
|
+
case 'datetime':
|
|
740
|
+
return format(value, 'MMM d, yyyy, HH:mm');
|
|
741
|
+
case 'datetimezone':
|
|
742
|
+
return format(value, `MMM d, yyyy, HH:mm:ss ('UTC'xxx)`);
|
|
743
|
+
case 'datetime-long':
|
|
744
|
+
return format(value, 'EEEE MMM dd, yyyy, HH:mm');
|
|
745
|
+
case 'datetime-short':
|
|
746
|
+
return format(value, 'yyyy-MM-dd, HH:mm');
|
|
747
|
+
default:
|
|
748
|
+
return format(value, 'MMM d, yyyy');
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
DateFormatPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: DateFormatPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
753
|
+
DateFormatPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: DateFormatPipe, name: "formatDate" });
|
|
754
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: DateFormatPipe, decorators: [{
|
|
755
|
+
type: Pipe,
|
|
756
|
+
args: [{
|
|
757
|
+
name: 'formatDate'
|
|
758
|
+
}]
|
|
759
|
+
}] });
|
|
760
|
+
|
|
761
|
+
class GetUnit {
|
|
762
|
+
transform(value, withParens) {
|
|
763
|
+
if (value) {
|
|
764
|
+
const arr = value.split('(');
|
|
765
|
+
if (arr.length > 0) {
|
|
766
|
+
if (withParens) {
|
|
767
|
+
value = '(' + arr[1];
|
|
768
|
+
}
|
|
769
|
+
else {
|
|
770
|
+
arr[1].slice(0, -1);
|
|
771
|
+
value = arr[1].slice(0, -1);
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
return value;
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
GetUnit.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: GetUnit, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
779
|
+
GetUnit.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: GetUnit, name: "getUnit" });
|
|
780
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: GetUnit, decorators: [{
|
|
781
|
+
type: Pipe,
|
|
782
|
+
args: [{ name: 'getUnit' }]
|
|
783
|
+
}] });
|
|
784
|
+
class ExcludeUnit {
|
|
785
|
+
transform(value) {
|
|
786
|
+
if (value) {
|
|
787
|
+
const arr = value.split('(');
|
|
788
|
+
if (arr.length > 0) {
|
|
789
|
+
value = arr[0];
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
return value;
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
ExcludeUnit.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: ExcludeUnit, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
796
|
+
ExcludeUnit.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: ExcludeUnit, name: "excludeUnit" });
|
|
797
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: ExcludeUnit, decorators: [{
|
|
798
|
+
type: Pipe,
|
|
799
|
+
args: [{ name: 'excludeUnit' }]
|
|
800
|
+
}] });
|
|
801
|
+
|
|
802
|
+
class YesNoPipe {
|
|
803
|
+
transform(value, ignoreNulls = false) {
|
|
804
|
+
let valueStr = '';
|
|
805
|
+
if (ignoreNulls) {
|
|
806
|
+
valueStr = value ? 'Yes' : value === false ? 'No' : '';
|
|
807
|
+
}
|
|
808
|
+
else {
|
|
809
|
+
valueStr = value ? 'Yes' : 'No';
|
|
810
|
+
}
|
|
811
|
+
return valueStr;
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
YesNoPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: YesNoPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
815
|
+
YesNoPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: YesNoPipe, name: "yesNo" });
|
|
816
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: YesNoPipe, decorators: [{
|
|
817
|
+
type: Pipe,
|
|
818
|
+
args: [{ name: 'yesNo' }]
|
|
819
|
+
}] });
|
|
820
|
+
|
|
821
|
+
class StoPipesModule {
|
|
822
|
+
}
|
|
823
|
+
StoPipesModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: StoPipesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
824
|
+
StoPipesModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: StoPipesModule, declarations: [DateFormatPipe,
|
|
825
|
+
KeysPipe,
|
|
826
|
+
NumberFormatPipe,
|
|
827
|
+
CurrencyFormatPipe,
|
|
828
|
+
GetUnit,
|
|
829
|
+
ExcludeUnit,
|
|
830
|
+
YesNoPipe], imports: [CommonModule], exports: [DateFormatPipe,
|
|
831
|
+
KeysPipe,
|
|
832
|
+
NumberFormatPipe,
|
|
833
|
+
CurrencyFormatPipe,
|
|
834
|
+
GetUnit,
|
|
835
|
+
ExcludeUnit,
|
|
836
|
+
YesNoPipe] });
|
|
837
|
+
StoPipesModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: StoPipesModule, imports: [[CommonModule]] });
|
|
838
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: StoPipesModule, decorators: [{
|
|
839
|
+
type: NgModule,
|
|
840
|
+
args: [{
|
|
841
|
+
imports: [CommonModule],
|
|
842
|
+
declarations: [
|
|
843
|
+
DateFormatPipe,
|
|
844
|
+
KeysPipe,
|
|
845
|
+
NumberFormatPipe,
|
|
846
|
+
CurrencyFormatPipe,
|
|
847
|
+
GetUnit,
|
|
848
|
+
ExcludeUnit,
|
|
849
|
+
YesNoPipe
|
|
850
|
+
],
|
|
851
|
+
exports: [
|
|
852
|
+
DateFormatPipe,
|
|
853
|
+
KeysPipe,
|
|
854
|
+
NumberFormatPipe,
|
|
855
|
+
CurrencyFormatPipe,
|
|
856
|
+
GetUnit,
|
|
857
|
+
ExcludeUnit,
|
|
858
|
+
YesNoPipe
|
|
859
|
+
]
|
|
860
|
+
}]
|
|
861
|
+
}] });
|
|
862
|
+
|
|
863
|
+
class StoUserPreferenceComponent {
|
|
864
|
+
constructor(fb, service) {
|
|
865
|
+
this.fb = fb;
|
|
866
|
+
this.service = service;
|
|
867
|
+
this.destroyed$ = new Subject();
|
|
868
|
+
}
|
|
869
|
+
initForm(value) {
|
|
870
|
+
var _a;
|
|
871
|
+
this.form = this.fb.group({
|
|
872
|
+
hasSelectTextOnFocusEnabled: [value]
|
|
873
|
+
});
|
|
874
|
+
(_a = this.form.get('hasSelectTextOnFocusEnabled')) === null || _a === void 0 ? void 0 : _a.valueChanges.pipe(takeUntil(this.destroyed$)).subscribe((hasSelectTextOnFocusEnabled) => {
|
|
875
|
+
this.service.setHasSelectTextOnFocusEnabled(hasSelectTextOnFocusEnabled);
|
|
876
|
+
});
|
|
877
|
+
}
|
|
878
|
+
ngOnInit() {
|
|
879
|
+
this.service.hasSelectTextOnFocusEnabled.asObservable()
|
|
880
|
+
.pipe(take(1))
|
|
881
|
+
.subscribe((value) => {
|
|
882
|
+
this.initForm(value);
|
|
883
|
+
});
|
|
884
|
+
}
|
|
885
|
+
ngOnDestroy() {
|
|
886
|
+
this.destroyed$.next(true);
|
|
887
|
+
this.destroyed$.complete();
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
StoUserPreferenceComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: StoUserPreferenceComponent, deps: [{ token: i1$1.FormBuilder }, { token: StoUserPreferenceService }], target: i0.ɵɵFactoryTarget.Component });
|
|
891
|
+
StoUserPreferenceComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.2", type: StoUserPreferenceComponent, selector: "sto-user-preference", ngImport: i0, template: "<mat-expansion-panel [expanded]=\"false\">\n <mat-expansion-panel-header>\n <mat-panel-title>Settings<span style=\"opacity: 0.36\"> (beta)</span></mat-panel-title>\n </mat-expansion-panel-header>\n <div *ngIf=\"form\" class=\"sto-grid sto-grid--4\">\n\n <ng-content></ng-content>\n\n </div>\n</mat-expansion-panel>\n", styles: [""], components: [{ type: i3.MatExpansionPanel, selector: "mat-expansion-panel", inputs: ["disabled", "expanded", "hideToggle", "togglePosition"], outputs: ["opened", "closed", "expandedChange", "afterExpand", "afterCollapse"], exportAs: ["matExpansionPanel"] }, { type: i3.MatExpansionPanelHeader, selector: "mat-expansion-panel-header", inputs: ["tabIndex", "expandedHeight", "collapsedHeight"] }], directives: [{ type: i3.MatExpansionPanelTitle, selector: "mat-panel-title" }, { type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
|
|
892
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: StoUserPreferenceComponent, decorators: [{
|
|
893
|
+
type: Component,
|
|
894
|
+
args: [{ selector: 'sto-user-preference', template: "<mat-expansion-panel [expanded]=\"false\">\n <mat-expansion-panel-header>\n <mat-panel-title>Settings<span style=\"opacity: 0.36\"> (beta)</span></mat-panel-title>\n </mat-expansion-panel-header>\n <div *ngIf=\"form\" class=\"sto-grid sto-grid--4\">\n\n <ng-content></ng-content>\n\n </div>\n</mat-expansion-panel>\n", styles: [""] }]
|
|
895
|
+
}], ctorParameters: function () { return [{ type: i1$1.FormBuilder }, { type: StoUserPreferenceService }]; } });
|
|
896
|
+
|
|
897
|
+
class StoUserPreferenceModule {
|
|
898
|
+
static forRoot() {
|
|
899
|
+
return {
|
|
900
|
+
ngModule: StoUserPreferenceModule,
|
|
901
|
+
providers: [StoUserPreferenceService]
|
|
902
|
+
};
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
StoUserPreferenceModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: StoUserPreferenceModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
906
|
+
StoUserPreferenceModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: StoUserPreferenceModule, declarations: [StoUserPreferenceComponent], imports: [CommonModule, MatExpansionModule, ReactiveFormsModule, FormsModule], exports: [StoUserPreferenceComponent] });
|
|
907
|
+
StoUserPreferenceModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: StoUserPreferenceModule, imports: [[CommonModule, MatExpansionModule, ReactiveFormsModule, FormsModule]] });
|
|
908
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: StoUserPreferenceModule, decorators: [{
|
|
909
|
+
type: NgModule,
|
|
910
|
+
args: [{
|
|
911
|
+
imports: [CommonModule, MatExpansionModule, ReactiveFormsModule, FormsModule],
|
|
912
|
+
exports: [StoUserPreferenceComponent],
|
|
913
|
+
declarations: [StoUserPreferenceComponent]
|
|
914
|
+
}]
|
|
915
|
+
}] });
|
|
916
|
+
|
|
917
|
+
/*
|
|
918
|
+
* Public API Surface of @ngx-stoui/core
|
|
919
|
+
*/
|
|
920
|
+
|
|
921
|
+
/**
|
|
922
|
+
* Generated bundle index. Do not edit.
|
|
923
|
+
*/
|
|
924
|
+
|
|
925
|
+
export { ContextMenuDirective, CurrencyFormatPipe, DateFormFieldClickDirective, DateFormatPipe, ExcludeUnit, GetUnit, Key, KeysPipe, MenuOverlayDirective, NumberFormatPipe, QuickKeysDirective, StoDirectivesModule, StoGridColumnDirective, StoGridDirective, StoGridSpacerDirective, StoPipesModule, StoSelectTextOnFocusDirective, StoUserPreferenceComponent, StoUserPreferenceModule, StoUserPreferenceService, YesNoPipe };
|
|
926
|
+
//# sourceMappingURL=ngx-stoui-core.mjs.map
|