infinity-forge 0.40.1 → 0.40.2

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 (26) hide show
  1. package/dist/index.d.ts +3 -0
  2. package/dist/index.js +20 -0
  3. package/dist/sites/components/index.d.ts +6 -0
  4. package/dist/sites/components/index.js +23 -0
  5. package/dist/sites/hook/index.d.ts +3 -0
  6. package/dist/sites/hook/index.js +20 -0
  7. package/dist/sites/index.d.ts +4 -0
  8. package/dist/sites/index.js +21 -0
  9. package/dist/sites/interfaces/index.d.ts +2 -0
  10. package/dist/sites/interfaces/index.js +19 -0
  11. package/dist/ui/components/accordion/index..d.ts +2 -0
  12. package/dist/ui/components/accordion/index..js +37 -0
  13. package/dist/ui/components/form/input-mask/lib/number-format/InputNumberFormat.d.ts +6 -0
  14. package/dist/ui/components/form/input-mask/lib/number-format/InputNumberFormat.js +58 -0
  15. package/dist/ui/components/form/input-mask/lib/number-format/index.d.ts +4 -0
  16. package/dist/ui/components/form/input-mask/lib/number-format/index.js +11 -0
  17. package/dist/ui/components/form/input-mask/lib/number-format/types.d.ts +26 -0
  18. package/dist/ui/components/form/input-mask/lib/number-format/useNumberFormat.d.ts +3 -0
  19. package/dist/ui/components/form/input-mask/lib/number-format/useNumberFormat.js +208 -0
  20. package/dist/ui/components/form/input-mask/lib/number-format/utils/localizeValues.d.ts +7 -0
  21. package/dist/ui/components/form/input-mask/lib/number-format/utils/resolveDetail.d.ts +20 -0
  22. package/dist/ui/components/form/input-mask/lib/number-format/utils/resolveDetail.js +123 -0
  23. package/dist/ui/components/form/input-mask/lib/number-format/utils/resolveMinimumFractionDigits.d.ts +11 -0
  24. package/dist/ui/components/form/input-mask/lib/number-format/utils/resolveOptions.d.ts +5 -0
  25. package/dist/ui/components/form/input-mask/lib/number-format/utils/resolveSelection.d.ts +24 -0
  26. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -0,0 +1,3 @@
1
+ export * from './ui/index.js';
2
+ export * from './sites/index.js';
3
+ export * from './system/index.js';
package/dist/index.js CHANGED
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./ui/index.js"), exports);
18
+ __exportStar(require("./sites/index.js"), exports);
19
+ __exportStar(require("./system/index.js"), exports);
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,6 @@
1
+ export * from './mvv/index.js';
2
+ export * from './head/index.js';
3
+ export * from './counter/index.js';
4
+ export * from './carousel/index.js';
5
+ export * from './header-link/index.js';
6
+ export * from './brands-carousel/index.js';
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./mvv/index.js"), exports);
18
+ __exportStar(require("./head/index.js"), exports);
19
+ __exportStar(require("./counter/index.js"), exports);
20
+ __exportStar(require("./carousel/index.js"), exports);
21
+ __exportStar(require("./header-link/index.js"), exports);
22
+ __exportStar(require("./brands-carousel/index.js"), exports);
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,3 @@
1
+ export * from './useScreen.js';
2
+ export * from './use-header.js';
3
+ export * from './use-footer.js';
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./useScreen.js"), exports);
18
+ __exportStar(require("./use-header.js"), exports);
19
+ __exportStar(require("./use-footer.js"), exports);
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,4 @@
1
+ export * from './api/index.js';
2
+ export * from './utils/index.js';
3
+ export * from './context/index.js';
4
+ export * from './components/index.js';
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./api/index.js"), exports);
18
+ __exportStar(require("./utils/index.js"), exports);
19
+ __exportStar(require("./context/index.js"), exports);
20
+ __exportStar(require("./components/index.js"), exports);
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,2 @@
1
+ export * from './generic/index.js';
2
+ export * from './api-data/index.js';
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./generic/index.js"), exports);
18
+ __exportStar(require("./api-data/index.js"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,2 @@
1
+ import { AccordionProps } from './interfaces.js';
2
+ export declare function Accordion({ title, openIcon, closeIcon, children }: AccordionProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.Accordion = void 0;
27
+ var jsx_runtime_1 = require("react/jsx-runtime");
28
+ var react_1 = require("react");
29
+ var ui_1 = require("../../../ui/index.js");
30
+ var S = __importStar(require("./styles.js"));
31
+ function Accordion(_a) {
32
+ var title = _a.title, openIcon = _a.openIcon, closeIcon = _a.closeIcon, children = _a.children;
33
+ var _b = (0, react_1.useState)(false), isOpen = _b[0], setIsOpen = _b[1];
34
+ return ((0, jsx_runtime_1.jsxs)(S.Accordion, { children: [(0, jsx_runtime_1.jsxs)("button", { type: 'button', onClick: function () { return setIsOpen(!isOpen); }, children: [title && (0, jsx_runtime_1.jsx)("h2", { children: title }), openIcon && closeIcon && (0, jsx_runtime_1.jsx)(ui_1.Icon, { name: !isOpen ? openIcon : closeIcon })] }), children && (0, jsx_runtime_1.jsx)("div", { className: "content ".concat(isOpen ? 'show' : ''), children: children })] }));
35
+ }
36
+ exports.Accordion = Accordion;
37
+ //# sourceMappingURL=index..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
@@ -0,0 +1,7 @@
1
+ import type { LocalizedNumberFormatValues } from '../types.js';
2
+ /**
3
+ * Возвращает применяемые значения по заданной локали
4
+ * @param locales
5
+ * @returns
6
+ */
7
+ export default function localizeValues(locales: string | string[] | undefined): LocalizedNumberFormatValues;
@@ -0,0 +1,20 @@
1
+ import type { LocalizedNumberFormatValues, NumberFormatOptions, ResolvedNumberFormatOptions } from '../types.js';
2
+ import type { InputType } from '../../core/index.js';
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 {};
@@ -0,0 +1,123 @@
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 resolveMinimumFractionDigits_1 = __importDefault(require("./resolveMinimumFractionDigits.js"));
29
+ /**
30
+ *
31
+ * @param value
32
+ * @param options
33
+ * @returns
34
+ */
35
+ function resolveDetail(value, _a) {
36
+ var inputType = _a.inputType, locales = _a.locales, localizedValues = _a.localizedValues, currentOptions = _a.currentOptions, resolvedOptions = _a.resolvedOptions;
37
+ if ((inputType === 'deleteBackward' || inputType === 'deleteForward') &&
38
+ (value === '' || value === '-' || /^-?\.?0*$/.test(value))) {
39
+ return { value: '', number: 0 };
40
+ }
41
+ var isNegative = value.startsWith('-');
42
+ var absValue = isNegative ? value.slice(1) : value;
43
+ // При `fraction` равном `undefined` - разделитель не был введён
44
+ var _b = absValue.split('.'), integer = _b[0], _c = _b[1], fraction = _c === void 0 ? undefined : _c;
45
+ // Определяем настройки для применения в `Intl.NumberFormat`
46
+ var currentMinimumFractionDigits = resolvedOptions.minimumFractionDigits;
47
+ var currentMaximumFractionDigits = resolvedOptions.maximumFractionDigits;
48
+ // let currentMinimumSignificantDigits = resolvedOptions.minimumSignificantDigits;
49
+ // Поскольку состояние ввода хранит последний введенный символ,
50
+ // при форматировании может произойти округление, поэтому нам важно
51
+ // заранее обрезать символ не соответствующий максимальному количеству символов
52
+ // - `replace` - Учитываем `minimumSignificantDigits` и `minimumIntegerDigits`.
53
+ // Так, при `addedValue` "2": "000 001" -> "000 0012" -> "12" -> "000 012"
54
+ integer = integer.replace(/^0+/g, '').slice(0, resolvedOptions.maximumIntegerDigits);
55
+ // if (fraction !== undefined && resolvedOptions.maximumSignificantDigits !== undefined) {
56
+ // currentMaximumFractionDigits = resolvedOptions.maximumSignificantDigits - integer.length;
57
+ // if (/^0*$/.test(integer) && /^0*$/.test(fraction)) {
58
+ // currentMaximumFractionDigits -= 1;
59
+ // } else if (/^0*$/.test(integer) && /^0*[1-9]+/.test(fraction)) {
60
+ // currentMaximumFractionDigits += fraction.match(/^0+/g)?.[0].length ?? 0;
61
+ // }
62
+ // }
63
+ fraction = fraction === null || fraction === void 0 ? void 0 : fraction.slice(0, currentMaximumFractionDigits);
64
+ var number = Number((isNegative ? '-' : '') + (integer || '0') + (fraction ? ".".concat(fraction) : ''));
65
+ // Чтобы иметь возможность прописывать "0" и сохранять его с каждой итерацией,
66
+ // переопределяем `minimumFractionDigits` и `minimumSignificantDigits`
67
+ currentMinimumFractionDigits = (0, resolveMinimumFractionDigits_1.default)({
68
+ // integer,
69
+ // fraction: fraction ?? '',
70
+ resolvedOptions: resolvedOptions,
71
+ });
72
+ // Если `currentMinimumFractionDigits` равен нулю, дробная часть будет округлена
73
+ if (inputType === 'insert' &&
74
+ fraction === '' &&
75
+ currentMinimumFractionDigits === 0 &&
76
+ currentMaximumFractionDigits > 0) {
77
+ currentMinimumFractionDigits = 1;
78
+ // if (currentMinimumSignificantDigits !== undefined) {
79
+ // currentMinimumSignificantDigits = (integer.length || 1) + 1;
80
+ // }
81
+ }
82
+ if (fraction !== undefined && fraction.length > currentMinimumFractionDigits) {
83
+ currentMinimumFractionDigits = fraction.length;
84
+ // `minimumFractionDigits` игнорируется при указанном `minimumSignificantDigits` или
85
+ // `maximumSignificantDigits`, поэтому указываем правило для `minimumSignificantDigits`
86
+ // if (currentMinimumSignificantDigits !== undefined) {
87
+ // if (/^0*$/.test(integer) && /^0*$/.test(fraction)) {
88
+ // currentMinimumSignificantDigits = fraction.length + 1;
89
+ // } else if (/^0*$/.test(integer) && /^0*[1-9]+/.test(fraction)) {
90
+ // currentMinimumSignificantDigits = fraction.replace(/^0+/g, '').length;
91
+ // } else if (/^0*[1-9]+/.test(integer)) {
92
+ // currentMinimumSignificantDigits = integer.length + fraction.length;
93
+ // }
94
+ // }
95
+ }
96
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
97
+ var _d = currentOptions !== null && currentOptions !== void 0 ? currentOptions : {}, format = _d.format, groupDisplay = _d.groupDisplay, maximumIntegerDigits = _d.maximumIntegerDigits, options = __rest(_d, ["format", "groupDisplay", "maximumIntegerDigits"]);
98
+ var nextValue = Intl.NumberFormat(locales, __assign(__assign({}, options), { style: format, useGrouping: groupDisplay, minimumFractionDigits: currentMinimumFractionDigits })).format(number);
99
+ // В значении может встречаться юникод, нам важно заменить
100
+ // такие символы для соответствия стандартному значению
101
+ nextValue = nextValue.replace(/\s/g, ' ');
102
+ var sign = nextValue.includes('+')
103
+ ? '+'
104
+ : nextValue.includes(localizedValues.minusSign)
105
+ ? localizedValues.minusSign
106
+ : undefined;
107
+ // Арабская локаль содержит юникод, что приводит к неожидаемому
108
+ // сдвигу курсора при смещении через клавиатуру, для предотвращения
109
+ // устанавливаем знак в конец числа с удалением нежелательного юникода
110
+ if (sign !== undefined && localizedValues.signBackwards) {
111
+ nextValue = nextValue.replace(RegExp("[\u200E\u061C\\".concat(sign, "]"), 'g'), '');
112
+ var lastDigitIndex = nextValue.search(RegExp("[".concat(localizedValues.digits, "](?!.*[").concat(localizedValues.digits, "])")));
113
+ if (lastDigitIndex !== -1) {
114
+ nextValue = nextValue.slice(0, lastDigitIndex + 1) + sign + nextValue.slice(lastDigitIndex + 1);
115
+ if (!nextValue.startsWith('‏')) {
116
+ nextValue = "\u200F".concat(nextValue);
117
+ }
118
+ }
119
+ }
120
+ return { value: nextValue, number: number };
121
+ }
122
+ exports.default = resolveDetail;
123
+ //# sourceMappingURL=resolveDetail.js.map
@@ -0,0 +1,11 @@
1
+ import type { ResolvedNumberFormatOptions } from '../types.js';
2
+ interface ResolveMinimumFractionDigitsParam {
3
+ resolvedOptions: ResolvedNumberFormatOptions;
4
+ }
5
+ /**
6
+ * Высчитываем фактический `minimumFractionDigits`
7
+ * @param param
8
+ * @returns
9
+ */
10
+ export default function resolveMinimumFractionDigits({ resolvedOptions, }: ResolveMinimumFractionDigitsParam): number;
11
+ export {};
@@ -0,0 +1,5 @@
1
+ import type { NumberFormatOptions, ResolvedNumberFormatOptions } from '../types.js';
2
+ export default function resolveOptions(locales: string | string[] | undefined, options?: NumberFormatOptions | undefined): {
3
+ current: NumberFormatOptions;
4
+ resolved: ResolvedNumberFormatOptions;
5
+ };
@@ -0,0 +1,24 @@
1
+ import type { LocalizedNumberFormatValues, ResolvedNumberFormatOptions } from '../types.js';
2
+ import type { InputType } from '../../core/index.js';
3
+ interface ResolveSelectionParam {
4
+ localizedValues: LocalizedNumberFormatValues;
5
+ previousLocalizedValues: LocalizedNumberFormatValues;
6
+ resolvedOptions: ResolvedNumberFormatOptions;
7
+ inputType: InputType;
8
+ addedValue: string;
9
+ previousValue: string;
10
+ nextValue: string;
11
+ changeStart: number;
12
+ changeEnd: number;
13
+ }
14
+ interface ResolveSelectionReturn {
15
+ start: number;
16
+ end: number;
17
+ }
18
+ /**
19
+ * Определяет позицию каретки для последующей установки
20
+ * @param param
21
+ * @returns
22
+ */
23
+ export default function resolveSelection({ localizedValues, previousLocalizedValues, resolvedOptions, inputType, previousValue, addedValue, nextValue, changeStart, changeEnd, }: ResolveSelectionParam): ResolveSelectionReturn;
24
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "infinity-forge",
3
- "version": "0.40.1",
3
+ "version": "0.40.2",
4
4
  "description": "codie Library",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",