mosuk-ui 1.0.9 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/components/actions/input/(otp)/component/component.d.ts +3 -0
  2. package/components/actions/input/(otp)/component/component.interface.d.ts +6 -0
  3. package/components/{display/image/(images)/skeleton → actions/input/(otp)/component}/component.js +8 -10
  4. package/components/actions/input/(otp)/component/component.module.css +49 -0
  5. package/components/actions/input/(otp)/component/field/component.d.ts +7 -0
  6. package/components/actions/input/(otp)/component/field/component.js +30 -0
  7. package/components/actions/input/(otp)/component/index.d.ts +13 -0
  8. package/components/actions/input/(otp)/component/index.js +7 -0
  9. package/components/actions/input/(otp)/component/separator/component.d.ts +7 -0
  10. package/components/actions/input/(otp)/component/separator/component.js +30 -0
  11. package/components/actions/input/(otp)/skeleton/component.d.ts +3 -0
  12. package/components/actions/input/(otp)/skeleton/component.interface.d.ts +6 -0
  13. package/components/{display/image/(images)/component/image → actions/input/(otp)/skeleton}/component.js +5 -4
  14. package/components/actions/input/(otp)/skeleton/component.module.css +18 -0
  15. package/components/actions/input/(otp)/skeleton/index.d.ts +6 -0
  16. package/components/actions/input/(otp)/skeleton/index.js +2 -0
  17. package/components/texts/counter/component/component.js +55 -12
  18. package/package.json +16 -16
  19. package/styles/components/actions/button/[size]/style.css +11 -265
  20. package/styles/components/actions/icon/[size]/style.css +12 -290
  21. package/styles/components/actions/input/[size]/style.css +18 -76
  22. package/styles/utilities/action/fill/style.css +1 -3
  23. package/styles/utilities/action/glass/style.css +0 -2
  24. package/styles/utilities/action/outline/style.css +1 -0
  25. package/styles/utilities/action/style.css +1 -2
  26. package/components/display/image/(images)/component/component.d.ts +0 -3
  27. package/components/display/image/(images)/component/component.interface.d.ts +0 -5
  28. package/components/display/image/(images)/component/component.js +0 -49
  29. package/components/display/image/(images)/component/component.module.css +0 -30
  30. package/components/display/image/(images)/component/image/component.d.ts +0 -3
  31. package/components/display/image/(images)/component/image/component.interface.d.ts +0 -4
  32. package/components/display/image/(images)/component/index.d.ts +0 -13
  33. package/components/display/image/(images)/component/index.js +0 -5
  34. package/components/display/image/(images)/skeleton/component.d.ts +0 -4
  35. package/components/display/image/(images)/skeleton/component.interface.d.ts +0 -5
  36. package/components/display/image/(images)/skeleton/component.interface.js +0 -1
  37. package/components/display/image/(images)/skeleton/component.module.css +0 -47
  38. package/components/display/image/(images)/skeleton/index.d.ts +0 -13
  39. package/components/display/image/(images)/skeleton/index.js +0 -7
  40. package/styles/utilities/action/transparent/style.css +0 -5
  41. /package/components/{display/image/(images) → actions/input/(otp)}/component/component.interface.js +0 -0
  42. /package/components/{display/image/(images)/component/image → actions/input/(otp)/skeleton}/component.interface.js +0 -0
@@ -0,0 +1,3 @@
1
+ import React, { ElementType } from 'react';
2
+ import { InputOtpProps } from './component.interface';
3
+ export declare function InputOtp<C extends ElementType = 'div'>({ as, children, length, ...rest }: InputOtpProps<C>): React.JSX.Element;
@@ -0,0 +1,6 @@
1
+ import { ComponentPropsWithoutRef, ElementType, Ref } from 'react';
2
+ import { OTPFieldPreview as BaseOTPField } from '@base-ui/react/otp-field';
3
+ export type InputOtpProps<C extends ElementType = 'div'> = {
4
+ as?: C;
5
+ ref?: Ref<any>;
6
+ } & Omit<ComponentPropsWithoutRef<C>, 'as' | 'ref'> & Omit<BaseOTPField.Root.Props, 'className' | 'style'>;
@@ -20,16 +20,14 @@ var __rest = (this && this.__rest) || function (s, e) {
20
20
  }
21
21
  return t;
22
22
  };
23
- import { Image as ImageIcon } from 'lucide-react';
24
- import React from 'react';
23
+ import classNames from 'classnames';
24
+ import React, { useId } from 'react';
25
+ import { OTPFieldPreview as OTPField } from '@base-ui/react/otp-field';
25
26
  import styles from './component.module.css';
26
- export function ImagesSkeleton(_a) {
27
+ export function InputOtp(_a) {
27
28
  var _b;
28
- var props = __rest(_a, []);
29
- return (React.createElement("div", __assign({}, props, { className: "mosuk-image-skeleton ".concat(styles.image, " ").concat((_b = props === null || props === void 0 ? void 0 : props.className) !== null && _b !== void 0 ? _b : '') }), props === null || props === void 0 ? void 0 : props.children));
30
- }
31
- export function ImagesSkeletonImage(_a) {
32
- var _b;
33
- var props = __rest(_a, []);
34
- return React.createElement(ImageIcon, __assign({}, props, { ref: props === null || props === void 0 ? void 0 : props.ref, className: "".concat(styles.icon, " ").concat((_b = props === null || props === void 0 ? void 0 : props.className) !== null && _b !== void 0 ? _b : '') }));
29
+ var as = _a.as, children = _a.children, length = _a.length, rest = __rest(_a, ["as", "children", "length"]);
30
+ var Component = (as || OTPField.Root);
31
+ var id = (_b = rest === null || rest === void 0 ? void 0 : rest.id) !== null && _b !== void 0 ? _b : useId();
32
+ return (React.createElement(Component, __assign({}, rest, { id: id, length: length, className: classNames(styles.root, 'mosuk-input-otp', rest === null || rest === void 0 ? void 0 : rest.className) }), children));
35
33
  }
@@ -0,0 +1,49 @@
1
+ @layer mosuk-ui {
2
+ @layer index-11 {
3
+ .root {
4
+ display: flex;
5
+ width: 100%;
6
+ gap: var(--spacing-2, calc(var(--spacing, 0.25rem) * 2));
7
+ }
8
+
9
+ .input {
10
+ box-sizing: border-box;
11
+ margin: 0;
12
+ height: var(--spacing-11, calc(var(--spacing, 0.25rem) * 11));
13
+ width: var(--spacing-10, calc(var(--spacing, 0.25rem) * 10));
14
+ border-radius: var(--radius-lg, calc(var(--spacing, 0.25rem) * 2));
15
+ border: 1px solid var(--color-gray-300, rgb(209 213 219));
16
+ background-color: transparent;
17
+ text-align: center;
18
+ font-family: inherit;
19
+ font-size: var(--text-xl, calc(var(--spacing, 0.25rem) * 4.5));
20
+ font-weight: var(--font-medium, 500);
21
+ color: var(--color-black, #000);
22
+ outline: none;
23
+ transition: all 200ms ease-in-out;
24
+
25
+ &::placeholder {
26
+ color: var(--color-gray-500, oklch(0.551 0.027 264.364));
27
+ }
28
+
29
+ &:focus {
30
+ outline: none;
31
+ border-color: var(--color-blue-500, oklch(0.623 0.214 259.815));
32
+ }
33
+
34
+ &:read-only {
35
+ opacity: 50%;
36
+ pointer-events: none;
37
+ }
38
+ }
39
+
40
+ .separator {
41
+ display: flex;
42
+ align-items: center;
43
+ justify-content: center;
44
+ color: var(--color-gray-500, oklch(0.551 0.027 264.364));
45
+ font-size: var(--text-xl, calc(var(--spacing, 0.25rem) * 4.5));
46
+ font-weight: var(--font-medium, 500);
47
+ }
48
+ }
49
+ }
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import { OTPFieldInputProps } from "@base-ui/react";
3
+ export interface InputOtpFieldProps extends OTPFieldInputProps {
4
+ index?: number;
5
+ length?: number;
6
+ }
7
+ export declare function InputOtpField({ index, length, className, ...rest }: InputOtpFieldProps): React.JSX.Element;
@@ -0,0 +1,30 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
23
+ import classNames from 'classnames';
24
+ import React from 'react';
25
+ import { OTPFieldPreview as OTPField } from '@base-ui/react/otp-field';
26
+ import styles from '../component.module.css';
27
+ export function InputOtpField(_a) {
28
+ var index = _a.index, length = _a.length, className = _a.className, rest = __rest(_a, ["index", "length", "className"]);
29
+ return (React.createElement(OTPField.Input, __assign({ className: classNames(styles.input, 'mosuk-input-otp-field', className), "aria-label": "Character ".concat(index !== null && index !== void 0 ? index : 1, " of ").concat(length) }, rest)));
30
+ }
@@ -0,0 +1,13 @@
1
+ import { InputOtp as Component } from './component';
2
+ import { InputOtpProps as ComponentProps } from './component.interface';
3
+ import { InputOtpField, InputOtpFieldProps } from './field/component';
4
+ import { InputOtpSeparator, InputOtpSeparatorProps } from './separator/component';
5
+ export declare const InputOtp: typeof Component & {
6
+ Field: typeof InputOtpField;
7
+ Separator: typeof InputOtpSeparator;
8
+ };
9
+ export declare namespace InputOtp {
10
+ type Props = ComponentProps;
11
+ type FieldProps = InputOtpFieldProps;
12
+ type SeparatorProps = InputOtpSeparatorProps;
13
+ }
@@ -0,0 +1,7 @@
1
+ import { InputOtp as Component } from './component';
2
+ import { InputOtpField } from './field/component';
3
+ import { InputOtpSeparator } from './separator/component';
4
+ export var InputOtp = Object.assign(Component, {
5
+ Field: InputOtpField,
6
+ Separator: InputOtpSeparator,
7
+ });
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import { SeparatorProps } from "@base-ui/react";
3
+ export interface InputOtpSeparatorProps extends SeparatorProps {
4
+ index?: number;
5
+ length?: number;
6
+ }
7
+ export declare function InputOtpSeparator({ index, length, className, ...rest }: InputOtpSeparatorProps): React.JSX.Element;
@@ -0,0 +1,30 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
23
+ import classNames from 'classnames';
24
+ import React from 'react';
25
+ import { OTPFieldPreview as OTPField } from '@base-ui/react/otp-field';
26
+ import styles from '../component.module.css';
27
+ export function InputOtpSeparator(_a) {
28
+ var index = _a.index, length = _a.length, className = _a.className, rest = __rest(_a, ["index", "length", "className"]);
29
+ return (React.createElement(OTPField.Separator, __assign({ className: classNames(styles.separator, 'mosuk-input-otp-separator', className), "aria-label": "Character ".concat(index !== null && index !== void 0 ? index : 1, " of ").concat(length) }, rest)));
30
+ }
@@ -0,0 +1,3 @@
1
+ import React, { ElementType } from 'react';
2
+ import { InputOtpSkeletonProps } from './component.interface';
3
+ export declare function InputOtpSkeleton<C extends ElementType = 'div'>({ as, slots, children, ...rest }: InputOtpSkeletonProps<C>): React.JSX.Element;
@@ -0,0 +1,6 @@
1
+ import { ComponentPropsWithoutRef, ElementType, Ref } from 'react';
2
+ export type InputOtpSkeletonProps<C extends ElementType = 'div'> = {
3
+ as?: C;
4
+ ref?: Ref<any>;
5
+ slots?: number;
6
+ } & Omit<ComponentPropsWithoutRef<C>, 'as' | 'ref'>;
@@ -22,8 +22,9 @@ var __rest = (this && this.__rest) || function (s, e) {
22
22
  };
23
23
  import classNames from 'classnames';
24
24
  import React from 'react';
25
- import { Image } from '../../../component/components/component';
26
- export function ImagesImage(_a) {
27
- var rest = __rest(_a, []);
28
- return (React.createElement(Image, __assign({}, rest, { className: classNames('images-image', rest === null || rest === void 0 ? void 0 : rest.className) }), rest === null || rest === void 0 ? void 0 : rest.children));
25
+ import styles from './component.module.css';
26
+ export function InputOtpSkeleton(_a) {
27
+ var as = _a.as, _b = _a.slots, slots = _b === void 0 ? 6 : _b, children = _a.children, rest = __rest(_a, ["as", "slots", "children"]);
28
+ var Component = (as || 'div');
29
+ return (React.createElement(Component, __assign({}, rest, { className: classNames('mosuk-input-otp-skeleton', styles.otp, rest === null || rest === void 0 ? void 0 : rest.className) }), children));
29
30
  }
@@ -0,0 +1,18 @@
1
+ @layer mosuk-ui {
2
+ @layer index-11 {
3
+ .otp {
4
+ display: flex;
5
+ gap: calc(var(--spacing, .25rem) * 2);
6
+ width: 100%;
7
+ }
8
+
9
+ .slot {
10
+ width: calc(var(--spacing, .25rem) * 10);
11
+ height: calc(var(--spacing, .25rem) * 10);
12
+ min-width: calc(var(--spacing, .25rem) * 10);
13
+ min-height: calc(var(--spacing, .25rem) * 10);
14
+
15
+ border-radius: calc(var(--spacing, .25rem) * 2);
16
+ }
17
+ }
18
+ }
@@ -0,0 +1,6 @@
1
+ import { InputOtpSkeleton as Component } from './component';
2
+ import { InputOtpSkeletonProps as ComponentProps } from './component.interface';
3
+ export declare const InputOtpSkeleton: typeof Component;
4
+ export declare namespace InputOtpSkeleton {
5
+ type Props = ComponentProps;
6
+ }
@@ -0,0 +1,2 @@
1
+ import { InputOtpSkeleton as Component } from './component';
2
+ export var InputOtpSkeleton = Object.assign(Component, {});
@@ -30,7 +30,9 @@ export var Counter = forwardRef(function (props, externalRef) {
30
30
  // Преобразуем children в число
31
31
  var targetValue = typeof children === 'number'
32
32
  ? children
33
- : parseFloat(String(children).replace(/[^\d.,-]/g, '').replace(/,/g, '.')) || 0;
33
+ : parseFloat(String(children)
34
+ .replace(/[^\d.,-]/g, '')
35
+ .replace(/,/g, '.')) || 0;
34
36
  // Определяем количество десятичных знаков в исходном числе
35
37
  var getDecimalPlaces = function (num) {
36
38
  var match = String(num).match(/(?:\.(\d+))?$/);
@@ -41,8 +43,43 @@ export var Counter = forwardRef(function (props, externalRef) {
41
43
  var element = ref.current;
42
44
  if (!element)
43
45
  return;
44
- var rafId;
46
+ var rafId = 0;
45
47
  var isActive = true;
48
+ var finished = false;
49
+ var formatter = new Intl.NumberFormat('ru-RU', {
50
+ minimumFractionDigits: 0,
51
+ maximumFractionDigits: maxDigits,
52
+ });
53
+ var tolerance = maxDigits > 0
54
+ ? 0.5 * Math.pow(10, -maxDigits)
55
+ : Math.max(1e-6, Math.abs(targetValue) * 1e-9);
56
+ var applyFinal = function () {
57
+ if (!element)
58
+ return;
59
+ element.textContent = formatter.format(targetValue);
60
+ };
61
+ var stopRaf = function () {
62
+ if (rafId !== 0) {
63
+ cancelAnimationFrame(rafId);
64
+ rafId = 0;
65
+ }
66
+ };
67
+ var complete = function () {
68
+ if (!isActive || finished)
69
+ return;
70
+ finished = true;
71
+ stopRaf();
72
+ applyFinal();
73
+ };
74
+ var onTransitionEnd = function (event) {
75
+ if (event.target !== element)
76
+ return;
77
+ // Registered custom property: Chromium reports "--value"
78
+ if (event.propertyName !== '--value')
79
+ return;
80
+ complete();
81
+ };
82
+ element.addEventListener('transitionend', onTransitionEnd);
46
83
  // Небольшая задержка для запуска transition
47
84
  requestAnimationFrame(function () {
48
85
  if (!element || !isActive)
@@ -51,23 +88,25 @@ export var Counter = forwardRef(function (props, externalRef) {
51
88
  element.style.setProperty('--value', String(targetValue));
52
89
  });
53
90
  var animate = function () {
54
- if (!isActive || !element)
91
+ if (!isActive || !element || finished)
55
92
  return;
56
93
  try {
57
- var currentValue = parseFloat(getComputedStyle(element).getPropertyValue('--value')) || 0;
58
- element.textContent = new Intl.NumberFormat('ru-RU', {
59
- minimumFractionDigits: 0,
60
- maximumFractionDigits: maxDigits,
61
- }).format(currentValue);
94
+ var currentValue = parseFloat(getComputedStyle(element).getPropertyValue('--value')) ||
95
+ 0;
96
+ element.textContent = formatter.format(currentValue);
97
+ if (Math.abs(currentValue - targetValue) <= tolerance) {
98
+ complete();
99
+ return;
100
+ }
62
101
  }
63
102
  catch (_a) { }
64
- if (isActive)
65
- rafId = requestAnimationFrame(animate);
103
+ rafId = requestAnimationFrame(animate);
66
104
  };
67
105
  rafId = requestAnimationFrame(animate);
68
106
  return function () {
69
107
  isActive = false;
70
- cancelAnimationFrame(rafId);
108
+ stopRaf();
109
+ element.removeEventListener('transitionend', onTransitionEnd);
71
110
  };
72
111
  }, [targetValue, maxDigits]);
73
112
  // Объединяем refs
@@ -81,5 +120,9 @@ export var Counter = forwardRef(function (props, externalRef) {
81
120
  }
82
121
  }
83
122
  }, [externalRef]);
84
- return (React.createElement(Component, __assign({}, rest, { ref: ref, className: classNames(styles.counter, className), style: __assign({ '--value': 0 }, style) }), "0"));
123
+ return (React.createElement(Component, __assign({}, rest, { ref: ref, className: classNames(styles.counter, className),
124
+ // Не задаём --value через React: при каждом ре-рендере это сбрасывало бы
125
+ // переменную и срывало transition, из‑за чего RAF никогда не останавливался.
126
+ // Начальное значение задаётся в CSS (@property --value initial-value: 0).
127
+ style: style }), "0"));
85
128
  });
package/package.json CHANGED
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "name": "mosuk-ui",
3
- "version": "1.0.9",
3
+ "version": "1.11.0",
4
4
  "author": "mosuk",
5
5
  "license": "MIT",
6
6
  "private": false,
7
7
  "type": "module",
8
8
  "dependencies": {
9
- "@base-ui/react": "^1.3.0",
9
+ "@base-ui/react": "^1.4.1",
10
10
  "@dnd-kit/core": "^6.3.1",
11
+ "@dnd-kit/modifiers": "^9.0.0",
11
12
  "@dnd-kit/sortable": "^10.0.0",
12
13
  "@dnd-kit/utilities": "^3.2.2",
13
- "@dnd-kit/modifiers": "^9.0.0",
14
14
  "classnames": "^2.5.1",
15
15
  "date-fns": "^4.1.0",
16
16
  "lucide-react": "latest",
17
- "mosuk-utilities": "^1.0.0",
18
17
  "mosuk-icons": "^1.0.5",
18
+ "mosuk-utilities": "^1.0.0",
19
19
  "react-hook-form": "^7.56.4",
20
20
  "react-imask": "^7.6.1",
21
21
  "react-textarea-autosize": "^8.5.9",
@@ -23,10 +23,10 @@
23
23
  "swr": "^2.3.8"
24
24
  },
25
25
  "peerDependencies": {
26
+ "framer-motion": "^12.34.3",
26
27
  "next": "^15.3.4 || ^16.0.0-beta.0",
27
28
  "react": "^19.0.0",
28
- "react-dom": "^19.0.0",
29
- "framer-motion": "^12.34.3"
29
+ "react-dom": "^19.0.0"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@yandex/ymaps3-types": "^1.0.17595433"
@@ -87,6 +87,16 @@
87
87
  "default": "./components/actions/input/(mask)/skeleton/index.js"
88
88
  }
89
89
  },
90
+ "./components/actions/input/(otp)/component": {
91
+ "import": {
92
+ "default": "./components/actions/input/(otp)/component/index.js"
93
+ }
94
+ },
95
+ "./components/actions/input/(otp)/skeleton": {
96
+ "import": {
97
+ "default": "./components/actions/input/(otp)/skeleton/index.js"
98
+ }
99
+ },
90
100
  "./components/actions/input/(search)/component": {
91
101
  "import": {
92
102
  "default": "./components/actions/input/(search)/component/index.js"
@@ -257,16 +267,6 @@
257
267
  "default": "./components/display/file/skeleton/index.js"
258
268
  }
259
269
  },
260
- "./components/display/image/(images)/component": {
261
- "import": {
262
- "default": "./components/display/image/(images)/component/index.js"
263
- }
264
- },
265
- "./components/display/image/(images)/skeleton": {
266
- "import": {
267
- "default": "./components/display/image/(images)/skeleton/index.js"
268
- }
269
- },
270
270
  "./components/display/image/component": {
271
271
  "import": {
272
272
  "default": "./components/display/image/component/index.js"