@dreamcommerce/aurora 3.1.52-1 → 3.1.52

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 (108) hide show
  1. package/build/cjs/packages/aurora/src/components/calendar/styled_day_picker/styled_day_picker.js +1 -1
  2. package/build/cjs/packages/aurora/src/components/color_picker/components/pure_color_picker.js +1 -0
  3. package/build/cjs/packages/aurora/src/components/color_picker/components/pure_color_picker.js.map +1 -1
  4. package/build/cjs/packages/aurora/src/components/controls/values_syncer_control/values_syncer_control.js +3 -5
  5. package/build/cjs/packages/aurora/src/components/controls/values_syncer_control/values_syncer_control.js.map +1 -1
  6. package/build/cjs/packages/aurora/src/components/date_and_time_picker/date_time_picker.js +27 -16
  7. package/build/cjs/packages/aurora/src/components/date_and_time_picker/date_time_picker.js.map +1 -1
  8. package/build/cjs/packages/aurora/src/components/date_picker/components/date_picker_input.js +11 -43
  9. package/build/cjs/packages/aurora/src/components/date_picker/components/date_picker_input.js.map +1 -1
  10. package/build/cjs/packages/aurora/src/components/date_picker/date_picker.js +13 -83
  11. package/build/cjs/packages/aurora/src/components/date_picker/date_picker.js.map +1 -1
  12. package/build/cjs/packages/aurora/src/components/date_picker/date_picker_utils.js +4 -203
  13. package/build/cjs/packages/aurora/src/components/date_picker/date_picker_utils.js.map +1 -1
  14. package/build/cjs/packages/aurora/src/components/time_picker/components/time_picker_input.js +10 -30
  15. package/build/cjs/packages/aurora/src/components/time_picker/components/time_picker_input.js.map +1 -1
  16. package/build/cjs/packages/aurora/src/components/time_picker/time_picker.js +50 -85
  17. package/build/cjs/packages/aurora/src/components/time_picker/time_picker.js.map +1 -1
  18. package/build/cjs/packages/aurora/src/components/time_picker/time_picker_utils.js +1 -62
  19. package/build/cjs/packages/aurora/src/components/time_picker/time_picker_utils.js.map +1 -1
  20. package/build/cjs/packages/aurora/src/index.js +0 -2
  21. package/build/cjs/packages/aurora/src/index.js.map +1 -1
  22. package/build/cjs/packages/aurora/src/translations/en.json.js +1 -4
  23. package/build/cjs/packages/aurora/src/translations/en.json.js.map +1 -1
  24. package/build/cjs/packages/aurora/src/translations/pl.json.js +1 -4
  25. package/build/cjs/packages/aurora/src/translations/pl.json.js.map +1 -1
  26. package/build/esm/packages/aurora/src/components/calendar/styled_day_picker/styled_day_picker.js +1 -1
  27. package/build/esm/packages/aurora/src/components/color_picker/components/pure_color_picker.js +1 -0
  28. package/build/esm/packages/aurora/src/components/color_picker/components/pure_color_picker.js.map +1 -1
  29. package/build/esm/packages/aurora/src/components/controls/values_syncer_control/values_syncer_control.js +3 -5
  30. package/build/esm/packages/aurora/src/components/controls/values_syncer_control/values_syncer_control.js.map +1 -1
  31. package/build/esm/packages/aurora/src/components/date_and_time_picker/date_time_picker.js +27 -16
  32. package/build/esm/packages/aurora/src/components/date_and_time_picker/date_time_picker.js.map +1 -1
  33. package/build/esm/packages/aurora/src/components/date_picker/components/date_picker_input.d.ts +1 -4
  34. package/build/esm/packages/aurora/src/components/date_picker/components/date_picker_input.js +11 -43
  35. package/build/esm/packages/aurora/src/components/date_picker/components/date_picker_input.js.map +1 -1
  36. package/build/esm/packages/aurora/src/components/date_picker/date_picker.d.ts +1 -1
  37. package/build/esm/packages/aurora/src/components/date_picker/date_picker.js +14 -84
  38. package/build/esm/packages/aurora/src/components/date_picker/date_picker.js.map +1 -1
  39. package/build/esm/packages/aurora/src/components/date_picker/date_picker_types.d.ts +1 -1
  40. package/build/esm/packages/aurora/src/components/date_picker/date_picker_utils.d.ts +1 -18
  41. package/build/esm/packages/aurora/src/components/date_picker/date_picker_utils.js +4 -203
  42. package/build/esm/packages/aurora/src/components/date_picker/date_picker_utils.js.map +1 -1
  43. package/build/esm/packages/aurora/src/components/time_picker/components/time_picker_input.d.ts +1 -2
  44. package/build/esm/packages/aurora/src/components/time_picker/components/time_picker_input.js +10 -30
  45. package/build/esm/packages/aurora/src/components/time_picker/components/time_picker_input.js.map +1 -1
  46. package/build/esm/packages/aurora/src/components/time_picker/time_picker.js +52 -87
  47. package/build/esm/packages/aurora/src/components/time_picker/time_picker.js.map +1 -1
  48. package/build/esm/packages/aurora/src/components/time_picker/time_picker_utils.d.ts +0 -11
  49. package/build/esm/packages/aurora/src/components/time_picker/time_picker_utils.js +1 -62
  50. package/build/esm/packages/aurora/src/components/time_picker/time_picker_utils.js.map +1 -1
  51. package/build/esm/packages/aurora/src/index.d.ts +0 -2
  52. package/build/esm/packages/aurora/src/index.js +0 -1
  53. package/build/esm/packages/aurora/src/index.js.map +1 -1
  54. package/build/esm/packages/aurora/src/translations/en.json +1 -4
  55. package/build/esm/packages/aurora/src/translations/en.json.js +1 -4
  56. package/build/esm/packages/aurora/src/translations/en.json.js.map +1 -1
  57. package/build/esm/packages/aurora/src/translations/pl.json +1 -4
  58. package/build/esm/packages/aurora/src/translations/pl.json.js +1 -4
  59. package/build/esm/packages/aurora/src/translations/pl.json.js.map +1 -1
  60. package/package.json +1 -1
  61. package/build/cjs/packages/aurora/src/components/input_mask/hooks/hooks.js +0 -196
  62. package/build/cjs/packages/aurora/src/components/input_mask/hooks/hooks.js.map +0 -1
  63. package/build/cjs/packages/aurora/src/components/input_mask/input-mask-constants.js +0 -14
  64. package/build/cjs/packages/aurora/src/components/input_mask/input-mask-constants.js.map +0 -1
  65. package/build/cjs/packages/aurora/src/components/input_mask/input_mask.js +0 -360
  66. package/build/cjs/packages/aurora/src/components/input_mask/input_mask.js.map +0 -1
  67. package/build/cjs/packages/aurora/src/components/input_mask/utils/defer.js +0 -16
  68. package/build/cjs/packages/aurora/src/components/input_mask/utils/defer.js.map +0 -1
  69. package/build/cjs/packages/aurora/src/components/input_mask/utils/helpers.js +0 -50
  70. package/build/cjs/packages/aurora/src/components/input_mask/utils/helpers.js.map +0 -1
  71. package/build/cjs/packages/aurora/src/components/input_mask/utils/input.js +0 -33
  72. package/build/cjs/packages/aurora/src/components/input_mask/utils/input.js.map +0 -1
  73. package/build/cjs/packages/aurora/src/components/input_mask/utils/mask.js +0 -371
  74. package/build/cjs/packages/aurora/src/components/input_mask/utils/mask.js.map +0 -1
  75. package/build/cjs/packages/aurora/src/components/input_mask/utils/parse-mask.js +0 -94
  76. package/build/cjs/packages/aurora/src/components/input_mask/utils/parse-mask.js.map +0 -1
  77. package/build/cjs/packages/aurora/src/components/input_mask/utils/validate-props.js +0 -37
  78. package/build/cjs/packages/aurora/src/components/input_mask/utils/validate-props.js.map +0 -1
  79. package/build/esm/packages/aurora/src/components/input_mask/hooks/hooks.d.ts +0 -10
  80. package/build/esm/packages/aurora/src/components/input_mask/hooks/hooks.js +0 -190
  81. package/build/esm/packages/aurora/src/components/input_mask/hooks/hooks.js.map +0 -1
  82. package/build/esm/packages/aurora/src/components/input_mask/input-mask-constants.d.ts +0 -6
  83. package/build/esm/packages/aurora/src/components/input_mask/input-mask-constants.js +0 -9
  84. package/build/esm/packages/aurora/src/components/input_mask/input-mask-constants.js.map +0 -1
  85. package/build/esm/packages/aurora/src/components/input_mask/input_mask.d.ts +0 -4
  86. package/build/esm/packages/aurora/src/components/input_mask/input_mask.js +0 -352
  87. package/build/esm/packages/aurora/src/components/input_mask/input_mask.js.map +0 -1
  88. package/build/esm/packages/aurora/src/components/input_mask/input_mask_types.d.ts +0 -39
  89. package/build/esm/packages/aurora/src/components/input_mask/input_mask_types.js +0 -2
  90. package/build/esm/packages/aurora/src/components/input_mask/input_mask_types.js.map +0 -1
  91. package/build/esm/packages/aurora/src/components/input_mask/utils/defer.d.ts +0 -2
  92. package/build/esm/packages/aurora/src/components/input_mask/utils/defer.js +0 -11
  93. package/build/esm/packages/aurora/src/components/input_mask/utils/defer.js.map +0 -1
  94. package/build/esm/packages/aurora/src/components/input_mask/utils/helpers.d.ts +0 -7
  95. package/build/esm/packages/aurora/src/components/input_mask/utils/helpers.js +0 -40
  96. package/build/esm/packages/aurora/src/components/input_mask/utils/helpers.js.map +0 -1
  97. package/build/esm/packages/aurora/src/components/input_mask/utils/input.d.ts +0 -9
  98. package/build/esm/packages/aurora/src/components/input_mask/utils/input.js +0 -29
  99. package/build/esm/packages/aurora/src/components/input_mask/utils/input.js.map +0 -1
  100. package/build/esm/packages/aurora/src/components/input_mask/utils/mask.d.ts +0 -63
  101. package/build/esm/packages/aurora/src/components/input_mask/utils/mask.js +0 -367
  102. package/build/esm/packages/aurora/src/components/input_mask/utils/mask.js.map +0 -1
  103. package/build/esm/packages/aurora/src/components/input_mask/utils/parse-mask.d.ts +0 -7
  104. package/build/esm/packages/aurora/src/components/input_mask/utils/parse-mask.js +0 -90
  105. package/build/esm/packages/aurora/src/components/input_mask/utils/parse-mask.js.map +0 -1
  106. package/build/esm/packages/aurora/src/components/input_mask/utils/validate-props.d.ts +0 -4
  107. package/build/esm/packages/aurora/src/components/input_mask/utils/validate-props.js +0 -31
  108. package/build/esm/packages/aurora/src/components/input_mask/utils/validate-props.js.map +0 -1
@@ -1,40 +0,0 @@
1
- // Element's window may differ from the one within React instance
2
- // if element rendered within iframe.
3
- // See https://github.com/sanniassin/react-input-mask/issues/182
4
- var getElementDocument = function getElementDocument(element) {
5
- return (element === null || element === void 0 ? void 0 : element.ownerDocument) || null;
6
- };
7
- var getElementWindow = function getElementWindow(element) {
8
- var _getElementDocument;
9
- return ((_getElementDocument = getElementDocument(element)) === null || _getElementDocument === void 0 ? void 0 : _getElementDocument.defaultView) || null;
10
- };
11
- var isDOMElement = function isDOMElement(element) {
12
- var elementWindow = getElementWindow(element);
13
- return !!elementWindow && element instanceof elementWindow.HTMLElement;
14
- };
15
- var isFunction = function isFunction(value) {
16
- return typeof value === 'function';
17
- };
18
- var findLastIndex = function findLastIndex(array, predicate) {
19
- for (var i = array.length - 1; i >= 0; i--) {
20
- var x = array[i];
21
- if (predicate(x, i)) {
22
- return i;
23
- }
24
- }
25
- return -1;
26
- };
27
- var repeat = function repeat(string) {
28
- var n = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
29
- var result = '';
30
- for (var i = 0; i < n; i++) {
31
- result += string;
32
- }
33
- return result;
34
- };
35
- var toString = function toString(value) {
36
- return "".concat(value);
37
- };
38
-
39
- export { findLastIndex, getElementDocument, getElementWindow, isDOMElement, isFunction, repeat, toString };
40
- //# sourceMappingURL=helpers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -1,9 +0,0 @@
1
- export default class InputUtils {
2
- setInputSelection: (input: HTMLInputElement, start: number, end?: number) => void;
3
- getInputSelection: (input: HTMLInputElement) => {
4
- start: number;
5
- end: number;
6
- length: number;
7
- };
8
- isInputFocused: (input: HTMLInputElement | null) => boolean;
9
- }
@@ -1,29 +0,0 @@
1
- import { createClass as _createClass, classCallCheck as _classCallCheck, defineProperty as _defineProperty } from '../../../../../../_virtual/_rollupPluginBabelHelpers.js';
2
-
3
- var InputUtils = /*#__PURE__*/_createClass(function InputUtils() {
4
- _classCallCheck(this, InputUtils);
5
- _defineProperty(this, "setInputSelection", function (input, start, end) {
6
- if (end === undefined) {
7
- end = start;
8
- }
9
- input.setSelectionRange(start, end);
10
- });
11
- _defineProperty(this, "getInputSelection", function (input) {
12
- var _input$selectionStart, _input$selectionEnd;
13
- var start = (_input$selectionStart = input.selectionStart) !== null && _input$selectionStart !== void 0 ? _input$selectionStart : 0;
14
- var end = (_input$selectionEnd = input.selectionEnd) !== null && _input$selectionEnd !== void 0 ? _input$selectionEnd : 0;
15
- return {
16
- start: start,
17
- end: end,
18
- length: end - start
19
- };
20
- });
21
- _defineProperty(this, "isInputFocused", function (input) {
22
- if (!input) return false;
23
- var inputDocument = input.ownerDocument;
24
- return inputDocument.hasFocus() && inputDocument.activeElement === input;
25
- });
26
- });
27
-
28
- export default InputUtils;
29
- //# sourceMappingURL=input.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -1,63 +0,0 @@
1
- import { InputState } from '../input_mask_types';
2
- export default class MaskUtils {
3
- private maskOptions;
4
- constructor(options: {
5
- mask?: string | Array<string | RegExp>;
6
- maskPlaceholder?: string;
7
- formatChars?: Record<string, RegExp>;
8
- });
9
- isCharacterAllowedAtPosition: (character: string, position: number) => boolean;
10
- isCharacterFillingPosition: (character: string, position: number) => boolean;
11
- isPositionEditable: (position: number) => boolean;
12
- isValueEmpty: (value: string) => boolean;
13
- isValueFilled: (value: string) => boolean;
14
- getDefaultSelectionForValue: (value: string) => {
15
- start: number;
16
- end: number;
17
- };
18
- getFilledLength: (value: string) => number;
19
- getStringFillingLengthAtPosition: (string: string, position: number) => number;
20
- getLeftEditablePosition: (position: number) => number | null;
21
- getRightEditablePosition: (position: number) => number | null;
22
- getFirstEditablePosition: () => number | null;
23
- getLastEditablePosition: () => number | null;
24
- /**
25
- * Gets all sections (groups of consecutive editable positions separated by permanents)
26
- * Returns an array of sections, where each section is an array of editable positions
27
- */
28
- getSections: () => number[][];
29
- /**
30
- * Finds which section a position belongs to
31
- * Returns the section index, or -1 if not found
32
- * @param position - The position to find the section for
33
- * @param sections - Optional pre-computed sections array to avoid recalculation
34
- */
35
- getSectionIndexForPosition: (position: number, sections?: number[][]) => number;
36
- /**
37
- * Gets the first editable position of the next section
38
- * Returns null if already at the last section
39
- * If position is not in any section (e.g., at a permanent character), finds the next section after the position
40
- */
41
- getNextSectionFirstPosition: (position: number) => number | null;
42
- /**
43
- * Gets the first editable position of the previous section
44
- * Returns null if already at the first section
45
- * If position is not in any section (e.g., at a permanent character), finds the previous section before the position
46
- */
47
- getPreviousSectionFirstPosition: (position: number) => number | null;
48
- /**
49
- * Gets the range (first and last positions) of a section
50
- * Returns null if position is not in any section
51
- * @param position - The position to find the section range for
52
- * @param sections - Optional pre-computed sections array to avoid recalculation
53
- */
54
- getSectionRange: (position: number, sections?: number[][]) => {
55
- start: number;
56
- end: number;
57
- } | null;
58
- formatValue: (value: string) => string;
59
- clearRange: (value: string, start: number, len: number) => string;
60
- insertCharacterAtPosition: (value: string, character: string, position: number) => string;
61
- insertStringAtPosition: (value: string, string: string, position: number) => string;
62
- processChange: (currentState: InputState, previousState: InputState) => InputState;
63
- }
@@ -1,367 +0,0 @@
1
- import { createClass as _createClass, classCallCheck as _classCallCheck, defineProperty as _defineProperty } from '../../../../../../_virtual/_rollupPluginBabelHelpers.js';
2
- import { findLastIndex, repeat } from './helpers.js';
3
- import { parseMask } from './parse-mask.js';
4
-
5
- var MaskUtils = /*#__PURE__*/_createClass(function MaskUtils(options) {
6
- var _this = this;
7
- _classCallCheck(this, MaskUtils);
8
- _defineProperty(this, "maskOptions", void 0);
9
- _defineProperty(this, "isCharacterAllowedAtPosition", function (character, position) {
10
- var maskPlaceholder = _this.maskOptions.maskPlaceholder;
11
- if (_this.isCharacterFillingPosition(character, position)) {
12
- return true;
13
- }
14
- if (!maskPlaceholder) {
15
- return false;
16
- }
17
- return maskPlaceholder[position] === character;
18
- });
19
- _defineProperty(this, "isCharacterFillingPosition", function (character, position) {
20
- var mask = _this.maskOptions.mask;
21
- if (!character || !mask || position >= mask.length) {
22
- return false;
23
- }
24
- if (!_this.isPositionEditable(position)) {
25
- return mask[position] === character;
26
- }
27
- var charRule = mask[position];
28
- if (typeof charRule === 'string') {
29
- return charRule === character;
30
- }
31
- return charRule.test(character);
32
- });
33
- _defineProperty(this, "isPositionEditable", function (position) {
34
- var _this$maskOptions = _this.maskOptions,
35
- mask = _this$maskOptions.mask,
36
- permanents = _this$maskOptions.permanents;
37
- if (!mask) return false;
38
- return position < mask.length && permanents.indexOf(position) === -1;
39
- });
40
- _defineProperty(this, "isValueEmpty", function (value) {
41
- return value.split('').every(function (character, position) {
42
- return !_this.isPositionEditable(position) || !_this.isCharacterFillingPosition(character, position);
43
- });
44
- });
45
- _defineProperty(this, "isValueFilled", function (value) {
46
- var lastEditablePosition = _this.maskOptions.lastEditablePosition;
47
- if (lastEditablePosition === null) return false;
48
- return _this.getFilledLength(value) === lastEditablePosition + 1;
49
- });
50
- _defineProperty(this, "getDefaultSelectionForValue", function (value) {
51
- var _this$getRightEditabl;
52
- var filledLength = _this.getFilledLength(value);
53
- var cursorPosition = (_this$getRightEditabl = _this.getRightEditablePosition(filledLength)) !== null && _this$getRightEditabl !== void 0 ? _this$getRightEditabl : 0;
54
- return {
55
- start: cursorPosition,
56
- end: cursorPosition
57
- };
58
- });
59
- _defineProperty(this, "getFilledLength", function (value) {
60
- var characters = value.split('');
61
- var lastFilledIndex = findLastIndex(characters, function (character, position) {
62
- return _this.isPositionEditable(position) && _this.isCharacterFillingPosition(character, position);
63
- });
64
- return lastFilledIndex + 1;
65
- });
66
- _defineProperty(this, "getStringFillingLengthAtPosition", function (string, position) {
67
- var characters = string.split('');
68
- var insertedValue = characters.reduce(function (value, character) {
69
- return _this.insertCharacterAtPosition(value, character, value.length);
70
- }, repeat(' ', position));
71
- return insertedValue.length - position;
72
- });
73
- _defineProperty(this, "getLeftEditablePosition", function (position) {
74
- for (var i = position; i >= 0; i--) {
75
- if (_this.isPositionEditable(i)) {
76
- return i;
77
- }
78
- }
79
- return null;
80
- });
81
- _defineProperty(this, "getRightEditablePosition", function (position) {
82
- var mask = _this.maskOptions.mask;
83
- if (!mask) return null;
84
- for (var i = position; i < mask.length; i++) {
85
- if (_this.isPositionEditable(i)) {
86
- return i;
87
- }
88
- }
89
- return null;
90
- });
91
- _defineProperty(this, "getFirstEditablePosition", function () {
92
- return _this.getRightEditablePosition(0);
93
- });
94
- _defineProperty(this, "getLastEditablePosition", function () {
95
- return _this.maskOptions.lastEditablePosition;
96
- });
97
- /**
98
- * Gets all sections (groups of consecutive editable positions separated by permanents)
99
- * Returns an array of sections, where each section is an array of editable positions
100
- */
101
- _defineProperty(this, "getSections", function () {
102
- var mask = _this.maskOptions.mask;
103
- if (!mask) return [];
104
- var sections = [];
105
- var currentSection = [];
106
- for (var i = 0; i < mask.length; i++) {
107
- if (_this.isPositionEditable(i)) {
108
- currentSection.push(i);
109
- } else {
110
- // Permanent character - end current section and start new one
111
- if (currentSection.length > 0) {
112
- sections.push(currentSection);
113
- currentSection = [];
114
- }
115
- }
116
- }
117
- // Add the last section if it exists
118
- if (currentSection.length > 0) {
119
- sections.push(currentSection);
120
- }
121
- return sections;
122
- });
123
- /**
124
- * Finds which section a position belongs to
125
- * Returns the section index, or -1 if not found
126
- * @param position - The position to find the section for
127
- * @param sections - Optional pre-computed sections array to avoid recalculation
128
- */
129
- _defineProperty(this, "getSectionIndexForPosition", function (position, sections) {
130
- var sectionsToUse = sections !== null && sections !== void 0 ? sections : _this.getSections();
131
- for (var i = 0; i < sectionsToUse.length; i++) {
132
- if (sectionsToUse[i].includes(position)) {
133
- return i;
134
- }
135
- }
136
- return -1;
137
- });
138
- /**
139
- * Gets the first editable position of the next section
140
- * Returns null if already at the last section
141
- * If position is not in any section (e.g., at a permanent character), finds the next section after the position
142
- */
143
- _defineProperty(this, "getNextSectionFirstPosition", function (position) {
144
- var sections = _this.getSections();
145
- var sectionIndex = _this.getSectionIndexForPosition(position);
146
- // If position is not in any section (e.g., at a permanent character),
147
- // find the first section that starts after this position
148
- if (sectionIndex === -1) {
149
- for (var i = 0; i < sections.length; i++) {
150
- if (sections[i].length > 0 && sections[i][0] > position) {
151
- return sections[i][0];
152
- }
153
- }
154
- return null; // No section after this position
155
- }
156
- if (sectionIndex >= sections.length - 1) return null;
157
- var nextSection = sections[sectionIndex + 1];
158
- return nextSection.length > 0 ? nextSection[0] : null;
159
- });
160
- /**
161
- * Gets the first editable position of the previous section
162
- * Returns null if already at the first section
163
- * If position is not in any section (e.g., at a permanent character), finds the previous section before the position
164
- */
165
- _defineProperty(this, "getPreviousSectionFirstPosition", function (position) {
166
- var sections = _this.getSections();
167
- var sectionIndex = _this.getSectionIndexForPosition(position);
168
- // If position is not in any section (e.g., at a permanent character),
169
- // find the last section that ends before this position
170
- if (sectionIndex === -1) {
171
- for (var i = sections.length - 1; i >= 0; i--) {
172
- if (sections[i].length > 0 && sections[i][sections[i].length - 1] < position) {
173
- return sections[i][0];
174
- }
175
- }
176
- return null; // No section before this position
177
- }
178
- if (sectionIndex <= 0) return null;
179
- var previousSection = sections[sectionIndex - 1];
180
- return previousSection.length > 0 ? previousSection[0] : null;
181
- });
182
- /**
183
- * Gets the range (first and last positions) of a section
184
- * Returns null if position is not in any section
185
- * @param position - The position to find the section range for
186
- * @param sections - Optional pre-computed sections array to avoid recalculation
187
- */
188
- _defineProperty(this, "getSectionRange", function (position, sections) {
189
- var sectionsToUse = sections !== null && sections !== void 0 ? sections : _this.getSections();
190
- var sectionIndex = _this.getSectionIndexForPosition(position, sectionsToUse);
191
- if (sectionIndex === -1) return null;
192
- var section = sectionsToUse[sectionIndex];
193
- if (section.length === 0) return null;
194
- return {
195
- start: section[0],
196
- end: section[section.length - 1]
197
- };
198
- });
199
- _defineProperty(this, "formatValue", function (value) {
200
- var _this$maskOptions2 = _this.maskOptions,
201
- maskPlaceholder = _this$maskOptions2.maskPlaceholder,
202
- mask = _this$maskOptions2.mask;
203
- if (!mask) return value;
204
- if (!maskPlaceholder) {
205
- value = _this.insertStringAtPosition('', value, 0);
206
- while (value.length < mask.length && !_this.isPositionEditable(value.length)) {
207
- var char = mask[value.length];
208
- value += typeof char === 'string' ? char : '';
209
- }
210
- return value;
211
- }
212
- return _this.insertStringAtPosition(maskPlaceholder, value, 0);
213
- });
214
- _defineProperty(this, "clearRange", function (value, start, len) {
215
- if (!len) {
216
- return value;
217
- }
218
- var end = start + len;
219
- var _this$maskOptions3 = _this.maskOptions,
220
- maskPlaceholder = _this$maskOptions3.maskPlaceholder,
221
- mask = _this$maskOptions3.mask;
222
- if (!mask) return value;
223
- var clearedValue = value.split('').map(function (character, i) {
224
- var isEditable = _this.isPositionEditable(i);
225
- if (!maskPlaceholder && i >= end && !isEditable) {
226
- return '';
227
- }
228
- if (i < start || i >= end) {
229
- return character;
230
- }
231
- if (!isEditable) {
232
- var char = mask[i];
233
- return typeof char === 'string' ? char : '';
234
- }
235
- if (maskPlaceholder) {
236
- return maskPlaceholder[i];
237
- }
238
- return '';
239
- }).join('');
240
- return _this.formatValue(clearedValue);
241
- });
242
- _defineProperty(this, "insertCharacterAtPosition", function (value, character, position) {
243
- var _this$maskOptions4 = _this.maskOptions,
244
- mask = _this$maskOptions4.mask,
245
- maskPlaceholder = _this$maskOptions4.maskPlaceholder;
246
- if (!mask || position >= mask.length) {
247
- return value;
248
- }
249
- var isAllowed = _this.isCharacterAllowedAtPosition(character, position);
250
- var isEditable = _this.isPositionEditable(position);
251
- var nextEditablePosition = _this.getRightEditablePosition(position);
252
- var isNextPlaceholder = maskPlaceholder && nextEditablePosition !== null ? character === maskPlaceholder[nextEditablePosition] : null;
253
- var valueBefore = value.slice(0, position);
254
- if (isAllowed || !isEditable) {
255
- var insertedCharacter = isAllowed ? character : mask[position] && typeof mask[position] === 'string' ? mask[position] : '';
256
- value = valueBefore + insertedCharacter;
257
- }
258
- if (!isAllowed && !isEditable && !isNextPlaceholder) {
259
- value = _this.insertCharacterAtPosition(value, character, position + 1);
260
- }
261
- return value;
262
- });
263
- _defineProperty(this, "insertStringAtPosition", function (value, string, position) {
264
- var _this$maskOptions5 = _this.maskOptions,
265
- mask = _this$maskOptions5.mask,
266
- maskPlaceholder = _this$maskOptions5.maskPlaceholder;
267
- if (!mask || !string || position >= mask.length) {
268
- return value;
269
- }
270
- var characters = string.split('');
271
- var isFixedLength = _this.isValueFilled(value) || !!maskPlaceholder;
272
- var valueAfter = value.slice(position);
273
- value = characters.reduce(function (value, character) {
274
- return _this.insertCharacterAtPosition(value, character, value.length);
275
- }, value.slice(0, position));
276
- if (isFixedLength) {
277
- value += valueAfter.slice(value.length - position);
278
- } else if (_this.isValueFilled(value)) {
279
- var remainingMask = mask.slice(value.length).map(function (char) {
280
- return typeof char === 'string' ? char : '';
281
- }).join('');
282
- value += remainingMask;
283
- } else {
284
- var editableCharactersAfter = valueAfter.split('').filter(function (character, i) {
285
- return _this.isPositionEditable(position + i);
286
- });
287
- value = editableCharactersAfter.reduce(function (value, character) {
288
- var nextEditablePosition = _this.getRightEditablePosition(value.length);
289
- if (nextEditablePosition === null) {
290
- return value;
291
- }
292
- if (!_this.isPositionEditable(value.length)) {
293
- var maskSlice = mask.slice(value.length, nextEditablePosition).map(function (char) {
294
- return typeof char === 'string' ? char : '';
295
- }).join('');
296
- value += maskSlice;
297
- }
298
- return _this.insertCharacterAtPosition(value, character, value.length);
299
- }, value);
300
- }
301
- return value;
302
- });
303
- _defineProperty(this, "processChange", function (currentState, previousState) {
304
- var _previousSelection$st, _selection$start, _selection$end, _previousSelection$st2, _prefix$length;
305
- var _this$maskOptions6 = _this.maskOptions,
306
- mask = _this$maskOptions6.mask,
307
- prefix = _this$maskOptions6.prefix,
308
- lastEditablePosition = _this$maskOptions6.lastEditablePosition;
309
- if (!mask) return currentState;
310
- var value = currentState.value,
311
- selection = currentState.selection;
312
- var previousValue = previousState.value;
313
- var previousSelection = previousState.selection;
314
- var newValue = value;
315
- var enteredString = '';
316
- var formattedEnteredStringLength = 0;
317
- var removedLength = 0;
318
- var cursorPosition = Math.min((_previousSelection$st = previousSelection.start) !== null && _previousSelection$st !== void 0 ? _previousSelection$st : 0, (_selection$start = selection.start) !== null && _selection$start !== void 0 ? _selection$start : 0);
319
- if (((_selection$end = selection.end) !== null && _selection$end !== void 0 ? _selection$end : 0) > ((_previousSelection$st2 = previousSelection.start) !== null && _previousSelection$st2 !== void 0 ? _previousSelection$st2 : 0)) {
320
- var _previousSelection$st3, _selection$end2;
321
- enteredString = newValue.slice((_previousSelection$st3 = previousSelection.start) !== null && _previousSelection$st3 !== void 0 ? _previousSelection$st3 : 0, (_selection$end2 = selection.end) !== null && _selection$end2 !== void 0 ? _selection$end2 : 0);
322
- formattedEnteredStringLength = _this.getStringFillingLengthAtPosition(enteredString, cursorPosition);
323
- if (!formattedEnteredStringLength) {
324
- removedLength = 0;
325
- } else {
326
- var _previousSelection$en, _previousSelection$st4;
327
- removedLength = ((_previousSelection$en = previousSelection.end) !== null && _previousSelection$en !== void 0 ? _previousSelection$en : 0) - ((_previousSelection$st4 = previousSelection.start) !== null && _previousSelection$st4 !== void 0 ? _previousSelection$st4 : 0);
328
- }
329
- } else if (newValue.length < previousValue.length) {
330
- removedLength = previousValue.length - newValue.length;
331
- }
332
- newValue = previousValue;
333
- if (removedLength) {
334
- if (removedLength === 1 && !(previousSelection.end && previousSelection.start && previousSelection.end > previousSelection.start)) {
335
- var _previousSelection$st5, _selection$start2, _ref, _this$getRightEditabl2, _selection$start3, _ref2, _this$getLeftEditable, _selection$start4;
336
- var deleteFromRight = ((_previousSelection$st5 = previousSelection.start) !== null && _previousSelection$st5 !== void 0 ? _previousSelection$st5 : 0) === ((_selection$start2 = selection.start) !== null && _selection$start2 !== void 0 ? _selection$start2 : 0);
337
- cursorPosition = deleteFromRight ? (_ref = (_this$getRightEditabl2 = _this.getRightEditablePosition((_selection$start3 = selection.start) !== null && _selection$start3 !== void 0 ? _selection$start3 : 0)) !== null && _this$getRightEditabl2 !== void 0 ? _this$getRightEditabl2 : selection.start) !== null && _ref !== void 0 ? _ref : 0 : (_ref2 = (_this$getLeftEditable = _this.getLeftEditablePosition((_selection$start4 = selection.start) !== null && _selection$start4 !== void 0 ? _selection$start4 : 0)) !== null && _this$getLeftEditable !== void 0 ? _this$getLeftEditable : selection.start) !== null && _ref2 !== void 0 ? _ref2 : 0;
338
- }
339
- newValue = _this.clearRange(newValue, cursorPosition, removedLength);
340
- }
341
- newValue = _this.insertStringAtPosition(newValue, enteredString, cursorPosition);
342
- cursorPosition += formattedEnteredStringLength;
343
- if (cursorPosition >= mask.length) {
344
- cursorPosition = mask.length;
345
- } else if (prefix && cursorPosition < prefix.length && !formattedEnteredStringLength) {
346
- cursorPosition = prefix.length;
347
- } else if (lastEditablePosition !== null && cursorPosition >= ((_prefix$length = prefix === null || prefix === void 0 ? void 0 : prefix.length) !== null && _prefix$length !== void 0 ? _prefix$length : 0) && cursorPosition < lastEditablePosition && formattedEnteredStringLength) {
348
- var rightPos = _this.getRightEditablePosition(cursorPosition);
349
- if (rightPos !== null) {
350
- cursorPosition = rightPos;
351
- }
352
- }
353
- newValue = _this.formatValue(newValue);
354
- return {
355
- value: newValue,
356
- enteredString: enteredString,
357
- selection: {
358
- start: cursorPosition,
359
- end: cursorPosition
360
- }
361
- };
362
- });
363
- this.maskOptions = parseMask(options);
364
- });
365
-
366
- export default MaskUtils;
367
- //# sourceMappingURL=mask.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -1,7 +0,0 @@
1
- import { MaskOptions } from '../input_mask_types';
2
- export declare const parseMask: ({ mask, maskPlaceholder, formatChars }: {
3
- mask?: string | (string | RegExp)[] | undefined;
4
- maskPlaceholder?: string | undefined;
5
- formatChars?: Record<string, RegExp> | undefined;
6
- }) => MaskOptions;
7
- export default parseMask;
@@ -1,90 +0,0 @@
1
- import { objectSpread2 as _objectSpread2 } from '../../../../../../_virtual/_rollupPluginBabelHelpers.js';
2
- import { defaultFormatChars } from '../input-mask-constants.js';
3
-
4
- var parseMask = function parseMask(_ref) {
5
- var mask = _ref.mask,
6
- maskPlaceholder = _ref.maskPlaceholder,
7
- formatChars = _ref.formatChars;
8
- var permanents = [];
9
- var activeFormatChars = _objectSpread2(_objectSpread2({}, defaultFormatChars), formatChars);
10
- if (!mask) {
11
- return {
12
- maskPlaceholder: null,
13
- mask: null,
14
- prefix: null,
15
- lastEditablePosition: null,
16
- permanents: []
17
- };
18
- }
19
- var parsedMask;
20
- if (typeof mask === 'string') {
21
- var isPermanent = false;
22
- var parsedMaskString = '';
23
- mask.split('').forEach(function (character) {
24
- if (!isPermanent && character === '\\') {
25
- isPermanent = true;
26
- } else {
27
- if (isPermanent || !activeFormatChars[character]) {
28
- permanents.push(parsedMaskString.length);
29
- }
30
- parsedMaskString += character;
31
- isPermanent = false;
32
- }
33
- });
34
- parsedMask = parsedMaskString.split('').map(function (character, index) {
35
- if (permanents.indexOf(index) === -1) {
36
- return activeFormatChars[character] || character;
37
- }
38
- return character;
39
- });
40
- } else {
41
- parsedMask = mask;
42
- mask.forEach(function (character, index) {
43
- if (typeof character === 'string') {
44
- permanents.push(index);
45
- }
46
- });
47
- }
48
- var processedMaskPlaceholder = null;
49
- if (maskPlaceholder) {
50
- if (maskPlaceholder.length === 1) {
51
- processedMaskPlaceholder = parsedMask.map(function (character, index) {
52
- if (permanents.indexOf(index) !== -1) {
53
- return typeof character === 'string' ? character : '';
54
- }
55
- return maskPlaceholder;
56
- }).join('');
57
- } else {
58
- processedMaskPlaceholder = maskPlaceholder;
59
- }
60
- var placeholderChars = processedMaskPlaceholder.split('');
61
- permanents.forEach(function (position) {
62
- var maskChar = parsedMask[position];
63
- if (typeof maskChar === 'string') {
64
- placeholderChars[position] = maskChar;
65
- }
66
- });
67
- processedMaskPlaceholder = placeholderChars.join('');
68
- }
69
- var prefix = permanents.filter(function (position, index) {
70
- return position === index;
71
- }).map(function (position) {
72
- var char = parsedMask[position];
73
- return typeof char === 'string' ? char : '';
74
- }).join('');
75
- var lastEditablePosition = parsedMask.length - 1;
76
- while (permanents.indexOf(lastEditablePosition) !== -1) {
77
- lastEditablePosition--;
78
- }
79
- return {
80
- maskPlaceholder: processedMaskPlaceholder,
81
- prefix: prefix,
82
- mask: parsedMask,
83
- lastEditablePosition: lastEditablePosition,
84
- permanents: permanents
85
- };
86
- };
87
-
88
- export default parseMask;
89
- export { parseMask };
90
- //# sourceMappingURL=parse-mask.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -1,4 +0,0 @@
1
- import { InputMaskProps } from '../input_mask_types';
2
- export declare const validateMaxLength: (props: InputMaskProps) => void;
3
- export declare const validateMaskPlaceholder: (props: InputMaskProps) => void;
4
- export declare const validateChildren: (props: InputMaskProps, inputElement: React.ReactElement) => void;
@@ -1,31 +0,0 @@
1
- import { CONTROLLED_PROPS } from '../input-mask-constants.js';
2
-
3
- var validateMaxLength = function validateMaxLength(props) {
4
- if (process.env.NODE_ENV !== 'production') {
5
- if (props.maxLength && props.mask) {
6
- console.warn("maxLength property shouldn't be passed to the masked input. It breaks masking and unnecessary because length is limited by the mask length.");
7
- }
8
- }
9
- };
10
- var validateMaskPlaceholder = function validateMaskPlaceholder(props) {
11
- var mask = props.mask,
12
- maskPlaceholder = props.maskPlaceholder;
13
- if (!mask || !maskPlaceholder) {
14
- return;
15
- }
16
- var maskLength = typeof mask === 'string' ? mask.length : mask.length;
17
- if (maskPlaceholder.length !== 1 && maskPlaceholder.length !== maskLength) {
18
- throw new Error("maskPlaceholder should either be a single character or have the same length as the mask:\n" + "mask: ".concat(mask, "\n") + "maskPlaceholder: ".concat(maskPlaceholder));
19
- }
20
- };
21
- var validateChildren = function validateChildren(props, inputElement) {
22
- var conflictProps = CONTROLLED_PROPS.filter(function (propId) {
23
- return inputElement.props[propId] != null && inputElement.props[propId] !== props[propId];
24
- });
25
- if (conflictProps.length) {
26
- throw new Error("the following props should be passed to the InputMask component, not to children: ".concat(conflictProps.join(', ')));
27
- }
28
- };
29
-
30
- export { validateChildren, validateMaskPlaceholder, validateMaxLength };
31
- //# sourceMappingURL=validate-props.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}