@skbkontur/react-ui 6.1.5 → 6.1.6-084cd.0

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.
Files changed (185) hide show
  1. package/components/FxInput/FxInput.d.ts +1 -1
  2. package/components/FxInput/FxInput.js.map +1 -1
  3. package/components/MaskedInput/MaskedInput.d.ts +6 -2
  4. package/components/MaskedInput/MaskedInput.js +10 -126
  5. package/components/MaskedInput/MaskedInput.js.map +1 -1
  6. package/components/MaskedInput/MaskedInputLegacy.d.ts +3 -0
  7. package/components/MaskedInput/MaskedInputLegacy.js +142 -0
  8. package/components/MaskedInput/MaskedInputLegacy.js.map +1 -0
  9. package/components/MaskedInput/index.d.ts +1 -0
  10. package/components/MaskedInput/index.js +1 -0
  11. package/components/MaskedInput/index.js.map +1 -1
  12. package/components/MaskedInputV2/MaskedInputV2.d.ts +62 -0
  13. package/components/MaskedInputV2/MaskedInputV2.helpers.d.ts +9 -0
  14. package/components/MaskedInputV2/MaskedInputV2.helpers.js +17 -0
  15. package/components/MaskedInputV2/MaskedInputV2.helpers.js.map +1 -0
  16. package/components/MaskedInputV2/MaskedInputV2.js +307 -0
  17. package/components/MaskedInputV2/MaskedInputV2.js.map +1 -0
  18. package/components/MaskedInputV2/MaskedInputV2.phone.d.ts +27 -0
  19. package/components/MaskedInputV2/MaskedInputV2.phone.js +37 -0
  20. package/components/MaskedInputV2/MaskedInputV2.phone.js.map +1 -0
  21. package/components/MaskedInputV2/MaskedInputV2.styles.d.ts +7 -0
  22. package/components/MaskedInputV2/MaskedInputV2.styles.js +19 -0
  23. package/components/MaskedInputV2/MaskedInputV2.styles.js.map +1 -0
  24. package/components/MaskedInputV2/index.d.ts +2 -0
  25. package/components/MaskedInputV2/index.js +3 -0
  26. package/components/MaskedInputV2/index.js.map +1 -0
  27. package/components/MaskedInputV2/internal/MaskOverlay.d.ts +19 -0
  28. package/components/MaskedInputV2/internal/MaskOverlay.js +54 -0
  29. package/components/MaskedInputV2/internal/MaskOverlay.js.map +1 -0
  30. package/components/MaskedInputV2/internal/MaskedCore.d.ts +8 -0
  31. package/components/MaskedInputV2/internal/MaskedCore.js +186 -0
  32. package/components/MaskedInputV2/internal/MaskedCore.js.map +1 -0
  33. package/components/MaskedInputV2/internal/MaskedCore.types.d.ts +37 -0
  34. package/components/MaskedInputV2/internal/MaskedCore.types.js +2 -0
  35. package/components/MaskedInputV2/internal/MaskedCore.types.js.map +1 -0
  36. package/components/MaskedInputV2/internal/MaskedInternal.styles.d.ts +15 -0
  37. package/components/MaskedInputV2/internal/MaskedInternal.styles.js +34 -0
  38. package/components/MaskedInputV2/internal/MaskedInternal.styles.js.map +1 -0
  39. package/components/MaskedInputV2/internal/buildSlotMap.d.ts +11 -0
  40. package/components/MaskedInputV2/internal/buildSlotMap.js +37 -0
  41. package/components/MaskedInputV2/internal/buildSlotMap.js.map +1 -0
  42. package/components/MaskedInputV2/internal/computeMaskAlignPadding.d.ts +6 -0
  43. package/components/MaskedInputV2/internal/computeMaskAlignPadding.js +47 -0
  44. package/components/MaskedInputV2/internal/computeMaskAlignPadding.js.map +1 -0
  45. package/components/MaskedInputV2/internal/computePasteMaskedCursor.d.ts +3 -0
  46. package/components/MaskedInputV2/internal/computePasteMaskedCursor.js +11 -0
  47. package/components/MaskedInputV2/internal/computePasteMaskedCursor.js.map +1 -0
  48. package/components/MaskedInputV2/internal/extractRaw.d.ts +10 -0
  49. package/components/MaskedInputV2/internal/extractRaw.js +16 -0
  50. package/components/MaskedInputV2/internal/extractRaw.js.map +1 -0
  51. package/components/MaskedInputV2/internal/findNearestRawLeft.d.ts +10 -0
  52. package/components/MaskedInputV2/internal/findNearestRawLeft.js +18 -0
  53. package/components/MaskedInputV2/internal/findNearestRawLeft.js.map +1 -0
  54. package/components/MaskedInputV2/internal/helpers.d.ts +8 -0
  55. package/components/MaskedInputV2/internal/helpers.js +9 -0
  56. package/components/MaskedInputV2/internal/helpers.js.map +1 -0
  57. package/components/MaskedInputV2/internal/maskedCoreClipboard.d.ts +37 -0
  58. package/components/MaskedInputV2/internal/maskedCoreClipboard.js +52 -0
  59. package/components/MaskedInputV2/internal/maskedCoreClipboard.js.map +1 -0
  60. package/components/MaskedInputV2/internal/maskedCoreDeletion.d.ts +28 -0
  61. package/components/MaskedInputV2/internal/maskedCoreDeletion.js +70 -0
  62. package/components/MaskedInputV2/internal/maskedCoreDeletion.js.map +1 -0
  63. package/components/MaskedInputV2/internal/maskedCoreInputChange.d.ts +38 -0
  64. package/components/MaskedInputV2/internal/maskedCoreInputChange.js +49 -0
  65. package/components/MaskedInputV2/internal/maskedCoreInputChange.js.map +1 -0
  66. package/components/MaskedInputV2/internal/maskedCoreNavigation.d.ts +13 -0
  67. package/components/MaskedInputV2/internal/maskedCoreNavigation.js +79 -0
  68. package/components/MaskedInputV2/internal/maskedCoreNavigation.js.map +1 -0
  69. package/components/MaskedInputV2/internal/measureInputTextWidth.d.ts +2 -0
  70. package/components/MaskedInputV2/internal/measureInputTextWidth.js +30 -0
  71. package/components/MaskedInputV2/internal/measureInputTextWidth.js.map +1 -0
  72. package/components/MaskedInputV2/internal/setMaskInputSelectionRange.d.ts +2 -0
  73. package/components/MaskedInputV2/internal/setMaskInputSelectionRange.js +25 -0
  74. package/components/MaskedInputV2/internal/setMaskInputSelectionRange.js.map +1 -0
  75. package/components/MaskedInputV2/internal/showOverlay.d.ts +3 -0
  76. package/components/MaskedInputV2/internal/showOverlay.js +16 -0
  77. package/components/MaskedInputV2/internal/showOverlay.js.map +1 -0
  78. package/components/MaskedInputV2/internal/stripMaskChars.d.ts +11 -0
  79. package/components/MaskedInputV2/internal/stripMaskChars.js +20 -0
  80. package/components/MaskedInputV2/internal/stripMaskChars.js.map +1 -0
  81. package/components/MaskedInputV2/internal/types.d.ts +74 -0
  82. package/components/MaskedInputV2/internal/types.js +2 -0
  83. package/components/MaskedInputV2/internal/types.js.map +1 -0
  84. package/components/MaskedInputV2/internal/useInputOverflow.d.ts +4 -0
  85. package/components/MaskedInputV2/internal/useInputOverflow.js +34 -0
  86. package/components/MaskedInputV2/internal/useInputOverflow.js.map +1 -0
  87. package/components/MaskedInputV2/internal/useMaskAlignPadding.d.ts +2 -0
  88. package/components/MaskedInputV2/internal/useMaskAlignPadding.js +33 -0
  89. package/components/MaskedInputV2/internal/useMaskAlignPadding.js.map +1 -0
  90. package/components/MaskedInputV2/internal/useMaskEngine.d.ts +42 -0
  91. package/components/MaskedInputV2/internal/useMaskEngine.js +84 -0
  92. package/components/MaskedInputV2/internal/useMaskEngine.js.map +1 -0
  93. package/components/MaskedInputV2/internal/useMaskedCoreHandlers.d.ts +34 -0
  94. package/components/MaskedInputV2/internal/useMaskedCoreHandlers.js +311 -0
  95. package/components/MaskedInputV2/internal/useMaskedCoreHandlers.js.map +1 -0
  96. package/components/MaskedInputV2/react-imask/imask/controls/html-input-mask-element.d.ts +16 -0
  97. package/components/MaskedInputV2/react-imask/imask/controls/html-input-mask-element.js +59 -0
  98. package/components/MaskedInputV2/react-imask/imask/controls/html-input-mask-element.js.map +1 -0
  99. package/components/MaskedInputV2/react-imask/imask/controls/html-mask-element.d.ts +20 -0
  100. package/components/MaskedInputV2/react-imask/imask/controls/html-mask-element.js +106 -0
  101. package/components/MaskedInputV2/react-imask/imask/controls/html-mask-element.js.map +1 -0
  102. package/components/MaskedInputV2/react-imask/imask/controls/input-history.d.ts +17 -0
  103. package/components/MaskedInputV2/react-imask/imask/controls/input-history.js +49 -0
  104. package/components/MaskedInputV2/react-imask/imask/controls/input-history.js.map +1 -0
  105. package/components/MaskedInputV2/react-imask/imask/controls/input.d.ts +95 -0
  106. package/components/MaskedInputV2/react-imask/imask/controls/input.js +420 -0
  107. package/components/MaskedInputV2/react-imask/imask/controls/input.js.map +1 -0
  108. package/components/MaskedInputV2/react-imask/imask/controls/mask-element.d.ts +30 -0
  109. package/components/MaskedInputV2/react-imask/imask/controls/mask-element.js +59 -0
  110. package/components/MaskedInputV2/react-imask/imask/controls/mask-element.js.map +1 -0
  111. package/components/MaskedInputV2/react-imask/imask/core/action-details.d.ts +30 -0
  112. package/components/MaskedInputV2/react-imask/imask/core/action-details.js +100 -0
  113. package/components/MaskedInputV2/react-imask/imask/core/action-details.js.map +1 -0
  114. package/components/MaskedInputV2/react-imask/imask/core/change-details.d.ts +20 -0
  115. package/components/MaskedInputV2/react-imask/imask/core/change-details.js +46 -0
  116. package/components/MaskedInputV2/react-imask/imask/core/change-details.js.map +1 -0
  117. package/components/MaskedInputV2/react-imask/imask/core/continuous-tail-details.d.ts +21 -0
  118. package/components/MaskedInputV2/react-imask/imask/core/continuous-tail-details.js +52 -0
  119. package/components/MaskedInputV2/react-imask/imask/core/continuous-tail-details.js.map +1 -0
  120. package/components/MaskedInputV2/react-imask/imask/core/holder.d.ts +34 -0
  121. package/components/MaskedInputV2/react-imask/imask/core/holder.js +38 -0
  122. package/components/MaskedInputV2/react-imask/imask/core/holder.js.map +1 -0
  123. package/components/MaskedInputV2/react-imask/imask/core/tail-details.d.ts +20 -0
  124. package/components/MaskedInputV2/react-imask/imask/core/tail-details.js +2 -0
  125. package/components/MaskedInputV2/react-imask/imask/core/tail-details.js.map +1 -0
  126. package/components/MaskedInputV2/react-imask/imask/core/utils.d.ts +24 -0
  127. package/components/MaskedInputV2/react-imask/imask/core/utils.js +100 -0
  128. package/components/MaskedInputV2/react-imask/imask/core/utils.js.map +1 -0
  129. package/components/MaskedInputV2/react-imask/imask/imask.d.ts +5 -0
  130. package/components/MaskedInputV2/react-imask/imask/imask.js +7 -0
  131. package/components/MaskedInputV2/react-imask/imask/imask.js.map +1 -0
  132. package/components/MaskedInputV2/react-imask/imask/index.d.ts +17 -0
  133. package/components/MaskedInputV2/react-imask/imask/index.js +16 -0
  134. package/components/MaskedInputV2/react-imask/imask/index.js.map +1 -0
  135. package/components/MaskedInputV2/react-imask/imask/masked/base.d.ts +114 -0
  136. package/components/MaskedInputV2/react-imask/imask/masked/base.js +411 -0
  137. package/components/MaskedInputV2/react-imask/imask/masked/base.js.map +1 -0
  138. package/components/MaskedInputV2/react-imask/imask/masked/create.d.ts +14 -0
  139. package/components/MaskedInputV2/react-imask/imask/masked/create.js +11 -0
  140. package/components/MaskedInputV2/react-imask/imask/masked/create.js.map +1 -0
  141. package/components/MaskedInputV2/react-imask/imask/masked/factory.d.ts +62 -0
  142. package/components/MaskedInputV2/react-imask/imask/masked/factory.js +107 -0
  143. package/components/MaskedInputV2/react-imask/imask/masked/factory.js.map +1 -0
  144. package/components/MaskedInputV2/react-imask/imask/masked/pattern.d.ts +101 -0
  145. package/components/MaskedInputV2/react-imask/imask/masked/pattern.js +549 -0
  146. package/components/MaskedInputV2/react-imask/imask/masked/pattern.js.map +1 -0
  147. package/components/MaskedInputV2/react-imask/imask/masked/patterns/block.d.ts +30 -0
  148. package/components/MaskedInputV2/react-imask/imask/masked/patterns/block.js +2 -0
  149. package/components/MaskedInputV2/react-imask/imask/masked/patterns/block.js.map +1 -0
  150. package/components/MaskedInputV2/react-imask/imask/masked/patterns/chunk-tail-details.d.ts +20 -0
  151. package/components/MaskedInputV2/react-imask/imask/masked/patterns/chunk-tail-details.js +182 -0
  152. package/components/MaskedInputV2/react-imask/imask/masked/patterns/chunk-tail-details.js.map +1 -0
  153. package/components/MaskedInputV2/react-imask/imask/masked/patterns/cursor.d.ts +31 -0
  154. package/components/MaskedInputV2/react-imask/imask/masked/patterns/cursor.js +163 -0
  155. package/components/MaskedInputV2/react-imask/imask/masked/patterns/cursor.js.map +1 -0
  156. package/components/MaskedInputV2/react-imask/imask/masked/patterns/fixed-definition.d.ts +42 -0
  157. package/components/MaskedInputV2/react-imask/imask/masked/patterns/fixed-definition.js +158 -0
  158. package/components/MaskedInputV2/react-imask/imask/masked/patterns/fixed-definition.js.map +1 -0
  159. package/components/MaskedInputV2/react-imask/imask/masked/patterns/input-definition.d.ts +56 -0
  160. package/components/MaskedInputV2/react-imask/imask/masked/patterns/input-definition.js +185 -0
  161. package/components/MaskedInputV2/react-imask/imask/masked/patterns/input-definition.js.map +1 -0
  162. package/components/MaskedInputV2/react-imask/imask/masked/regexp.d.ts +17 -0
  163. package/components/MaskedInputV2/react-imask/imask/masked/regexp.js +36 -0
  164. package/components/MaskedInputV2/react-imask/imask/masked/regexp.js.map +1 -0
  165. package/components/MaskedInputV2/react-imask/index.d.ts +3 -0
  166. package/components/MaskedInputV2/react-imask/index.js +4 -0
  167. package/components/MaskedInputV2/react-imask/index.js.map +1 -0
  168. package/components/MaskedInputV2/react-imask/input.d.ts +8 -0
  169. package/components/MaskedInputV2/react-imask/input.js +35 -0
  170. package/components/MaskedInputV2/react-imask/input.js.map +1 -0
  171. package/components/MaskedInputV2/react-imask/mixin.d.ts +31 -0
  172. package/components/MaskedInputV2/react-imask/mixin.js +246 -0
  173. package/components/MaskedInputV2/react-imask/mixin.js.map +1 -0
  174. package/lib/events/keyboard/KeyboardEventCodes.d.ts +2 -0
  175. package/lib/events/keyboard/KeyboardEventCodes.js +2 -0
  176. package/lib/events/keyboard/KeyboardEventCodes.js.map +1 -1
  177. package/lib/events/keyboard/KeyboardMapKeys.js +2 -0
  178. package/lib/events/keyboard/KeyboardMapKeys.js.map +1 -1
  179. package/lib/events/keyboard/identifiers.d.ts +2 -0
  180. package/lib/events/keyboard/identifiers.js +6 -0
  181. package/lib/events/keyboard/identifiers.js.map +1 -1
  182. package/lib/featureFlagsContext/ReactUIFeatureFlagsContext.d.ts +1 -0
  183. package/lib/featureFlagsContext/ReactUIFeatureFlagsContext.js +1 -0
  184. package/lib/featureFlagsContext/ReactUIFeatureFlagsContext.js.map +1 -1
  185. package/package.json +4 -1
@@ -0,0 +1,20 @@
1
+ import { ChangeDetails } from '../../core/change-details.js';
2
+ import type { TailDetails, AppendTail } from '../../core/tail-details.js';
3
+ export type ChunksTailState = Pick<ChunksTailDetails, 'from' | 'stop' | 'blockIndex'> & {
4
+ chunks: Array<TailDetails['state']>;
5
+ };
6
+ export declare class ChunksTailDetails implements TailDetails {
7
+ chunks: TailDetails[];
8
+ from: number;
9
+ stop?: number;
10
+ /** */
11
+ blockIndex?: number;
12
+ constructor(chunks?: TailDetails[], from?: number);
13
+ toString(): string;
14
+ extend(tailChunk: string | TailDetails): void;
15
+ appendTo(masked: AppendTail): ChangeDetails;
16
+ get state(): ChunksTailState;
17
+ set state(state: ChunksTailState);
18
+ unshift(beforePos?: number): string;
19
+ shift(): string;
20
+ }
@@ -0,0 +1,182 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { ChangeDetails } from '../../core/change-details.js';
13
+ import { ContinuousTailDetails } from '../../core/continuous-tail-details.js';
14
+ import { isString } from '../../core/utils.js';
15
+ function isPatternTailTarget(masked) {
16
+ return typeof masked._mapPosToBlock === 'function';
17
+ }
18
+ var ChunksTailDetails = /** @class */ (function () {
19
+ function ChunksTailDetails(chunks, from) {
20
+ if (chunks === void 0) { chunks = []; }
21
+ if (from === void 0) { from = 0; }
22
+ this.chunks = chunks;
23
+ this.from = from;
24
+ }
25
+ ChunksTailDetails.prototype.toString = function () {
26
+ return this.chunks.map(String).join('');
27
+ };
28
+ ChunksTailDetails.prototype.extend = function (tailChunk) {
29
+ if (!String(tailChunk)) {
30
+ return;
31
+ }
32
+ // eslint-disable-next-line no-param-reassign
33
+ tailChunk = (isString(tailChunk) ? new ContinuousTailDetails(String(tailChunk)) : tailChunk);
34
+ var lastChunk = this.chunks[this.chunks.length - 1];
35
+ var extendLast = lastChunk &&
36
+ // if stops are same or tail has no stop
37
+ (lastChunk.stop === tailChunk.stop || tailChunk.stop == null) &&
38
+ // if tail chunk goes just after last chunk
39
+ tailChunk.from === lastChunk.from + lastChunk.toString().length;
40
+ if (tailChunk instanceof ContinuousTailDetails) {
41
+ // check the ability to extend previous chunk
42
+ if (extendLast) {
43
+ // extend previous chunk
44
+ lastChunk.extend(tailChunk.toString());
45
+ }
46
+ else {
47
+ // append new chunk
48
+ this.chunks.push(tailChunk);
49
+ }
50
+ }
51
+ else if (tailChunk instanceof ChunksTailDetails) {
52
+ if (tailChunk.stop == null) {
53
+ // unwrap floating chunks to parent, keeping `from` pos
54
+ var firstTailChunk = void 0;
55
+ while (tailChunk.chunks.length && tailChunk.chunks[0].stop == null) {
56
+ firstTailChunk = tailChunk.chunks.shift(); // not possible to be `undefined` because length was checked above
57
+ firstTailChunk.from += tailChunk.from;
58
+ this.extend(firstTailChunk);
59
+ }
60
+ }
61
+ // if tail chunk still has value
62
+ if (tailChunk.toString()) {
63
+ // if chunks contains stops, then popup stop to container
64
+ tailChunk.stop = tailChunk.blockIndex;
65
+ this.chunks.push(tailChunk);
66
+ }
67
+ }
68
+ };
69
+ ChunksTailDetails.prototype.appendTo = function (masked) {
70
+ if (!isPatternTailTarget(masked)) {
71
+ var tail = new ContinuousTailDetails(this.toString());
72
+ return tail.appendTo(masked);
73
+ }
74
+ var details = new ChangeDetails();
75
+ for (var ci = 0; ci < this.chunks.length; ++ci) {
76
+ var chunk = this.chunks[ci];
77
+ var lastBlockIter = masked._mapPosToBlock(masked.displayValue.length);
78
+ var stop_1 = chunk.stop;
79
+ var chunkBlock = void 0;
80
+ if (stop_1 != null &&
81
+ // if block not found or stop is behind lastBlock
82
+ (!lastBlockIter || lastBlockIter.index <= stop_1)) {
83
+ if (chunk instanceof ChunksTailDetails ||
84
+ // for continuous block also check if stop is exist
85
+ masked._stops.indexOf(stop_1) >= 0) {
86
+ details.aggregate(masked._appendPlaceholder(stop_1));
87
+ }
88
+ chunkBlock = chunk instanceof ChunksTailDetails && masked._blocks[stop_1];
89
+ }
90
+ if (chunkBlock) {
91
+ var tailDetails = chunkBlock.appendTail(chunk);
92
+ details.aggregate(tailDetails);
93
+ // get not inserted chars
94
+ var remainChars = chunk.toString().slice(tailDetails.rawInserted.length);
95
+ if (remainChars) {
96
+ details.aggregate(masked.append(remainChars, { tail: true }));
97
+ }
98
+ }
99
+ else {
100
+ details.aggregate(masked.append(chunk.toString(), { tail: true }));
101
+ }
102
+ }
103
+ return details;
104
+ };
105
+ Object.defineProperty(ChunksTailDetails.prototype, "state", {
106
+ get: function () {
107
+ return {
108
+ chunks: this.chunks.map(function (c) { return c.state; }),
109
+ from: this.from,
110
+ stop: this.stop,
111
+ blockIndex: this.blockIndex,
112
+ };
113
+ },
114
+ set: function (state) {
115
+ var chunks = state.chunks, props = __rest(state, ["chunks"]);
116
+ Object.assign(this, props);
117
+ this.chunks = chunks.map(function (cstate) {
118
+ var chunk = 'chunks' in cstate ? new ChunksTailDetails() : new ContinuousTailDetails();
119
+ chunk.state = cstate;
120
+ return chunk;
121
+ });
122
+ },
123
+ enumerable: false,
124
+ configurable: true
125
+ });
126
+ ChunksTailDetails.prototype.unshift = function (beforePos) {
127
+ if (!this.chunks.length || (beforePos != null && this.from >= beforePos)) {
128
+ return '';
129
+ }
130
+ var chunkShiftPos = beforePos != null ? beforePos - this.from : beforePos;
131
+ var ci = 0;
132
+ while (ci < this.chunks.length) {
133
+ var chunk = this.chunks[ci];
134
+ var shiftChar = chunk.unshift(chunkShiftPos);
135
+ if (chunk.toString()) {
136
+ // chunk still contains value
137
+ // but not shifted - means no more available chars to shift
138
+ if (!shiftChar) {
139
+ break;
140
+ }
141
+ ++ci;
142
+ }
143
+ else {
144
+ // clean if chunk has no value
145
+ this.chunks.splice(ci, 1);
146
+ }
147
+ if (shiftChar) {
148
+ return shiftChar;
149
+ }
150
+ }
151
+ return '';
152
+ };
153
+ ChunksTailDetails.prototype.shift = function () {
154
+ if (!this.chunks.length) {
155
+ return '';
156
+ }
157
+ var ci = this.chunks.length - 1;
158
+ while (ci >= 0) {
159
+ var chunk = this.chunks[ci];
160
+ var shiftChar = chunk.shift();
161
+ if (chunk.toString()) {
162
+ // chunk still contains value
163
+ // but not shifted - means no more available chars to shift
164
+ if (!shiftChar) {
165
+ break;
166
+ }
167
+ --ci;
168
+ }
169
+ else {
170
+ // clean if chunk has no value
171
+ this.chunks.splice(ci, 1);
172
+ }
173
+ if (shiftChar) {
174
+ return shiftChar;
175
+ }
176
+ }
177
+ return '';
178
+ };
179
+ return ChunksTailDetails;
180
+ }());
181
+ export { ChunksTailDetails };
182
+ //# sourceMappingURL=chunk-tail-details.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk-tail-details.js","sourceRoot":"","sources":["chunk-tail-details.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAG9E,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAW/C,SAAS,mBAAmB,CAAC,MAAkB;IAC7C,OAAO,OAAQ,MAA4B,CAAC,cAAc,KAAK,UAAU,CAAC;AAC5E,CAAC;AAMD;IAOE,2BAAY,MAA0B,EAAE,IAAgB;QAA5C,uBAAA,EAAA,WAA0B;QAAE,qBAAA,EAAA,QAAgB;QACtD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,oCAAQ,GAAR;QACE,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC1C,CAAC;IAED,kCAAM,GAAN,UAAO,SAA+B;QACpC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;YACvB,OAAO;QACT,CAAC;QACD,6CAA6C;QAC7C,SAAS,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI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AAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;YACxB,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,IAAI,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;QAChC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC;YACf,IAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YAC9B,IAAM,SAAS,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC;YAEhC,IAAI,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC;gBACrB,6BAA6B;gBAC7B,2DAA2D;gBAC3D,IAAI,CAAC,SAAS,EAAE,CAAC;oBACf,MAAM;gBACR,CAAC;gBACD,EAAE,EAAE,CAAC;YACP,CAAC;iBAAM,CAAC;gBACN,8BAA8B;gBAC9B,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;YAC5B,CAAC;YAED,IAAI,SAAS,EAAE,CAAC;gBACd,OAAO,SAAS,CAAC;YACnB,CAAC;QACH,CAAC;QAED,OAAO,EAAE,CAAC;IACZ,CAAC;IACH,wBAAC;AAAD,CAAC,AAzLD,IAyLC","sourcesContent":["import { ChangeDetails } from '../../core/change-details.js';\nimport { ContinuousTailDetails } from '../../core/continuous-tail-details.js';\n/* eslint-disable eqeqeq */\nimport type { TailDetails, AppendTail } from '../../core/tail-details.js';\nimport { isString } from '../../core/utils.js';\n\n/** Pattern-mask surface used by appendTo — duck-typed to avoid pattern ↔ chunk-tail cycle. */\ninterface PatternTailTarget extends AppendTail {\n displayValue: string;\n _stops: number[];\n _blocks: Array<{ appendTail(chunk: TailDetails): ChangeDetails }>;\n _mapPosToBlock(pos: number): { index: number } | undefined;\n _appendPlaceholder(toBlockIndex?: number): ChangeDetails;\n}\n\nfunction isPatternTailTarget(masked: AppendTail): masked is PatternTailTarget {\n return typeof (masked as PatternTailTarget)._mapPosToBlock === 'function';\n}\n\nexport type ChunksTailState = Pick<ChunksTailDetails, 'from' | 'stop' | 'blockIndex'> & {\n chunks: Array<TailDetails['state']>;\n};\n\nexport class ChunksTailDetails implements TailDetails {\n chunks!: TailDetails[];\n from!: number;\n stop?: number;\n /** */\n blockIndex?: number;\n\n constructor(chunks: TailDetails[] = [], from: number = 0) {\n this.chunks = chunks;\n this.from = from;\n }\n\n toString(): string {\n return this.chunks.map(String).join('');\n }\n\n extend(tailChunk: string | TailDetails): void {\n if (!String(tailChunk)) {\n return;\n }\n // eslint-disable-next-line no-param-reassign\n tailChunk = (isString(tailChunk) ? new ContinuousTailDetails(String(tailChunk)) : tailChunk) as TailDetails;\n\n const lastChunk = this.chunks[this.chunks.length - 1];\n const extendLast =\n lastChunk &&\n // if stops are same or tail has no stop\n (lastChunk.stop === tailChunk.stop || tailChunk.stop == null) &&\n // if tail chunk goes just after last chunk\n tailChunk.from === lastChunk.from + lastChunk.toString().length;\n\n if (tailChunk instanceof ContinuousTailDetails) {\n // check the ability to extend previous chunk\n if (extendLast) {\n // extend previous chunk\n lastChunk.extend(tailChunk.toString());\n } else {\n // append new chunk\n this.chunks.push(tailChunk);\n }\n } else if (tailChunk instanceof ChunksTailDetails) {\n if (tailChunk.stop == null) {\n // unwrap floating chunks to parent, keeping `from` pos\n let firstTailChunk;\n while (tailChunk.chunks.length && tailChunk.chunks[0].stop == null) {\n firstTailChunk = tailChunk.chunks.shift() as TailDetails; // not possible to be `undefined` because length was checked above\n firstTailChunk.from += tailChunk.from;\n this.extend(firstTailChunk);\n }\n }\n\n // if tail chunk still has value\n if (tailChunk.toString()) {\n // if chunks contains stops, then popup stop to container\n tailChunk.stop = tailChunk.blockIndex;\n this.chunks.push(tailChunk);\n }\n }\n }\n\n appendTo(masked: AppendTail): ChangeDetails {\n if (!isPatternTailTarget(masked)) {\n const tail = new ContinuousTailDetails(this.toString());\n return tail.appendTo(masked);\n }\n\n const details = new ChangeDetails();\n\n for (let ci = 0; ci < this.chunks.length; ++ci) {\n const chunk = this.chunks[ci];\n\n const lastBlockIter = masked._mapPosToBlock(masked.displayValue.length);\n const stop = chunk.stop;\n let chunkBlock;\n if (\n stop != null &&\n // if block not found or stop is behind lastBlock\n (!lastBlockIter || lastBlockIter.index <= stop)\n ) {\n if (\n chunk instanceof ChunksTailDetails ||\n // for continuous block also check if stop is exist\n masked._stops.indexOf(stop) >= 0\n ) {\n details.aggregate(masked._appendPlaceholder(stop));\n }\n chunkBlock = chunk instanceof ChunksTailDetails && masked._blocks[stop];\n }\n\n if (chunkBlock) {\n const tailDetails = chunkBlock.appendTail(chunk);\n details.aggregate(tailDetails);\n\n // get not inserted chars\n const remainChars = chunk.toString().slice(tailDetails.rawInserted.length);\n if (remainChars) {\n details.aggregate(masked.append(remainChars, { tail: true }));\n }\n } else {\n details.aggregate(masked.append(chunk.toString(), { tail: true }));\n }\n }\n\n return details;\n }\n\n get state(): ChunksTailState {\n return {\n chunks: this.chunks.map((c) => c.state),\n from: this.from,\n stop: this.stop,\n blockIndex: this.blockIndex,\n };\n }\n\n set state(state: ChunksTailState) {\n const { chunks, ...props } = state;\n Object.assign(this, props);\n this.chunks = chunks.map((cstate) => {\n const chunk = 'chunks' in cstate ? new ChunksTailDetails() : new ContinuousTailDetails();\n chunk.state = cstate;\n return chunk;\n });\n }\n\n unshift(beforePos?: number): string {\n if (!this.chunks.length || (beforePos != null && this.from >= beforePos)) {\n return '';\n }\n\n const chunkShiftPos = beforePos != null ? beforePos - this.from : beforePos;\n let ci = 0;\n while (ci < this.chunks.length) {\n const chunk = this.chunks[ci];\n const shiftChar = chunk.unshift(chunkShiftPos);\n\n if (chunk.toString()) {\n // chunk still contains value\n // but not shifted - means no more available chars to shift\n if (!shiftChar) {\n break;\n }\n ++ci;\n } else {\n // clean if chunk has no value\n this.chunks.splice(ci, 1);\n }\n\n if (shiftChar) {\n return shiftChar;\n }\n }\n\n return '';\n }\n\n shift(): string {\n if (!this.chunks.length) {\n return '';\n }\n\n let ci = this.chunks.length - 1;\n while (ci >= 0) {\n const chunk = this.chunks[ci];\n const shiftChar = chunk.shift();\n\n if (chunk.toString()) {\n // chunk still contains value\n // but not shifted - means no more available chars to shift\n if (!shiftChar) {\n break;\n }\n --ci;\n } else {\n // clean if chunk has no value\n this.chunks.splice(ci, 1);\n }\n\n if (shiftChar) {\n return shiftChar;\n }\n }\n\n return '';\n }\n}\n"]}
@@ -0,0 +1,31 @@
1
+ import type { MaskedPattern } from '../pattern.js';
2
+ import type { PatternBlock } from './block.js';
3
+ interface PatternCursorState {
4
+ offset: number;
5
+ index: number;
6
+ ok: boolean;
7
+ }
8
+ export declare class PatternCursor<Value> {
9
+ masked: MaskedPattern<Value>;
10
+ offset: number;
11
+ index: number;
12
+ ok: boolean;
13
+ _log: PatternCursorState[];
14
+ constructor(masked: MaskedPattern<Value>, pos: number);
15
+ get block(): PatternBlock;
16
+ get pos(): number;
17
+ get state(): PatternCursorState;
18
+ set state(s: PatternCursorState);
19
+ pushState(): void;
20
+ popState(): PatternCursorState | undefined;
21
+ bindBlock(): void;
22
+ _pushLeft(fn: () => boolean | undefined): boolean;
23
+ _pushRight(fn: () => boolean | undefined): boolean;
24
+ pushLeftBeforeFilled(): boolean;
25
+ pushLeftBeforeInput(): boolean;
26
+ pushLeftBeforeRequired(): boolean;
27
+ pushRightBeforeFilled(): boolean;
28
+ pushRightBeforeInput(): boolean;
29
+ pushRightBeforeRequired(): boolean;
30
+ }
31
+ export {};
@@ -0,0 +1,163 @@
1
+ import { DIRECTION } from '../../core/utils.js';
2
+ var PatternCursor = /** @class */ (function () {
3
+ function PatternCursor(masked, pos) {
4
+ this.masked = masked;
5
+ this._log = [];
6
+ var _a = masked._mapPosToBlock(pos) ||
7
+ (pos < 0
8
+ ? // first
9
+ { index: 0, offset: 0 }
10
+ : // last
11
+ { index: this.masked._blocks.length, offset: 0 }), offset = _a.offset, index = _a.index;
12
+ this.offset = offset;
13
+ this.index = index;
14
+ this.ok = false;
15
+ }
16
+ Object.defineProperty(PatternCursor.prototype, "block", {
17
+ get: function () {
18
+ return this.masked._blocks[this.index];
19
+ },
20
+ enumerable: false,
21
+ configurable: true
22
+ });
23
+ Object.defineProperty(PatternCursor.prototype, "pos", {
24
+ get: function () {
25
+ return this.masked._blockStartPos(this.index) + this.offset;
26
+ },
27
+ enumerable: false,
28
+ configurable: true
29
+ });
30
+ Object.defineProperty(PatternCursor.prototype, "state", {
31
+ get: function () {
32
+ return { index: this.index, offset: this.offset, ok: this.ok };
33
+ },
34
+ set: function (s) {
35
+ Object.assign(this, s);
36
+ },
37
+ enumerable: false,
38
+ configurable: true
39
+ });
40
+ PatternCursor.prototype.pushState = function () {
41
+ this._log.push(this.state);
42
+ };
43
+ PatternCursor.prototype.popState = function () {
44
+ var s = this._log.pop();
45
+ if (s) {
46
+ this.state = s;
47
+ }
48
+ return s;
49
+ };
50
+ PatternCursor.prototype.bindBlock = function () {
51
+ var _a;
52
+ if (this.block) {
53
+ return;
54
+ }
55
+ if (this.index < 0) {
56
+ this.index = 0;
57
+ this.offset = 0;
58
+ }
59
+ if (this.index >= this.masked._blocks.length) {
60
+ this.index = this.masked._blocks.length - 1;
61
+ var lastBlock = this.masked._blocks[this.masked._blocks.length - 1];
62
+ this.offset = (_a = lastBlock === null || lastBlock === void 0 ? void 0 : lastBlock.displayValue.length) !== null && _a !== void 0 ? _a : 0;
63
+ }
64
+ };
65
+ PatternCursor.prototype._pushLeft = function (fn) {
66
+ var _a;
67
+ this.pushState();
68
+ for (this.bindBlock(); this.index >= 0; --this.index, this.offset = ((_a = this.block) === null || _a === void 0 ? void 0 : _a.displayValue.length) || 0) {
69
+ if (fn()) {
70
+ return (this.ok = true);
71
+ }
72
+ }
73
+ return (this.ok = false);
74
+ };
75
+ PatternCursor.prototype._pushRight = function (fn) {
76
+ this.pushState();
77
+ for (this.bindBlock(); this.index < this.masked._blocks.length; ++this.index, this.offset = 0) {
78
+ if (fn()) {
79
+ return (this.ok = true);
80
+ }
81
+ }
82
+ return (this.ok = false);
83
+ };
84
+ PatternCursor.prototype.pushLeftBeforeFilled = function () {
85
+ var _this = this;
86
+ return this._pushLeft(function () {
87
+ if (_this.block.isFixed || !_this.block.value) {
88
+ return;
89
+ }
90
+ _this.offset = _this.block.nearestInputPos(_this.offset, DIRECTION.FORCE_LEFT);
91
+ if (_this.offset !== 0) {
92
+ return true;
93
+ }
94
+ return;
95
+ });
96
+ };
97
+ PatternCursor.prototype.pushLeftBeforeInput = function () {
98
+ var _this = this;
99
+ // cases:
100
+ // filled input: 00|
101
+ // optional empty input: 00[]|
102
+ // nested block: XX<[]>|
103
+ return this._pushLeft(function () {
104
+ if (_this.block.isFixed) {
105
+ return;
106
+ }
107
+ _this.offset = _this.block.nearestInputPos(_this.offset, DIRECTION.LEFT);
108
+ return true;
109
+ });
110
+ };
111
+ PatternCursor.prototype.pushLeftBeforeRequired = function () {
112
+ var _this = this;
113
+ return this._pushLeft(function () {
114
+ if (_this.block.isFixed || (_this.block.isOptional && !_this.block.value)) {
115
+ return;
116
+ }
117
+ _this.offset = _this.block.nearestInputPos(_this.offset, DIRECTION.LEFT);
118
+ return true;
119
+ });
120
+ };
121
+ PatternCursor.prototype.pushRightBeforeFilled = function () {
122
+ var _this = this;
123
+ return this._pushRight(function () {
124
+ if (_this.block.isFixed || !_this.block.value) {
125
+ return;
126
+ }
127
+ _this.offset = _this.block.nearestInputPos(_this.offset, DIRECTION.FORCE_RIGHT);
128
+ if (_this.offset !== _this.block.value.length) {
129
+ return true;
130
+ }
131
+ return;
132
+ });
133
+ };
134
+ PatternCursor.prototype.pushRightBeforeInput = function () {
135
+ var _this = this;
136
+ return this._pushRight(function () {
137
+ if (_this.block.isFixed) {
138
+ return;
139
+ }
140
+ // const o = this.offset;
141
+ _this.offset = _this.block.nearestInputPos(_this.offset, DIRECTION.NONE);
142
+ // HACK cases like (STILL DOES NOT WORK FOR NESTED)
143
+ // aa|X
144
+ // aa<X|[]>X_ - this will not work
145
+ // if (o && o === this.offset && this.block instanceof PatternInputDefinition) continue;
146
+ return true;
147
+ });
148
+ };
149
+ PatternCursor.prototype.pushRightBeforeRequired = function () {
150
+ var _this = this;
151
+ return this._pushRight(function () {
152
+ if (_this.block.isFixed || (_this.block.isOptional && !_this.block.value)) {
153
+ return;
154
+ }
155
+ // TODO check |[*]XX_
156
+ _this.offset = _this.block.nearestInputPos(_this.offset, DIRECTION.NONE);
157
+ return true;
158
+ });
159
+ };
160
+ return PatternCursor;
161
+ }());
162
+ export { PatternCursor };
163
+ //# sourceMappingURL=cursor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cursor.js","sourceRoot":"","sources":["cursor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAUhD;IAOE,uBAAY,MAA4B,EAAE,GAAW;QACnD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC;QAET,IAAA,KACJ,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC;YAC1B,CAAC,GAAG,GAAG,CAAC;gBACN,CAAC,CAAC,QAAQ;oBACR,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE;gBACzB,CAAC,CAAC,OAAO;oBACP,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,EAN/C,MAAM,YAAA,EAAE,KAAK,WAMkC,CAAC;QACxD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,EAAE,GAAG,KAAK,CAAC;IAClB,CAAC;IAED,sBAAI,gCAAK;aAAT;YACE,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACzC,CAAC;;;OAAA;IAED,sBAAI,8BAAG;aAAP;YACE,OAAO,IAAI,CAAC,MAAM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AI,CAAC,MAAM,GAAG,KAAI,CAAC,KAAK,CAAC,eAAe,CAAC,KAAI,CAAC,MAAM,EAAE,SAAS,CAAC,WAAW,CAAC,CAAC;YAC7E,IAAI,KAAI,CAAC,MAAM,KAAK,KAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;gBAC5C,OAAO,IAAI,CAAC;YACd,CAAC;YACD,OAAO;QACT,CAAC,CAAC,CAAC;IACL,CAAC;IAED,4CAAoB,GAApB;QAAA,iBAcC;QAbC,OAAO,IAAI,CAAC,UAAU,CAAC;YACrB,IAAI,KAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;gBACvB,OAAO;YACT,CAAC;YAED,yBAAyB;YACzB,KAAI,CAAC,MAAM,GAAG,KAAI,CAAC,KAAK,CAAC,eAAe,CAAC,KAAI,CAAC,MAAM,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;YACtE,mDAAmD;YACnD,OAAO;YACP,qCAAqC;YACrC,wFAAwF;YACxF,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;IACL,CAAC;IAED,+CAAuB,GAAvB;QAAA,iBAUC;QATC,OAAO,IAAI,CAAC,UAAU,CAAC;YACrB,IAAI,KAAI,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,KAAI,CAAC,KAAK,CAAC,UAAU,IAAI,CAAC,KAAI,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;gBACvE,OAAO;YACT,CAAC;YAED,qBAAqB;YACrB,KAAI,CAAC,MAAM,GAAG,KAAI,CAAC,KAAK,CAAC,eAAe,CAAC,KAAI,CAAC,MAAM,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;YACtE,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;IACL,CAAC;IACH,oBAAC;AAAD,CAAC,AAzKD,IAyKC","sourcesContent":["import { DIRECTION } from '../../core/utils.js';\nimport type { MaskedPattern } from '../pattern.js';\nimport type { PatternBlock } from './block.js';\n\ninterface PatternCursorState {\n offset: number;\n index: number;\n ok: boolean;\n}\n\nexport class PatternCursor<Value> {\n masked!: MaskedPattern<Value>;\n offset!: number;\n index!: number;\n ok!: boolean;\n _log!: PatternCursorState[];\n\n constructor(masked: MaskedPattern<Value>, pos: number) {\n this.masked = masked;\n this._log = [];\n\n const { offset, index } =\n masked._mapPosToBlock(pos) ||\n (pos < 0\n ? // first\n { index: 0, offset: 0 }\n : // last\n { index: this.masked._blocks.length, offset: 0 });\n this.offset = offset;\n this.index = index;\n this.ok = false;\n }\n\n get block(): PatternBlock {\n return this.masked._blocks[this.index];\n }\n\n get pos(): number {\n return this.masked._blockStartPos(this.index) + this.offset;\n }\n\n get state(): PatternCursorState {\n return { index: this.index, offset: this.offset, ok: this.ok };\n }\n\n set state(s: PatternCursorState) {\n Object.assign(this, s);\n }\n\n pushState(): void {\n this._log.push(this.state);\n }\n\n popState(): PatternCursorState | undefined {\n const s = this._log.pop();\n if (s) {\n this.state = s;\n }\n return s;\n }\n\n bindBlock(): void {\n if (this.block) {\n return;\n }\n if (this.index < 0) {\n this.index = 0;\n this.offset = 0;\n }\n if (this.index >= this.masked._blocks.length) {\n this.index = this.masked._blocks.length - 1;\n const lastBlock = this.masked._blocks[this.masked._blocks.length - 1];\n this.offset = lastBlock?.displayValue.length ?? 0;\n }\n }\n\n _pushLeft(fn: () => boolean | undefined): boolean {\n this.pushState();\n for (this.bindBlock(); this.index >= 0; --this.index, this.offset = this.block?.displayValue.length || 0) {\n if (fn()) {\n return (this.ok = true);\n }\n }\n\n return (this.ok = false);\n }\n\n _pushRight(fn: () => boolean | undefined): boolean {\n this.pushState();\n for (this.bindBlock(); this.index < this.masked._blocks.length; ++this.index, this.offset = 0) {\n if (fn()) {\n return (this.ok = true);\n }\n }\n\n return (this.ok = false);\n }\n\n pushLeftBeforeFilled(): boolean {\n return this._pushLeft(() => {\n if (this.block.isFixed || !this.block.value) {\n return;\n }\n\n this.offset = this.block.nearestInputPos(this.offset, DIRECTION.FORCE_LEFT);\n if (this.offset !== 0) {\n return true;\n }\n return;\n });\n }\n\n pushLeftBeforeInput(): boolean {\n // cases:\n // filled input: 00|\n // optional empty input: 00[]|\n // nested block: XX<[]>|\n return this._pushLeft(() => {\n if (this.block.isFixed) {\n return;\n }\n\n this.offset = this.block.nearestInputPos(this.offset, DIRECTION.LEFT);\n return true;\n });\n }\n\n pushLeftBeforeRequired(): boolean {\n return this._pushLeft(() => {\n if (this.block.isFixed || (this.block.isOptional && !this.block.value)) {\n return;\n }\n\n this.offset = this.block.nearestInputPos(this.offset, DIRECTION.LEFT);\n return true;\n });\n }\n\n pushRightBeforeFilled(): boolean {\n return this._pushRight(() => {\n if (this.block.isFixed || !this.block.value) {\n return;\n }\n\n this.offset = this.block.nearestInputPos(this.offset, DIRECTION.FORCE_RIGHT);\n if (this.offset !== this.block.value.length) {\n return true;\n }\n return;\n });\n }\n\n pushRightBeforeInput(): boolean {\n return this._pushRight(() => {\n if (this.block.isFixed) {\n return;\n }\n\n // const o = this.offset;\n this.offset = this.block.nearestInputPos(this.offset, DIRECTION.NONE);\n // HACK cases like (STILL DOES NOT WORK FOR NESTED)\n // aa|X\n // aa<X|[]>X_ - this will not work\n // if (o && o === this.offset && this.block instanceof PatternInputDefinition) continue;\n return true;\n });\n }\n\n pushRightBeforeRequired(): boolean {\n return this._pushRight(() => {\n if (this.block.isFixed || (this.block.isOptional && !this.block.value)) {\n return;\n }\n\n // TODO check |[*]XX_\n this.offset = this.block.nearestInputPos(this.offset, DIRECTION.NONE);\n return true;\n });\n }\n}\n"]}
@@ -0,0 +1,42 @@
1
+ import { ChangeDetails } from '../../core/change-details.js';
2
+ import { type TailDetails } from '../../core/tail-details.js';
3
+ import { type Direction } from '../../core/utils.js';
4
+ import { type ExtractFlags, type AppendFlags, type MaskedState } from '../base.js';
5
+ import type { PatternBlock } from './block.js';
6
+ export type PatternFixedDefinitionOptions = Pick<PatternFixedDefinition, 'char' | 'isUnmasking' | 'eager'>;
7
+ export declare class PatternFixedDefinition implements PatternBlock {
8
+ /** */
9
+ _value: string;
10
+ /** */
11
+ char: string;
12
+ /** */
13
+ isUnmasking?: boolean;
14
+ /** */
15
+ eager: boolean | 'remove' | 'append' | undefined;
16
+ /** */
17
+ _isRawInput?: boolean;
18
+ /** */
19
+ isFixed: boolean;
20
+ constructor(opts: PatternFixedDefinitionOptions);
21
+ get value(): string;
22
+ get unmaskedValue(): string;
23
+ get rawInputValue(): string;
24
+ get displayValue(): string;
25
+ reset(): void;
26
+ remove(fromPos?: number, toPos?: number): ChangeDetails;
27
+ nearestInputPos(cursorPos: number, direction?: Direction): number;
28
+ totalInputPositions(fromPos?: number, toPos?: number): number;
29
+ extractInput(fromPos?: number, toPos?: number, flags?: ExtractFlags): string;
30
+ get isComplete(): boolean;
31
+ get isFilled(): boolean;
32
+ _appendChar(ch: string, flags?: AppendFlags): ChangeDetails;
33
+ _appendEager(): ChangeDetails;
34
+ _appendPlaceholder(): ChangeDetails;
35
+ extractTail(): TailDetails;
36
+ appendTail(tail: string | TailDetails): ChangeDetails;
37
+ append(str: string, flags?: AppendFlags, tail?: TailDetails): ChangeDetails;
38
+ doCommit(): void;
39
+ get state(): MaskedState;
40
+ set state(state: MaskedState);
41
+ pad(): ChangeDetails;
42
+ }
@@ -0,0 +1,158 @@
1
+ import { ChangeDetails } from '../../core/change-details.js';
2
+ import { ContinuousTailDetails } from '../../core/continuous-tail-details.js';
3
+ import { DIRECTION, isString } from '../../core/utils.js';
4
+ var PatternFixedDefinition = /** @class */ (function () {
5
+ function PatternFixedDefinition(opts) {
6
+ Object.assign(this, opts);
7
+ this._value = '';
8
+ this.isFixed = true;
9
+ }
10
+ Object.defineProperty(PatternFixedDefinition.prototype, "value", {
11
+ get: function () {
12
+ return this._value;
13
+ },
14
+ enumerable: false,
15
+ configurable: true
16
+ });
17
+ Object.defineProperty(PatternFixedDefinition.prototype, "unmaskedValue", {
18
+ get: function () {
19
+ return this.isUnmasking ? this.value : '';
20
+ },
21
+ enumerable: false,
22
+ configurable: true
23
+ });
24
+ Object.defineProperty(PatternFixedDefinition.prototype, "rawInputValue", {
25
+ get: function () {
26
+ return this._isRawInput ? this.value : '';
27
+ },
28
+ enumerable: false,
29
+ configurable: true
30
+ });
31
+ Object.defineProperty(PatternFixedDefinition.prototype, "displayValue", {
32
+ get: function () {
33
+ return this.value;
34
+ },
35
+ enumerable: false,
36
+ configurable: true
37
+ });
38
+ PatternFixedDefinition.prototype.reset = function () {
39
+ this._isRawInput = false;
40
+ this._value = '';
41
+ };
42
+ PatternFixedDefinition.prototype.remove = function (fromPos, toPos) {
43
+ if (fromPos === void 0) { fromPos = 0; }
44
+ if (toPos === void 0) { toPos = this._value.length; }
45
+ this._value = this._value.slice(0, fromPos) + this._value.slice(toPos);
46
+ if (!this._value) {
47
+ this._isRawInput = false;
48
+ }
49
+ return new ChangeDetails();
50
+ };
51
+ PatternFixedDefinition.prototype.nearestInputPos = function (cursorPos, direction) {
52
+ if (direction === void 0) { direction = DIRECTION.NONE; }
53
+ var minPos = 0;
54
+ var maxPos = this._value.length;
55
+ switch (direction) {
56
+ case DIRECTION.LEFT:
57
+ case DIRECTION.FORCE_LEFT:
58
+ return minPos;
59
+ case DIRECTION.NONE:
60
+ case DIRECTION.RIGHT:
61
+ case DIRECTION.FORCE_RIGHT:
62
+ default:
63
+ return maxPos;
64
+ }
65
+ };
66
+ PatternFixedDefinition.prototype.totalInputPositions = function (fromPos, toPos) {
67
+ if (fromPos === void 0) { fromPos = 0; }
68
+ if (toPos === void 0) { toPos = this._value.length; }
69
+ return this._isRawInput ? toPos - fromPos : 0;
70
+ };
71
+ PatternFixedDefinition.prototype.extractInput = function (fromPos, toPos, flags) {
72
+ if (fromPos === void 0) { fromPos = 0; }
73
+ if (toPos === void 0) { toPos = this._value.length; }
74
+ if (flags === void 0) { flags = {}; }
75
+ return (flags.raw && this._isRawInput && this._value.slice(fromPos, toPos)) || '';
76
+ };
77
+ Object.defineProperty(PatternFixedDefinition.prototype, "isComplete", {
78
+ get: function () {
79
+ return true;
80
+ },
81
+ enumerable: false,
82
+ configurable: true
83
+ });
84
+ Object.defineProperty(PatternFixedDefinition.prototype, "isFilled", {
85
+ get: function () {
86
+ return Boolean(this._value);
87
+ },
88
+ enumerable: false,
89
+ configurable: true
90
+ });
91
+ PatternFixedDefinition.prototype._appendChar = function (ch, flags) {
92
+ if (flags === void 0) { flags = {}; }
93
+ if (this.isFilled) {
94
+ return new ChangeDetails();
95
+ }
96
+ var appendEager = this.eager === true || this.eager === 'append';
97
+ var appended = this.char === ch;
98
+ var isResolved = appended && (this.isUnmasking || flags.input || flags.raw) && (!flags.raw || !appendEager) && !flags.tail;
99
+ var details = new ChangeDetails({
100
+ inserted: this.char,
101
+ rawInserted: isResolved ? this.char : '',
102
+ });
103
+ this._value = this.char;
104
+ this._isRawInput = isResolved && flags.raw;
105
+ return details;
106
+ };
107
+ PatternFixedDefinition.prototype._appendEager = function () {
108
+ return this._appendChar(this.char, { tail: true });
109
+ };
110
+ PatternFixedDefinition.prototype._appendPlaceholder = function () {
111
+ var details = new ChangeDetails();
112
+ if (this.isFilled) {
113
+ return details;
114
+ }
115
+ // eslint-disable-next-line no-multi-assign
116
+ this._value = details.inserted = this.char;
117
+ return details;
118
+ };
119
+ PatternFixedDefinition.prototype.extractTail = function () {
120
+ return new ContinuousTailDetails('');
121
+ };
122
+ PatternFixedDefinition.prototype.appendTail = function (tail) {
123
+ if (isString(tail)) {
124
+ // eslint-disable-next-line no-param-reassign
125
+ tail = new ContinuousTailDetails(String(tail));
126
+ }
127
+ return tail.appendTo(this);
128
+ };
129
+ PatternFixedDefinition.prototype.append = function (str, flags, tail) {
130
+ var details = this._appendChar(str[0], flags);
131
+ // eslint-disable-next-line eqeqeq
132
+ if (tail != null) {
133
+ details.tailShift += this.appendTail(tail).tailShift;
134
+ }
135
+ return details;
136
+ };
137
+ PatternFixedDefinition.prototype.doCommit = function () { };
138
+ Object.defineProperty(PatternFixedDefinition.prototype, "state", {
139
+ get: function () {
140
+ return {
141
+ _value: this._value,
142
+ _rawInputValue: this.rawInputValue,
143
+ };
144
+ },
145
+ set: function (state) {
146
+ this._value = state._value;
147
+ this._isRawInput = Boolean(state._rawInputValue);
148
+ },
149
+ enumerable: false,
150
+ configurable: true
151
+ });
152
+ PatternFixedDefinition.prototype.pad = function () {
153
+ return this._appendPlaceholder();
154
+ };
155
+ return PatternFixedDefinition;
156
+ }());
157
+ export { PatternFixedDefinition };
158
+ //# sourceMappingURL=fixed-definition.js.map