infinity-forge 3.4.7 → 3.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/sites/components/default-pages/blog/components/blog-item/index.d.ts +1 -1
- package/dist/sites/components/default-pages/blog/components/blog-item/index.js +1 -1
- package/dist/sites/components/default-pages/blog/components/categorias/index.js +1 -1
- package/dist/sites/components/default-pages/blog/components/featured-blog/featured-blog-item/index.d.ts +4 -0
- package/dist/sites/components/default-pages/blog/components/featured-blog/featured-blog-item/index.js +42 -0
- package/dist/sites/components/default-pages/blog/components/featured-blog/index.js +1 -1
- package/dist/sites/components/default-pages/blog/components/side-box-newsletter/index.js +1 -1
- package/dist/sites/components/default-pages/blog/components/side-box-search/index.js +1 -1
- package/dist/sites/components/default-pages/blog/components/title-blog/index.js +1 -1
- package/dist/system/presentation/components/data/buttons/sidebar-button/index.js +1 -1
- package/dist/system/presentation/components/data/chat/card-message/index.d.ts +1 -1
- package/dist/system/presentation/components/data/chat/card-message/index.js +1 -1
- package/dist/system/presentation/components/data/chat/loader/index.js +1 -1
- package/dist/system/presentation/components/data/menu/components/menu-item/index.js +78 -0
- package/dist/system/presentation/components/data/menu/modes/collapsed-menu/index.js +43 -0
- package/dist/system/presentation/components/data/menu/modes/collapsed-menu/styles.js +15 -0
- package/dist/system/presentation/components/data/menu/modes/opened/index.js +50 -0
- package/dist/system/presentation/components/data/menu/modes/opened/styles.js +15 -0
- package/dist/system/presentation/components/data/notifications/card/index.d.ts +1 -1
- package/dist/system/presentation/components/data/notifications/card/index.js +1 -1
- package/dist/system/presentation/components/data/profile-infos/profile/index.js +1 -1
- package/dist/system/presentation/components/data/tab/tab-item/index.js +1 -1
- package/dist/system/presentation/components/layout/header/components/menu-right/component.d.ts +5 -0
- package/dist/system/presentation/components/layout/header/components/menu-right/component.js +34 -0
- package/dist/system/presentation/components/layout/header/components/menu-right/index.d.ts +3 -0
- package/dist/system/presentation/components/layout/header/components/menu-right/index.js +20 -0
- package/dist/system/presentation/components/layout/header/components/menu-right/messages/content/card/index.d.ts +0 -2
- package/dist/system/presentation/components/layout/header/components/menu-right/messages/content/card/index.js +0 -47
- package/dist/system/presentation/components/layout/header/components/menu-right/messages/content/index.js +0 -92
- package/dist/system/presentation/components/layout/header/components/menu-right/messages/content/interfaces.d.ts +0 -6
- package/dist/system/presentation/components/layout/header/components/menu-right/messages/index.js +0 -36
- package/dist/system/presentation/components/layout/header/components/menu-right/profile/content/index.js +0 -36
- package/dist/system/presentation/components/layout/header/components/menu-right/profile/index.js +0 -38
- package/dist/system/presentation/components/layout/header/components/search-modal/index.js +40 -0
- package/dist/system/presentation/components/layout/header/components/search-modal/search-list/index.js +0 -52
- package/dist/system/presentation/components/layout/header/components/search-modal/trigger/index.js +0 -45
- package/dist/system/presentation/components/layout/header/version-01/index.js +1 -1
- package/dist/system/presentation/components/pages/menus/table/columns.d.ts +1 -1
- package/dist/system/presentation/components/pages/menus/table/create.d.ts +1 -1
- package/dist/system/presentation/components/pages/menus/table/create.js +1 -1
- package/dist/system/presentation/components/pages/menus/table/delete.js +1 -1
- package/dist/system/presentation/components/pages/menus/table/edit.d.ts +1 -1
- package/dist/system/presentation/components/pages/menus/table/edit.js +1 -0
- package/dist/system/presentation/components/pages/menus/table/icon/index.js +34 -0
- package/dist/system/presentation/components/pages/users/table/columns.d.ts +1 -1
- package/dist/system/presentation/components/pages/users/table/create.d.ts +1 -1
- package/dist/system/presentation/components/pages/users/table/create.js +1 -1
- package/dist/system/presentation/components/pages/users/table/delete.js +1 -1
- package/dist/system/presentation/components/pages/users/table/edit.d.ts +1 -1
- package/dist/system/presentation/components/pages/users/table/edit.js +1 -0
- package/dist/system/presentation/context/auth/components/login/form-login/index.js +12 -0
- package/dist/system/presentation/context/auth/components/login/index.js +1 -1
- package/dist/system/presentation/context/auth/components/private-page/index.js +1 -1
- package/dist/system/presentation/hooks/locales/ibge/use-load-cities-by-uf/index.d.ts +1 -1
- package/dist/system/presentation/hooks/locales/ibge/use-load-cities-by-uf/index.js +1 -1
- package/dist/system/presentation/hooks/ui/use-table/components/table/actions/delete/index.d.ts +0 -5
- package/dist/system/presentation/hooks/ui/use-table/components/table/actions/delete/index.js +0 -80
- package/dist/system/presentation/hooks/ui/use-table/components/table/actions/index.d.ts +0 -5
- package/dist/system/presentation/hooks/ui/use-table/components/table/actions/index.js +0 -111
- package/dist/system/presentation/hooks/ui/use-table/components/table/active-filters/index.d.ts +0 -2
- package/dist/system/presentation/hooks/ui/use-table/components/table/active-filters/index.js +0 -78
- package/dist/system/presentation/hooks/ui/use-table/components/table/create/index.d.ts +0 -4
- package/dist/system/presentation/hooks/ui/use-table/components/table/create/index.js +0 -60
- package/dist/system/presentation/hooks/ui/use-table/components/table/export/index.d.ts +0 -4
- package/dist/system/presentation/hooks/ui/use-table/components/table/export/index.js +0 -35
- package/dist/system/presentation/hooks/ui/use-table/components/table/filters/index.d.ts +0 -2
- package/dist/system/presentation/hooks/ui/use-table/components/table/filters/index.js +0 -144
- package/dist/system/presentation/hooks/ui/use-table/components/table/index.d.ts +2 -0
- package/dist/system/presentation/hooks/ui/use-table/components/table/index.js +105 -0
- package/dist/system/presentation/hooks/ui/use-table/components/table/interfaces.d.ts +14 -0
- package/dist/system/presentation/hooks/ui/use-table/components/table/pagination/index.d.ts +0 -2
- package/dist/system/presentation/hooks/ui/use-table/components/table/pagination/index.js +0 -56
- package/dist/system/presentation/hooks/ui/use-table/components/table/skeleton-table/index.js +0 -34
- package/dist/system/presentation/hooks/ui/use-table/components/table/thead-item/index.d.ts +0 -2
- package/dist/system/presentation/hooks/ui/use-table/components/table/thead-item/index.js +0 -50
- package/dist/system/presentation/hooks/ui/use-table/components/table/thead-item/interfaces.d.ts +0 -6
- package/dist/system/presentation/hooks/ui/use-table/query/hook.js +1 -1
- package/dist/ui/components/carousel/carousel-lib/core/modules/observer/observer.js +2 -2
- package/dist/ui/components/carousel/carousel-lib/core/modules/resize/resize.js +1 -1
- package/dist/ui/components/form/input-cep/use-cep/providers/ibge/hook.d.ts +1 -1
- package/dist/ui/components/form/input-cep/use-cep/providers/ibge/hook.js +1 -1
- package/dist/ui/components/form/input-cep/use-cep/providers/ibge/index.d.ts +3 -3
- package/dist/ui/components/form/input-cep/use-cep/providers/ibge/index.js +3 -3
- package/dist/ui/components/form/input-date-picker/calendar/calendar-header/index.js +62 -0
- package/dist/ui/components/form/input-date-picker/calendar/days/index.d.ts +2 -0
- package/dist/ui/components/form/input-date-picker/calendar/days/index.js +87 -0
- package/dist/ui/components/form/input-date-picker/calendar/months/index.d.ts +2 -0
- package/dist/ui/components/form/input-date-picker/calendar/months/index.js +66 -0
- package/dist/ui/components/form/input-file/render-files/file-item/button-upload-image-mobile/index.d.ts +0 -13
- package/dist/ui/components/form/input-file/render-files/file-item/button-upload-image-mobile/index.js +0 -18
- package/dist/ui/components/form/input-file/render-files/file-item/index.d.ts +3 -0
- package/dist/ui/components/form/input-file/render-files/file-item/index.js +49 -0
- package/dist/ui/components/form/input-mask/lib/core/errors/SyntheticChangeError.d.ts +0 -14
- package/dist/ui/components/form/input-mask/lib/core/hooks/useInput.d.ts +0 -10
- package/dist/ui/components/form/input-mask/lib/core/hooks/useInput.js +0 -204
- package/dist/ui/components/form/input-mask/lib/core/index.d.ts +5 -0
- package/dist/ui/components/form/input-mask/lib/core/index.js +15 -0
- package/dist/ui/components/form/input-mask/lib/core/utils/setInputAttributes.d.ts +0 -2
- package/dist/ui/components/form/input-mask/lib/mask/InputMask.d.ts +6 -0
- package/dist/ui/components/form/input-mask/lib/mask/InputMask.js +44 -0
- package/dist/ui/components/form/input-mask/lib/mask/index.d.ts +5 -0
- package/dist/ui/components/form/input-mask/lib/mask/index.js +26 -0
- package/dist/ui/components/form/input-mask/lib/mask/types.d.ts +61 -0
- package/dist/ui/components/form/input-mask/lib/mask/useMask.d.ts +3 -0
- package/dist/ui/components/form/input-mask/lib/mask/useMask.js +150 -0
- package/dist/ui/components/form/input-mask/lib/mask/utils/filter.d.ts +0 -14
- package/dist/ui/components/form/input-mask/lib/mask/utils/format.d.ts +0 -14
- package/dist/ui/components/form/input-mask/lib/mask/utils/formatToParts.d.ts +0 -17
- package/dist/ui/components/form/input-mask/lib/mask/utils/formatToReplacementObject.d.ts +0 -2
- package/dist/ui/components/form/input-mask/lib/mask/utils/resolveDetail.d.ts +0 -14
- package/dist/ui/components/form/input-mask/lib/mask/utils/resolveDetail.js +0 -25
- package/dist/ui/components/form/input-mask/lib/mask/utils/resolveSelection.d.ts +0 -18
- package/dist/ui/components/form/input-mask/lib/mask/utils/unformat.d.ts +0 -16
- package/dist/ui/components/form/input-mask/lib/mask/utils/validate.d.ts +0 -13
- package/dist/ui/components/form/input-mask/lib/mask/utils.d.ts +63 -0
- package/dist/ui/components/form/input-mask/lib/mask/utils.js +114 -0
- package/dist/ui/components/form/input-mask/lib/number-format/InputNumberFormat.d.ts +6 -0
- package/dist/ui/components/form/input-mask/lib/number-format/InputNumberFormat.js +58 -0
- package/dist/ui/components/form/input-mask/lib/number-format/index.d.ts +4 -0
- package/dist/ui/components/form/input-mask/lib/number-format/index.js +11 -0
- package/dist/ui/components/form/input-mask/lib/number-format/types.d.ts +26 -0
- package/dist/ui/components/form/input-mask/lib/number-format/useNumberFormat.d.ts +3 -0
- package/dist/ui/components/form/input-mask/lib/number-format/useNumberFormat.js +208 -0
- package/dist/ui/components/form/input-mask/lib/number-format/utils/localizeValues.d.ts +0 -7
- package/dist/ui/components/form/input-mask/lib/number-format/utils/resolveDetail.d.ts +0 -20
- package/dist/ui/components/form/input-mask/lib/number-format/utils/resolveDetail.js +0 -123
- package/dist/ui/components/form/input-mask/lib/number-format/utils/resolveMinimumFractionDigits.d.ts +0 -11
- package/dist/ui/components/form/input-mask/lib/number-format/utils/resolveOptions.d.ts +0 -5
- package/dist/ui/components/form/input-mask/lib/number-format/utils/resolveSelection.d.ts +0 -24
- package/dist/ui/components/form/input-seo/input-meta-image/index.d.ts +1 -1
- package/dist/ui/components/form/input-seo/input-meta-image/index.js +1 -1
- package/dist/ui/components/menu-mobile/components/nav-links/index.js +1 -1
- package/package.json +1 -1
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { Replacement } from '../types';
|
|
2
|
-
interface Options {
|
|
3
|
-
start?: number;
|
|
4
|
-
end?: number;
|
|
5
|
-
mask: string;
|
|
6
|
-
replacement: Replacement;
|
|
7
|
-
separate: boolean;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
*
|
|
11
|
-
* @param formattedValue
|
|
12
|
-
* @param options
|
|
13
|
-
* @returns
|
|
14
|
-
*/
|
|
15
|
-
export default function unformat(formattedValue: string, { start, end, mask, replacement, separate }: Options): string;
|
|
16
|
-
export {};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Replacement } from '../types';
|
|
2
|
-
interface ValidateParam {
|
|
3
|
-
initialValue: string;
|
|
4
|
-
mask: string;
|
|
5
|
-
replacement: Replacement;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Выводит в консоль сообщения об ошибках.
|
|
9
|
-
* Сообщения выводятся на этапе инициализации элеменета.
|
|
10
|
-
* @param param
|
|
11
|
-
*/
|
|
12
|
-
export default function validate({ initialValue, mask, replacement }: ValidateParam): void;
|
|
13
|
-
export {};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { MaskPart, Replacement } from './types.js';
|
|
2
|
+
interface Options {
|
|
3
|
+
mask: string;
|
|
4
|
+
replacement: string | Replacement;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Masks a value using the specified mask (see «[Utils](https://github.com/GoncharukBro/react-input/tree/main/packages/mask#format)»).
|
|
8
|
+
*
|
|
9
|
+
* The result fully corresponds to the value obtained when entering.
|
|
10
|
+
* Useful when you need to get a masked value without calling an input event.
|
|
11
|
+
*
|
|
12
|
+
* Since the principle of operation of `InputMask` is fully consistent with the operation
|
|
13
|
+
* of the `input` element, `InputMask` will not change the value outside the input event, so
|
|
14
|
+
* you may find yourself in a situation where the `input` element will have a value that does not
|
|
15
|
+
* correspond to the mask, for example when initializing the value of the received from the backend.
|
|
16
|
+
*
|
|
17
|
+
* `format('1', { mask: '+__', replacement: { _: /\d/ } })` → "+1"
|
|
18
|
+
*/
|
|
19
|
+
export declare function format(value: string, { mask, replacement }: Options): string;
|
|
20
|
+
/**
|
|
21
|
+
* Unmasks the value using the specified mask (see «[Utils](https://github.com/GoncharukBro/react-input/tree/main/packages/mask#unformat)»).
|
|
22
|
+
*
|
|
23
|
+
* Returns all characters entered by the user. Essentially does the opposite of the `format` utility.
|
|
24
|
+
*
|
|
25
|
+
* `unformat('+1_', { mask: '+__', replacement: { _: /\d/ } })` → "1"
|
|
26
|
+
*/
|
|
27
|
+
export declare function unformat(formattedValue: string, { mask, replacement }: Options): string;
|
|
28
|
+
/**
|
|
29
|
+
* Specifies the parts of the masked value (see «[Utils](https://github.com/GoncharukBro/react-input/tree/main/packages/mask#formattoparts)»).
|
|
30
|
+
*
|
|
31
|
+
* The masked value parts are an array of objects, where each object contains the
|
|
32
|
+
* necessary information about each character of the value. Parts of the masked value
|
|
33
|
+
* are used to manipulate a character or group of characters in a point-by-point manner.
|
|
34
|
+
*
|
|
35
|
+
* Parts of the masked value, where each object contains the character type:
|
|
36
|
+
* - `replacement` - the replacement character;
|
|
37
|
+
* - `mask` - the mask character;
|
|
38
|
+
* - `input` - the character entered by the user.
|
|
39
|
+
*
|
|
40
|
+
* `formatToParts('1', { mask: '+__', replacement: { _: /\d/ } })` →
|
|
41
|
+
* ```
|
|
42
|
+
* [
|
|
43
|
+
* { index: 0, value: '+', type: 'mask' },
|
|
44
|
+
* { index: 1, value: '1', type: 'input' },
|
|
45
|
+
* { index: 2, value: '_', type: 'replacement' },
|
|
46
|
+
* ]
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare function formatToParts(value: string, { mask, replacement }: Options): MaskPart[];
|
|
50
|
+
/**
|
|
51
|
+
* Generates a regular expression to match a masked value (see «[Utils](https://github.com/GoncharukBro/react-input/tree/main/packages/mask#generatepattern)»).
|
|
52
|
+
*
|
|
53
|
+
* If `takeReplacementKey: true`, then the regular expression search will not take into account the
|
|
54
|
+
* `replacement` parameter key, that is, the character at the index of the replacement character in the
|
|
55
|
+
* value can be any character corresponding to the `replacement` value except the `replacement` key itself.
|
|
56
|
+
*
|
|
57
|
+
* So, if `mask: '_'` and `replacement: { _: /\D/ }` then:
|
|
58
|
+
* - if `takeReplacementKey: false`, the regular expression (pattern) will match `/^(\D)$/` and `RegExp(pattern).test(mask)` will return `true`;
|
|
59
|
+
* - if `takeReplacementKey: true`, the regular expression (pattern) will match `/^(?!_)(\D)$/` and `RegExp(pattern).test(mask)` will return `false`,
|
|
60
|
+
* but any a valid character, in addition to the replacement character, will contribute to the return of `true`.
|
|
61
|
+
*/
|
|
62
|
+
export declare function generatePattern({ mask, replacement }: Options, takeReplacementKey?: boolean): string;
|
|
63
|
+
export {};
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.generatePattern = exports.formatToParts = exports.unformat = exports.format = void 0;
|
|
7
|
+
var filter_1 = __importDefault(require("./utils/filter.js"));
|
|
8
|
+
var format_1 = __importDefault(require("./utils/format.js"));
|
|
9
|
+
var formatToParts_1 = __importDefault(require("./utils/formatToParts.js"));
|
|
10
|
+
var formatToReplacementObject_1 = __importDefault(require("./utils/formatToReplacementObject.js"));
|
|
11
|
+
var unformat_1 = __importDefault(require("./utils/unformat.js"));
|
|
12
|
+
/**
|
|
13
|
+
* Masks a value using the specified mask (see «[Utils](https://github.com/GoncharukBro/react-input/tree/main/packages/mask#format)»).
|
|
14
|
+
*
|
|
15
|
+
* The result fully corresponds to the value obtained when entering.
|
|
16
|
+
* Useful when you need to get a masked value without calling an input event.
|
|
17
|
+
*
|
|
18
|
+
* Since the principle of operation of `InputMask` is fully consistent with the operation
|
|
19
|
+
* of the `input` element, `InputMask` will not change the value outside the input event, so
|
|
20
|
+
* you may find yourself in a situation where the `input` element will have a value that does not
|
|
21
|
+
* correspond to the mask, for example when initializing the value of the received from the backend.
|
|
22
|
+
*
|
|
23
|
+
* `format('1', { mask: '+__', replacement: { _: /\d/ } })` → "+1"
|
|
24
|
+
*/
|
|
25
|
+
function format(value, _a) {
|
|
26
|
+
var mask = _a.mask, replacement = _a.replacement;
|
|
27
|
+
var replacementObject = typeof replacement === 'string' ? (0, formatToReplacementObject_1.default)(replacement) : replacement;
|
|
28
|
+
var regExp$1 = RegExp("[^".concat(Object.keys(replacementObject).join(''), "]"), 'g');
|
|
29
|
+
var replacementChars = mask.replace(regExp$1, '');
|
|
30
|
+
var input = (0, filter_1.default)(value, { replacementChars: replacementChars, replacement: replacementObject, separate: false });
|
|
31
|
+
return (0, format_1.default)(input, { mask: mask, replacement: replacementObject, showMask: false });
|
|
32
|
+
}
|
|
33
|
+
exports.format = format;
|
|
34
|
+
/**
|
|
35
|
+
* Unmasks the value using the specified mask (see «[Utils](https://github.com/GoncharukBro/react-input/tree/main/packages/mask#unformat)»).
|
|
36
|
+
*
|
|
37
|
+
* Returns all characters entered by the user. Essentially does the opposite of the `format` utility.
|
|
38
|
+
*
|
|
39
|
+
* `unformat('+1_', { mask: '+__', replacement: { _: /\d/ } })` → "1"
|
|
40
|
+
*/
|
|
41
|
+
function unformat(formattedValue, _a) {
|
|
42
|
+
var mask = _a.mask, replacement = _a.replacement;
|
|
43
|
+
var replacementObject = typeof replacement === 'string' ? (0, formatToReplacementObject_1.default)(replacement) : replacement;
|
|
44
|
+
var value = (0, unformat_1.default)(formattedValue, { mask: mask, replacement: replacementObject, separate: false });
|
|
45
|
+
var regExp$1 = RegExp("[^".concat(Object.keys(replacementObject).join(''), "]"), 'g');
|
|
46
|
+
var replacementChars = mask.replace(regExp$1, '');
|
|
47
|
+
return (0, filter_1.default)(value, { replacementChars: replacementChars, replacement: replacementObject, separate: false });
|
|
48
|
+
}
|
|
49
|
+
exports.unformat = unformat;
|
|
50
|
+
/**
|
|
51
|
+
* Specifies the parts of the masked value (see «[Utils](https://github.com/GoncharukBro/react-input/tree/main/packages/mask#formattoparts)»).
|
|
52
|
+
*
|
|
53
|
+
* The masked value parts are an array of objects, where each object contains the
|
|
54
|
+
* necessary information about each character of the value. Parts of the masked value
|
|
55
|
+
* are used to manipulate a character or group of characters in a point-by-point manner.
|
|
56
|
+
*
|
|
57
|
+
* Parts of the masked value, where each object contains the character type:
|
|
58
|
+
* - `replacement` - the replacement character;
|
|
59
|
+
* - `mask` - the mask character;
|
|
60
|
+
* - `input` - the character entered by the user.
|
|
61
|
+
*
|
|
62
|
+
* `formatToParts('1', { mask: '+__', replacement: { _: /\d/ } })` →
|
|
63
|
+
* ```
|
|
64
|
+
* [
|
|
65
|
+
* { index: 0, value: '+', type: 'mask' },
|
|
66
|
+
* { index: 1, value: '1', type: 'input' },
|
|
67
|
+
* { index: 2, value: '_', type: 'replacement' },
|
|
68
|
+
* ]
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
function formatToParts(value, _a) {
|
|
72
|
+
var mask = _a.mask, replacement = _a.replacement;
|
|
73
|
+
var replacementObject = typeof replacement === 'string' ? (0, formatToReplacementObject_1.default)(replacement) : replacement;
|
|
74
|
+
var formattedValue = format(value, { mask: mask, replacement: replacementObject });
|
|
75
|
+
return (0, formatToParts_1.default)(formattedValue, { mask: mask, replacement: replacementObject });
|
|
76
|
+
}
|
|
77
|
+
exports.formatToParts = formatToParts;
|
|
78
|
+
/**
|
|
79
|
+
* Generates a regular expression to match a masked value (see «[Utils](https://github.com/GoncharukBro/react-input/tree/main/packages/mask#generatepattern)»).
|
|
80
|
+
*
|
|
81
|
+
* If `takeReplacementKey: true`, then the regular expression search will not take into account the
|
|
82
|
+
* `replacement` parameter key, that is, the character at the index of the replacement character in the
|
|
83
|
+
* value can be any character corresponding to the `replacement` value except the `replacement` key itself.
|
|
84
|
+
*
|
|
85
|
+
* So, if `mask: '_'` and `replacement: { _: /\D/ }` then:
|
|
86
|
+
* - if `takeReplacementKey: false`, the regular expression (pattern) will match `/^(\D)$/` and `RegExp(pattern).test(mask)` will return `true`;
|
|
87
|
+
* - if `takeReplacementKey: true`, the regular expression (pattern) will match `/^(?!_)(\D)$/` and `RegExp(pattern).test(mask)` will return `false`,
|
|
88
|
+
* but any a valid character, in addition to the replacement character, will contribute to the return of `true`.
|
|
89
|
+
*/
|
|
90
|
+
function generatePattern(_a, takeReplacementKey) {
|
|
91
|
+
var mask = _a.mask, replacement = _a.replacement;
|
|
92
|
+
if (takeReplacementKey === void 0) { takeReplacementKey = false; }
|
|
93
|
+
var replacementObject = typeof replacement === 'string' ? (0, formatToReplacementObject_1.default)(replacement) : replacement;
|
|
94
|
+
var special = ['[', ']', '\\', '/', '^', '$', '.', '|', '?', '*', '+', '(', ')', '{', '}'];
|
|
95
|
+
var pattern = '';
|
|
96
|
+
for (var i = 0; i < mask.length; i++) {
|
|
97
|
+
var isReplacementKey = Object.prototype.hasOwnProperty.call(replacementObject, mask[i]);
|
|
98
|
+
var lookahead = takeReplacementKey ? "(?!".concat(mask[i], ")") : '';
|
|
99
|
+
if (i === 0) {
|
|
100
|
+
pattern += '^';
|
|
101
|
+
}
|
|
102
|
+
pattern += isReplacementKey
|
|
103
|
+
? "".concat(lookahead, "(").concat(replacementObject[mask[i]].toString().slice(1, -1), ")")
|
|
104
|
+
: special.includes(mask[i])
|
|
105
|
+
? "\\".concat(mask[i])
|
|
106
|
+
: mask[i];
|
|
107
|
+
if (i === mask.length - 1) {
|
|
108
|
+
pattern += '$';
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return pattern;
|
|
112
|
+
}
|
|
113
|
+
exports.generatePattern = generatePattern;
|
|
114
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { NumberFormatProps } from './types.js';
|
|
3
|
+
import type { InputComponent, InputComponentProps } from '../core/index.js';
|
|
4
|
+
export type InputNumberFormatProps<C extends React.ComponentType | undefined = undefined> = NumberFormatProps & InputComponentProps<C>;
|
|
5
|
+
declare const InputNumberFormat: InputComponent<NumberFormatProps>;
|
|
6
|
+
export default InputNumberFormat;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
|
+
var t = {};
|
|
15
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
16
|
+
t[p] = s[p];
|
|
17
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20
|
+
t[p[i]] = s[p[i]];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
24
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
25
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
|
+
};
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
29
|
+
var react_1 = require("react");
|
|
30
|
+
var core_1 = require("../core/index.js");
|
|
31
|
+
var useNumberFormat_1 = __importDefault(require("./useNumberFormat.js"));
|
|
32
|
+
function ForwardedInputNumberFormat(_a, forwardedInputRef) {
|
|
33
|
+
var Component = _a.component, locales = _a.locales, format = _a.format, currency = _a.currency, currencyDisplay = _a.currencyDisplay, unit = _a.unit, unitDisplay = _a.unitDisplay, signDisplay = _a.signDisplay, groupDisplay = _a.groupDisplay, minimumIntegerDigits = _a.minimumIntegerDigits, maximumIntegerDigits = _a.maximumIntegerDigits, minimumFractionDigits = _a.minimumFractionDigits, maximumFractionDigits = _a.maximumFractionDigits, onNumberFormat = _a.onNumberFormat, props = __rest(_a, ["component", "locales", "format", "currency", "currencyDisplay", "unit", "unitDisplay", "signDisplay", "groupDisplay", "minimumIntegerDigits", "maximumIntegerDigits", "minimumFractionDigits", "maximumFractionDigits", "onNumberFormat"]);
|
|
34
|
+
var inputRef = (0, useNumberFormat_1.default)({
|
|
35
|
+
locales: locales,
|
|
36
|
+
format: format,
|
|
37
|
+
currency: currency,
|
|
38
|
+
currencyDisplay: currencyDisplay,
|
|
39
|
+
unit: unit,
|
|
40
|
+
unitDisplay: unitDisplay,
|
|
41
|
+
signDisplay: signDisplay,
|
|
42
|
+
groupDisplay: groupDisplay,
|
|
43
|
+
minimumIntegerDigits: minimumIntegerDigits,
|
|
44
|
+
maximumIntegerDigits: maximumIntegerDigits,
|
|
45
|
+
minimumFractionDigits: minimumFractionDigits,
|
|
46
|
+
maximumFractionDigits: maximumFractionDigits,
|
|
47
|
+
onNumberFormat: onNumberFormat,
|
|
48
|
+
});
|
|
49
|
+
var connectedInputRef = (0, core_1.useConnectedInputRef)(inputRef, forwardedInputRef);
|
|
50
|
+
if (Component) {
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
52
|
+
return (0, jsx_runtime_1.jsx)(Component, __assign({ ref: connectedInputRef }, props));
|
|
53
|
+
}
|
|
54
|
+
return (0, jsx_runtime_1.jsx)("input", __assign({ ref: connectedInputRef }, props));
|
|
55
|
+
}
|
|
56
|
+
var InputNumberFormat = (0, react_1.forwardRef)(ForwardedInputNumberFormat);
|
|
57
|
+
exports.default = InputNumberFormat;
|
|
58
|
+
//# sourceMappingURL=InputNumberFormat.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { default as InputNumberFormat } from './InputNumberFormat.js';
|
|
2
|
+
export { default as useNumberFormat } from './useNumberFormat.js';
|
|
3
|
+
export type { InputNumberFormatProps } from './InputNumberFormat.js';
|
|
4
|
+
export type { NumberFormatProps, NumberFormatEvent, NumberFormatEventDetail, NumberFormatEventHandler } from './types.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.useNumberFormat = exports.InputNumberFormat = void 0;
|
|
7
|
+
var InputNumberFormat_1 = require("./InputNumberFormat.js");
|
|
8
|
+
Object.defineProperty(exports, "InputNumberFormat", { enumerable: true, get: function () { return __importDefault(InputNumberFormat_1).default; } });
|
|
9
|
+
var useNumberFormat_1 = require("./useNumberFormat.js");
|
|
10
|
+
Object.defineProperty(exports, "useNumberFormat", { enumerable: true, get: function () { return __importDefault(useNumberFormat_1).default; } });
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { CustomInputEvent, CustomInputEventHandler } from '../core/index.js';
|
|
2
|
+
export interface NumberFormatEventDetail {
|
|
3
|
+
value: string;
|
|
4
|
+
number: number;
|
|
5
|
+
}
|
|
6
|
+
export type NumberFormatEvent = CustomInputEvent<NumberFormatEventDetail>;
|
|
7
|
+
export type NumberFormatEventHandler = CustomInputEventHandler<NumberFormatEvent>;
|
|
8
|
+
type ResolveOptions<T extends Record<string, any>> = Pick<T, 'currency' | 'currencyDisplay' | 'unit' | 'unitDisplay' | 'signDisplay' | 'minimumIntegerDigits' | 'minimumFractionDigits' | 'maximumFractionDigits'>;
|
|
9
|
+
interface IncludedOptions {
|
|
10
|
+
format?: Intl.NumberFormatOptions['style'];
|
|
11
|
+
groupDisplay?: Intl.NumberFormatOptions['useGrouping'];
|
|
12
|
+
maximumIntegerDigits?: number;
|
|
13
|
+
}
|
|
14
|
+
export type NumberFormatOptions = ResolveOptions<Intl.NumberFormatOptions> & IncludedOptions;
|
|
15
|
+
export type ResolvedNumberFormatOptions = ResolveOptions<Intl.ResolvedNumberFormatOptions> & Required<IncludedOptions>;
|
|
16
|
+
export interface LocalizedNumberFormatValues {
|
|
17
|
+
signBackwards: boolean;
|
|
18
|
+
minusSign: string;
|
|
19
|
+
decimal: string;
|
|
20
|
+
digits: string;
|
|
21
|
+
}
|
|
22
|
+
export interface NumberFormatProps extends NumberFormatOptions {
|
|
23
|
+
locales?: string | string[];
|
|
24
|
+
onNumberFormat?: NumberFormatEventHandler;
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { NumberFormatProps } from './types.js';
|
|
3
|
+
export default function useNumberFormat({ locales, format, currency, currencyDisplay, unit, unitDisplay, signDisplay, groupDisplay, minimumIntegerDigits, maximumIntegerDigits, minimumFractionDigits, maximumFractionDigits, onNumberFormat, }?: NumberFormatProps): React.MutableRefObject<HTMLInputElement | null>;
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var react_1 = require("react");
|
|
7
|
+
var core_1 = require("../core/index.js");
|
|
8
|
+
var localizeValues_1 = __importDefault(require("./utils/localizeValues.js"));
|
|
9
|
+
var resolveDetail_1 = __importDefault(require("./utils/resolveDetail.js"));
|
|
10
|
+
var resolveMinimumFractionDigits_1 = __importDefault(require("./utils/resolveMinimumFractionDigits.js"));
|
|
11
|
+
var resolveOptions_1 = __importDefault(require("./utils/resolveOptions.js"));
|
|
12
|
+
var resolveSelection_1 = __importDefault(require("./utils/resolveSelection.js"));
|
|
13
|
+
function useNumberFormat(_a) {
|
|
14
|
+
var _b = _a === void 0 ? {} : _a, locales = _b.locales, format = _b.format, currency = _b.currency, currencyDisplay = _b.currencyDisplay, unit = _b.unit, unitDisplay = _b.unitDisplay, signDisplay = _b.signDisplay, groupDisplay = _b.groupDisplay, minimumIntegerDigits = _b.minimumIntegerDigits, maximumIntegerDigits = _b.maximumIntegerDigits, minimumFractionDigits = _b.minimumFractionDigits, maximumFractionDigits = _b.maximumFractionDigits,
|
|
15
|
+
// minimumSignificantDigits,
|
|
16
|
+
// maximumSignificantDigits,
|
|
17
|
+
onNumberFormat = _b.onNumberFormat;
|
|
18
|
+
var options = {
|
|
19
|
+
format: format,
|
|
20
|
+
currency: currency,
|
|
21
|
+
currencyDisplay: currencyDisplay,
|
|
22
|
+
unit: unit,
|
|
23
|
+
unitDisplay: unitDisplay,
|
|
24
|
+
signDisplay: signDisplay,
|
|
25
|
+
groupDisplay: groupDisplay,
|
|
26
|
+
minimumIntegerDigits: minimumIntegerDigits,
|
|
27
|
+
maximumIntegerDigits: maximumIntegerDigits,
|
|
28
|
+
minimumFractionDigits: minimumFractionDigits,
|
|
29
|
+
maximumFractionDigits: maximumFractionDigits,
|
|
30
|
+
// minimumSignificantDigits,
|
|
31
|
+
// maximumSignificantDigits,
|
|
32
|
+
};
|
|
33
|
+
var cache = (0, react_1.useRef)(null);
|
|
34
|
+
/**
|
|
35
|
+
*
|
|
36
|
+
* Init
|
|
37
|
+
*
|
|
38
|
+
*/
|
|
39
|
+
var init = function (_a) {
|
|
40
|
+
var initialValue = _a.initialValue;
|
|
41
|
+
var _b = (0, resolveOptions_1.default)(locales, options), current = _b.current, resolved = _b.resolved;
|
|
42
|
+
var invalidType = current.maximumIntegerDigits !== undefined && typeof current.maximumIntegerDigits !== 'number';
|
|
43
|
+
var invalidRange = typeof current.maximumIntegerDigits === 'number' && current.maximumIntegerDigits < resolved.minimumIntegerDigits;
|
|
44
|
+
if (invalidType || invalidRange) {
|
|
45
|
+
throw new RangeError('maximumIntegerDigits value is out of range.');
|
|
46
|
+
}
|
|
47
|
+
var cachedProps = { locales: locales, options: options };
|
|
48
|
+
cache.current = { value: initialValue, props: cachedProps, fallbackProps: cachedProps };
|
|
49
|
+
return { value: initialValue };
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
*
|
|
53
|
+
* Tracking
|
|
54
|
+
*
|
|
55
|
+
*/
|
|
56
|
+
var tracking = function (_a) {
|
|
57
|
+
var inputType = _a.inputType, previousValue = _a.previousValue, addedValue = _a.addedValue, changeStart = _a.changeStart, changeEnd = _a.changeEnd;
|
|
58
|
+
if (cache.current === null) {
|
|
59
|
+
throw new core_1.SyntheticChangeError('The state has not been initialized.');
|
|
60
|
+
}
|
|
61
|
+
// Предыдущее значение всегда должно соответствовать маскированному значению из кэша. Обратная ситуация может
|
|
62
|
+
// возникнуть при контроле значения, если значение не было изменено после ввода. Для предотвращения подобных
|
|
63
|
+
// ситуаций, нам важно синхронизировать предыдущее значение с кэшированным значением, если они различаются
|
|
64
|
+
if (cache.current.value !== previousValue) {
|
|
65
|
+
cache.current.props = cache.current.fallbackProps;
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
cache.current.fallbackProps = cache.current.props;
|
|
69
|
+
}
|
|
70
|
+
var previousLocalizedValues = (0, localizeValues_1.default)(cache.current.props.locales);
|
|
71
|
+
var localizedValues = (0, localizeValues_1.default)(locales);
|
|
72
|
+
var _b = (0, resolveOptions_1.default)(locales, options), current = _b.current, resolved = _b.resolved;
|
|
73
|
+
// Удаляем неразрешённые символы
|
|
74
|
+
var filter = function (value) {
|
|
75
|
+
var p$1 = "\\-\\".concat(localizedValues.minusSign);
|
|
76
|
+
var p$2 = ".,".concat(localizedValues.decimal);
|
|
77
|
+
var p$3 = "\\d".concat(localizedValues.digits);
|
|
78
|
+
var p$4 = "[^".concat(p$1).concat(p$2).concat(p$3, "]|[").concat(p$2, "](?=.*[").concat(p$2, "])");
|
|
79
|
+
var _value = value.replace(RegExp(p$4, 'g'), '');
|
|
80
|
+
if (localizedValues.signBackwards) {
|
|
81
|
+
return _value.replace(RegExp("[".concat(p$1, "](?=.*[").concat(p$1).concat(p$2).concat(p$3, "])"), 'g'), '');
|
|
82
|
+
}
|
|
83
|
+
var firstMinusSignIndex = _value.search(RegExp("[".concat(p$1, "]")));
|
|
84
|
+
var firstDecimalIndex = _value.search(RegExp("[".concat(p$2, "]")));
|
|
85
|
+
var firstDigitIndex = _value.search(RegExp("[".concat(p$3, "]")));
|
|
86
|
+
return _value.replace(RegExp("[".concat(p$1, "]"), 'g'), function (match, offset) {
|
|
87
|
+
var isMoreMinusSignIndex = firstMinusSignIndex !== -1 && offset > firstMinusSignIndex;
|
|
88
|
+
var isMoreDecimalIndex = firstDecimalIndex !== -1 && offset > firstDecimalIndex;
|
|
89
|
+
var isMoreDigitIndex = firstDigitIndex !== -1 && offset > firstDigitIndex;
|
|
90
|
+
return isMoreMinusSignIndex || isMoreDecimalIndex || isMoreDigitIndex ? '' : match;
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
addedValue = filter(addedValue);
|
|
94
|
+
if (inputType === 'insert' && !addedValue) {
|
|
95
|
+
throw new core_1.SyntheticChangeError('The added value does not contain allowed characters.');
|
|
96
|
+
}
|
|
97
|
+
var regExp$1 = RegExp("[^\\".concat(previousLocalizedValues.minusSign).concat(previousLocalizedValues.decimal).concat(previousLocalizedValues.digits, "]"), 'g');
|
|
98
|
+
// Нам важно удалить ненужные символы перед преобразованием в число, так
|
|
99
|
+
// как символ группы и символ десятичного разделителя могут пересекаться
|
|
100
|
+
var beforeChangeValue = previousValue.slice(0, changeStart).replace(regExp$1, '');
|
|
101
|
+
var afterChangeValue = previousValue.slice(changeEnd).replace(regExp$1, '');
|
|
102
|
+
var normalizedValue = beforeChangeValue + addedValue + afterChangeValue;
|
|
103
|
+
// Фильтруем значение для преобразование в число
|
|
104
|
+
normalizedValue = filter(normalizedValue)
|
|
105
|
+
// Нормализуем десятичный разделитель
|
|
106
|
+
.replace(RegExp("[,".concat(localizedValues.decimal, "]"), 'g'), '.')
|
|
107
|
+
// Нормализуем знак минуса
|
|
108
|
+
.replace(RegExp(localizedValues.minusSign, 'g'), '-')
|
|
109
|
+
// Нормализуем цифры
|
|
110
|
+
.replace(RegExp("[".concat(localizedValues.digits, "]"), 'g'), function (localeDigit) {
|
|
111
|
+
var digit = localizedValues.digits.indexOf(localeDigit);
|
|
112
|
+
return digit !== -1 ? digit.toString() : localeDigit;
|
|
113
|
+
});
|
|
114
|
+
// В случае ввода знака минуса нам нужно его удалить если
|
|
115
|
+
// оно присутствует, в противном случае добавить, тем самым
|
|
116
|
+
// создав автоматическую вставку при любой позиции каретки
|
|
117
|
+
{
|
|
118
|
+
var isReflectMinusSign = RegExp("^[\\-\\".concat(localizedValues.minusSign, "]$")).test(addedValue) && changeStart === changeEnd;
|
|
119
|
+
var hasPreviousValueMinusSign = previousValue.includes(previousLocalizedValues.minusSign);
|
|
120
|
+
var hasNormalizedValueMinusSign = normalizedValue.includes('-');
|
|
121
|
+
if (isReflectMinusSign && hasPreviousValueMinusSign && hasNormalizedValueMinusSign) {
|
|
122
|
+
normalizedValue = normalizedValue.replace('-', '');
|
|
123
|
+
}
|
|
124
|
+
if (isReflectMinusSign && !hasPreviousValueMinusSign && !hasNormalizedValueMinusSign) {
|
|
125
|
+
normalizedValue = "-".concat(normalizedValue);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
// Для нормализации значения, ставим минус слева.
|
|
129
|
+
// В случае арабской локали он может находиться справа
|
|
130
|
+
if (normalizedValue.endsWith('-')) {
|
|
131
|
+
normalizedValue = "-".concat(normalizedValue.slice(0, -1));
|
|
132
|
+
}
|
|
133
|
+
// Если изменения происходят в области `minimumFractionDigits`, очищаем дробную часть
|
|
134
|
+
// для замены значения, чтобы заменить "0" на вводимое значение,
|
|
135
|
+
// например, при вводе "1", получим "0.00" -> "0.1" -> "0.10" (не "0.100")
|
|
136
|
+
if (/\..*0$/.test(normalizedValue)) {
|
|
137
|
+
// let previousInteger = '';
|
|
138
|
+
var previousFraction = '';
|
|
139
|
+
var previousFractionIndex = -1;
|
|
140
|
+
for (var i = 0, decimal = false; i < previousValue.length; i++) {
|
|
141
|
+
var isDigit = previousLocalizedValues.digits.includes(previousValue[i]);
|
|
142
|
+
var isDecimal = previousValue[i] === previousLocalizedValues.decimal;
|
|
143
|
+
if (!decimal) {
|
|
144
|
+
if (isDecimal)
|
|
145
|
+
decimal = true;
|
|
146
|
+
// if (isDigit) previousInteger += previousValue[i];
|
|
147
|
+
}
|
|
148
|
+
else if (isDigit) {
|
|
149
|
+
previousFraction += previousValue[i];
|
|
150
|
+
if (previousFractionIndex === -1)
|
|
151
|
+
previousFractionIndex = i;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if (previousFractionIndex !== -1) {
|
|
155
|
+
var previousMinimumFractionDigits = (0, resolveMinimumFractionDigits_1.default)({
|
|
156
|
+
// integer: previousInteger,
|
|
157
|
+
// fraction: previousFraction,
|
|
158
|
+
resolvedOptions: (0, resolveOptions_1.default)(cache.current.props.locales, cache.current.props.options).resolved,
|
|
159
|
+
});
|
|
160
|
+
// Если изменения происходят в области `minimumFractionDigits`
|
|
161
|
+
var isRange = changeStart >= previousFractionIndex &&
|
|
162
|
+
changeEnd < previousFractionIndex + (previousMinimumFractionDigits || 1);
|
|
163
|
+
if (isRange && previousFraction.length <= (previousMinimumFractionDigits || 1)) {
|
|
164
|
+
normalizedValue = normalizedValue.replace(/0+$/g, '');
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
var detail = (0, resolveDetail_1.default)(normalizedValue, {
|
|
169
|
+
inputType: inputType,
|
|
170
|
+
locales: locales,
|
|
171
|
+
localizedValues: localizedValues,
|
|
172
|
+
currentOptions: current,
|
|
173
|
+
resolvedOptions: resolved,
|
|
174
|
+
});
|
|
175
|
+
var selection = (0, resolveSelection_1.default)({
|
|
176
|
+
localizedValues: localizedValues,
|
|
177
|
+
previousLocalizedValues: previousLocalizedValues,
|
|
178
|
+
resolvedOptions: resolved,
|
|
179
|
+
inputType: inputType,
|
|
180
|
+
previousValue: previousValue,
|
|
181
|
+
addedValue: addedValue,
|
|
182
|
+
nextValue: detail.value,
|
|
183
|
+
changeStart: changeStart,
|
|
184
|
+
changeEnd: changeEnd,
|
|
185
|
+
});
|
|
186
|
+
cache.current.value = detail.value;
|
|
187
|
+
cache.current.props = { locales: locales, options: options };
|
|
188
|
+
return {
|
|
189
|
+
value: detail.value,
|
|
190
|
+
selectionStart: selection.start,
|
|
191
|
+
selectionEnd: selection.end,
|
|
192
|
+
__detail: detail,
|
|
193
|
+
};
|
|
194
|
+
};
|
|
195
|
+
/**
|
|
196
|
+
*
|
|
197
|
+
* Use input
|
|
198
|
+
*
|
|
199
|
+
*/
|
|
200
|
+
return (0, core_1.useInput)({
|
|
201
|
+
init: init,
|
|
202
|
+
tracking: tracking,
|
|
203
|
+
eventType: 'input-number-format',
|
|
204
|
+
eventHandler: onNumberFormat,
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
exports.default = useNumberFormat;
|
|
208
|
+
//# sourceMappingURL=useNumberFormat.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { LocalizedNumberFormatValues } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Возвращает применяемые значения по заданной локали
|
|
4
|
-
* @param locales
|
|
5
|
-
* @returns
|
|
6
|
-
*/
|
|
7
|
-
export default function localizeValues(locales: string | string[] | undefined): LocalizedNumberFormatValues;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { LocalizedNumberFormatValues, NumberFormatOptions, ResolvedNumberFormatOptions } from '../types';
|
|
2
|
-
import type { InputType } from '../../core';
|
|
3
|
-
interface Options {
|
|
4
|
-
inputType: InputType;
|
|
5
|
-
locales: string | string[] | undefined;
|
|
6
|
-
localizedValues: LocalizedNumberFormatValues;
|
|
7
|
-
currentOptions: NumberFormatOptions | undefined;
|
|
8
|
-
resolvedOptions: ResolvedNumberFormatOptions;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
*
|
|
12
|
-
* @param value
|
|
13
|
-
* @param options
|
|
14
|
-
* @returns
|
|
15
|
-
*/
|
|
16
|
-
export default function resolveDetail(value: string, { inputType, locales, localizedValues, currentOptions, resolvedOptions }: Options): {
|
|
17
|
-
value: string;
|
|
18
|
-
number: number;
|
|
19
|
-
};
|
|
20
|
-
export {};
|