@libs-ui/components-inputs-input 0.1.1-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/README.md +3 -0
- package/defines/index-iframe-area.define.d.ts +2 -0
- package/esm2022/defines/index-iframe-area.define.mjs +124 -0
- package/esm2022/index.mjs +3 -0
- package/esm2022/input.component.mjs +832 -0
- package/esm2022/interfaces/focus-and-blur-event.interface.mjs +2 -0
- package/esm2022/interfaces/function-control-event.interface.mjs +2 -0
- package/esm2022/interfaces/index.mjs +4 -0
- package/esm2022/interfaces/input.interface.mjs +2 -0
- package/esm2022/libs-ui-components-inputs-input.mjs +5 -0
- package/fesm2022/libs-ui-components-inputs-input.mjs +962 -0
- package/fesm2022/libs-ui-components-inputs-input.mjs.map +1 -0
- package/index.d.ts +2 -0
- package/input.component.d.ts +133 -0
- package/interfaces/focus-and-blur-event.interface.d.ts +14 -0
- package/interfaces/function-control-event.interface.d.ts +9 -0
- package/interfaces/index.d.ts +3 -0
- package/interfaces/input.interface.d.ts +5 -0
- package/package.json +32 -0
|
@@ -0,0 +1,962 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { signal, computed, input, model, output, viewChild, inject, Renderer2, effect, untracked, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
|
+
import { DomSanitizer } from '@angular/platform-browser';
|
|
4
|
+
import { LibsUiComponentsButtonsSortComponent } from '@libs-ui/components-buttons-sort';
|
|
5
|
+
import { LibsUiComponentsPopoverComponent } from '@libs-ui/components-popover';
|
|
6
|
+
import { LibsUiConfigProjectService } from '@libs-ui/services-config-project';
|
|
7
|
+
import { viewDataNumberByLanguage, UtilsKeyCodeConstant, isTypeFile, UtilsCache, UtilsLanguageConstants, isNil, formatNumber, removeEmoji, uuid, setCaretPosition } from '@libs-ui/utils';
|
|
8
|
+
import * as i1 from '@ngx-translate/core';
|
|
9
|
+
import { TranslateService, TranslateModule } from '@ngx-translate/core';
|
|
10
|
+
import { Subject, fromEvent } from 'rxjs';
|
|
11
|
+
import { take, tap, mergeMap, filter, takeUntil, debounceTime } from 'rxjs/operators';
|
|
12
|
+
import { NgTemplateOutlet } from '@angular/common';
|
|
13
|
+
|
|
14
|
+
const indexInputHtml = (customStyle) => `
|
|
15
|
+
<!DOCTYPE html>
|
|
16
|
+
<html>
|
|
17
|
+
<head>
|
|
18
|
+
<base href="/" />
|
|
19
|
+
</head>
|
|
20
|
+
<style type="text/css">
|
|
21
|
+
::-webkit-scrollbar {
|
|
22
|
+
width: 8px;
|
|
23
|
+
height: 8px;
|
|
24
|
+
cursor: default;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
::-webkit-scrollbar-track {
|
|
28
|
+
border-radius: 0;
|
|
29
|
+
background: #fff;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
::-webkit-scrollbar-track:hover {
|
|
34
|
+
background: rgba(78, 78, 78, 0.05);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
::-webkit-scrollbar-track:focus {
|
|
38
|
+
background: #b3b3b3;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
::-webkit-scrollbar-track:checked {
|
|
42
|
+
background: #b3b3b3;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
::-webkit-scrollbar-thumb {
|
|
47
|
+
border-radius: 0;
|
|
48
|
+
background: rgba(78, 78, 78, 0.15);
|
|
49
|
+
box-shadow: inset 1px 1px 2px 0 rgba(78, 78, 78, 0.3);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
::-webkit-scrollbar-thumb:hover {
|
|
53
|
+
background: #dadada;
|
|
54
|
+
box-shadow: inset 1px 1px 2px 0 rgba(78, 78, 78, 0.3);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
::-webkit-scrollbar-thumb:focus {
|
|
58
|
+
background: #b3b3b3;
|
|
59
|
+
box-shadow: inset 1px 1px 2px 0 rgba(78, 78, 78, 0.3);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
::-webkit-scrollbar-thumb:checked {
|
|
63
|
+
background: #b3b3b3;
|
|
64
|
+
box-shadow: inset 1px 1px 2px 0 rgba(78, 78, 78, 0.3);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
body{
|
|
68
|
+
max-width: 100vw;
|
|
69
|
+
max-height:100vh;
|
|
70
|
+
padding: 0;
|
|
71
|
+
margin: 0;
|
|
72
|
+
overflow: hidden;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
textarea{
|
|
76
|
+
max-width: 100vw;
|
|
77
|
+
max-height:100vh;
|
|
78
|
+
resize: none;
|
|
79
|
+
border: none;
|
|
80
|
+
border: ${customStyle.borderColor ? ' 1px solid #e6e7ea;' : 'none'};
|
|
81
|
+
width: 100%;
|
|
82
|
+
border-radius: ${customStyle.borderRadius ?? '4px'};
|
|
83
|
+
font-weight: normal;
|
|
84
|
+
font-style: normal;
|
|
85
|
+
line-height: ${customStyle.lineHeight ?? '16px'};
|
|
86
|
+
height: ${customStyle.height ?? 'auto'};
|
|
87
|
+
color: ${customStyle.color ?? '#4e4e4e'};
|
|
88
|
+
padding: ${customStyle.padding ?? '6px 12px'};
|
|
89
|
+
background-color: ${customStyle.backgroundColor ?? '#fff'};
|
|
90
|
+
font-size: ${customStyle.fontSize ?? '12px'};
|
|
91
|
+
font-family:var(--libs-ui-font-family-name) !important;
|
|
92
|
+
overflow: hidden;
|
|
93
|
+
margin: 0;
|
|
94
|
+
resize: none;
|
|
95
|
+
}
|
|
96
|
+
${customStyle.borderColor
|
|
97
|
+
? `textarea:focus:not(:read-only):not(:disabled) {
|
|
98
|
+
border: 1px solid ${customStyle.borderColor};
|
|
99
|
+
}`
|
|
100
|
+
: ''}
|
|
101
|
+
|
|
102
|
+
textarea::-webkit-input-placeholder {
|
|
103
|
+
padding-left: '4px';
|
|
104
|
+
color: rgba(78, 78, 78, 0.5) !important;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
textarea:-moz-placeholder {
|
|
108
|
+
/* Firefox 18- */
|
|
109
|
+
padding-left: '4px';
|
|
110
|
+
color: rgba(78, 78, 78, 0.5) !important;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
textarea::-moz-placeholder {
|
|
114
|
+
/* Firefox 19+ */
|
|
115
|
+
padding-left: '4px';
|
|
116
|
+
color: rgba(78, 78, 78, 0.5) !important;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
textarea:-ms-input-placeholder {
|
|
120
|
+
padding-left: '4px';
|
|
121
|
+
color: rgba(78, 78, 78, 0.5) !important;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
textarea:focus {
|
|
125
|
+
outline: none;
|
|
126
|
+
}
|
|
127
|
+
*, ::after, ::before {
|
|
128
|
+
box-sizing: border-box;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
</style>
|
|
132
|
+
|
|
133
|
+
<body>
|
|
134
|
+
<textarea></textarea>
|
|
135
|
+
</body>
|
|
136
|
+
</html>`;
|
|
137
|
+
|
|
138
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
139
|
+
class LibsUiComponentsInputsInputComponent {
|
|
140
|
+
// #region PROPERTY
|
|
141
|
+
disableAsc = signal(false);
|
|
142
|
+
disableDesc = signal(false);
|
|
143
|
+
htmlIframeArea = signal(undefined);
|
|
144
|
+
countDisplay = computed(this.countDisplayComputed.bind(this));
|
|
145
|
+
maxLengthDisplay = computed(() => `${viewDataNumberByLanguage(this.maxLength() || 0, false)}`);
|
|
146
|
+
paddingRightCustom = signal(undefined);
|
|
147
|
+
inputIframeRef = signal(undefined);
|
|
148
|
+
DEFAULT_MAX_HEIGHT_TEXT_AREA = 250;
|
|
149
|
+
charFirstIsZero = signal(false);
|
|
150
|
+
preHeightArea = signal(0);
|
|
151
|
+
iframeRef;
|
|
152
|
+
dataTextPaste = signal('');
|
|
153
|
+
onDestroy = new Subject();
|
|
154
|
+
// #region INPUT
|
|
155
|
+
tagInput = input('input', { transform: (value) => value || 'input' });
|
|
156
|
+
dataType = input('string', { transform: (val) => val || 'string' });
|
|
157
|
+
typeInput = input('text', { transform: (val) => val || 'text' });
|
|
158
|
+
modeInput = input('text', { transform: (val) => val || 'text' });
|
|
159
|
+
tabInsertContentTagInput = input(false);
|
|
160
|
+
textAreaEnterNotNewLine = input(false);
|
|
161
|
+
emitEmptyInDataTypeNumber = input(false);
|
|
162
|
+
keepZeroInTypeInt = input(false);
|
|
163
|
+
autoAddZeroLessThan10InTypeInt = input(false);
|
|
164
|
+
ignoreBlockInputMaxValue = input();
|
|
165
|
+
maxValueNumber = model();
|
|
166
|
+
minValueNumber = model();
|
|
167
|
+
fixedFloat = model();
|
|
168
|
+
acceptNegativeValue = model(false);
|
|
169
|
+
valueUpDownNumber = input();
|
|
170
|
+
classInclude = input(' w-full ', { transform: (value) => value || ' w-full ' });
|
|
171
|
+
maxLength = model();
|
|
172
|
+
readonly = input(false);
|
|
173
|
+
disable = input(false);
|
|
174
|
+
noBorder = input();
|
|
175
|
+
backgroundNone = input(false);
|
|
176
|
+
borderError = input(false);
|
|
177
|
+
useColorModeExist = input(false);
|
|
178
|
+
placeholder = input(' ', { transform: (value) => value || ' ' });
|
|
179
|
+
keepPlaceholderOnly = input(false);
|
|
180
|
+
value = model('');
|
|
181
|
+
autoRemoveEmoji = input(false);
|
|
182
|
+
defaultHeight = input(32, { transform: (value) => value || 32 });
|
|
183
|
+
minHeightTextArea = input();
|
|
184
|
+
maxHeightTextArea = input(this.DEFAULT_MAX_HEIGHT_TEXT_AREA, { transform: (value) => value || this.DEFAULT_MAX_HEIGHT_TEXT_AREA });
|
|
185
|
+
focusTimeOut = input(600, { transform: (value) => value ?? 600 });
|
|
186
|
+
selectAllTimeOut = input(600, { transform: (value) => value ?? 600 });
|
|
187
|
+
blurTimeOut = input(32, { transform: (value) => value || 32 });
|
|
188
|
+
zIndexPopoverContent = input(10, { transform: (value) => value || 10 });
|
|
189
|
+
classContainerInput = input('w-full', { transform: (value) => value || 'w-full' });
|
|
190
|
+
showCount = input();
|
|
191
|
+
ignoreStopPropagationEvent = input();
|
|
192
|
+
resize = input('vertical', { transform: (value) => value || 'vertical' });
|
|
193
|
+
templateLeftBottomInput = input();
|
|
194
|
+
templateRightBottomInput = input();
|
|
195
|
+
classContainerBottomInput = input(' ', { transform: (value) => value || ' ' });
|
|
196
|
+
ignoreWidthInput100 = input();
|
|
197
|
+
iframeTextareaCustomStyle = input();
|
|
198
|
+
iconLeftClass = input('', { transform: (value) => value || '' });
|
|
199
|
+
popoverContentIconLeft = input('', { transform: (value) => value || '' });
|
|
200
|
+
iconRightClass = input();
|
|
201
|
+
popoverContentIconRight = input('', { transform: (value) => value || '' });
|
|
202
|
+
resetAutoCompletePassword = input(false, { transform: (value) => value ?? false });
|
|
203
|
+
acceptOnlyClickIcon = input(false);
|
|
204
|
+
setIconRightColorSameColorDisableReadOnly = input(false);
|
|
205
|
+
onlyAcceptNegativeValue = input(false);
|
|
206
|
+
maxLengthNumberCount = model();
|
|
207
|
+
focusInput = input(false);
|
|
208
|
+
// #region OUTPUT
|
|
209
|
+
outHeightAreaChange = output();
|
|
210
|
+
outChange = output();
|
|
211
|
+
outFocusAndBlurEvent = output();
|
|
212
|
+
outEnterEvent = output();
|
|
213
|
+
outInputEvent = output(); // emit pure event input
|
|
214
|
+
outIconLeft = output();
|
|
215
|
+
outIconRight = output();
|
|
216
|
+
outFunctionsControl = output();
|
|
217
|
+
outFilesDrop = output();
|
|
218
|
+
outFileDrop = output();
|
|
219
|
+
outChangeValueByButtonUpDown = output();
|
|
220
|
+
/* VIEW CHILD */
|
|
221
|
+
inputRef = viewChild('inputRef');
|
|
222
|
+
textCountRef = viewChild('textCountRef');
|
|
223
|
+
elementRightRef = viewChild('elementRightRef');
|
|
224
|
+
// #region INJECT
|
|
225
|
+
renderer = inject(Renderer2);
|
|
226
|
+
configProjectService = inject(LibsUiConfigProjectService);
|
|
227
|
+
translateService = inject(TranslateService);
|
|
228
|
+
sanitizer = inject(DomSanitizer);
|
|
229
|
+
constructor() {
|
|
230
|
+
effect(() => {
|
|
231
|
+
if (this.onlyAcceptNegativeValue()) {
|
|
232
|
+
this.acceptNegativeValue.set(true);
|
|
233
|
+
}
|
|
234
|
+
if (!this.Element) {
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
if (this.dataType() === 'string') {
|
|
238
|
+
if (this.Element.value !== this.value()) {
|
|
239
|
+
this.init();
|
|
240
|
+
}
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
this.updateMaxLengthMinMaxValueByDataType();
|
|
244
|
+
const value = this.parseValueByDataType(this.Element.value);
|
|
245
|
+
if ((this.Element.value !== '' && value === this.value()) || (this.Element.value === '' && this.emitEmptyInDataTypeNumber() && this.value() === undefined)) {
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
this.init();
|
|
249
|
+
}, { allowSignalWrites: true });
|
|
250
|
+
effect(() => {
|
|
251
|
+
if (this.Element) {
|
|
252
|
+
this.onDestroy.next();
|
|
253
|
+
untracked(() => this.afterViewInit());
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
ngOnInit() {
|
|
258
|
+
this.htmlIframeArea.set(this.sanitizer.bypassSecurityTrustHtml(indexInputHtml(this.iframeTextareaCustomStyle() || { borderColor: this.noBorder() ? '' : `${this.configProjectService.colorStepContrastFromOrigin(20)?.light}` })));
|
|
259
|
+
}
|
|
260
|
+
afterViewInit() {
|
|
261
|
+
if (!this.Element) {
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
this.outHeightAreaChange.emit({ isChange: false, height: this.Element?.scrollHeight });
|
|
265
|
+
this.outFunctionsControl.emit(this.FunctionsControl);
|
|
266
|
+
this.init();
|
|
267
|
+
this.initEvent('focus', this.ignoreStopPropagationEvent()).subscribe((e) => this.outFocusAndBlurEvent.emit({ name: 'focus', event: e }));
|
|
268
|
+
this.initEvent('blur', this.ignoreStopPropagationEvent()).subscribe((e) => this.outFocusAndBlurEvent.emit({ name: 'blur', event: e }));
|
|
269
|
+
const mouseDownEvent = this.initEvent('mousedown', this.ignoreStopPropagationEvent()).pipe(take(1));
|
|
270
|
+
const keyDownEvent = this.initEvent('keydown', this.ignoreStopPropagationEvent());
|
|
271
|
+
const inputEvent = this.initEvent('input', this.ignoreStopPropagationEvent());
|
|
272
|
+
const cutEvent = this.initEvent('cut', this.ignoreStopPropagationEvent());
|
|
273
|
+
const pasteEvent = this.initEvent('paste', this.ignoreStopPropagationEvent());
|
|
274
|
+
const keyupEvent = this.initEvent('keyup', this.ignoreStopPropagationEvent());
|
|
275
|
+
this.initEvent('click', this.ignoreStopPropagationEvent() ?? true).subscribe();
|
|
276
|
+
this.initEvent('dragover', this.ignoreStopPropagationEvent())
|
|
277
|
+
.pipe(tap((event) => {
|
|
278
|
+
event.preventDefault();
|
|
279
|
+
event.stopPropagation();
|
|
280
|
+
if (event.dataTransfer) {
|
|
281
|
+
event.dataTransfer.dropEffect = 'copy';
|
|
282
|
+
}
|
|
283
|
+
}))
|
|
284
|
+
.subscribe();
|
|
285
|
+
this.initEvent('drop', this.ignoreStopPropagationEvent()).subscribe(this.checkAndEmitFiles.bind(this));
|
|
286
|
+
pasteEvent.subscribe(this.checkAndEmitFiles.bind(this));
|
|
287
|
+
this.combineObservable(mouseDownEvent, pasteEvent);
|
|
288
|
+
this.combineObservable(mouseDownEvent, cutEvent);
|
|
289
|
+
keyDownEvent
|
|
290
|
+
.pipe(take(1), tap((e) => this.checkTypeNumber(e, 'key')), mergeMap(() => inputEvent), tap((e) => this.checkTypeNumber(e, 'data')))
|
|
291
|
+
.subscribe((e) => {
|
|
292
|
+
if (this.dataType() === 'string' && this.maxLength() && (e.inputType === 'insertCompositionText' || e.inputType === 'insertText') && e.target.value?.length > (this.maxLength() || 0)) {
|
|
293
|
+
e.target.value = e.target.value.slice(0, this.maxLength());
|
|
294
|
+
}
|
|
295
|
+
this.processEventAndEmitValue(e);
|
|
296
|
+
});
|
|
297
|
+
keyupEvent
|
|
298
|
+
.pipe(filter((event) => event.keyCode === UtilsKeyCodeConstant.ENTER), filter((event) => !this.textAreaEnterNotNewLine() || (this.textAreaEnterNotNewLine() && !event.shiftKey)))
|
|
299
|
+
.subscribe((event) => this.outEnterEvent.emit(event));
|
|
300
|
+
if (this.dataType() === 'string' && (this.tagInput() !== 'input' || (this.tagInput() === 'input' && this.tabInsertContentTagInput()))) {
|
|
301
|
+
keyDownEvent
|
|
302
|
+
.pipe(filter((event) => event.keyCode === UtilsKeyCodeConstant.TAB), tap((event) => event.preventDefault()), filter((event) => !event.target.value || !this.maxLength() || event.target.value.length < (this.maxLength() || 25)), tap((event) => {
|
|
303
|
+
if (this.readonly() || this.disable()) {
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
this.insetValueToSelectionStart('\t', event);
|
|
307
|
+
}))
|
|
308
|
+
.subscribe();
|
|
309
|
+
}
|
|
310
|
+
if (this.textAreaEnterNotNewLine()) {
|
|
311
|
+
keyDownEvent
|
|
312
|
+
.pipe(filter((event) => event.keyCode === UtilsKeyCodeConstant.ENTER && !event.shiftKey), tap((e) => e.preventDefault()))
|
|
313
|
+
.subscribe();
|
|
314
|
+
}
|
|
315
|
+
this.countDisplayComputed();
|
|
316
|
+
}
|
|
317
|
+
// #region FUNCTIONS
|
|
318
|
+
get FunctionsControl() {
|
|
319
|
+
return {
|
|
320
|
+
focus: this.focus.bind(this),
|
|
321
|
+
blur: this.blur.bind(this),
|
|
322
|
+
insertContent: this.addDataToSelectionInput.bind(this),
|
|
323
|
+
resetValue: this.resetValue.bind(this),
|
|
324
|
+
getElementValue: this.getElementValue.bind(this),
|
|
325
|
+
checkAndDisableUpDownButton: this.checkAndDisableUpDownButton.bind(this),
|
|
326
|
+
selectAllContent: this.selectAllContent.bind(this),
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
updateMaxLengthMinMaxValueByDataType() {
|
|
330
|
+
if (this.dataType() === 'int' || this.dataType() === 'float') {
|
|
331
|
+
this.maxLength.update((value) => {
|
|
332
|
+
return !value || value > 21 ? 21 : value;
|
|
333
|
+
});
|
|
334
|
+
this.minValueNumber.update((value) => value ?? Number.MIN_SAFE_INTEGER);
|
|
335
|
+
this.maxValueNumber.update((value) => value ?? Number.MAX_SAFE_INTEGER);
|
|
336
|
+
}
|
|
337
|
+
if (this.dataType() === 'bigint') {
|
|
338
|
+
this.maxLength.update((value) => (!value || value > 25 ? 25 : value));
|
|
339
|
+
this.fixedFloat.update((value) => value ?? 4);
|
|
340
|
+
this.maxLengthNumberCount.update((value) => value ?? 19);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
async getElementValue() {
|
|
344
|
+
return this.Element?.value;
|
|
345
|
+
}
|
|
346
|
+
checkAndEmitFiles(event) {
|
|
347
|
+
const files = event.dataTransfer?.files || event.clipboardData?.files;
|
|
348
|
+
const text = (event.clipboardData || window.clipboardData)?.getData('text');
|
|
349
|
+
this.dataTextPaste.set(text);
|
|
350
|
+
if (!files || !files.length) {
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
if (!text) {
|
|
354
|
+
event.preventDefault();
|
|
355
|
+
}
|
|
356
|
+
event.stopPropagation();
|
|
357
|
+
const fileList = [];
|
|
358
|
+
for (const file of Array.from(files)) {
|
|
359
|
+
if (isTypeFile(file)) {
|
|
360
|
+
this.outFileDrop.emit(file);
|
|
361
|
+
fileList.push(file);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
this.outFilesDrop.emit(fileList);
|
|
365
|
+
}
|
|
366
|
+
insetValueToSelectionStart(text, event) {
|
|
367
|
+
event.preventDefault();
|
|
368
|
+
event.stopPropagation();
|
|
369
|
+
this.Element.setRangeText(text, this.Element.selectionStart, this.Element.selectionStart, 'end');
|
|
370
|
+
this.processEventAndEmitValue(event);
|
|
371
|
+
}
|
|
372
|
+
get Element() {
|
|
373
|
+
return this.inputIframeRef()?.nativeElement || this.inputRef()?.nativeElement;
|
|
374
|
+
}
|
|
375
|
+
handlerChangeValue(data) {
|
|
376
|
+
data.reset();
|
|
377
|
+
if (this.disable() || this.readonly()) {
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
const operator = data.mode === 'asc' ? 1 : -1;
|
|
381
|
+
let value = +this.value() || 0;
|
|
382
|
+
const separator = UtilsCache.getLang() === UtilsLanguageConstants.VI ? '.' : ',';
|
|
383
|
+
const splitValue = (this.value() || this.minValueNumber() || 0).toString().split(separator);
|
|
384
|
+
const dataBehindSeparator = splitValue?.[1];
|
|
385
|
+
if (this.dataType() === 'bigint') {
|
|
386
|
+
value = +(splitValue?.[0] || 0);
|
|
387
|
+
}
|
|
388
|
+
value = value + (this.valueUpDownNumber() ?? 1) * operator;
|
|
389
|
+
if (!this.acceptNegativeValue() && value < 0) {
|
|
390
|
+
value = 0;
|
|
391
|
+
}
|
|
392
|
+
const dataEmit = this.dataType() === 'bigint' ? `${value}${dataBehindSeparator ? separator : ''}${dataBehindSeparator}` : value;
|
|
393
|
+
this.value.set(dataEmit);
|
|
394
|
+
this.outChange.emit(dataEmit);
|
|
395
|
+
this.outChangeValueByButtonUpDown.emit();
|
|
396
|
+
this.checkAndDisableUpDownButton(value);
|
|
397
|
+
}
|
|
398
|
+
handlerEventIconLeft(e, eventName) {
|
|
399
|
+
e.stopPropagation();
|
|
400
|
+
if ((this.disable() || this.readonly()) && !this.acceptOnlyClickIcon()) {
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
this.outIconLeft.emit(eventName);
|
|
404
|
+
}
|
|
405
|
+
handlerEventIconRight(e, eventName) {
|
|
406
|
+
e.stopPropagation();
|
|
407
|
+
if ((this.disable() || this.readonly()) && !this.acceptOnlyClickIcon()) {
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
410
|
+
this.outIconRight.emit(eventName);
|
|
411
|
+
}
|
|
412
|
+
async checkAndDisableUpDownButton(value) {
|
|
413
|
+
if (this.dataType() !== 'int' && this.dataType() !== 'float' && this.dataType() !== 'bigint') {
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
this.disableAsc.set(false);
|
|
417
|
+
this.disableDesc.set(false);
|
|
418
|
+
this.minValueNumber.update((value) => value ?? Number.MIN_SAFE_INTEGER);
|
|
419
|
+
this.maxValueNumber.update((value) => value ?? Number.MAX_SAFE_INTEGER);
|
|
420
|
+
value = value ?? 0;
|
|
421
|
+
if (!isNil(this.maxValueNumber()) && value >= (this.maxValueNumber() ?? Number.MAX_SAFE_INTEGER)) {
|
|
422
|
+
this.disableAsc.set(true);
|
|
423
|
+
}
|
|
424
|
+
if (!isNil(this.minValueNumber()) && value <= (this.minValueNumber() || 0)) {
|
|
425
|
+
this.disableDesc.set(true);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
initEvent(eventName, ignoreStopPropagationEvent) {
|
|
429
|
+
return fromEvent(this.Element, eventName).pipe(tap((e) => {
|
|
430
|
+
if (!ignoreStopPropagationEvent) {
|
|
431
|
+
e.stopPropagation();
|
|
432
|
+
}
|
|
433
|
+
this.outInputEvent.emit(e);
|
|
434
|
+
}), takeUntil(this.onDestroy));
|
|
435
|
+
}
|
|
436
|
+
convertValue(value) {
|
|
437
|
+
if (value && this.dataType() === 'bigint') {
|
|
438
|
+
const separator = UtilsCache.getLang() === UtilsLanguageConstants.VI ? '.' : ',';
|
|
439
|
+
let [int, decimal] = value.split(separator);
|
|
440
|
+
const decimalSplit = decimal ? decimal.split('') : [];
|
|
441
|
+
const decimalEveryZero = decimalSplit.every((item) => item === '0');
|
|
442
|
+
if (int === '-0' && (!decimal || decimalEveryZero)) {
|
|
443
|
+
int = '0';
|
|
444
|
+
}
|
|
445
|
+
if (!decimal || decimalEveryZero) {
|
|
446
|
+
decimal = '0';
|
|
447
|
+
}
|
|
448
|
+
if (decimalSplit.some((item) => item !== '0')) {
|
|
449
|
+
const decimalReverse = decimalSplit.reverse().join('');
|
|
450
|
+
decimal = decimalReverse
|
|
451
|
+
.replace(/(^[0]+)/, '')
|
|
452
|
+
.split('')
|
|
453
|
+
.reverse()
|
|
454
|
+
.join('');
|
|
455
|
+
}
|
|
456
|
+
return `${int}${separator}${decimal}`;
|
|
457
|
+
}
|
|
458
|
+
return value;
|
|
459
|
+
}
|
|
460
|
+
init() {
|
|
461
|
+
if (!this.maxLength()) {
|
|
462
|
+
this.updateMaxLengthMinMaxValueByDataType();
|
|
463
|
+
}
|
|
464
|
+
if (!this.Element) {
|
|
465
|
+
return;
|
|
466
|
+
}
|
|
467
|
+
let elementValue = this.convertValue(`${this.value() ?? ''}`);
|
|
468
|
+
if (this.dataType() !== 'string') {
|
|
469
|
+
elementValue = elementValue.replace(new RegExp(`[^0-9.,${this.acceptNegativeValue() ? '-' : ''}]`, 'g'), '');
|
|
470
|
+
if (UtilsCache.getLang() === UtilsLanguageConstants.EN) {
|
|
471
|
+
elementValue = elementValue.replace(/[,]/, '');
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
this.Element.value = elementValue;
|
|
475
|
+
const eventFake = {
|
|
476
|
+
preventDefault: () => {
|
|
477
|
+
return;
|
|
478
|
+
},
|
|
479
|
+
target: this.Element,
|
|
480
|
+
data: elementValue,
|
|
481
|
+
fakeEvent: true,
|
|
482
|
+
};
|
|
483
|
+
this.checkTypeNumber(eventFake, 'data');
|
|
484
|
+
this.processEventAndEmitValue(eventFake);
|
|
485
|
+
}
|
|
486
|
+
processEventAndEmitValue(e) {
|
|
487
|
+
const value = this.parseValueByDataType(e.target.value);
|
|
488
|
+
if (this.dataType() !== 'string' && !this.ignoreBlockInputMaxValue() && !isNil(this.maxValueNumber()) && value > (this.maxValueNumber() || 0) && this.value() < value) {
|
|
489
|
+
const valueDisplay = viewDataNumberByLanguage(`${this.value()}`.replace(/[.]/g, ','), this.acceptNegativeValue(), this.fixedFloat() ?? 14);
|
|
490
|
+
e.target.value = `${this.getCheckZero(+valueDisplay, e.target.value)}${valueDisplay}`;
|
|
491
|
+
return this.processEventAndEmitValue(e);
|
|
492
|
+
}
|
|
493
|
+
if (this.dataType() !== 'string' && isNil(value)) {
|
|
494
|
+
e.target.value = 0;
|
|
495
|
+
return this.processEventAndEmitValue(e);
|
|
496
|
+
}
|
|
497
|
+
if (e.fakeEvent && (`${this.value() ?? ''}` === `${value}` || (this.emitEmptyInDataTypeNumber() && e.target.value.trim() === ''))) {
|
|
498
|
+
this.checkAndDisableUpDownButton(this.dataType() === 'bigint' ? value : +value);
|
|
499
|
+
setTimeout(() => {
|
|
500
|
+
this.calculatorHeightTextArea(e);
|
|
501
|
+
}, 250);
|
|
502
|
+
return;
|
|
503
|
+
}
|
|
504
|
+
this.value.set(value);
|
|
505
|
+
if (this.emitEmptyInDataTypeNumber() && e.target.value.trim() === '') {
|
|
506
|
+
const dataEmit = this.dataType() === 'string' ? '' : undefined;
|
|
507
|
+
this.value.set(dataEmit);
|
|
508
|
+
}
|
|
509
|
+
this.outChange.emit(this.value());
|
|
510
|
+
this.checkAndDisableUpDownButton(this.dataType() === 'bigint' ? value : +value);
|
|
511
|
+
this.calculatorHeightTextArea(e);
|
|
512
|
+
}
|
|
513
|
+
checkMaxLengthNumberAndSetValue(valueDisplay, e) {
|
|
514
|
+
if (isNil(this.value()) || (+this.value() > 0 && this.parseValueByDataType(valueDisplay) < this.value()) || (+this.value() < 0 && this.parseValueByDataType(valueDisplay) > this.value())) {
|
|
515
|
+
return false;
|
|
516
|
+
}
|
|
517
|
+
const valueCompare = formatNumber(valueDisplay).toString();
|
|
518
|
+
const numbers = valueCompare.split('.');
|
|
519
|
+
let lengthValueCompare = 0;
|
|
520
|
+
let maxLength = this.acceptNegativeValue() && typeof +this.value() === 'number' && +this.value() < 0 ? (this.maxLength() || 21) + 1 : this.maxLength() || 21;
|
|
521
|
+
if (this.dataType() === 'float') {
|
|
522
|
+
maxLength--;
|
|
523
|
+
}
|
|
524
|
+
if (numbers && numbers[0]) {
|
|
525
|
+
lengthValueCompare = viewDataNumberByLanguage(`${numbers[0]}`.replace(/[.]/g, ','), this.acceptNegativeValue(), this.fixedFloat() ?? 14).length;
|
|
526
|
+
}
|
|
527
|
+
if (numbers && numbers[1]) {
|
|
528
|
+
lengthValueCompare += 1 + numbers[1].length;
|
|
529
|
+
}
|
|
530
|
+
if (maxLength && lengthValueCompare >= maxLength) {
|
|
531
|
+
const valueDisplay = viewDataNumberByLanguage((lengthValueCompare === maxLength ? valueCompare : `${this.value()}`).replace(/[.]/g, ','), this.acceptNegativeValue(), this.fixedFloat() ?? 14);
|
|
532
|
+
e.target.value = `${this.getCheckZero(+valueDisplay, e.target.value)}${valueDisplay}`;
|
|
533
|
+
return true;
|
|
534
|
+
}
|
|
535
|
+
return false;
|
|
536
|
+
}
|
|
537
|
+
checkTypeNumber(e, fieldName) {
|
|
538
|
+
const currentLang = UtilsCache.getLang();
|
|
539
|
+
const separator = currentLang === UtilsLanguageConstants.VI ? '.' : ',';
|
|
540
|
+
const separatorRevert = currentLang === UtilsLanguageConstants.VI ? ',' : '.';
|
|
541
|
+
let valueTarget = e.target.value;
|
|
542
|
+
const selectionStart = e.target.selectionStart - 1;
|
|
543
|
+
const { data, keyCode } = e;
|
|
544
|
+
this.charFirstIsZero.set(false);
|
|
545
|
+
if (valueTarget.charAt(0) === '0') {
|
|
546
|
+
this.charFirstIsZero.set(true);
|
|
547
|
+
}
|
|
548
|
+
if (this.dataType() === 'string') {
|
|
549
|
+
if (this.autoRemoveEmoji()) {
|
|
550
|
+
e.target.value = removeEmoji(valueTarget);
|
|
551
|
+
}
|
|
552
|
+
return;
|
|
553
|
+
}
|
|
554
|
+
if (/[0-9]/g.test(data) && valueTarget.charAt(selectionStart + 1) === '-') {
|
|
555
|
+
valueTarget = valueTarget.replaceAt(0, '');
|
|
556
|
+
}
|
|
557
|
+
let strRegex = `[^0-9.,${this.acceptNegativeValue() ? '-' : ''}]`;
|
|
558
|
+
if (new RegExp(strRegex, 'gi').test(e[fieldName]) && keyCode !== UtilsKeyCodeConstant.BACKSPACE) {
|
|
559
|
+
e.preventDefault();
|
|
560
|
+
e.target.value = valueTarget = e.target.value.replace(new RegExp(strRegex, 'gi'), '');
|
|
561
|
+
}
|
|
562
|
+
if (!e.fakeEvent) {
|
|
563
|
+
switch (data) {
|
|
564
|
+
case separator:
|
|
565
|
+
valueTarget = valueTarget.replace(new RegExp(`[${separator}]`, 'gi'), '');
|
|
566
|
+
break;
|
|
567
|
+
case separatorRevert: {
|
|
568
|
+
if (currentLang === UtilsLanguageConstants.VI && this.dataType() === 'int') {
|
|
569
|
+
e.target.value = valueTarget.replace(new RegExp(`[${separatorRevert}]`, 'gi'), '');
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
if (valueTarget === separatorRevert) {
|
|
573
|
+
e.target.value = '';
|
|
574
|
+
return;
|
|
575
|
+
}
|
|
576
|
+
if (valueTarget && valueTarget.length === 2 && valueTarget.charAt(0) === '-' && data && !/[0-9]/g.test(data)) {
|
|
577
|
+
e.target.value = '-';
|
|
578
|
+
return;
|
|
579
|
+
}
|
|
580
|
+
const occurrencesByCharacter = valueTarget.occurrencesByCharacter(separatorRevert);
|
|
581
|
+
if (occurrencesByCharacter > 1) {
|
|
582
|
+
valueTarget = valueTarget.replaceAt(e.target.selectionStart - 1, '');
|
|
583
|
+
break;
|
|
584
|
+
}
|
|
585
|
+
let maxLength = this.dataType() === 'float' ? (this.maxLength() || 21) - 1 : this.maxLength() || 21;
|
|
586
|
+
if (valueTarget.indexOf('-') >= 0) {
|
|
587
|
+
maxLength++;
|
|
588
|
+
}
|
|
589
|
+
if (occurrencesByCharacter === 1 && valueTarget.length === maxLength && valueTarget.indexOf(separatorRevert) === valueTarget.length - 1) {
|
|
590
|
+
valueTarget = valueTarget.replaceAt(e.target.selectionStart - 1, '');
|
|
591
|
+
break;
|
|
592
|
+
}
|
|
593
|
+
if (this.onlyAcceptNegativeValue() && valueTarget === `0${separatorRevert}`) {
|
|
594
|
+
e.target.value = '0';
|
|
595
|
+
}
|
|
596
|
+
return;
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
valueTarget = formatNumber(valueTarget);
|
|
600
|
+
}
|
|
601
|
+
const indexesOfDash = valueTarget.indexesOfCharacter?.('-') || [];
|
|
602
|
+
if (indexesOfDash.length) {
|
|
603
|
+
const [firstIndex, secondIndex] = indexesOfDash;
|
|
604
|
+
const indexReplace = firstIndex || secondIndex; // firstIndex=0 thì ko xóa
|
|
605
|
+
if (indexReplace) {
|
|
606
|
+
valueTarget = valueTarget.replaceAll(indexReplace, '-', '');
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
if (this.acceptNegativeValue() && valueTarget === '-') {
|
|
610
|
+
e.target.value = valueTarget;
|
|
611
|
+
return;
|
|
612
|
+
}
|
|
613
|
+
switch (this.dataType()) {
|
|
614
|
+
case 'int': {
|
|
615
|
+
strRegex = `[^0-9${this.acceptNegativeValue() ? '-' : ''}]`;
|
|
616
|
+
if (!e.fakeEvent) {
|
|
617
|
+
valueTarget = valueTarget.replace(new RegExp(strRegex, 'gi'), '');
|
|
618
|
+
const maxTotalNumber = valueTarget.includes('-') ? 17 : 16;
|
|
619
|
+
if (valueTarget.length > maxTotalNumber) {
|
|
620
|
+
valueTarget = valueTarget.slice(0, maxTotalNumber);
|
|
621
|
+
}
|
|
622
|
+
if (Math.abs(parseInt(valueTarget)) > (this.maxValueNumber() ?? 9007199254740991)) {
|
|
623
|
+
valueTarget = valueTarget.slice(0, maxTotalNumber - 1);
|
|
624
|
+
}
|
|
625
|
+
if (this.onlyAcceptNegativeValue() && valueTarget[0] !== '-' && valueTarget[0] !== '0') {
|
|
626
|
+
valueTarget = '';
|
|
627
|
+
}
|
|
628
|
+
if (valueTarget && /(^-)?(^[0]+)/.test(valueTarget)) {
|
|
629
|
+
const id = uuid();
|
|
630
|
+
valueTarget = valueTarget.replace(/(^-)?(^[0]+)/, `$1${id}`).replace(id, '0');
|
|
631
|
+
}
|
|
632
|
+
if (valueTarget === '-0') {
|
|
633
|
+
valueTarget = '0';
|
|
634
|
+
}
|
|
635
|
+
if (valueTarget && /(^[0])([1-9])([0-9]+)?/.test(valueTarget)) {
|
|
636
|
+
valueTarget = valueTarget.replace(/(^[0])([1-9])([0-9]+)?/, '$2$3');
|
|
637
|
+
}
|
|
638
|
+
const valueDisplay = viewDataNumberByLanguage(valueTarget, this.acceptNegativeValue() || false, 0);
|
|
639
|
+
if (this.checkMaxLengthNumberAndSetValue(valueDisplay, e)) {
|
|
640
|
+
break;
|
|
641
|
+
}
|
|
642
|
+
e.target.value = `${this.getCheckZero(+valueDisplay, e.target.value)}${valueDisplay}`;
|
|
643
|
+
break;
|
|
644
|
+
}
|
|
645
|
+
const indexOfDot = valueTarget.indexOf('.');
|
|
646
|
+
const indexOfComma = valueTarget.indexOf(',');
|
|
647
|
+
let indexChoose = indexOfDot;
|
|
648
|
+
if (indexOfDot < 0 || indexOfDot > indexOfComma) {
|
|
649
|
+
indexChoose = indexOfComma;
|
|
650
|
+
}
|
|
651
|
+
if (indexChoose >= 0) {
|
|
652
|
+
valueTarget = valueTarget.substring(0, indexChoose);
|
|
653
|
+
}
|
|
654
|
+
const valueDisplay = viewDataNumberByLanguage(valueTarget, this.acceptNegativeValue() || false, 0);
|
|
655
|
+
if (this.checkMaxLengthNumberAndSetValue(valueDisplay, e)) {
|
|
656
|
+
break;
|
|
657
|
+
}
|
|
658
|
+
e.target.value = `${this.getCheckZero(+valueDisplay, e.target.value)}${valueDisplay}`;
|
|
659
|
+
break;
|
|
660
|
+
}
|
|
661
|
+
case 'float':
|
|
662
|
+
// eslint-disable-next-line no-fallthrough
|
|
663
|
+
case 'bigint':
|
|
664
|
+
this.getValueFormat(e, valueTarget, separator, separatorRevert, currentLang);
|
|
665
|
+
break;
|
|
666
|
+
}
|
|
667
|
+
if (valueTarget === 'NaN') {
|
|
668
|
+
e.target.value = '';
|
|
669
|
+
}
|
|
670
|
+
if (e.fakeEvent || data === undefined) {
|
|
671
|
+
return;
|
|
672
|
+
}
|
|
673
|
+
this.setCaretPosition(e, selectionStart + 1);
|
|
674
|
+
}
|
|
675
|
+
getValueFormat(e, valueTarget, separator, separatorRevert, currentLang) {
|
|
676
|
+
let strRegex = `[^0-9${separator}${currentLang === UtilsLanguageConstants.EN ? '.' : ''}${this.acceptNegativeValue() ? '-' : ''}]`;
|
|
677
|
+
if (!e.fakeEvent) {
|
|
678
|
+
valueTarget = valueTarget.replace(new RegExp(strRegex, 'gi'), '');
|
|
679
|
+
}
|
|
680
|
+
const indexesOfSeparator = valueTarget.indexesOfCharacter(separator);
|
|
681
|
+
const [firstIndex, secondIndex] = indexesOfSeparator;
|
|
682
|
+
if (secondIndex) {
|
|
683
|
+
valueTarget = e.target.value.replaceAll(secondIndex, separator, '');
|
|
684
|
+
}
|
|
685
|
+
if (firstIndex && valueTarget.substring(firstIndex + 1).length >= (this.fixedFloat() ?? 14)) {
|
|
686
|
+
valueTarget = valueTarget.substring(0, firstIndex + (this.fixedFloat() ?? 14) + 1);
|
|
687
|
+
}
|
|
688
|
+
strRegex = `[${separator}]`;
|
|
689
|
+
valueTarget = valueTarget.replace(new RegExp(strRegex, 'g'), separatorRevert);
|
|
690
|
+
let valueFormat = '';
|
|
691
|
+
let [fontSeparatorNumber, behindSeparatorNumber] = valueTarget.split(separatorRevert);
|
|
692
|
+
let maxFontTotalNumber = fontSeparatorNumber && fontSeparatorNumber.includes('-') ? 16 : 15;
|
|
693
|
+
if (this.dataType() === 'bigint') {
|
|
694
|
+
maxFontTotalNumber = (this.maxLengthNumberCount() ?? 19) - (this.fixedFloat() ?? 4) + (fontSeparatorNumber.includes('-') ? 1 : 0);
|
|
695
|
+
}
|
|
696
|
+
const fontOverMaxTotalNumber = fontSeparatorNumber && fontSeparatorNumber.length >= maxFontTotalNumber;
|
|
697
|
+
if (fontOverMaxTotalNumber) {
|
|
698
|
+
fontSeparatorNumber = fontSeparatorNumber.slice(0, maxFontTotalNumber);
|
|
699
|
+
if (this.dataType() === 'float') {
|
|
700
|
+
behindSeparatorNumber = '';
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
switch (this.dataType()) {
|
|
704
|
+
case 'float':
|
|
705
|
+
if (!fontOverMaxTotalNumber && behindSeparatorNumber && behindSeparatorNumber.length) {
|
|
706
|
+
behindSeparatorNumber = behindSeparatorNumber.slice(0, maxFontTotalNumber - fontSeparatorNumber.length);
|
|
707
|
+
}
|
|
708
|
+
behindSeparatorNumber = `${behindSeparatorNumber ?? ''}`;
|
|
709
|
+
break;
|
|
710
|
+
case 'bigint':
|
|
711
|
+
if (behindSeparatorNumber && behindSeparatorNumber.length && behindSeparatorNumber.length > (this.fixedFloat() ?? 4)) {
|
|
712
|
+
behindSeparatorNumber = behindSeparatorNumber.slice(0, this.fixedFloat() ?? 4);
|
|
713
|
+
}
|
|
714
|
+
break;
|
|
715
|
+
}
|
|
716
|
+
const indexOfSeparatorRevert = valueTarget.indexOf(separatorRevert);
|
|
717
|
+
if (this.onlyAcceptNegativeValue() && fontSeparatorNumber[0] !== '-' && fontSeparatorNumber[0] !== '0') {
|
|
718
|
+
fontSeparatorNumber = '';
|
|
719
|
+
}
|
|
720
|
+
if (this.onlyAcceptNegativeValue() && indexOfSeparatorRevert >= 0 && fontSeparatorNumber[0] !== '-') {
|
|
721
|
+
fontSeparatorNumber = '0';
|
|
722
|
+
behindSeparatorNumber = this.dataType() === 'bigint' ? '0' : '';
|
|
723
|
+
}
|
|
724
|
+
if (fontSeparatorNumber && /(^-)([0]+)/.test(fontSeparatorNumber)) {
|
|
725
|
+
const id = uuid();
|
|
726
|
+
fontSeparatorNumber = fontSeparatorNumber.replace(/(^-)([0]+)/, `$1${id}`).replace(id, '0');
|
|
727
|
+
}
|
|
728
|
+
if (fontSeparatorNumber && /(^[0]+)/.test(fontSeparatorNumber)) {
|
|
729
|
+
fontSeparatorNumber = fontSeparatorNumber.replace(/(^[0]+)/, '0');
|
|
730
|
+
}
|
|
731
|
+
if (/(^-)([0]+)([1-9])([0-9.]+)?/.test(fontSeparatorNumber)) {
|
|
732
|
+
fontSeparatorNumber = fontSeparatorNumber.replace(/(^-)([0]+)([1-9])([0-9.]+)?/, '$1$3$4');
|
|
733
|
+
}
|
|
734
|
+
if (/(^[0]+)([1-9])([0-9.]+)?/.test(fontSeparatorNumber)) {
|
|
735
|
+
fontSeparatorNumber = fontSeparatorNumber.replace(/(^[0]+)([1-9])([0-9.]+)?/, '$2$3');
|
|
736
|
+
}
|
|
737
|
+
switch (this.dataType()) {
|
|
738
|
+
case 'float':
|
|
739
|
+
if (/(^[0]{6})/.test(behindSeparatorNumber)) {
|
|
740
|
+
behindSeparatorNumber = behindSeparatorNumber.replace(/(^[0]{6})/, '00000');
|
|
741
|
+
}
|
|
742
|
+
break;
|
|
743
|
+
case 'bigint':
|
|
744
|
+
if (/(^[0]{4})/.test(behindSeparatorNumber)) {
|
|
745
|
+
behindSeparatorNumber = behindSeparatorNumber.replace(/(^[0]{4})/, '0000');
|
|
746
|
+
}
|
|
747
|
+
break;
|
|
748
|
+
}
|
|
749
|
+
if (fontSeparatorNumber) {
|
|
750
|
+
fontSeparatorNumber = viewDataNumberByLanguage(fontSeparatorNumber, this.acceptNegativeValue(), this.fixedFloat() ?? (this.dataType() === 'bigint' ? 4 : 14));
|
|
751
|
+
}
|
|
752
|
+
const hasSeparatorRevert = (this.dataType() === 'bigint' ? true : !fontOverMaxTotalNumber) && indexOfSeparatorRevert >= 0;
|
|
753
|
+
valueFormat = `${fontSeparatorNumber ?? ''}${hasSeparatorRevert ? separatorRevert : ''}${behindSeparatorNumber ?? ''}`;
|
|
754
|
+
if (valueFormat && this.onlyAcceptNegativeValue() && valueFormat[0] !== '-' && valueFormat[0] !== '0') {
|
|
755
|
+
valueFormat = '0';
|
|
756
|
+
}
|
|
757
|
+
if (this.checkMaxLengthNumberAndSetValue(valueFormat, e)) {
|
|
758
|
+
valueTarget = e.target.value;
|
|
759
|
+
return;
|
|
760
|
+
}
|
|
761
|
+
valueTarget = e.target.value = valueFormat;
|
|
762
|
+
}
|
|
763
|
+
getCheckZero(value, targetCurrent) {
|
|
764
|
+
let zero = '';
|
|
765
|
+
if (this.dataType() !== 'int') {
|
|
766
|
+
return zero;
|
|
767
|
+
}
|
|
768
|
+
if (this.charFirstIsZero() && this.keepZeroInTypeInt() && value !== 0) {
|
|
769
|
+
zero = '0';
|
|
770
|
+
}
|
|
771
|
+
if (this.charFirstIsZero() && this.autoAddZeroLessThan10InTypeInt() && ((value > 0 && value < 10 && !/(^0)+/.test(`${targetCurrent}`)) || (targetCurrent && targetCurrent.match(/^[0]{2,}$/)?.length && value === 0))) {
|
|
772
|
+
zero = '0';
|
|
773
|
+
}
|
|
774
|
+
return zero;
|
|
775
|
+
}
|
|
776
|
+
setCaretPosition(e, selectionStart) {
|
|
777
|
+
const { keyCode, inputType } = e;
|
|
778
|
+
if (keyCode === UtilsKeyCodeConstant.UP_ARROW || keyCode === UtilsKeyCodeConstant.DOWN_ARROW || keyCode === UtilsKeyCodeConstant.LEFT_ARROW || keyCode === UtilsKeyCodeConstant.RIGHT_ARROW) {
|
|
779
|
+
return;
|
|
780
|
+
}
|
|
781
|
+
const valueTarget = e.target.value.replace('-', '');
|
|
782
|
+
let value = UtilsCache.getLang() === UtilsLanguageConstants.VI ? `${this.value() || 0}`.replace('.', ',') : `${this.value() || 0}`;
|
|
783
|
+
value = viewDataNumberByLanguage(value, this.acceptNegativeValue(), this.fixedFloat() ?? 14);
|
|
784
|
+
value = `${value}`.replace('-', '');
|
|
785
|
+
if (value === valueTarget && value !== '0' && value !== '-') {
|
|
786
|
+
setCaretPosition(this.Element, selectionStart);
|
|
787
|
+
return;
|
|
788
|
+
}
|
|
789
|
+
let factor = 0;
|
|
790
|
+
const distance = valueTarget.length - value.length;
|
|
791
|
+
if (distance < -1) {
|
|
792
|
+
factor = -1;
|
|
793
|
+
}
|
|
794
|
+
if (distance > 1) {
|
|
795
|
+
factor = 1;
|
|
796
|
+
}
|
|
797
|
+
selectionStart += factor;
|
|
798
|
+
if (inputType === 'insertFromPaste' && this.dataTextPaste()) {
|
|
799
|
+
const dataTextDisplay = `${viewDataNumberByLanguage(this.dataTextPaste(), this.acceptNegativeValue(), this.fixedFloat() ?? 14)}`;
|
|
800
|
+
const indexes = e.target.value.indexesByString(dataTextDisplay);
|
|
801
|
+
selectionStart -= factor;
|
|
802
|
+
if (indexes.some((index) => index === selectionStart) || !indexes.length) {
|
|
803
|
+
return setCaretPosition(this.Element, selectionStart);
|
|
804
|
+
}
|
|
805
|
+
let newSelectionStart = indexes[0];
|
|
806
|
+
for (const index of indexes) {
|
|
807
|
+
let replaceValue = formatNumber(`${valueTarget.substring(0, index)}${valueTarget.substring(index + dataTextDisplay.length + 1, valueTarget.length)}`);
|
|
808
|
+
replaceValue = viewDataNumberByLanguage(replaceValue, this.acceptNegativeValue(), this.fixedFloat() ?? 14);
|
|
809
|
+
if (value === replaceValue) {
|
|
810
|
+
newSelectionStart = index;
|
|
811
|
+
break;
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
if (newSelectionStart >= 0) {
|
|
815
|
+
selectionStart = newSelectionStart + dataTextDisplay.length + 1;
|
|
816
|
+
return setCaretPosition(this.Element, selectionStart);
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
setCaretPosition(this.Element, selectionStart);
|
|
820
|
+
}
|
|
821
|
+
parseValueByDataType(value) {
|
|
822
|
+
switch (this.dataType()) {
|
|
823
|
+
case 'string':
|
|
824
|
+
return value;
|
|
825
|
+
case 'int':
|
|
826
|
+
if (this.acceptNegativeValue() && (value === '-' || value === ',' || value === '.')) {
|
|
827
|
+
return 0;
|
|
828
|
+
}
|
|
829
|
+
return +formatNumber(value);
|
|
830
|
+
case 'float':
|
|
831
|
+
if (this.acceptNegativeValue() && (value === '-' || value === ',' || value === '.')) {
|
|
832
|
+
return 0;
|
|
833
|
+
}
|
|
834
|
+
return parseFloat((+formatNumber(value)).toFixed(this.fixedFloat() ?? 14));
|
|
835
|
+
case 'bigint':
|
|
836
|
+
if (this.acceptNegativeValue() && (value === '-' || value === ',' || value === '.')) {
|
|
837
|
+
return '0';
|
|
838
|
+
}
|
|
839
|
+
return formatNumber(value);
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
calculatorHeightTextArea(e) {
|
|
843
|
+
if (this.tagInput() === 'input') {
|
|
844
|
+
return;
|
|
845
|
+
}
|
|
846
|
+
const target = e.target;
|
|
847
|
+
target.style.overflow = 'hidden';
|
|
848
|
+
target.style.height = `${this.defaultHeight()}px`;
|
|
849
|
+
const { scrollHeight } = target;
|
|
850
|
+
const height = scrollHeight + 2; // border top + bottom = 2
|
|
851
|
+
if (!this.preHeightArea() && this.preHeightArea() !== height) {
|
|
852
|
+
this.outHeightAreaChange.emit({ isChange: true, height: height });
|
|
853
|
+
}
|
|
854
|
+
if (height > (this.maxHeightTextArea() ?? 32)) {
|
|
855
|
+
target.style.overflow = 'auto';
|
|
856
|
+
}
|
|
857
|
+
if (this.iframeRef) {
|
|
858
|
+
this.iframeRef.style.height = `${height}px`;
|
|
859
|
+
}
|
|
860
|
+
target.style.height = `${height}px`;
|
|
861
|
+
this.preHeightArea.set(height);
|
|
862
|
+
}
|
|
863
|
+
combineObservable(mouseDownEvent, observableMerge) {
|
|
864
|
+
mouseDownEvent
|
|
865
|
+
.pipe(mergeMap(() => observableMerge), debounceTime(0), tap((e) => this.checkTypeNumber(e, 'key')))
|
|
866
|
+
.subscribe((e) => this.processEventAndEmitValue(e));
|
|
867
|
+
}
|
|
868
|
+
async focus() {
|
|
869
|
+
setTimeout(() => {
|
|
870
|
+
this.Element?.focus();
|
|
871
|
+
}, this.focusTimeOut());
|
|
872
|
+
}
|
|
873
|
+
async blur() {
|
|
874
|
+
setTimeout(() => {
|
|
875
|
+
this.Element?.blur();
|
|
876
|
+
}, this.blurTimeOut());
|
|
877
|
+
}
|
|
878
|
+
async addDataToSelectionInput(data) {
|
|
879
|
+
const target = this.Element;
|
|
880
|
+
const selectionStart = target.selectionStart;
|
|
881
|
+
const value = this.Element.value;
|
|
882
|
+
const beforeValue = value.substring(0, selectionStart);
|
|
883
|
+
const afterValue = value.substring(selectionStart);
|
|
884
|
+
this.Element.value = `${beforeValue}${data}${afterValue}`;
|
|
885
|
+
setCaretPosition(this.Element, selectionStart + data.toString().length);
|
|
886
|
+
const eventFake = {
|
|
887
|
+
preventDefault: () => {
|
|
888
|
+
return;
|
|
889
|
+
},
|
|
890
|
+
target: this.Element,
|
|
891
|
+
data: '',
|
|
892
|
+
fakeEvent: true,
|
|
893
|
+
};
|
|
894
|
+
this.processEventAndEmitValue(eventFake);
|
|
895
|
+
}
|
|
896
|
+
handlerOnLoad(e, element) {
|
|
897
|
+
e.stopPropagation();
|
|
898
|
+
this.iframeRef = element;
|
|
899
|
+
const iframe = element.contentWindow || element.contentDocument;
|
|
900
|
+
this.configProjectService.setupFontFamily(iframe.document);
|
|
901
|
+
this.inputIframeRef.set({ nativeElement: iframe.document.getElementsByTagName('TEXTAREA')[0] });
|
|
902
|
+
if (this.Element) {
|
|
903
|
+
this.renderer.setAttribute(this.Element, 'placeholder', this.translateService.instant(this.placeholder()));
|
|
904
|
+
if (this.disable()) {
|
|
905
|
+
this.renderer.setAttribute(this.Element, 'disabled', 'true');
|
|
906
|
+
}
|
|
907
|
+
this.afterViewInit();
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
async resetValue() {
|
|
911
|
+
const value = '';
|
|
912
|
+
this.Element.value = value;
|
|
913
|
+
this.value.set(value);
|
|
914
|
+
this.outChange.emit(value);
|
|
915
|
+
}
|
|
916
|
+
countDisplayComputed() {
|
|
917
|
+
if ((this.dataType() !== 'string' && this.valueUpDownNumber()) || !isNil(this.iconRightClass())) {
|
|
918
|
+
setTimeout(() => {
|
|
919
|
+
this.paddingRightCustom.set((this.elementRightRef()?.nativeElement.getBoundingClientRect().width || 0) + 12);
|
|
920
|
+
});
|
|
921
|
+
}
|
|
922
|
+
if (!this.showCount() || this.dataType() !== 'string' || typeof this.value() !== 'string') {
|
|
923
|
+
return '0';
|
|
924
|
+
}
|
|
925
|
+
setTimeout(() => {
|
|
926
|
+
this.paddingRightCustom.set((this.elementRightRef()?.nativeElement.getBoundingClientRect().width || 0) + 12);
|
|
927
|
+
if (this.showCount()) {
|
|
928
|
+
if (this.textCountRef()) {
|
|
929
|
+
this.paddingRightCustom.set(this.textCountRef()?.nativeElement.clientWidth + 16);
|
|
930
|
+
}
|
|
931
|
+
if (this.tagInput() === 'input') {
|
|
932
|
+
this.paddingRightCustom.update((value) => {
|
|
933
|
+
return value + (this.elementRightRef()?.nativeElement.getBoundingClientRect().width || 0);
|
|
934
|
+
});
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
});
|
|
938
|
+
return `${viewDataNumberByLanguage(this.value().length, false)}`;
|
|
939
|
+
}
|
|
940
|
+
async selectAllContent() {
|
|
941
|
+
setTimeout(() => {
|
|
942
|
+
this.Element?.select();
|
|
943
|
+
}, this.selectAllTimeOut());
|
|
944
|
+
}
|
|
945
|
+
ngOnDestroy() {
|
|
946
|
+
this.onDestroy.next();
|
|
947
|
+
this.onDestroy.complete();
|
|
948
|
+
}
|
|
949
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: LibsUiComponentsInputsInputComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
950
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: LibsUiComponentsInputsInputComponent, isStandalone: true, selector: "libs_ui-components-inputs-input", inputs: { tagInput: { classPropertyName: "tagInput", publicName: "tagInput", isSignal: true, isRequired: false, transformFunction: null }, dataType: { classPropertyName: "dataType", publicName: "dataType", isSignal: true, isRequired: false, transformFunction: null }, typeInput: { classPropertyName: "typeInput", publicName: "typeInput", isSignal: true, isRequired: false, transformFunction: null }, modeInput: { classPropertyName: "modeInput", publicName: "modeInput", isSignal: true, isRequired: false, transformFunction: null }, tabInsertContentTagInput: { classPropertyName: "tabInsertContentTagInput", publicName: "tabInsertContentTagInput", isSignal: true, isRequired: false, transformFunction: null }, textAreaEnterNotNewLine: { classPropertyName: "textAreaEnterNotNewLine", publicName: "textAreaEnterNotNewLine", isSignal: true, isRequired: false, transformFunction: null }, emitEmptyInDataTypeNumber: { classPropertyName: "emitEmptyInDataTypeNumber", publicName: "emitEmptyInDataTypeNumber", isSignal: true, isRequired: false, transformFunction: null }, keepZeroInTypeInt: { classPropertyName: "keepZeroInTypeInt", publicName: "keepZeroInTypeInt", isSignal: true, isRequired: false, transformFunction: null }, autoAddZeroLessThan10InTypeInt: { classPropertyName: "autoAddZeroLessThan10InTypeInt", publicName: "autoAddZeroLessThan10InTypeInt", isSignal: true, isRequired: false, transformFunction: null }, ignoreBlockInputMaxValue: { classPropertyName: "ignoreBlockInputMaxValue", publicName: "ignoreBlockInputMaxValue", isSignal: true, isRequired: false, transformFunction: null }, maxValueNumber: { classPropertyName: "maxValueNumber", publicName: "maxValueNumber", isSignal: true, isRequired: false, transformFunction: null }, minValueNumber: { classPropertyName: "minValueNumber", publicName: "minValueNumber", isSignal: true, isRequired: false, transformFunction: null }, fixedFloat: { classPropertyName: "fixedFloat", publicName: "fixedFloat", isSignal: true, isRequired: false, transformFunction: null }, acceptNegativeValue: { classPropertyName: "acceptNegativeValue", publicName: "acceptNegativeValue", isSignal: true, isRequired: false, transformFunction: null }, valueUpDownNumber: { classPropertyName: "valueUpDownNumber", publicName: "valueUpDownNumber", isSignal: true, isRequired: false, transformFunction: null }, classInclude: { classPropertyName: "classInclude", publicName: "classInclude", isSignal: true, isRequired: false, transformFunction: null }, maxLength: { classPropertyName: "maxLength", publicName: "maxLength", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, disable: { classPropertyName: "disable", publicName: "disable", isSignal: true, isRequired: false, transformFunction: null }, noBorder: { classPropertyName: "noBorder", publicName: "noBorder", isSignal: true, isRequired: false, transformFunction: null }, backgroundNone: { classPropertyName: "backgroundNone", publicName: "backgroundNone", isSignal: true, isRequired: false, transformFunction: null }, borderError: { classPropertyName: "borderError", publicName: "borderError", isSignal: true, isRequired: false, transformFunction: null }, useColorModeExist: { classPropertyName: "useColorModeExist", publicName: "useColorModeExist", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, keepPlaceholderOnly: { classPropertyName: "keepPlaceholderOnly", publicName: "keepPlaceholderOnly", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, autoRemoveEmoji: { classPropertyName: "autoRemoveEmoji", publicName: "autoRemoveEmoji", isSignal: true, isRequired: false, transformFunction: null }, defaultHeight: { classPropertyName: "defaultHeight", publicName: "defaultHeight", isSignal: true, isRequired: false, transformFunction: null }, minHeightTextArea: { classPropertyName: "minHeightTextArea", publicName: "minHeightTextArea", isSignal: true, isRequired: false, transformFunction: null }, maxHeightTextArea: { classPropertyName: "maxHeightTextArea", publicName: "maxHeightTextArea", isSignal: true, isRequired: false, transformFunction: null }, focusTimeOut: { classPropertyName: "focusTimeOut", publicName: "focusTimeOut", isSignal: true, isRequired: false, transformFunction: null }, selectAllTimeOut: { classPropertyName: "selectAllTimeOut", publicName: "selectAllTimeOut", isSignal: true, isRequired: false, transformFunction: null }, blurTimeOut: { classPropertyName: "blurTimeOut", publicName: "blurTimeOut", isSignal: true, isRequired: false, transformFunction: null }, zIndexPopoverContent: { classPropertyName: "zIndexPopoverContent", publicName: "zIndexPopoverContent", isSignal: true, isRequired: false, transformFunction: null }, classContainerInput: { classPropertyName: "classContainerInput", publicName: "classContainerInput", isSignal: true, isRequired: false, transformFunction: null }, showCount: { classPropertyName: "showCount", publicName: "showCount", isSignal: true, isRequired: false, transformFunction: null }, ignoreStopPropagationEvent: { classPropertyName: "ignoreStopPropagationEvent", publicName: "ignoreStopPropagationEvent", isSignal: true, isRequired: false, transformFunction: null }, resize: { classPropertyName: "resize", publicName: "resize", isSignal: true, isRequired: false, transformFunction: null }, templateLeftBottomInput: { classPropertyName: "templateLeftBottomInput", publicName: "templateLeftBottomInput", isSignal: true, isRequired: false, transformFunction: null }, templateRightBottomInput: { classPropertyName: "templateRightBottomInput", publicName: "templateRightBottomInput", isSignal: true, isRequired: false, transformFunction: null }, classContainerBottomInput: { classPropertyName: "classContainerBottomInput", publicName: "classContainerBottomInput", isSignal: true, isRequired: false, transformFunction: null }, ignoreWidthInput100: { classPropertyName: "ignoreWidthInput100", publicName: "ignoreWidthInput100", isSignal: true, isRequired: false, transformFunction: null }, iframeTextareaCustomStyle: { classPropertyName: "iframeTextareaCustomStyle", publicName: "iframeTextareaCustomStyle", isSignal: true, isRequired: false, transformFunction: null }, iconLeftClass: { classPropertyName: "iconLeftClass", publicName: "iconLeftClass", isSignal: true, isRequired: false, transformFunction: null }, popoverContentIconLeft: { classPropertyName: "popoverContentIconLeft", publicName: "popoverContentIconLeft", isSignal: true, isRequired: false, transformFunction: null }, iconRightClass: { classPropertyName: "iconRightClass", publicName: "iconRightClass", isSignal: true, isRequired: false, transformFunction: null }, popoverContentIconRight: { classPropertyName: "popoverContentIconRight", publicName: "popoverContentIconRight", isSignal: true, isRequired: false, transformFunction: null }, resetAutoCompletePassword: { classPropertyName: "resetAutoCompletePassword", publicName: "resetAutoCompletePassword", isSignal: true, isRequired: false, transformFunction: null }, acceptOnlyClickIcon: { classPropertyName: "acceptOnlyClickIcon", publicName: "acceptOnlyClickIcon", isSignal: true, isRequired: false, transformFunction: null }, setIconRightColorSameColorDisableReadOnly: { classPropertyName: "setIconRightColorSameColorDisableReadOnly", publicName: "setIconRightColorSameColorDisableReadOnly", isSignal: true, isRequired: false, transformFunction: null }, onlyAcceptNegativeValue: { classPropertyName: "onlyAcceptNegativeValue", publicName: "onlyAcceptNegativeValue", isSignal: true, isRequired: false, transformFunction: null }, maxLengthNumberCount: { classPropertyName: "maxLengthNumberCount", publicName: "maxLengthNumberCount", isSignal: true, isRequired: false, transformFunction: null }, focusInput: { classPropertyName: "focusInput", publicName: "focusInput", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { maxValueNumber: "maxValueNumberChange", minValueNumber: "minValueNumberChange", fixedFloat: "fixedFloatChange", acceptNegativeValue: "acceptNegativeValueChange", maxLength: "maxLengthChange", value: "valueChange", maxLengthNumberCount: "maxLengthNumberCountChange", outHeightAreaChange: "outHeightAreaChange", outChange: "outChange", outFocusAndBlurEvent: "outFocusAndBlurEvent", outEnterEvent: "outEnterEvent", outInputEvent: "outInputEvent", outIconLeft: "outIconLeft", outIconRight: "outIconRight", outFunctionsControl: "outFunctionsControl", outFilesDrop: "outFilesDrop", outFileDrop: "outFileDrop", outChangeValueByButtonUpDown: "outChangeValueByButtonUpDown" }, viewQueries: [{ propertyName: "inputRef", first: true, predicate: ["inputRef"], descendants: true, isSignal: true }, { propertyName: "textCountRef", first: true, predicate: ["textCountRef"], descendants: true, isSignal: true }, { propertyName: "elementRightRef", first: true, predicate: ["elementRightRef"], descendants: true, isSignal: true }], ngImport: i0, template: "<div\n [class]=\"'flex relative !text-[#9ca2ad] ' + classContainerInput()\"\n [class.libs-ui-components-input-textarea-container]=\"tagInput() === 'textarea' && resize() === 'auto'\">\n @if (tagInput() === 'input') {\n <input\n #inputRef\n [class.libs-ui-readonly]=\"readonly()\"\n [class.libs-ui-readonly-background]=\"readonly()\"\n [class.libs-ui-disable]=\"disable()\"\n [class.libs-ui-disable-background]=\"disable()\"\n [style.height.px]=\"defaultHeight()\"\n [style.minHeight.px]=\"defaultHeight()\"\n [style.paddingRight.px.important]=\"paddingRightCustom()\"\n [class.w-full]=\"!ignoreWidthInput100()\"\n [class]=\"'libs-ui-input libs-ui-font-h5r ' + classInclude()\"\n [class.border-primary-focus-general]=\"focusInput()\"\n [class.libs-ui-input-not-border]=\"noBorder()\"\n [class.libs-ui-bg-special-none]=\"backgroundNone()\"\n [class.libs-ui-border-error-general]=\"borderError()\"\n [class.text-[#29c7cc]]=\"useColorModeExist()\"\n [class.!pl-[40px]]=\"iconLeftClass()\"\n [attr.maxLength]=\"maxLength() || undefined\"\n [placeholder]=\"placeholder() | translate\"\n [attr.type]=\"typeInput()\"\n [attr.inputmode]=\"modeInput()\"\n [readonly]=\"readonly()\"\n [disabled]=\"disable()\"\n [autocomplete]=\"resetAutoCompletePassword() ? 'new-password' : ''\" />\n }\n @if (tagInput() === 'textarea') {\n @if (resize() === 'auto') {\n <div class=\"libs-ui-components-input-textarea-container-resize-icon\"></div>\n }\n <textarea\n #inputRef\n [class.libs-ui-readonly]=\"readonly()\"\n [class.libs-ui-readonly-background]=\"readonly()\"\n [class.libs-ui-disable]=\"disable()\"\n [class.libs-ui-disable-background]=\"disable()\"\n [style.height.px]=\"defaultHeight()\"\n [style.minHeight.px]=\"minHeightTextArea() ?? defaultHeight()\"\n [style.paddingRight.px.important]=\"paddingRightCustom()\"\n [style.maxHeight.px]=\"maxHeightTextArea()\"\n [style.resize]=\"resize()\"\n [class.w-full]=\"!ignoreWidthInput100()\"\n [class]=\"'libs-ui-input libs-ui-font-h5r libs-ui-cursor-auto ' + classInclude()\"\n [class.libs-ui-input-not-border]=\"noBorder()\"\n [class.libs-ui-bg-special-none]=\"backgroundNone()\"\n [class.libs-ui-border-error-general]=\"borderError()\"\n [class.text-[#29c7cc]]=\"useColorModeExist()\"\n [class.pl-[32px]]=\"iconLeftClass()\"\n [attr.maxLength]=\"maxLength() || undefined\"\n [placeholder]=\"placeholder() | translate\"\n [readonly]=\"readonly()\"\n [disabled]=\"disable()\"></textarea>\n }\n\n @if (tagInput() === 'iframe-textarea' && htmlIframeArea()) {\n <span class=\"d-none\"></span>\n <iframe\n #iframeRef\n [style.maxHeight.px]=\"maxHeightTextArea()\"\n [style.height.px]=\"defaultHeight()\"\n [srcdoc]=\"htmlIframeArea()\"\n class=\"w-full\"\n frameBorder=\"0\"\n (load)=\"handlerOnLoad($event, iframeRef)\"></iframe>\n }\n @if (iconLeftClass()) {\n <libs_ui-components-popover\n [ignoreShowPopover]=\"!popoverContentIconLeft()\"\n [config]=\"{ maxWidth: 250, direction: 'bottom', content: popoverContentIconLeft(), zIndex: zIndexPopoverContent() }\">\n <i\n [attr.tagInput]=\"tagInput()\"\n [class]=\"iconLeftClass() + ' libs-ui-input-icon-left !text-[#9ca2ad]'\"\n (click)=\"handlerEventIconLeft($event, 'click')\"></i>\n </libs_ui-components-popover>\n }\n <div\n #elementRightRef\n class=\"absolute flex items-center h-full top-0 right-0\">\n @if (value() && placeholder().trim() && keepPlaceholderOnly()) {\n <span [class]=\"'libs-ui-input-placeholder-custom libs-ui-font-h5r'\">\n {{ placeholder() }}\n </span>\n }\n @if (dataType() !== 'string' && valueUpDownNumber()) {\n <libs_ui-components-buttons-sort\n class=\"mr-[12px]\"\n [disableAsc]=\"disableAsc()\"\n [disableDesc]=\"disableDesc()\"\n [attr.tagInput]=\"tagInput()\"\n [onlyEmit]=\"true\"\n [disable]=\"disable() || readonly()\"\n (outChange)=\"handlerChangeValue($event)\" />\n }\n @if (iconRightClass()) {\n <libs_ui-components-popover\n class=\"flex\"\n [ignoreShowPopover]=\"!popoverContentIconRight()\"\n [config]=\"{ maxWidth: 250, direction: 'bottom', content: popoverContentIconRight(), zIndex: zIndexPopoverContent() }\">\n <i\n [attr.tagInput]=\"tagInput()\"\n [class.text-[#6a7383]]=\"(!disable() && !readonly()) || acceptOnlyClickIcon()\"\n [class.text-[#cdd0d6]]=\"((disable() || readonly()) && !acceptOnlyClickIcon()) || setIconRightColorSameColorDisableReadOnly()\"\n [class]=\"iconRightClass() + ' libs-ui-input-icon-right'\"\n (click)=\"handlerEventIconRight($event, 'click')\"></i>\n </libs_ui-components-popover>\n }\n </div>\n <div\n class=\"libs-ui-input-text-bottom {{ classContainerBottomInput() }}\"\n [style.right.px]=\"(tagInput() === 'input' ? elementRightRef.clientWidth || 0 : 0) + 8\">\n @if (templateLeftBottomInput(); as templateLeftBottomInput) {\n <ng-container *ngTemplateOutlet=\"templateLeftBottomInput\" />\n }\n <div\n #textCountRef\n class=\"text-[#9ca2ad] libs-ui-font-h7r\"\n [class.hidden]=\"dataType() !== 'string' || !showCount()\">\n <span>{{ countDisplay() }}</span>\n @if (maxLength()) {\n <span>/{{ maxLengthDisplay() }}</span>\n }\n </div>\n @if (templateRightBottomInput(); as templateRightBottomInput) {\n <ng-container *ngTemplateOutlet=\"templateRightBottomInput\" />\n }\n </div>\n</div>\n", styles: [".libs-ui-input{max-width:100%;border-radius:none;color:#071631;padding:7px 12px;background-color:#fff;background-clip:padding-box;min-height:32px}.libs-ui-input:not(.libs-ui-input-not-border){border:1px solid #e6e7ea;border-radius:4px}.libs-ui-input:focus{outline:none}.libs-ui-input:focus:not(:read-only):not(:disabled):not(.libs-ui-input-not-border){border:1px solid var(--libs-ui-color-light-1, #4e8cf7)}.libs-ui-input .libs-ui-input-valid-check{position:absolute;left:-27px}.libs-ui-input-not-border{border:transparent}libs-ui-components-button-sort{position:absolute;right:12px;top:0}libs-ui-components-button-sort[tagInput=textarea]{top:-10px}.libs-ui-input-icon-left{position:absolute;top:8px;left:16px;font-size:16px}.libs-ui-input-icon-right{font-size:16px;margin-right:8px}.libs-ui-input-text-bottom{display:flex;align-items:center;position:absolute;bottom:8px}input::-ms-reveal,input::-ms-clear{display:none}input::-webkit-credentials-auto-fill-button{margin-right:8px!important}textarea::-webkit-resizer{border:transparent;outline:none}.libs-ui-components-input-textarea-container:after{content:\"\";border-top:1.5px solid #9ca2ad;width:15px;transform:rotate(-45deg);background:transparent;position:absolute;right:0;bottom:8px;pointer-events:none;border-radius:25%}.libs-ui-components-input-textarea-container .libs-ui-components-input-textarea-container-resize-icon{border-top:1.5px solid #9ca2ad;width:7px;transform:rotate(-45deg);position:absolute;bottom:5px;right:1px;pointer-events:none;border-radius:25%}.libs-ui-input-placeholder-custom{color:#6a7378;margin-right:16px;background:inherit}\n"], dependencies: [{ kind: "ngmodule", type: TranslateModule }, { kind: "pipe", type: i1.TranslatePipe, name: "translate" }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: LibsUiComponentsPopoverComponent, selector: "libs_ui-components-popover,[LibsUiComponentsPopoverDirective]", inputs: ["debugId", "flagMouse", "type", "mode", "config", "ignoreShowPopover", "elementRefCustom", "initEventInElementRefCustom", "classInclude", "ignoreHiddenPopoverContentWhenMouseLeave", "ignoreStopPropagationEvent", "ignoreCursorPointerModeLikeClick", "isAddContentToParentDocument", "ignoreClickOutside"], outputs: ["outEvent", "outChangStageFlagMouse", "outEventPopoverContent", "outFunctionsControl"] }, { kind: "component", type: LibsUiComponentsButtonsSortComponent, selector: "libs_ui-components-buttons-sort", inputs: ["size", "mode", "fieldSort", "disable", "disableAsc", "disableDesc", "onlyEmit"], outputs: ["modeChange", "outChange"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
951
|
+
}
|
|
952
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: LibsUiComponentsInputsInputComponent, decorators: [{
|
|
953
|
+
type: Component,
|
|
954
|
+
args: [{ selector: 'libs_ui-components-inputs-input', standalone: true, imports: [TranslateModule, NgTemplateOutlet, LibsUiComponentsPopoverComponent, LibsUiComponentsButtonsSortComponent], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div\n [class]=\"'flex relative !text-[#9ca2ad] ' + classContainerInput()\"\n [class.libs-ui-components-input-textarea-container]=\"tagInput() === 'textarea' && resize() === 'auto'\">\n @if (tagInput() === 'input') {\n <input\n #inputRef\n [class.libs-ui-readonly]=\"readonly()\"\n [class.libs-ui-readonly-background]=\"readonly()\"\n [class.libs-ui-disable]=\"disable()\"\n [class.libs-ui-disable-background]=\"disable()\"\n [style.height.px]=\"defaultHeight()\"\n [style.minHeight.px]=\"defaultHeight()\"\n [style.paddingRight.px.important]=\"paddingRightCustom()\"\n [class.w-full]=\"!ignoreWidthInput100()\"\n [class]=\"'libs-ui-input libs-ui-font-h5r ' + classInclude()\"\n [class.border-primary-focus-general]=\"focusInput()\"\n [class.libs-ui-input-not-border]=\"noBorder()\"\n [class.libs-ui-bg-special-none]=\"backgroundNone()\"\n [class.libs-ui-border-error-general]=\"borderError()\"\n [class.text-[#29c7cc]]=\"useColorModeExist()\"\n [class.!pl-[40px]]=\"iconLeftClass()\"\n [attr.maxLength]=\"maxLength() || undefined\"\n [placeholder]=\"placeholder() | translate\"\n [attr.type]=\"typeInput()\"\n [attr.inputmode]=\"modeInput()\"\n [readonly]=\"readonly()\"\n [disabled]=\"disable()\"\n [autocomplete]=\"resetAutoCompletePassword() ? 'new-password' : ''\" />\n }\n @if (tagInput() === 'textarea') {\n @if (resize() === 'auto') {\n <div class=\"libs-ui-components-input-textarea-container-resize-icon\"></div>\n }\n <textarea\n #inputRef\n [class.libs-ui-readonly]=\"readonly()\"\n [class.libs-ui-readonly-background]=\"readonly()\"\n [class.libs-ui-disable]=\"disable()\"\n [class.libs-ui-disable-background]=\"disable()\"\n [style.height.px]=\"defaultHeight()\"\n [style.minHeight.px]=\"minHeightTextArea() ?? defaultHeight()\"\n [style.paddingRight.px.important]=\"paddingRightCustom()\"\n [style.maxHeight.px]=\"maxHeightTextArea()\"\n [style.resize]=\"resize()\"\n [class.w-full]=\"!ignoreWidthInput100()\"\n [class]=\"'libs-ui-input libs-ui-font-h5r libs-ui-cursor-auto ' + classInclude()\"\n [class.libs-ui-input-not-border]=\"noBorder()\"\n [class.libs-ui-bg-special-none]=\"backgroundNone()\"\n [class.libs-ui-border-error-general]=\"borderError()\"\n [class.text-[#29c7cc]]=\"useColorModeExist()\"\n [class.pl-[32px]]=\"iconLeftClass()\"\n [attr.maxLength]=\"maxLength() || undefined\"\n [placeholder]=\"placeholder() | translate\"\n [readonly]=\"readonly()\"\n [disabled]=\"disable()\"></textarea>\n }\n\n @if (tagInput() === 'iframe-textarea' && htmlIframeArea()) {\n <span class=\"d-none\"></span>\n <iframe\n #iframeRef\n [style.maxHeight.px]=\"maxHeightTextArea()\"\n [style.height.px]=\"defaultHeight()\"\n [srcdoc]=\"htmlIframeArea()\"\n class=\"w-full\"\n frameBorder=\"0\"\n (load)=\"handlerOnLoad($event, iframeRef)\"></iframe>\n }\n @if (iconLeftClass()) {\n <libs_ui-components-popover\n [ignoreShowPopover]=\"!popoverContentIconLeft()\"\n [config]=\"{ maxWidth: 250, direction: 'bottom', content: popoverContentIconLeft(), zIndex: zIndexPopoverContent() }\">\n <i\n [attr.tagInput]=\"tagInput()\"\n [class]=\"iconLeftClass() + ' libs-ui-input-icon-left !text-[#9ca2ad]'\"\n (click)=\"handlerEventIconLeft($event, 'click')\"></i>\n </libs_ui-components-popover>\n }\n <div\n #elementRightRef\n class=\"absolute flex items-center h-full top-0 right-0\">\n @if (value() && placeholder().trim() && keepPlaceholderOnly()) {\n <span [class]=\"'libs-ui-input-placeholder-custom libs-ui-font-h5r'\">\n {{ placeholder() }}\n </span>\n }\n @if (dataType() !== 'string' && valueUpDownNumber()) {\n <libs_ui-components-buttons-sort\n class=\"mr-[12px]\"\n [disableAsc]=\"disableAsc()\"\n [disableDesc]=\"disableDesc()\"\n [attr.tagInput]=\"tagInput()\"\n [onlyEmit]=\"true\"\n [disable]=\"disable() || readonly()\"\n (outChange)=\"handlerChangeValue($event)\" />\n }\n @if (iconRightClass()) {\n <libs_ui-components-popover\n class=\"flex\"\n [ignoreShowPopover]=\"!popoverContentIconRight()\"\n [config]=\"{ maxWidth: 250, direction: 'bottom', content: popoverContentIconRight(), zIndex: zIndexPopoverContent() }\">\n <i\n [attr.tagInput]=\"tagInput()\"\n [class.text-[#6a7383]]=\"(!disable() && !readonly()) || acceptOnlyClickIcon()\"\n [class.text-[#cdd0d6]]=\"((disable() || readonly()) && !acceptOnlyClickIcon()) || setIconRightColorSameColorDisableReadOnly()\"\n [class]=\"iconRightClass() + ' libs-ui-input-icon-right'\"\n (click)=\"handlerEventIconRight($event, 'click')\"></i>\n </libs_ui-components-popover>\n }\n </div>\n <div\n class=\"libs-ui-input-text-bottom {{ classContainerBottomInput() }}\"\n [style.right.px]=\"(tagInput() === 'input' ? elementRightRef.clientWidth || 0 : 0) + 8\">\n @if (templateLeftBottomInput(); as templateLeftBottomInput) {\n <ng-container *ngTemplateOutlet=\"templateLeftBottomInput\" />\n }\n <div\n #textCountRef\n class=\"text-[#9ca2ad] libs-ui-font-h7r\"\n [class.hidden]=\"dataType() !== 'string' || !showCount()\">\n <span>{{ countDisplay() }}</span>\n @if (maxLength()) {\n <span>/{{ maxLengthDisplay() }}</span>\n }\n </div>\n @if (templateRightBottomInput(); as templateRightBottomInput) {\n <ng-container *ngTemplateOutlet=\"templateRightBottomInput\" />\n }\n </div>\n</div>\n", styles: [".libs-ui-input{max-width:100%;border-radius:none;color:#071631;padding:7px 12px;background-color:#fff;background-clip:padding-box;min-height:32px}.libs-ui-input:not(.libs-ui-input-not-border){border:1px solid #e6e7ea;border-radius:4px}.libs-ui-input:focus{outline:none}.libs-ui-input:focus:not(:read-only):not(:disabled):not(.libs-ui-input-not-border){border:1px solid var(--libs-ui-color-light-1, #4e8cf7)}.libs-ui-input .libs-ui-input-valid-check{position:absolute;left:-27px}.libs-ui-input-not-border{border:transparent}libs-ui-components-button-sort{position:absolute;right:12px;top:0}libs-ui-components-button-sort[tagInput=textarea]{top:-10px}.libs-ui-input-icon-left{position:absolute;top:8px;left:16px;font-size:16px}.libs-ui-input-icon-right{font-size:16px;margin-right:8px}.libs-ui-input-text-bottom{display:flex;align-items:center;position:absolute;bottom:8px}input::-ms-reveal,input::-ms-clear{display:none}input::-webkit-credentials-auto-fill-button{margin-right:8px!important}textarea::-webkit-resizer{border:transparent;outline:none}.libs-ui-components-input-textarea-container:after{content:\"\";border-top:1.5px solid #9ca2ad;width:15px;transform:rotate(-45deg);background:transparent;position:absolute;right:0;bottom:8px;pointer-events:none;border-radius:25%}.libs-ui-components-input-textarea-container .libs-ui-components-input-textarea-container-resize-icon{border-top:1.5px solid #9ca2ad;width:7px;transform:rotate(-45deg);position:absolute;bottom:5px;right:1px;pointer-events:none;border-radius:25%}.libs-ui-input-placeholder-custom{color:#6a7378;margin-right:16px;background:inherit}\n"] }]
|
|
955
|
+
}], ctorParameters: () => [] });
|
|
956
|
+
|
|
957
|
+
/**
|
|
958
|
+
* Generated bundle index. Do not edit.
|
|
959
|
+
*/
|
|
960
|
+
|
|
961
|
+
export { LibsUiComponentsInputsInputComponent };
|
|
962
|
+
//# sourceMappingURL=libs-ui-components-inputs-input.mjs.map
|