@progress/kendo-dateinputs-common 0.1.0 → 0.2.0-dev.202301061353
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 +34 -3
- package/dist/cdn/js/kendo-dateinputs-common.js +1 -0
- package/dist/cdn/main.js +1 -1
- package/dist/es/common/constants.js +6 -0
- package/dist/es/common/dateobject.js +1159 -0
- package/dist/es/common/key.js +16 -0
- package/dist/es/common/keycode.js +16 -0
- package/dist/es/common/mask.js +8 -0
- package/dist/es/common/observable.js +32 -0
- package/dist/es/common/utils.js +128 -0
- package/dist/es/dateinput/dateinput.js +1011 -0
- package/dist/es/dateinput/interaction-mode.js +6 -0
- package/dist/es/dateinput/utils.js +93 -0
- package/dist/es/main.js +1 -1
- package/dist/es2015/common/constants.js +6 -0
- package/dist/es2015/common/dateobject.js +1137 -0
- package/dist/es2015/common/key.js +16 -0
- package/dist/es2015/common/keycode.js +16 -0
- package/dist/es2015/common/mask.js +6 -0
- package/dist/es2015/common/observable.js +29 -0
- package/dist/es2015/common/utils.js +117 -0
- package/dist/es2015/dateinput/dateinput.js +969 -0
- package/dist/es2015/dateinput/interaction-mode.js +6 -0
- package/dist/es2015/dateinput/utils.js +92 -0
- package/dist/es2015/main.js +1 -1
- package/dist/npm/common/constants.d.ts +6 -0
- package/dist/npm/common/constants.js +8 -0
- package/dist/npm/common/dateobject.d.ts +172 -0
- package/dist/npm/common/dateobject.js +1161 -0
- package/dist/npm/common/key.d.ts +16 -0
- package/dist/npm/common/key.js +18 -0
- package/dist/npm/common/keycode.d.ts +16 -0
- package/dist/npm/common/keycode.js +18 -0
- package/dist/npm/common/mask.d.ts +4 -0
- package/dist/npm/common/mask.js +10 -0
- package/dist/npm/common/observable.d.ts +9 -0
- package/dist/npm/common/observable.js +34 -0
- package/dist/npm/common/utils.d.ts +60 -0
- package/dist/npm/common/utils.js +130 -0
- package/dist/npm/dateinput/dateinput.d.ts +204 -0
- package/dist/npm/dateinput/dateinput.js +1013 -0
- package/dist/npm/dateinput/interaction-mode.d.ts +5 -0
- package/dist/npm/dateinput/interaction-mode.js +8 -0
- package/dist/npm/dateinput/utils.d.ts +27 -0
- package/dist/npm/dateinput/utils.js +95 -0
- package/dist/npm/main.d.ts +1 -1
- package/dist/npm/main.js +2 -2
- package/dist/systemjs/kendo-dateinputs-common.js +1 -0
- package/package.json +10 -8
- package/dist/cdn/js/kendo-typescript-package-base.js +0 -1
- package/dist/es/my-class.js +0 -15
- package/dist/es2015/my-class.js +0 -11
- package/dist/npm/my-class.d.ts +0 -9
- package/dist/npm/my-class.js +0 -17
- package/dist/systemjs/kendo-typescript-package-base.js +0 -1
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export var DateInputInteractionMode;
|
|
2
|
+
(function (DateInputInteractionMode) {
|
|
3
|
+
DateInputInteractionMode["None"] = "none";
|
|
4
|
+
DateInputInteractionMode["Caret"] = "caret";
|
|
5
|
+
DateInputInteractionMode["Selection"] = "selection";
|
|
6
|
+
})(DateInputInteractionMode || (DateInputInteractionMode = {}));
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { Constants } from '../common/constants';
|
|
2
|
+
import { Key } from '../common/key';
|
|
3
|
+
/**
|
|
4
|
+
* @hidden
|
|
5
|
+
*/
|
|
6
|
+
export const padZero = (length) => new Array(Math.max(length, 0)).fill('0').join('');
|
|
7
|
+
/**
|
|
8
|
+
* @hidden
|
|
9
|
+
*/
|
|
10
|
+
export const unpadZero = (value) => value.replace(/^0*/, '');
|
|
11
|
+
/**
|
|
12
|
+
* @hidden
|
|
13
|
+
*/
|
|
14
|
+
export const approximateStringMatching = ({ oldText, newText, formatPattern, selectionStart, isInCaretMode, keyEvent }) => {
|
|
15
|
+
/*
|
|
16
|
+
Remove the right part of the cursor.
|
|
17
|
+
oldFormat = oldFormat.substring(0, caret + oldText.length - newText.length);
|
|
18
|
+
*/
|
|
19
|
+
const oldTextSeparator = oldText[selectionStart + oldText.length - newText.length];
|
|
20
|
+
const oldSegmentText = oldText.substring(0, selectionStart + oldText.length - newText.length);
|
|
21
|
+
const newSegmentText = newText.substring(0, selectionStart);
|
|
22
|
+
const diff = [];
|
|
23
|
+
/* Handle the typing of a single character over the same selection. */
|
|
24
|
+
if (oldSegmentText === newSegmentText && selectionStart > 0) {
|
|
25
|
+
diff.push([formatPattern[selectionStart - 1], newSegmentText[selectionStart - 1]]);
|
|
26
|
+
return diff;
|
|
27
|
+
}
|
|
28
|
+
if (oldSegmentText.indexOf(newSegmentText) === 0 && (isInCaretMode &&
|
|
29
|
+
(keyEvent.key === Key.DELETE || keyEvent.key === Key.BACKSPACE)) ||
|
|
30
|
+
(oldSegmentText.indexOf(newSegmentText) === 0 && !isInCaretMode &&
|
|
31
|
+
(newSegmentText.length === 0 ||
|
|
32
|
+
formatPattern[newSegmentText.length - 1] !== formatPattern[newSegmentText.length]))) {
|
|
33
|
+
/* Handle Delete/Backspace. */
|
|
34
|
+
let deletedSymbol = '';
|
|
35
|
+
/*
|
|
36
|
+
The whole text is replaced by the same character.
|
|
37
|
+
A nasty patch is required to keep the selection in the first segment.
|
|
38
|
+
*/
|
|
39
|
+
if (!isInCaretMode && newSegmentText.length === 1) {
|
|
40
|
+
diff.push([formatPattern[0], newSegmentText[0]]);
|
|
41
|
+
}
|
|
42
|
+
for (let i = newSegmentText.length; i < oldSegmentText.length; i++) {
|
|
43
|
+
if (formatPattern[i] !== deletedSymbol && formatPattern[i] !== Constants.formatSeparator) {
|
|
44
|
+
deletedSymbol = formatPattern[i];
|
|
45
|
+
diff.push([deletedSymbol, '']);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return diff;
|
|
49
|
+
}
|
|
50
|
+
/*
|
|
51
|
+
Handle the insertion of the text (the new text is longer than the previous one).
|
|
52
|
+
Handle the typing over a literal as well.
|
|
53
|
+
*/
|
|
54
|
+
if ((isInCaretMode &&
|
|
55
|
+
newSegmentText.indexOf(oldSegmentText) === 0 && formatPattern[selectionStart - 1]) ||
|
|
56
|
+
(!isInCaretMode &&
|
|
57
|
+
(newSegmentText.indexOf(oldSegmentText) === 0 ||
|
|
58
|
+
formatPattern[selectionStart - 1] === Constants.formatSeparator))) {
|
|
59
|
+
if (isInCaretMode) {
|
|
60
|
+
let symbol = formatPattern[selectionStart - 1];
|
|
61
|
+
return [[symbol, newSegmentText[selectionStart - 1]]];
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
let symbol = formatPattern[0];
|
|
65
|
+
for (let i = Math.max(0, oldSegmentText.length - 1); i < formatPattern.length; i++) {
|
|
66
|
+
if (formatPattern[i] !== Constants.formatSeparator) {
|
|
67
|
+
symbol = formatPattern[i];
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return [[symbol, newSegmentText[selectionStart - 1]]];
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/* Handle the entering of a space or a separator for navigating to the next item. */
|
|
75
|
+
if (newSegmentText[newSegmentText.length - 1] === ' ' || newSegmentText[newSegmentText.length - 1] === oldTextSeparator) {
|
|
76
|
+
return [[formatPattern[selectionStart - 1], Constants.formatSeparator]];
|
|
77
|
+
}
|
|
78
|
+
/* Handle typing over a correctly selected part. */
|
|
79
|
+
const result = [[formatPattern[selectionStart - 1], newSegmentText[selectionStart - 1]]];
|
|
80
|
+
return result;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* @hidden
|
|
84
|
+
*/
|
|
85
|
+
export const dateSymbolMap = (map, part) => {
|
|
86
|
+
map[part.pattern[0]] = part.type;
|
|
87
|
+
return map;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* @hidden
|
|
91
|
+
*/
|
|
92
|
+
export const isInRange = (candidate, min, max) => (candidate === null || !((min && min > candidate) || (max && max < candidate)));
|
package/dist/es2015/main.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { DateInput } from './dateinput/dateinput';
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { Mask } from './mask';
|
|
2
|
+
export declare class DateObject {
|
|
3
|
+
year: boolean;
|
|
4
|
+
month: boolean;
|
|
5
|
+
date: boolean;
|
|
6
|
+
hours: boolean;
|
|
7
|
+
minutes: boolean;
|
|
8
|
+
seconds: boolean;
|
|
9
|
+
milliseconds: boolean;
|
|
10
|
+
formatPlaceholder: any;
|
|
11
|
+
format: string | any;
|
|
12
|
+
intl: any;
|
|
13
|
+
private leadingZero;
|
|
14
|
+
private monthNames;
|
|
15
|
+
private typedMonthPart;
|
|
16
|
+
private knownParts;
|
|
17
|
+
private symbols;
|
|
18
|
+
private _value;
|
|
19
|
+
value: Date;
|
|
20
|
+
private readonly localeId;
|
|
21
|
+
private cycleTime;
|
|
22
|
+
private dayPeriods;
|
|
23
|
+
private twoDigitYearMax;
|
|
24
|
+
private autoCorrectParts;
|
|
25
|
+
private _partiallyInvalidDate;
|
|
26
|
+
constructor({ intlService, formatPlaceholder, format, cycleTime, twoDigitYearMax, value, autoCorrectParts }: {
|
|
27
|
+
intlService: any;
|
|
28
|
+
formatPlaceholder: any;
|
|
29
|
+
format: any;
|
|
30
|
+
cycleTime?: boolean;
|
|
31
|
+
twoDigitYearMax?: number;
|
|
32
|
+
value?: any;
|
|
33
|
+
autoCorrectParts?: boolean;
|
|
34
|
+
});
|
|
35
|
+
setValue(value: any): void;
|
|
36
|
+
/**
|
|
37
|
+
* @hidden
|
|
38
|
+
*/
|
|
39
|
+
hasValue(): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* @hidden
|
|
42
|
+
*/
|
|
43
|
+
getValue(): Date;
|
|
44
|
+
/**
|
|
45
|
+
* @hidden
|
|
46
|
+
*/
|
|
47
|
+
getFormattedDate(format: any): string;
|
|
48
|
+
/**
|
|
49
|
+
* @hidden
|
|
50
|
+
*/
|
|
51
|
+
getTextAndFormat(customFormat?: string): any;
|
|
52
|
+
/**
|
|
53
|
+
* @hidden
|
|
54
|
+
*/
|
|
55
|
+
getFormattedInvalidDates(customFormat?: string): any;
|
|
56
|
+
modifyExisting(value: any): void;
|
|
57
|
+
/**
|
|
58
|
+
* @hidden
|
|
59
|
+
*/
|
|
60
|
+
getExisting(symbol: any): boolean;
|
|
61
|
+
setExisting(symbol: any, value: any): void;
|
|
62
|
+
modifyPart(symbol: any, offset: any): void;
|
|
63
|
+
/**
|
|
64
|
+
* @hidden
|
|
65
|
+
*/
|
|
66
|
+
parsePart({ symbol, currentChar, resetSegmentValue, cycleSegmentValue, rawTextValue, isDeleting }: {
|
|
67
|
+
symbol: any;
|
|
68
|
+
currentChar: any;
|
|
69
|
+
resetSegmentValue: any;
|
|
70
|
+
cycleSegmentValue: any;
|
|
71
|
+
rawTextValue: any;
|
|
72
|
+
isDeleting: any;
|
|
73
|
+
}): any;
|
|
74
|
+
/**
|
|
75
|
+
* @hidden
|
|
76
|
+
*/
|
|
77
|
+
symbolMap(symbol: any): any;
|
|
78
|
+
/**
|
|
79
|
+
* @hidden
|
|
80
|
+
*/
|
|
81
|
+
resetLeadingZero(): boolean;
|
|
82
|
+
setLeadingZero(leadingZero: any): void;
|
|
83
|
+
/**
|
|
84
|
+
* @hidden
|
|
85
|
+
*/
|
|
86
|
+
normalizeCentury(date: Date): Date;
|
|
87
|
+
incrementLeadingZero(symbol: any): void;
|
|
88
|
+
/**
|
|
89
|
+
* @hidden
|
|
90
|
+
*/
|
|
91
|
+
isAbbrMonth(parts: any, symbol: any): any;
|
|
92
|
+
/**
|
|
93
|
+
* @hidden
|
|
94
|
+
*/
|
|
95
|
+
partPattern(parts: any, symbol: any): any;
|
|
96
|
+
/**
|
|
97
|
+
* @hidden
|
|
98
|
+
*/
|
|
99
|
+
peek(value: any, pattern: any): string;
|
|
100
|
+
/**
|
|
101
|
+
* @hidden
|
|
102
|
+
*/
|
|
103
|
+
matchMonth(typedChar: any): string;
|
|
104
|
+
/**
|
|
105
|
+
* @hidden
|
|
106
|
+
*/
|
|
107
|
+
matchDayPeriod(typedChar: any, symbol: any): string;
|
|
108
|
+
/**
|
|
109
|
+
* @hidden
|
|
110
|
+
*/
|
|
111
|
+
allFormattedMonths(locale?: string): string[];
|
|
112
|
+
/**
|
|
113
|
+
* @hidden
|
|
114
|
+
*/
|
|
115
|
+
allDayPeriods(locale?: string): string[];
|
|
116
|
+
/**
|
|
117
|
+
* @hidden
|
|
118
|
+
*/
|
|
119
|
+
patternLength(pattern: string): number;
|
|
120
|
+
/**
|
|
121
|
+
* @hidden
|
|
122
|
+
*/
|
|
123
|
+
dateFormatString(date: any, format: any): Mask;
|
|
124
|
+
/**
|
|
125
|
+
* @hidden
|
|
126
|
+
*/
|
|
127
|
+
merge(text: any, mask: any): {
|
|
128
|
+
text: string;
|
|
129
|
+
format: string;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* @hidden
|
|
133
|
+
*/
|
|
134
|
+
dateFieldName(part: any): string;
|
|
135
|
+
/**
|
|
136
|
+
* @hidden
|
|
137
|
+
*/
|
|
138
|
+
getNormalizedCenturyBase(twoDigitYear: number): number;
|
|
139
|
+
/**
|
|
140
|
+
* @hidden
|
|
141
|
+
*/
|
|
142
|
+
shouldNormalizeCentury(): boolean;
|
|
143
|
+
resetInvalidDate(): void;
|
|
144
|
+
resetInvalidDateSymbol(symbol: any): void;
|
|
145
|
+
resetInvalidDatePart(symbol: any): void;
|
|
146
|
+
/**
|
|
147
|
+
* @hidden
|
|
148
|
+
*/
|
|
149
|
+
getInvalidDatePart(symbol: any): any;
|
|
150
|
+
/**
|
|
151
|
+
* @hidden
|
|
152
|
+
*/
|
|
153
|
+
getInvalidDatePartValue(symbol: any): any;
|
|
154
|
+
setInvalidDatePart(symbol: any, { value, date, startDateOffset, startDate }: {
|
|
155
|
+
value?: any;
|
|
156
|
+
date?: any;
|
|
157
|
+
startDateOffset?: number;
|
|
158
|
+
startDate?: any;
|
|
159
|
+
}): void;
|
|
160
|
+
/**
|
|
161
|
+
* @hidden
|
|
162
|
+
*/
|
|
163
|
+
modifyDateSymbolWithOffset(date: any, symbol: any, offset: any): {
|
|
164
|
+
date: Date;
|
|
165
|
+
timeModified: boolean;
|
|
166
|
+
};
|
|
167
|
+
/**
|
|
168
|
+
* @hidden
|
|
169
|
+
*/
|
|
170
|
+
modifyDateSymbolWithValue(date: any, symbol: any, value: any): Date;
|
|
171
|
+
markDatePartsAsExisting(): void;
|
|
172
|
+
}
|