infinity-forge 3.2.6 → 3.2.7
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/featured-blog/featured-blog-item/index.d.ts +0 -6
- package/dist/sites/components/default-pages/blog/components/featured-blog/featured-blog-item/index.js +0 -42
- package/dist/system/presentation/components/data/menu/components/menu-item/index.js +0 -80
- package/dist/system/presentation/components/data/menu/components/menu-item/index.js.map +1 -1
- package/dist/system/presentation/components/data/menu/modes/collapsed-menu/index.js +0 -44
- package/dist/system/presentation/components/data/menu/modes/collapsed-menu/styles.js +0 -15
- package/dist/system/presentation/components/data/menu/modes/opened/index.js +0 -51
- package/dist/system/presentation/components/data/menu/modes/opened/styles.js +0 -15
- package/dist/system/presentation/components/data/tab/component.js +4 -4
- package/dist/system/presentation/components/data/tab/interfaces.d.ts +1 -3
- package/dist/system/presentation/components/layout/header/components/menu-right/component.d.ts +0 -6
- package/dist/system/presentation/components/layout/header/components/menu-right/component.js +0 -35
- package/dist/system/presentation/components/layout/header/components/menu-right/index.d.ts +0 -3
- package/dist/system/presentation/components/layout/header/components/menu-right/index.js +3 -3
- package/dist/system/presentation/components/layout/header/components/menu-right/messages/content/card/index.d.ts +1 -1
- package/dist/system/presentation/components/layout/header/components/menu-right/messages/content/card/index.js +3 -3
- package/dist/system/presentation/components/layout/header/components/menu-right/messages/content/index.js +3 -3
- package/dist/system/presentation/components/layout/header/components/menu-right/messages/content/interfaces.d.ts +1 -1
- package/dist/system/presentation/components/layout/header/components/menu-right/messages/index.js +4 -4
- package/dist/system/presentation/components/layout/header/components/menu-right/profile/content/index.js +3 -3
- package/dist/system/presentation/components/layout/header/components/menu-right/profile/index.js +4 -4
- package/dist/system/presentation/components/layout/header/components/search-modal/index.js +5 -5
- package/dist/system/presentation/components/layout/header/components/search-modal/search-list/index.js +3 -3
- package/dist/system/presentation/components/layout/header/components/search-modal/trigger/index.js +2 -2
- package/dist/system/presentation/components/layout/header/index.js +2 -2
- package/dist/system/presentation/components/pages/menus/page.js +4 -4
- package/dist/system/presentation/components/pages/menus/table/icon/index.js +1 -1
- package/dist/system/presentation/components/pages/users/page.js +4 -4
- package/dist/system/presentation/context/auth/components/login/form-login/index.js +3 -3
- package/dist/system/presentation/hooks/notifications/use-load-all/index.d.ts +1 -2
- package/dist/system/presentation/hooks/notifications/use-load-all/index.js +3 -3
- package/dist/system/presentation/hooks/notifications/use-load-no-read/index.d.ts +2 -3
- package/dist/system/presentation/hooks/notifications/use-load-no-read/index.js +3 -3
- package/dist/system/presentation/hooks/ui/use-table/components/table/actions/delete/index.d.ts +1 -1
- package/dist/system/presentation/hooks/ui/use-table/components/table/actions/delete/index.js +2 -2
- package/dist/system/presentation/hooks/ui/use-table/components/table/actions/index.d.ts +1 -1
- package/dist/system/presentation/hooks/ui/use-table/components/table/actions/index.js +4 -4
- package/dist/system/presentation/hooks/ui/use-table/components/table/active-filters/index.d.ts +1 -1
- package/dist/system/presentation/hooks/ui/use-table/components/table/active-filters/index.js +2 -2
- package/dist/system/presentation/hooks/ui/use-table/components/table/create/index.d.ts +1 -1
- package/dist/system/presentation/hooks/ui/use-table/components/table/create/index.js +3 -3
- package/dist/system/presentation/hooks/ui/use-table/components/table/export/index.d.ts +1 -1
- package/dist/system/presentation/hooks/ui/use-table/components/table/export/index.js +2 -2
- package/dist/system/presentation/hooks/ui/use-table/components/table/filters/index.d.ts +1 -1
- package/dist/system/presentation/hooks/ui/use-table/components/table/filters/index.js +3 -3
- package/dist/system/presentation/hooks/ui/use-table/components/table/index.d.ts +1 -1
- package/dist/system/presentation/hooks/ui/use-table/components/table/index.js +11 -11
- package/dist/system/presentation/hooks/ui/use-table/components/table/interfaces.d.ts +3 -3
- package/dist/system/presentation/hooks/ui/use-table/components/table/pagination/index.d.ts +1 -1
- package/dist/system/presentation/hooks/ui/use-table/components/table/pagination/index.js +3 -3
- package/dist/system/presentation/hooks/ui/use-table/components/table/skeleton-table/index.js +2 -2
- package/dist/system/presentation/hooks/ui/use-table/components/table/thead-item/index.d.ts +1 -1
- package/dist/system/presentation/hooks/ui/use-table/components/table/thead-item/index.js +2 -2
- package/dist/system/presentation/hooks/ui/use-table/components/table/thead-item/interfaces.d.ts +1 -1
- package/dist/system/presentation/hooks/ui/use-table/interfaces.d.ts +2 -3
- 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/carousel/carousel-lib/core/translate/translateTo.js +0 -81
- package/dist/ui/components/carousel/carousel-lib/core/update/index.d.ts +0 -21
- package/dist/ui/components/carousel/carousel-lib/core/update/index.js +0 -26
- package/dist/ui/components/carousel/carousel-lib/core/update/updateActiveIndex.js +0 -125
- package/dist/ui/components/carousel/carousel-lib/core/update/updateSize.js +0 -45
- package/dist/ui/components/carousel/carousel-lib/core/update/updateSlides.js +0 -306
- package/dist/ui/components/carousel/carousel-lib/core/update/updateSlidesClasses.js +0 -69
- package/dist/ui/components/form/handler/i18n/capture-i18n-errors/index.d.ts +0 -6
- package/dist/ui/components/form/input-cep/use-cep/providers/ibge/hook.d.ts +3 -2
- package/dist/ui/components/form/input-cep/use-cep/providers/ibge/hook.js +2 -2
- 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-cep/use-cep/providers/index.d.ts +0 -1
- package/dist/ui/components/form/input-cep/use-cep/providers/index.js +0 -18
- package/dist/ui/components/form/input-currency/components/utils/cleanValue.d.ts +0 -8
- package/dist/ui/components/form/input-currency/components/utils/cleanValue.js +0 -62
- package/dist/ui/components/form/input-currency/components/utils/formatValue.d.ts +0 -49
- package/dist/ui/components/form/input-currency/components/utils/formatValue.js +0 -132
- package/dist/ui/components/form/input-currency/components/utils/getLocaleConfig.d.ts +0 -13
- package/dist/ui/components/form/input-currency/components/utils/getSuffix.js +0 -12
- package/dist/ui/components/form/input-currency/components/utils/index.d.ts +0 -8
- package/dist/ui/components/form/input-currency/components/utils/index.js +0 -25
- package/dist/ui/components/form/input-currency/components/utils/parseAbbrValue.js +0 -40
- package/dist/ui/components/form/input-currency/components/utils/removeInvalidChars.js +0 -14
- package/dist/ui/components/form/input-currency/components/utils/removeSeparators.js +0 -14
- package/dist/ui/components/form/input-date-picker/calendar/calendar-header/index.d.ts +0 -2
- package/dist/ui/components/form/input-date-picker/calendar/calendar-header/index.js +0 -62
- package/dist/ui/components/form/input-date-picker/calendar/days/index.d.ts +0 -2
- package/dist/ui/components/form/input-date-picker/calendar/days/index.js +0 -87
- package/dist/ui/components/form/input-date-picker/calendar/months/index.d.ts +0 -2
- package/dist/ui/components/form/input-date-picker/calendar/months/index.js +0 -66
- package/dist/ui/components/form/input-file/render-files/file-item/button-upload-image-mobile/index.d.ts +2 -2
- package/dist/ui/components/form/input-file/render-files/file-item/button-upload-image-mobile/index.js +2 -2
- package/dist/ui/components/form/input-file/render-files/file-item/index.d.ts +0 -3
- package/dist/ui/components/form/input-file/render-files/file-item/index.js +0 -49
- package/dist/ui/components/form/input-mask/lib/core/errors/SyntheticChangeError.d.ts +1 -1
- package/dist/ui/components/form/input-mask/lib/core/hooks/useInput.d.ts +1 -1
- package/dist/ui/components/form/input-mask/lib/core/hooks/useInput.js +2 -2
- package/dist/ui/components/form/input-mask/lib/core/index.d.ts +0 -5
- package/dist/ui/components/form/input-mask/lib/core/index.js +0 -15
- package/dist/ui/components/form/input-mask/lib/core/utils/setInputAttributes.d.ts +1 -1
- package/dist/ui/components/form/input-mask/lib/mask/InputMask.d.ts +0 -6
- package/dist/ui/components/form/input-mask/lib/mask/InputMask.js +0 -44
- package/dist/ui/components/form/input-mask/lib/mask/index.d.ts +0 -5
- package/dist/ui/components/form/input-mask/lib/mask/index.js +0 -26
- package/dist/ui/components/form/input-mask/lib/mask/types.d.ts +0 -61
- package/dist/ui/components/form/input-mask/lib/mask/useMask.d.ts +0 -3
- package/dist/ui/components/form/input-mask/lib/mask/useMask.js +0 -150
- package/dist/ui/components/form/input-mask/lib/mask/utils/filter.d.ts +1 -1
- package/dist/ui/components/form/input-mask/lib/mask/utils/format.d.ts +1 -1
- package/dist/ui/components/form/input-mask/lib/mask/utils/formatToParts.d.ts +1 -1
- package/dist/ui/components/form/input-mask/lib/mask/utils/formatToReplacementObject.d.ts +1 -1
- package/dist/ui/components/form/input-mask/lib/mask/utils/resolveDetail.d.ts +1 -1
- package/dist/ui/components/form/input-mask/lib/mask/utils/resolveDetail.js +3 -3
- package/dist/ui/components/form/input-mask/lib/mask/utils/resolveSelection.d.ts +2 -2
- package/dist/ui/components/form/input-mask/lib/mask/utils/unformat.d.ts +1 -1
- package/dist/ui/components/form/input-mask/lib/mask/utils/validate.d.ts +1 -1
- package/dist/ui/components/form/input-mask/lib/mask/utils.d.ts +0 -63
- package/dist/ui/components/form/input-mask/lib/mask/utils.js +0 -114
- package/dist/ui/components/form/input-mask/lib/number-format/InputNumberFormat.d.ts +0 -6
- package/dist/ui/components/form/input-mask/lib/number-format/InputNumberFormat.js +0 -58
- package/dist/ui/components/form/input-mask/lib/number-format/index.d.ts +0 -4
- package/dist/ui/components/form/input-mask/lib/number-format/index.js +0 -11
- package/dist/ui/components/form/input-mask/lib/number-format/types.d.ts +0 -26
- package/dist/ui/components/form/input-mask/lib/number-format/useNumberFormat.d.ts +0 -3
- package/dist/ui/components/form/input-mask/lib/number-format/useNumberFormat.js +0 -208
- package/dist/ui/components/form/input-mask/lib/number-format/utils/localizeValues.d.ts +1 -1
- package/dist/ui/components/form/input-mask/lib/number-format/utils/resolveDetail.d.ts +2 -2
- package/dist/ui/components/form/input-mask/lib/number-format/utils/resolveDetail.js +1 -1
- package/dist/ui/components/form/input-mask/lib/number-format/utils/resolveMinimumFractionDigits.d.ts +1 -1
- package/dist/ui/components/form/input-mask/lib/number-format/utils/resolveOptions.d.ts +1 -1
- package/dist/ui/components/form/input-mask/lib/number-format/utils/resolveSelection.d.ts +2 -2
- package/package.json +1 -1
|
@@ -1,26 +0,0 @@
|
|
|
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 {};
|
|
@@ -1,3 +0,0 @@
|
|
|
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>;
|
|
@@ -1,208 +0,0 @@
|
|
|
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,5 +1,5 @@
|
|
|
1
|
-
import type { LocalizedNumberFormatValues, NumberFormatOptions, ResolvedNumberFormatOptions } from '../types
|
|
2
|
-
import type { InputType } from '../../core
|
|
1
|
+
import type { LocalizedNumberFormatValues, NumberFormatOptions, ResolvedNumberFormatOptions } from '../types';
|
|
2
|
+
import type { InputType } from '../../core';
|
|
3
3
|
interface Options {
|
|
4
4
|
inputType: InputType;
|
|
5
5
|
locales: string | string[] | undefined;
|
|
@@ -25,7 +25,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
25
25
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
26
|
};
|
|
27
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
var resolveMinimumFractionDigits_1 = __importDefault(require("./resolveMinimumFractionDigits
|
|
28
|
+
var resolveMinimumFractionDigits_1 = __importDefault(require("./resolveMinimumFractionDigits"));
|
|
29
29
|
/**
|
|
30
30
|
*
|
|
31
31
|
* @param value
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { NumberFormatOptions, ResolvedNumberFormatOptions } from '../types
|
|
1
|
+
import type { NumberFormatOptions, ResolvedNumberFormatOptions } from '../types';
|
|
2
2
|
export default function resolveOptions(locales: string | string[] | undefined, options?: NumberFormatOptions | undefined): {
|
|
3
3
|
current: NumberFormatOptions;
|
|
4
4
|
resolved: ResolvedNumberFormatOptions;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { LocalizedNumberFormatValues, ResolvedNumberFormatOptions } from '../types
|
|
2
|
-
import type { InputType } from '../../core
|
|
1
|
+
import type { LocalizedNumberFormatValues, ResolvedNumberFormatOptions } from '../types';
|
|
2
|
+
import type { InputType } from '../../core';
|
|
3
3
|
interface ResolveSelectionParam {
|
|
4
4
|
localizedValues: LocalizedNumberFormatValues;
|
|
5
5
|
previousLocalizedValues: LocalizedNumberFormatValues;
|