PluginProbe
Booking Calendar / 11.9
Booking Calendar v11.9
11.9 11.8.4 11.8.3 11.8.2 11.8.1 11.8 11.7 11.6.1 11.6 11.5 11.4.3 11.4.2 11.4.1 11.4 11.3 11.2.1 11.2 11.1 11.0 10.15.7 10.15.6 10.1.3 10.10 10.10.1 10.10.2 All 205 releases
booking / vendors / imask / esm / core / change-details.js

change-details.js in Booking Calendar 11.9, at vendors/imask/esm/core/change-details.js

48 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import IMask from './holder.js';
2
3 /** Provides details of changing model value */
4 class ChangeDetails {
5 /** Inserted symbols */
6
7 /** Additional offset if any changes occurred before tail */
8
9 /** Raw inserted is used by dynamic mask */
10
11 /** Can skip chars */
12
13 static normalize(prep) {
14 return Array.isArray(prep) ? prep : [prep, new ChangeDetails()];
15 }
16 constructor(details) {
17 Object.assign(this, {
18 inserted: '',
19 rawInserted: '',
20 tailShift: 0,
21 skip: false
22 }, details);
23 }
24
25 /** Aggregate changes */
26 aggregate(details) {
27 this.inserted += details.inserted;
28 this.rawInserted += details.rawInserted;
29 this.tailShift += details.tailShift;
30 this.skip = this.skip || details.skip;
31 return this;
32 }
33
34 /** Total offset considering all changes */
35 get offset() {
36 return this.tailShift + this.inserted.length;
37 }
38 get consumed() {
39 return Boolean(this.rawInserted) || this.skip;
40 }
41 equals(details) {
42 return this.inserted === details.inserted && this.tailShift === details.tailShift && this.rawInserted === details.rawInserted && this.skip === details.skip;
43 }
44 }
45 IMask.ChangeDetails = ChangeDetails;
46
47 export { ChangeDetails as default };
48