@acorex/components 22.0.0-next.4 → 22.0.0-next.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/datetime-text-box/README.md +3 -0
- package/fesm2022/acorex-components-datetime-text-box.mjs +632 -0
- package/fesm2022/acorex-components-datetime-text-box.mjs.map +1 -0
- package/fesm2022/acorex-components-decorators.mjs +2 -2
- package/fesm2022/acorex-components-decorators.mjs.map +1 -1
- package/fesm2022/acorex-components-file-viewer.mjs +368 -107
- package/fesm2022/acorex-components-file-viewer.mjs.map +1 -1
- package/package.json +7 -3
- package/types/acorex-components-datetime-text-box.d.ts +142 -0
- package/types/acorex-components-file-viewer.d.ts +146 -17
|
@@ -0,0 +1,632 @@
|
|
|
1
|
+
import { MXInputBaseValueComponent, MXLookComponent, AXComponent, AXFocusableComponent, AXValuableComponent, AXClearableComponent } from '@acorex/cdk/common';
|
|
2
|
+
import { AXCalendarService } from '@acorex/core/date-time';
|
|
3
|
+
import { AXLocaleService } from '@acorex/core/locale';
|
|
4
|
+
import { AXPlatform } from '@acorex/core/platform';
|
|
5
|
+
import { getWordBoundsAtPosition } from '@acorex/core/utils';
|
|
6
|
+
import * as i0 from '@angular/core';
|
|
7
|
+
import { inject, signal, input, output, computed, linkedSignal, viewChild, effect, untracked, forwardRef, ViewEncapsulation, ChangeDetectionStrategy, Component, NgModule } from '@angular/core';
|
|
8
|
+
import * as i1 from '@angular/forms';
|
|
9
|
+
import { FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
10
|
+
import { classes } from 'polytype';
|
|
11
|
+
import { map } from 'rxjs';
|
|
12
|
+
|
|
13
|
+
/* eslint-disable @angular-eslint/no-inputs-metadata-property */
|
|
14
|
+
/**
|
|
15
|
+
* A date & time editor that works like a text box: the user types digits directly into a
|
|
16
|
+
* masked value (separators come from the active format), navigates between date/time
|
|
17
|
+
* segments with Left/Right arrows and spins segment values with Up/Down arrows.
|
|
18
|
+
*
|
|
19
|
+
* The committed value is a native `Date` (same contract as `ax-datetime-box`), and both
|
|
20
|
+
* `gregorian` and `solar-hijri` calendar systems are supported.
|
|
21
|
+
*
|
|
22
|
+
* @category Components
|
|
23
|
+
*/
|
|
24
|
+
class AXDateTimeTextBoxComponent extends classes((MXInputBaseValueComponent), MXLookComponent) {
|
|
25
|
+
constructor() {
|
|
26
|
+
super(...arguments);
|
|
27
|
+
this.platformService = inject(AXPlatform);
|
|
28
|
+
this.localeService = inject(AXLocaleService);
|
|
29
|
+
this.calendarService = inject(AXCalendarService);
|
|
30
|
+
/** @ignore */
|
|
31
|
+
this._editingParts = {
|
|
32
|
+
year: {
|
|
33
|
+
key: 'year',
|
|
34
|
+
placeholder: 'yyyy',
|
|
35
|
+
placeholders: ['YY', 'yy', 'YYYY', 'yyyy'],
|
|
36
|
+
enabled: false,
|
|
37
|
+
default: 2023,
|
|
38
|
+
typedValue: null,
|
|
39
|
+
realValue: () => this._formatPart(this._editingDate(), this._editingParts.year.placeholder),
|
|
40
|
+
},
|
|
41
|
+
month: {
|
|
42
|
+
key: 'month',
|
|
43
|
+
placeholder: 'MM',
|
|
44
|
+
placeholders: ['MM', 'M'],
|
|
45
|
+
enabled: false,
|
|
46
|
+
default: 1,
|
|
47
|
+
typedValue: null,
|
|
48
|
+
realValue: () => this._formatPart(this._editingDate(), this._editingParts.month.placeholder),
|
|
49
|
+
},
|
|
50
|
+
day: {
|
|
51
|
+
key: 'day',
|
|
52
|
+
placeholder: 'dd',
|
|
53
|
+
placeholders: ['dd', 'DD', 'd'],
|
|
54
|
+
enabled: false,
|
|
55
|
+
default: 1,
|
|
56
|
+
typedValue: null,
|
|
57
|
+
realValue: () => this._formatPart(this._editingDate(), this._editingParts.day.placeholder),
|
|
58
|
+
},
|
|
59
|
+
hour: {
|
|
60
|
+
key: 'hour',
|
|
61
|
+
placeholder: 'HH',
|
|
62
|
+
placeholders: ['HH', 'H', 'hh', 'h'],
|
|
63
|
+
enabled: false,
|
|
64
|
+
default: 0,
|
|
65
|
+
typedValue: null,
|
|
66
|
+
realValue: () => this._formatPart(this._editingDate(), this._editingParts.hour.placeholder),
|
|
67
|
+
},
|
|
68
|
+
minute: {
|
|
69
|
+
key: 'minute',
|
|
70
|
+
placeholder: 'mm',
|
|
71
|
+
placeholders: ['mm', 'm'],
|
|
72
|
+
enabled: false,
|
|
73
|
+
default: 0,
|
|
74
|
+
typedValue: null,
|
|
75
|
+
realValue: () => this._formatPart(this._editingDate(), this._editingParts.minute.placeholder),
|
|
76
|
+
},
|
|
77
|
+
second: {
|
|
78
|
+
key: 'second',
|
|
79
|
+
placeholder: 'ss',
|
|
80
|
+
placeholders: ['ss', 's'],
|
|
81
|
+
enabled: false,
|
|
82
|
+
default: 0,
|
|
83
|
+
typedValue: null,
|
|
84
|
+
realValue: () => this._formatPart(this._editingDate(), this._editingParts.second.placeholder),
|
|
85
|
+
},
|
|
86
|
+
AMPM: {
|
|
87
|
+
key: 'AMPM',
|
|
88
|
+
placeholder: 'a',
|
|
89
|
+
placeholders: ['a', 'A'],
|
|
90
|
+
enabled: false,
|
|
91
|
+
default: 0,
|
|
92
|
+
typedValue: null,
|
|
93
|
+
realValue: () => this._formatPart(this._editingDate(), this._editingParts.AMPM.placeholder),
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
/** @ignore */
|
|
97
|
+
this._editingText = signal('', /* @ts-ignore */
|
|
98
|
+
...(ngDevMode ? [{ debugName: "_editingText" }] : /* istanbul ignore next */ []));
|
|
99
|
+
/** @ignore */
|
|
100
|
+
this._inputChars = [];
|
|
101
|
+
/** @ignore */
|
|
102
|
+
this._activePart = signal(null, /* @ts-ignore */
|
|
103
|
+
...(ngDevMode ? [{ debugName: "_activePart" }] : /* istanbul ignore next */ []));
|
|
104
|
+
/**
|
|
105
|
+
* Determines which parts are editable: `date`, `time` or `datetime`.
|
|
106
|
+
* The mask format is resolved from the active locale profile for this mode.
|
|
107
|
+
* @defaultValue 'datetime'
|
|
108
|
+
*/
|
|
109
|
+
this.picker = input('datetime', /* @ts-ignore */
|
|
110
|
+
...(ngDevMode ? [{ debugName: "picker" }] : /* istanbul ignore next */ []));
|
|
111
|
+
/**
|
|
112
|
+
* The calendar system to use (`gregorian` or `solar-hijri`).
|
|
113
|
+
* Falls back to the active locale profile calendar when not provided.
|
|
114
|
+
*/
|
|
115
|
+
this.calendar = input(null, /* @ts-ignore */
|
|
116
|
+
...(ngDevMode ? [{ debugName: "calendar" }] : /* istanbul ignore next */ []));
|
|
117
|
+
/**
|
|
118
|
+
* Optional format override (e.g. `yyyy/MM/dd HH:mm:ss`).
|
|
119
|
+
* When omitted, the short format of the active locale profile is used.
|
|
120
|
+
*/
|
|
121
|
+
this.format = input(null, /* @ts-ignore */
|
|
122
|
+
...(ngDevMode ? [{ debugName: "format" }] : /* istanbul ignore next */ []));
|
|
123
|
+
/**
|
|
124
|
+
* The minimum allowed date value. Applied when the editor loses focus.
|
|
125
|
+
*/
|
|
126
|
+
this.minValue = input(null, /* @ts-ignore */
|
|
127
|
+
...(ngDevMode ? [{ debugName: "minValue" }] : /* istanbul ignore next */ []));
|
|
128
|
+
/**
|
|
129
|
+
* The maximum allowed date value. Applied when the editor loses focus.
|
|
130
|
+
*/
|
|
131
|
+
this.maxValue = input(null, /* @ts-ignore */
|
|
132
|
+
...(ngDevMode ? [{ debugName: "maxValue" }] : /* istanbul ignore next */ []));
|
|
133
|
+
/**
|
|
134
|
+
* Emitted when a click event occurs on the editor input.
|
|
135
|
+
* @event
|
|
136
|
+
*/
|
|
137
|
+
this.onClick = output();
|
|
138
|
+
/** @ignore */
|
|
139
|
+
this.classNames = input('', { ...(ngDevMode ? { debugName: "classNames" } : /* istanbul ignore next */ {}), alias: 'class' });
|
|
140
|
+
this._calendarSystem = computed(() => this.calendar() ?? this.localeService.activeProfile().calendar.system, /* @ts-ignore */
|
|
141
|
+
...(ngDevMode ? [{ debugName: "_calendarSystem" }] : /* istanbul ignore next */ []));
|
|
142
|
+
this._resolvedFormat = computed(() => this.format() ?? this.localeService.activeProfile().formats[this.picker()]?.short ?? '', /* @ts-ignore */
|
|
143
|
+
...(ngDevMode ? [{ debugName: "_resolvedFormat" }] : /* istanbul ignore next */ []));
|
|
144
|
+
/** @ignore */
|
|
145
|
+
this._editingDate = linkedSignal(() => this.calendarService.now(this._calendarSystem()), /* @ts-ignore */
|
|
146
|
+
...(ngDevMode ? [{ debugName: "_editingDate" }] : /* istanbul ignore next */ []));
|
|
147
|
+
/** @ignore */
|
|
148
|
+
this.inputRef = viewChild('input', /* @ts-ignore */
|
|
149
|
+
...(ngDevMode ? [{ debugName: "inputRef" }] : /* istanbul ignore next */ []));
|
|
150
|
+
/**
|
|
151
|
+
* @description check if page is in rtl or ltr
|
|
152
|
+
*/
|
|
153
|
+
this.isRtl = signal(this.platformService.isRtl(), /* @ts-ignore */
|
|
154
|
+
...(ngDevMode ? [{ debugName: "isRtl" }] : /* istanbul ignore next */ []));
|
|
155
|
+
/** @ignore */
|
|
156
|
+
this.#formatEffect = effect(() => {
|
|
157
|
+
this._resolvedFormat();
|
|
158
|
+
this._calendarSystem();
|
|
159
|
+
this._detectParts();
|
|
160
|
+
untracked(() => {
|
|
161
|
+
this.internalValueChanged(this.value);
|
|
162
|
+
});
|
|
163
|
+
}, /* @ts-ignore */
|
|
164
|
+
...(ngDevMode ? [{ debugName: "#formatEffect" }] : /* istanbul ignore next */ []));
|
|
165
|
+
}
|
|
166
|
+
/** @ignore */
|
|
167
|
+
get inputElement() {
|
|
168
|
+
return this.inputRef()?.nativeElement;
|
|
169
|
+
}
|
|
170
|
+
/** @ignore */
|
|
171
|
+
#formatEffect;
|
|
172
|
+
/** @ignore */
|
|
173
|
+
ngOnInit() {
|
|
174
|
+
super.ngOnInit();
|
|
175
|
+
this.platformService.directionChange.pipe(map((i) => i.data === 'rtl')).subscribe((isRtl) => this.isRtl.set(isRtl));
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Formats a part using the calendar already attached to the AXDateTime.
|
|
179
|
+
* Avoids formatService's string-options path, which always uses the active locale calendar.
|
|
180
|
+
* @ignore
|
|
181
|
+
*/
|
|
182
|
+
_formatPart(date, placeholder) {
|
|
183
|
+
return date.format(placeholder);
|
|
184
|
+
}
|
|
185
|
+
/** @ignore */
|
|
186
|
+
_detectParts() {
|
|
187
|
+
Object.values(this._editingParts).forEach((e) => {
|
|
188
|
+
e.enabled = false;
|
|
189
|
+
});
|
|
190
|
+
const formatParts = this._resolvedFormat().split(/[^a-zA-Z]+/);
|
|
191
|
+
formatParts.forEach((f) => {
|
|
192
|
+
const found = Object.values(this._editingParts).find((c) => c.placeholders.some((d) => d == f));
|
|
193
|
+
if (found) {
|
|
194
|
+
found.enabled = true;
|
|
195
|
+
found.placeholder = f;
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
/** @ignore */
|
|
200
|
+
_getOrderedParts() {
|
|
201
|
+
const formatParts = this._resolvedFormat().split(/[^a-zA-Z]+/);
|
|
202
|
+
const result = [];
|
|
203
|
+
formatParts.forEach((f) => {
|
|
204
|
+
const found = Object.values(this._editingParts).find((c) => c.placeholders.some((d) => d == f));
|
|
205
|
+
if (found && found.enabled)
|
|
206
|
+
result.push(found);
|
|
207
|
+
});
|
|
208
|
+
return result;
|
|
209
|
+
}
|
|
210
|
+
/** @ignore */
|
|
211
|
+
_clearInputBuffer() {
|
|
212
|
+
this._inputChars = [];
|
|
213
|
+
}
|
|
214
|
+
/** @ignore */
|
|
215
|
+
_updateText() {
|
|
216
|
+
let text = this._resolvedFormat();
|
|
217
|
+
Object.values(this._editingParts).forEach((part) => {
|
|
218
|
+
if (this._activePart() == part.key) {
|
|
219
|
+
if (part.typedValue)
|
|
220
|
+
text = text.replace(part.placeholder, part.typedValue);
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
if (part.typedValue != part.placeholder && part.typedValue != null) {
|
|
224
|
+
text = text.replace(part.placeholder, part.realValue());
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
this._editingText.set(text == this._resolvedFormat() ? '' : text);
|
|
229
|
+
if (this._activePart()) {
|
|
230
|
+
this._highlightActivePart();
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Handles changes to the internal date value, updating editing parts and text representation.
|
|
235
|
+
* @ignore
|
|
236
|
+
*/
|
|
237
|
+
internalValueChanged(value) {
|
|
238
|
+
if (value && this.calendarService.isValidDate(value)) {
|
|
239
|
+
this._editingDate.set(this.calendarService.create(value, this._calendarSystem()));
|
|
240
|
+
}
|
|
241
|
+
Object.values(this._editingParts).forEach((part) => {
|
|
242
|
+
if (value) {
|
|
243
|
+
if (part.typedValue != part.placeholder)
|
|
244
|
+
part.typedValue = part.realValue();
|
|
245
|
+
}
|
|
246
|
+
else
|
|
247
|
+
part.typedValue = null;
|
|
248
|
+
});
|
|
249
|
+
this._updateText();
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Normalizes Persian (U+06F0-U+06F9) and Arabic-Indic (U+0660-U+0669) digits to ASCII.
|
|
253
|
+
* @ignore
|
|
254
|
+
*/
|
|
255
|
+
_normalizeDigit(key) {
|
|
256
|
+
if (!key || key.length !== 1)
|
|
257
|
+
return null;
|
|
258
|
+
const code = key.charCodeAt(0);
|
|
259
|
+
if (code >= 0x30 && code <= 0x39)
|
|
260
|
+
return key;
|
|
261
|
+
if (code >= 0x06f0 && code <= 0x06f9)
|
|
262
|
+
return String.fromCharCode(code - 0x06f0 + 0x30);
|
|
263
|
+
if (code >= 0x0660 && code <= 0x0669)
|
|
264
|
+
return String.fromCharCode(code - 0x0660 + 0x30);
|
|
265
|
+
return null;
|
|
266
|
+
}
|
|
267
|
+
/** @ignore */
|
|
268
|
+
_handleOnKeydownEvent(e) {
|
|
269
|
+
const ignore = () => {
|
|
270
|
+
if (e.key === 'Tab' || e.code === 'Space' || e.code === 'Enter') {
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
e.preventDefault();
|
|
274
|
+
e.stopPropagation();
|
|
275
|
+
};
|
|
276
|
+
const input = e.target;
|
|
277
|
+
const orderedParts = this._getOrderedParts();
|
|
278
|
+
const part = this._activePart() ? this._editingParts[this._activePart()] : orderedParts[0];
|
|
279
|
+
const nextPart = part ? orderedParts[orderedParts.indexOf(part) + 1] : null;
|
|
280
|
+
const prevPart = part ? orderedParts[orderedParts.indexOf(part) - 1] : null;
|
|
281
|
+
const goNext = () => {
|
|
282
|
+
this._clearInputBuffer();
|
|
283
|
+
if (nextPart) {
|
|
284
|
+
this._activePart.set(nextPart.key);
|
|
285
|
+
this._highlightActivePart();
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
const goPrev = () => {
|
|
289
|
+
this._clearInputBuffer();
|
|
290
|
+
if (prevPart) {
|
|
291
|
+
this._activePart.set(prevPart.key);
|
|
292
|
+
this._highlightActivePart();
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
const digit = this._normalizeDigit(e.key);
|
|
296
|
+
/*************** Handle Left and Right **************/
|
|
297
|
+
if (e.code === 'ArrowRight' || e.code === 'ArrowLeft') {
|
|
298
|
+
ignore();
|
|
299
|
+
if (!this._activePart()) {
|
|
300
|
+
this._activePart.set(part?.key ?? null);
|
|
301
|
+
this._highlightActivePart();
|
|
302
|
+
}
|
|
303
|
+
else {
|
|
304
|
+
e.code === 'ArrowRight' ? goNext() : goPrev();
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
else if ((e.code === 'ArrowUp' || e.code === 'ArrowDown') && !e.ctrlKey) {
|
|
308
|
+
/*************** Handle Up and Down **************/
|
|
309
|
+
ignore();
|
|
310
|
+
if (this.disabled || this.readonly || !part) {
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
const sign = e.code === 'ArrowUp' ? +1 : -1;
|
|
314
|
+
this._activePart.set(part.key);
|
|
315
|
+
this._clearInputBuffer();
|
|
316
|
+
const unit = part.key === 'AMPM' ? 'hour' : part.key;
|
|
317
|
+
const amount = part.key === 'AMPM' ? sign * 12 : sign;
|
|
318
|
+
const newVal = this._editingDate().add(unit, amount);
|
|
319
|
+
this._editingDate.set(newVal);
|
|
320
|
+
// mark every enabled part as edited, so the whole value gets displayed
|
|
321
|
+
this._getOrderedParts().forEach((p) => {
|
|
322
|
+
p.typedValue = p.realValue();
|
|
323
|
+
});
|
|
324
|
+
this._detectValueChanges();
|
|
325
|
+
}
|
|
326
|
+
else if (e.code == 'Backspace' || e.code == 'Delete') {
|
|
327
|
+
/*************** Handle Backspace / Delete **************/
|
|
328
|
+
if (this.disabled || this.readonly || !part) {
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
if (input.value) {
|
|
332
|
+
ignore();
|
|
333
|
+
this._clearInputBuffer();
|
|
334
|
+
this._activePart.set(part.key);
|
|
335
|
+
this._editingParts[part.key].typedValue = this._editingParts[part.key].placeholder;
|
|
336
|
+
this._updateText();
|
|
337
|
+
goPrev();
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
else if (e.code == 'Tab' || e.code == 'Space') {
|
|
341
|
+
/*************** Handle Tab and Space **************/
|
|
342
|
+
if (input.value) {
|
|
343
|
+
if (!e.shiftKey && nextPart) {
|
|
344
|
+
ignore();
|
|
345
|
+
goNext();
|
|
346
|
+
}
|
|
347
|
+
else if (e.shiftKey && prevPart) {
|
|
348
|
+
ignore();
|
|
349
|
+
goPrev();
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
else if (digit != null) {
|
|
354
|
+
/*************** Handle Digits **************/
|
|
355
|
+
ignore();
|
|
356
|
+
if (this.disabled || this.readonly || !part) {
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
this._activePart.set(part.key);
|
|
360
|
+
this._handleDigitInput(part, digit, goNext);
|
|
361
|
+
}
|
|
362
|
+
else if (part?.key === 'AMPM' && (e.key?.toLowerCase() === 'a' || e.key?.toLowerCase() === 'p')) {
|
|
363
|
+
/*************** Handle AM/PM letters **************/
|
|
364
|
+
ignore();
|
|
365
|
+
if (this.disabled || this.readonly) {
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
const hour = this._editingDate().hour;
|
|
369
|
+
const wantsPM = e.key.toLowerCase() === 'p';
|
|
370
|
+
if (wantsPM && hour < 12) {
|
|
371
|
+
this._applyEditingDate(this._editingDate().add('hour', 12));
|
|
372
|
+
}
|
|
373
|
+
else if (!wantsPM && hour >= 12) {
|
|
374
|
+
this._applyEditingDate(this._editingDate().add('hour', -12));
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
else {
|
|
378
|
+
ignore();
|
|
379
|
+
}
|
|
380
|
+
/*************** Emit Event **************/
|
|
381
|
+
super.emitOnKeydownEvent(e);
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Applies typed digits to the active part with calendar-aware limits, auto advancing
|
|
385
|
+
* to the next part when the segment is complete or unambiguous.
|
|
386
|
+
* @ignore
|
|
387
|
+
*/
|
|
388
|
+
_handleDigitInput(part, digit, goNext) {
|
|
389
|
+
let next = false;
|
|
390
|
+
const editing = this._editingParts[part.key];
|
|
391
|
+
switch (part.key) {
|
|
392
|
+
case 'year': {
|
|
393
|
+
if (editing.placeholder.length == 2 && this._inputChars.length == 0) {
|
|
394
|
+
// 2-digit year placeholder: prefill the current century of the active calendar
|
|
395
|
+
this._inputChars.push(...this._formatPart(this.calendarService.now(this._calendarSystem()), 'yyyy').substring(0, 2).split(''));
|
|
396
|
+
}
|
|
397
|
+
this._inputChars.push(digit);
|
|
398
|
+
editing.typedValue = ('0000' + this._inputChars.join('')).slice(-4);
|
|
399
|
+
if (this._inputChars.length >= 4) {
|
|
400
|
+
next = true;
|
|
401
|
+
}
|
|
402
|
+
const nv = parseInt(editing.typedValue);
|
|
403
|
+
if (nv > 0) {
|
|
404
|
+
this._applyEditingDate(this._editingDate().set('year', nv));
|
|
405
|
+
}
|
|
406
|
+
break;
|
|
407
|
+
}
|
|
408
|
+
case 'month': {
|
|
409
|
+
if (this._inputChars.length == 0) {
|
|
410
|
+
this._inputChars.push(digit);
|
|
411
|
+
editing.typedValue = `0${digit}`;
|
|
412
|
+
if (parseInt(digit) > 1) {
|
|
413
|
+
next = true;
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
else {
|
|
417
|
+
const combined = parseInt(`${this._inputChars[0]}${digit}`);
|
|
418
|
+
editing.typedValue = combined > 12 || combined < 1 ? `0${digit}` : `${combined}`.padStart(2, '0');
|
|
419
|
+
next = true;
|
|
420
|
+
}
|
|
421
|
+
const nv = parseInt(editing.typedValue);
|
|
422
|
+
if (nv > 0) {
|
|
423
|
+
this._applyEditingDate(this._editingDate().set('month', nv));
|
|
424
|
+
}
|
|
425
|
+
break;
|
|
426
|
+
}
|
|
427
|
+
case 'day': {
|
|
428
|
+
const totalDays = this._editingDate().month.totalDays;
|
|
429
|
+
if (this._inputChars.length == 0) {
|
|
430
|
+
this._inputChars.push(digit);
|
|
431
|
+
editing.typedValue = `0${digit}`;
|
|
432
|
+
if (parseInt(digit) > Math.floor(totalDays / 10)) {
|
|
433
|
+
next = true;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
else {
|
|
437
|
+
const combined = parseInt(`${this._inputChars[0]}${digit}`);
|
|
438
|
+
editing.typedValue = combined > totalDays || combined < 1 ? `0${digit}` : `${combined}`.padStart(2, '0');
|
|
439
|
+
next = true;
|
|
440
|
+
}
|
|
441
|
+
const nv = parseInt(editing.typedValue);
|
|
442
|
+
if (nv > 0) {
|
|
443
|
+
this._applyEditingDate(this._editingDate().set('day', nv));
|
|
444
|
+
}
|
|
445
|
+
break;
|
|
446
|
+
}
|
|
447
|
+
case 'hour': {
|
|
448
|
+
if (this._inputChars.length == 0) {
|
|
449
|
+
this._inputChars.push(digit);
|
|
450
|
+
editing.typedValue = `0${digit}`;
|
|
451
|
+
if (parseInt(digit) > 2) {
|
|
452
|
+
next = true;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
else {
|
|
456
|
+
const combined = parseInt(`${this._inputChars[0]}${digit}`);
|
|
457
|
+
editing.typedValue = combined > 23 ? `0${digit}` : `${combined}`.padStart(2, '0');
|
|
458
|
+
next = true;
|
|
459
|
+
}
|
|
460
|
+
this._applyEditingDate(this._editingDate().set('hour', parseInt(editing.typedValue)));
|
|
461
|
+
break;
|
|
462
|
+
}
|
|
463
|
+
case 'minute':
|
|
464
|
+
case 'second': {
|
|
465
|
+
if (this._inputChars.length == 0) {
|
|
466
|
+
this._inputChars.push(digit);
|
|
467
|
+
editing.typedValue = `0${digit}`;
|
|
468
|
+
if (parseInt(digit) > 5) {
|
|
469
|
+
next = true;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
else {
|
|
473
|
+
const combined = parseInt(`${this._inputChars[0]}${digit}`);
|
|
474
|
+
editing.typedValue = combined > 59 ? `0${digit}` : `${combined}`.padStart(2, '0');
|
|
475
|
+
next = true;
|
|
476
|
+
}
|
|
477
|
+
this._applyEditingDate(this._editingDate().set(part.key, parseInt(editing.typedValue)));
|
|
478
|
+
break;
|
|
479
|
+
}
|
|
480
|
+
default:
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
483
|
+
if (next) {
|
|
484
|
+
goNext();
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
/** @ignore */
|
|
488
|
+
_applyEditingDate(value) {
|
|
489
|
+
this._editingDate.set(value);
|
|
490
|
+
this._detectValueChanges();
|
|
491
|
+
}
|
|
492
|
+
/** @ignore */
|
|
493
|
+
_handleKeyUpEvent() {
|
|
494
|
+
if (this._activePart()) {
|
|
495
|
+
this._highlightActivePart();
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
/** @ignore */
|
|
499
|
+
_handleFocusEvent(e) {
|
|
500
|
+
super.emitOnFocusEvent(e);
|
|
501
|
+
}
|
|
502
|
+
/** @ignore */
|
|
503
|
+
_handleBlurEvent(e) {
|
|
504
|
+
this._activePart.set(null);
|
|
505
|
+
this._clearInputBuffer();
|
|
506
|
+
this._clampToRange();
|
|
507
|
+
super.emitOnBlurEvent(e);
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* Clamps the committed value into the [minValue, maxValue] range.
|
|
511
|
+
* @ignore
|
|
512
|
+
*/
|
|
513
|
+
_clampToRange() {
|
|
514
|
+
const value = this.value;
|
|
515
|
+
if (!value)
|
|
516
|
+
return;
|
|
517
|
+
const min = this.minValue();
|
|
518
|
+
const max = this.maxValue();
|
|
519
|
+
if (min && value.getTime() < min.getTime()) {
|
|
520
|
+
this.commitValue(new Date(min), true);
|
|
521
|
+
}
|
|
522
|
+
else if (max && value.getTime() > max.getTime()) {
|
|
523
|
+
this.commitValue(new Date(max), true);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
/** @ignore */
|
|
527
|
+
_handleOnInputClickEvent(e) {
|
|
528
|
+
setTimeout(() => {
|
|
529
|
+
this._detectPartAtPosition();
|
|
530
|
+
}, 0);
|
|
531
|
+
this.onClick.emit({
|
|
532
|
+
component: this,
|
|
533
|
+
htmlElement: this.getHostElement(),
|
|
534
|
+
nativeEvent: e,
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
/** @ignore */
|
|
538
|
+
_detectPartAtPosition() {
|
|
539
|
+
const input = this.inputElement;
|
|
540
|
+
if (!input || !input.value)
|
|
541
|
+
return;
|
|
542
|
+
const sStart = input.selectionEnd || 0;
|
|
543
|
+
const re = /[a-zA-Z0-9]+/gi;
|
|
544
|
+
const valueParts = Array.from(input.value.matchAll(re));
|
|
545
|
+
const orderedParts = this._getOrderedParts();
|
|
546
|
+
const index = valueParts.findIndex((c) => c.index <= sStart && c.index + c[0].length >= sStart);
|
|
547
|
+
if (index < 0 || !orderedParts[index])
|
|
548
|
+
return;
|
|
549
|
+
this._clearInputBuffer();
|
|
550
|
+
this._activePart.set(orderedParts[index].key);
|
|
551
|
+
this._highlightActivePart();
|
|
552
|
+
}
|
|
553
|
+
/** @ignore */
|
|
554
|
+
_highlightActivePart() {
|
|
555
|
+
const input = this.inputElement;
|
|
556
|
+
if (!input || !input.value || !this._activePart())
|
|
557
|
+
return;
|
|
558
|
+
const orderedParts = this._getOrderedParts();
|
|
559
|
+
const index = orderedParts.findIndex((c) => c.key == this._activePart());
|
|
560
|
+
const re = /[a-zA-Z0-9]+/gi;
|
|
561
|
+
const valueParts = Array.from(input.value.matchAll(re));
|
|
562
|
+
const { start, end } = getWordBoundsAtPosition(input.value, valueParts[index]?.index);
|
|
563
|
+
if (input && typeof input.setSelectionRange === 'function') {
|
|
564
|
+
input.setSelectionRange(start, end);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
/** @ignore */
|
|
568
|
+
_detectValueChanges() {
|
|
569
|
+
this.commitValue(this._editingDate().date, true);
|
|
570
|
+
}
|
|
571
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXDateTimeTextBoxComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
572
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.8", type: AXDateTimeTextBoxComponent, isStandalone: true, selector: "ax-datetime-text-box", inputs: { disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: false, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: false, isRequired: false, transformFunction: null }, tabIndex: { classPropertyName: "tabIndex", publicName: "tabIndex", isSignal: false, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: false, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: false, isRequired: false, transformFunction: null }, state: { classPropertyName: "state", publicName: "state", isSignal: false, isRequired: false, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: false, isRequired: false, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: false, isRequired: false, transformFunction: null }, look: { classPropertyName: "look", publicName: "look", isSignal: false, isRequired: false, transformFunction: null }, picker: { classPropertyName: "picker", publicName: "picker", isSignal: true, isRequired: false, transformFunction: null }, calendar: { classPropertyName: "calendar", publicName: "calendar", isSignal: true, isRequired: false, transformFunction: null }, format: { classPropertyName: "format", publicName: "format", isSignal: true, isRequired: false, transformFunction: null }, minValue: { classPropertyName: "minValue", publicName: "minValue", isSignal: true, isRequired: false, transformFunction: null }, maxValue: { classPropertyName: "maxValue", publicName: "maxValue", isSignal: true, isRequired: false, transformFunction: null }, classNames: { classPropertyName: "classNames", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { valueChange: "valueChange", stateChange: "stateChange", onValueChanged: "onValueChanged", onBlur: "onBlur", onFocus: "onFocus", readonlyChange: "readonlyChange", disabledChange: "disabledChange", onKeyDown: "onKeyDown", onKeyUp: "onKeyUp", onKeyPress: "onKeyPress", onClick: "onClick" }, host: { listeners: { "keydown": "_handleOnKeydownEvent($event)", "keyup": "_handleKeyUpEvent()" }, properties: { "attr.name": "name" } }, providers: [
|
|
573
|
+
{ provide: AXComponent, useExisting: AXDateTimeTextBoxComponent },
|
|
574
|
+
{ provide: AXFocusableComponent, useExisting: AXDateTimeTextBoxComponent },
|
|
575
|
+
{ provide: AXValuableComponent, useExisting: AXDateTimeTextBoxComponent },
|
|
576
|
+
{ provide: AXClearableComponent, useExisting: AXDateTimeTextBoxComponent },
|
|
577
|
+
{
|
|
578
|
+
provide: NG_VALUE_ACCESSOR,
|
|
579
|
+
useExisting: forwardRef(() => AXDateTimeTextBoxComponent),
|
|
580
|
+
multi: true,
|
|
581
|
+
},
|
|
582
|
+
], viewQueries: [{ propertyName: "inputRef", first: true, predicate: ["input"], descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0, template: "<div\n class=\"ax-editor-container ax-default {{ classNames() }} {{ look }}\"\n [class.ax-state-disabled]=\"disabled\"\n [class.ax-state-readonly]=\"readonly\"\n>\n <ng-content select=\"ax-prefix\"> </ng-content>\n <input\n #input\n [name]=\"name\"\n [id]=\"id\"\n class=\"ax-input\"\n type=\"text\"\n [dir]=\"isRtl() ? 'rtl' : 'ltr'\"\n autocomplete=\"off\"\n autocorrect=\"off\"\n autocapitalize=\"off\"\n spellcheck=\"false\"\n [attr.placeholder]=\"placeholder || _resolvedFormat()\"\n [class.ax-state-disabled]=\"disabled\"\n [class.ax-state-readonly]=\"readonly\"\n [disabled]=\"disabled\"\n [readonly]=\"true\"\n [tabindex]=\"tabIndex\"\n [ngModel]=\"_editingText()\"\n [style.text-align]=\"isRtl() ? 'end' : 'start'\"\n (mouseup)=\"_handleOnInputClickEvent($event)\"\n (focus)=\"_handleFocusEvent($event)\"\n (blur)=\"_handleBlurEvent($event)\"\n />\n @if (_editingText() && !disabled && !readonly) {\n <ng-content select=\"ax-clear-button\"></ng-content>\n }\n <ng-content select=\"ax-suffix\"> </ng-content>\n</div>\n<ng-content select=\"ax-validation-rule\"> </ng-content>\n<div class=\"ax-error-container\"></div>\n", styles: ["ax-datetime-text-box{width:100%}ax-datetime-text-box .ax-input{cursor:text}\n"], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
|
|
583
|
+
}
|
|
584
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXDateTimeTextBoxComponent, decorators: [{
|
|
585
|
+
type: Component,
|
|
586
|
+
args: [{ selector: 'ax-datetime-text-box', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, inputs: ['disabled', 'readonly', 'tabIndex', 'placeholder', 'value', 'state', 'name', 'id', 'look'], outputs: [
|
|
587
|
+
'valueChange',
|
|
588
|
+
'stateChange',
|
|
589
|
+
'onValueChanged',
|
|
590
|
+
'onBlur',
|
|
591
|
+
'onFocus',
|
|
592
|
+
'readonlyChange',
|
|
593
|
+
'disabledChange',
|
|
594
|
+
'onKeyDown',
|
|
595
|
+
'onKeyUp',
|
|
596
|
+
'onKeyPress',
|
|
597
|
+
], providers: [
|
|
598
|
+
{ provide: AXComponent, useExisting: AXDateTimeTextBoxComponent },
|
|
599
|
+
{ provide: AXFocusableComponent, useExisting: AXDateTimeTextBoxComponent },
|
|
600
|
+
{ provide: AXValuableComponent, useExisting: AXDateTimeTextBoxComponent },
|
|
601
|
+
{ provide: AXClearableComponent, useExisting: AXDateTimeTextBoxComponent },
|
|
602
|
+
{
|
|
603
|
+
provide: NG_VALUE_ACCESSOR,
|
|
604
|
+
useExisting: forwardRef(() => AXDateTimeTextBoxComponent),
|
|
605
|
+
multi: true,
|
|
606
|
+
},
|
|
607
|
+
], imports: [FormsModule], host: {
|
|
608
|
+
'(keydown)': '_handleOnKeydownEvent($event)',
|
|
609
|
+
'(keyup)': '_handleKeyUpEvent()',
|
|
610
|
+
'[attr.name]': 'name',
|
|
611
|
+
}, template: "<div\n class=\"ax-editor-container ax-default {{ classNames() }} {{ look }}\"\n [class.ax-state-disabled]=\"disabled\"\n [class.ax-state-readonly]=\"readonly\"\n>\n <ng-content select=\"ax-prefix\"> </ng-content>\n <input\n #input\n [name]=\"name\"\n [id]=\"id\"\n class=\"ax-input\"\n type=\"text\"\n [dir]=\"isRtl() ? 'rtl' : 'ltr'\"\n autocomplete=\"off\"\n autocorrect=\"off\"\n autocapitalize=\"off\"\n spellcheck=\"false\"\n [attr.placeholder]=\"placeholder || _resolvedFormat()\"\n [class.ax-state-disabled]=\"disabled\"\n [class.ax-state-readonly]=\"readonly\"\n [disabled]=\"disabled\"\n [readonly]=\"true\"\n [tabindex]=\"tabIndex\"\n [ngModel]=\"_editingText()\"\n [style.text-align]=\"isRtl() ? 'end' : 'start'\"\n (mouseup)=\"_handleOnInputClickEvent($event)\"\n (focus)=\"_handleFocusEvent($event)\"\n (blur)=\"_handleBlurEvent($event)\"\n />\n @if (_editingText() && !disabled && !readonly) {\n <ng-content select=\"ax-clear-button\"></ng-content>\n }\n <ng-content select=\"ax-suffix\"> </ng-content>\n</div>\n<ng-content select=\"ax-validation-rule\"> </ng-content>\n<div class=\"ax-error-container\"></div>\n", styles: ["ax-datetime-text-box{width:100%}ax-datetime-text-box .ax-input{cursor:text}\n"] }]
|
|
612
|
+
}], propDecorators: { picker: [{ type: i0.Input, args: [{ isSignal: true, alias: "picker", required: false }] }], calendar: [{ type: i0.Input, args: [{ isSignal: true, alias: "calendar", required: false }] }], format: [{ type: i0.Input, args: [{ isSignal: true, alias: "format", required: false }] }], minValue: [{ type: i0.Input, args: [{ isSignal: true, alias: "minValue", required: false }] }], maxValue: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxValue", required: false }] }], onClick: [{ type: i0.Output, args: ["onClick"] }], classNames: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], inputRef: [{ type: i0.ViewChild, args: ['input', { isSignal: true }] }] } });
|
|
613
|
+
|
|
614
|
+
class AXDateTimeTextBoxModule {
|
|
615
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXDateTimeTextBoxModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
616
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "22.0.8", ngImport: i0, type: AXDateTimeTextBoxModule, imports: [AXDateTimeTextBoxComponent], exports: [AXDateTimeTextBoxComponent] }); }
|
|
617
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXDateTimeTextBoxModule, imports: [AXDateTimeTextBoxComponent] }); }
|
|
618
|
+
}
|
|
619
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AXDateTimeTextBoxModule, decorators: [{
|
|
620
|
+
type: NgModule,
|
|
621
|
+
args: [{
|
|
622
|
+
imports: [AXDateTimeTextBoxComponent],
|
|
623
|
+
exports: [AXDateTimeTextBoxComponent],
|
|
624
|
+
}]
|
|
625
|
+
}] });
|
|
626
|
+
|
|
627
|
+
/**
|
|
628
|
+
* Generated bundle index. Do not edit.
|
|
629
|
+
*/
|
|
630
|
+
|
|
631
|
+
export { AXDateTimeTextBoxComponent, AXDateTimeTextBoxModule };
|
|
632
|
+
//# sourceMappingURL=acorex-components-datetime-text-box.mjs.map
|