@dss-kit/ui-kit 1.0.3 → 1.1.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.
- package/README.md +19 -0
- package/dist/components/builders/Sheet/SheetLayer.js +95 -83
- package/dist/components/builders/Sheet/hooks/index.d.ts +1 -0
- package/dist/components/builders/Sheet/hooks/useMotionValueStyle.d.ts +8 -0
- package/dist/components/builders/Sheet/hooks/useMotionValueStyle.js +14 -0
- package/dist/components/builders/Table/TablePagination/TablePagination.d.ts +10 -4
- package/dist/components/builders/Table/TablePagination/TablePagination.js +230 -177
- package/dist/components/builders/Text/Text.d.ts +4 -1
- package/dist/components/builders/Text/Text.js +78 -76
- package/dist/components/controls/Button/Button.d.ts +1 -1
- package/dist/components/controls/Button/Button.js +47 -46
- package/dist/components/controls/OtpInput/OtpInput.js +121 -143
- package/dist/components/controls/OtpInput/styles.d.ts +1 -0
- package/dist/components/controls/OtpInput/styles.js +9 -3
- package/dist/components/controls/Select/Select.js +72 -70
- package/dist/components/controls/Switch/Switch.d.ts +10 -6
- package/dist/components/controls/Switch/Switch.js +109 -86
- package/dist/components/controls/Switch/styles.d.ts +3 -2
- package/dist/components/controls/Switch/styles.js +76 -73
- package/dist/components/shared/Toast/ToastContainer.d.ts +1 -1
- package/dist/components/shared/Toast/ToastContainer.js +25 -23
- package/dist/fonts/inter-cyrillic-ext-400.woff2 +0 -0
- package/dist/fonts/inter-cyrillic-ext-500.woff2 +0 -0
- package/dist/fonts/inter-cyrillic-ext-600.woff2 +0 -0
- package/dist/fonts/inter-cyrillic-ext-700.woff2 +0 -0
- package/dist/fonts/inter-cyrillic-ext-800.woff2 +0 -0
- package/dist/fonts/inter-latin-cyrillic-400.woff2 +0 -0
- package/dist/fonts/inter-latin-cyrillic-500.woff2 +0 -0
- package/dist/fonts/inter-latin-cyrillic-600.woff2 +0 -0
- package/dist/fonts/inter-latin-cyrillic-700.woff2 +0 -0
- package/dist/fonts/inter-latin-cyrillic-800.woff2 +0 -0
- package/dist/fonts/inter-latin-ext-400.woff2 +0 -0
- package/dist/fonts/inter-latin-ext-500.woff2 +0 -0
- package/dist/fonts/inter-latin-ext-600.woff2 +0 -0
- package/dist/fonts/inter-latin-ext-700.woff2 +0 -0
- package/dist/fonts/inter-latin-ext-800.woff2 +0 -0
- package/dist/index.js +34 -32
- package/dist/providers/MotionProvider/MotionProvider.d.ts +9 -0
- package/dist/providers/MotionProvider/MotionProvider.js +21 -0
- package/dist/providers/MotionProvider/MotionProvider.types.d.ts +12 -0
- package/dist/providers/MotionProvider/features.d.ts +1 -0
- package/dist/providers/MotionProvider/features.js +4 -0
- package/dist/providers/MotionProvider/index.d.ts +2 -0
- package/dist/providers/MotionProvider/loadMotionFeatures.d.ts +13 -0
- package/dist/providers/MotionProvider/loadMotionFeatures.js +9 -0
- package/dist/providers/index.d.ts +1 -0
- package/dist/styles/utils/breakpoints.d.ts +12 -0
- package/dist/styles/utils/breakpoints.js +20 -13
- package/dist/styles/utils/breakpoints.ts +32 -0
- package/dist/ui-kit.cjs +8 -8
- package/dist/ui-kit.css +1 -1
- package/package.json +3 -1
- package/dist/fonts/inter-normal-200.woff2 +0 -0
- package/dist/fonts/inter-normal-300.woff2 +0 -0
- package/dist/fonts/inter-normal-400.woff2 +0 -0
- package/dist/fonts/inter-normal-500.woff2 +0 -0
- package/dist/fonts/inter-normal-600.woff2 +0 -0
- package/dist/fonts/inter-normal-700.woff2 +0 -0
- package/dist/fonts/inter-normal-800.woff2 +0 -0
package/README.md
CHANGED
|
@@ -19,6 +19,25 @@ Storybook для библиотеки React-компонентов **UI Kit** (`
|
|
|
19
19
|
этой ветки на `storybook-trials-<id>.staging.dssnet.tech` (живёт 7 дней, продлевается при
|
|
20
20
|
повторном деплое).
|
|
21
21
|
|
|
22
|
+
## Предзагрузка шрифтов
|
|
23
|
+
|
|
24
|
+
Шрифт Inter приходит вместе с `ui-kit.css`, но браузер начинает его качать только
|
|
25
|
+
после разбора CSS. Основные начертания (500 и 400) приложение может запросить
|
|
26
|
+
заранее. В Vite-приложении достаточно сослаться на файл в `node_modules`, и Vite
|
|
27
|
+
подставит тот же хешированный URL, что и в CSS:
|
|
28
|
+
|
|
29
|
+
```html
|
|
30
|
+
<link
|
|
31
|
+
rel="preload"
|
|
32
|
+
href="/node_modules/@dss-kit/ui-kit/dist/fonts/inter-latin-cyrillic-500.woff2"
|
|
33
|
+
as="font"
|
|
34
|
+
type="font/woff2"
|
|
35
|
+
crossorigin
|
|
36
|
+
/>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Подробнее, включая подмножества шрифта и предзагрузку из кода: [Шрифты](./docs/styles/fonts/index.md).
|
|
40
|
+
|
|
22
41
|
## Документация
|
|
23
42
|
|
|
24
43
|
Ссылки на более подробную документацию по разделам
|
|
@@ -1,106 +1,118 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { css as
|
|
3
|
-
import { useMergeRefs as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { styles as e, positionStyles as W } from "./styles.js";
|
|
1
|
+
import { jsx as s, jsxs as k } from "react/jsx-runtime";
|
|
2
|
+
import { css as G, cx as a } from "@emotion/css";
|
|
3
|
+
import { useMergeRefs as L } from "@floating-ui/react";
|
|
4
|
+
import { forwardRef as $, useRef as v, useState as U, useMemo as q } from "react";
|
|
5
|
+
import { SHEET_POSITION_CONFIG as J, SHEET_SNAP_POINT_VAR as K } from "./Sheet.const.js";
|
|
6
|
+
import { getClosestSnapPoint as Q } from "./Sheet.utils.js";
|
|
7
|
+
import { styles as o, positionStyles as W } from "./styles.js";
|
|
9
8
|
import { useSheetMotion as X } from "./hooks/useSheetMotion.js";
|
|
10
9
|
import { useSheetGesture as Y } from "./hooks/useSheetGesture.js";
|
|
11
10
|
import { useBackdropClose as Z } from "../Dialog/hooks/useBackdropClose.js";
|
|
12
|
-
import {
|
|
13
|
-
|
|
11
|
+
import { useMotionValueStyle as d } from "./hooks/useMotionValueStyle.js";
|
|
12
|
+
import { DialogCloseButton as ee } from "../Dialog/DialogCloseButton/DialogCloseButton.js";
|
|
13
|
+
const oe = $(
|
|
14
14
|
({
|
|
15
|
-
isOpen:
|
|
16
|
-
onClose:
|
|
17
|
-
onExited:
|
|
18
|
-
position:
|
|
19
|
-
backgroundColor:
|
|
20
|
-
sizing:
|
|
21
|
-
snapPoints:
|
|
22
|
-
defaultSnapPoint:
|
|
23
|
-
onSnapPointChange:
|
|
24
|
-
closeThreshold:
|
|
25
|
-
closeOnDrag:
|
|
26
|
-
closeOnBackdropClick:
|
|
27
|
-
showAbsoluteCloseButton:
|
|
28
|
-
overlayClassName:
|
|
29
|
-
sheetClassName:
|
|
30
|
-
handleClassName:
|
|
31
|
-
absoluteCloseButtonClassName:
|
|
32
|
-
children:
|
|
33
|
-
},
|
|
34
|
-
const { axis:
|
|
35
|
-
|
|
36
|
-
),
|
|
37
|
-
isOpen:
|
|
38
|
-
onExited:
|
|
39
|
-
direction:
|
|
40
|
-
snapPoint:
|
|
41
|
-
}), { onPointerDown:
|
|
42
|
-
axis:
|
|
43
|
-
direction:
|
|
44
|
-
panelRef:
|
|
45
|
-
isOpen:
|
|
46
|
-
snapPoints:
|
|
47
|
-
closeOnDrag:
|
|
48
|
-
closeThreshold:
|
|
49
|
-
motion:
|
|
50
|
-
onClose:
|
|
51
|
-
onSnapPointSettle: (
|
|
52
|
-
|
|
15
|
+
isOpen: l,
|
|
16
|
+
onClose: p,
|
|
17
|
+
onExited: C,
|
|
18
|
+
position: u,
|
|
19
|
+
backgroundColor: f,
|
|
20
|
+
sizing: M,
|
|
21
|
+
snapPoints: c,
|
|
22
|
+
defaultSnapPoint: R,
|
|
23
|
+
onSnapPointChange: b,
|
|
24
|
+
closeThreshold: x,
|
|
25
|
+
closeOnDrag: _,
|
|
26
|
+
closeOnBackdropClick: w,
|
|
27
|
+
showAbsoluteCloseButton: B,
|
|
28
|
+
overlayClassName: D,
|
|
29
|
+
sheetClassName: E,
|
|
30
|
+
handleClassName: H,
|
|
31
|
+
absoluteCloseButtonClassName: I,
|
|
32
|
+
children: T
|
|
33
|
+
}, V) => {
|
|
34
|
+
const { axis: S, direction: m } = J[u], r = W[u], h = v(null), n = v(null), F = L([n, V]), [O, j] = U(
|
|
35
|
+
R ?? c[0] ?? 1
|
|
36
|
+
), y = Q(c, O), i = X({
|
|
37
|
+
isOpen: l,
|
|
38
|
+
onExited: C,
|
|
39
|
+
direction: m,
|
|
40
|
+
snapPoint: y
|
|
41
|
+
}), { onPointerDown: z } = Y({
|
|
42
|
+
axis: S,
|
|
43
|
+
direction: m,
|
|
44
|
+
panelRef: n,
|
|
45
|
+
isOpen: l,
|
|
46
|
+
snapPoints: c,
|
|
47
|
+
closeOnDrag: _,
|
|
48
|
+
closeThreshold: x,
|
|
49
|
+
motion: i,
|
|
50
|
+
onClose: p,
|
|
51
|
+
onSnapPointSettle: (e) => {
|
|
52
|
+
e !== y && (j(e), b?.(e));
|
|
53
53
|
}
|
|
54
|
-
}),
|
|
55
|
-
() =>
|
|
56
|
-
[
|
|
57
|
-
)
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
54
|
+
}), N = Z(w, p), A = q(
|
|
55
|
+
() => G({ backgroundColor: f }),
|
|
56
|
+
[f]
|
|
57
|
+
);
|
|
58
|
+
d(
|
|
59
|
+
h,
|
|
60
|
+
i.backdropOpacity,
|
|
61
|
+
(e, t) => {
|
|
62
|
+
e.style.opacity = String(t);
|
|
63
|
+
}
|
|
64
|
+
), d(
|
|
65
|
+
n,
|
|
66
|
+
i.translate,
|
|
67
|
+
(e, t) => {
|
|
68
|
+
e.style.transform = parseFloat(t) === 0 ? "none" : `translate${S.toUpperCase()}(${t})`;
|
|
69
|
+
}
|
|
70
|
+
), d(n, i.snapSize, (e, t) => {
|
|
71
|
+
e.style.setProperty(K, String(t));
|
|
72
|
+
});
|
|
73
|
+
const P = m === 1, g = /* @__PURE__ */ s(
|
|
61
74
|
"div",
|
|
62
75
|
{
|
|
63
76
|
"data-sheet-handle": "",
|
|
64
77
|
"aria-hidden": !0,
|
|
65
|
-
className:
|
|
66
|
-
children: /* @__PURE__ */
|
|
78
|
+
className: a(o.handle, r.handle, H),
|
|
79
|
+
children: /* @__PURE__ */ s("div", { className: a(o.handleBar, r.handleBar) })
|
|
67
80
|
}
|
|
68
81
|
);
|
|
69
|
-
return /* @__PURE__ */
|
|
70
|
-
/* @__PURE__ */
|
|
71
|
-
|
|
82
|
+
return /* @__PURE__ */ k("div", { className: a(o.root, !l && o.rootClosing), children: [
|
|
83
|
+
/* @__PURE__ */ s(
|
|
84
|
+
"div",
|
|
72
85
|
{
|
|
86
|
+
ref: h,
|
|
73
87
|
"aria-hidden": !0,
|
|
74
|
-
className:
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
onClick: S.onClick
|
|
88
|
+
className: a(o.backdrop, D),
|
|
89
|
+
onMouseDown: N.onMouseDown,
|
|
90
|
+
onClick: N.onClick
|
|
78
91
|
}
|
|
79
92
|
),
|
|
80
|
-
/* @__PURE__ */
|
|
81
|
-
|
|
93
|
+
/* @__PURE__ */ k(
|
|
94
|
+
"div",
|
|
82
95
|
{
|
|
83
|
-
ref:
|
|
96
|
+
ref: F,
|
|
84
97
|
role: "dialog",
|
|
85
98
|
"aria-modal": "true",
|
|
86
|
-
className:
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
99
|
+
className: a(
|
|
100
|
+
o.panel,
|
|
101
|
+
r.panel,
|
|
102
|
+
r.sizing[M],
|
|
103
|
+
A,
|
|
104
|
+
E
|
|
92
105
|
),
|
|
93
|
-
|
|
94
|
-
onPointerDown: V,
|
|
106
|
+
onPointerDown: z,
|
|
95
107
|
children: [
|
|
96
|
-
|
|
97
|
-
/* @__PURE__ */
|
|
98
|
-
!
|
|
99
|
-
|
|
100
|
-
|
|
108
|
+
P && g,
|
|
109
|
+
/* @__PURE__ */ s("div", { className: o.content, children: T }),
|
|
110
|
+
!P && g,
|
|
111
|
+
B && /* @__PURE__ */ s(
|
|
112
|
+
ee,
|
|
101
113
|
{
|
|
102
114
|
absolute: !0,
|
|
103
|
-
className:
|
|
115
|
+
className: I
|
|
104
116
|
}
|
|
105
117
|
)
|
|
106
118
|
]
|
|
@@ -109,7 +121,7 @@ const ee = G(
|
|
|
109
121
|
] });
|
|
110
122
|
}
|
|
111
123
|
);
|
|
112
|
-
|
|
124
|
+
oe.displayName = "SheetLayer";
|
|
113
125
|
export {
|
|
114
|
-
|
|
126
|
+
oe as SheetLayer
|
|
115
127
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { MotionValue } from 'framer-motion';
|
|
2
|
+
import { RefObject } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* Пишет motion value прямо в стиль элемента, как это делал `motion.div`, но
|
|
5
|
+
* без renderer'а framer-motion. Renderer грузится лениво (см. MotionProvider),
|
|
6
|
+
* а Sheet должен двигаться сразу и даже если чанк с фичами не загрузился.
|
|
7
|
+
*/
|
|
8
|
+
export declare function useMotionValueStyle<T>(ref: RefObject<HTMLElement>, value: MotionValue<T>, apply: (element: HTMLElement, latest: T) => void): void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useLayoutEffect as f } from "react";
|
|
2
|
+
import { useLatestRef as s } from "../../../../utils/hooks/useLatestRef.js";
|
|
3
|
+
function m(e, t, u) {
|
|
4
|
+
const n = s(u);
|
|
5
|
+
f(() => {
|
|
6
|
+
const o = e.current;
|
|
7
|
+
if (!o) return;
|
|
8
|
+
const r = (c) => n.current(o, c);
|
|
9
|
+
return r(t.get()), t.on("change", r);
|
|
10
|
+
}, [e, t, n]);
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
m as useMotionValueStyle
|
|
14
|
+
};
|
|
@@ -27,8 +27,11 @@ export interface TablePaginationProps {
|
|
|
27
27
|
/** Вариант отображения пагинации */
|
|
28
28
|
/** @default "numbered" */
|
|
29
29
|
variant?: TablePaginationVariant;
|
|
30
|
-
/**
|
|
31
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Подписи кнопок навигации (используется в варианте `simple`).
|
|
32
|
+
* Когда пагинация уже 576px, кнопки становятся иконками, а подписи — их `aria-label`.
|
|
33
|
+
* @default { prev: "Previous", next: "Next" }
|
|
34
|
+
*/
|
|
32
35
|
labels?: TablePaginationLabels;
|
|
33
36
|
/** Доступные размеры страниц */
|
|
34
37
|
/** @default [10, 20, 50, 100] */
|
|
@@ -42,8 +45,11 @@ export interface TablePaginationProps {
|
|
|
42
45
|
value: string;
|
|
43
46
|
label: string;
|
|
44
47
|
}) => string;
|
|
45
|
-
/**
|
|
46
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Функция для рендера значения селектора размера страницы.
|
|
50
|
+
* Когда пагинация уже 576px, вместо неё в поле показывается только число.
|
|
51
|
+
* @default undefined
|
|
52
|
+
*/
|
|
47
53
|
renderPageSizeSelectorInputItem?: (selectedItem: {
|
|
48
54
|
value: string;
|
|
49
55
|
label: string;
|