@dss-kit/ui-kit 1.0.4 → 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.
Files changed (55) hide show
  1. package/README.md +19 -0
  2. package/dist/components/builders/Sheet/SheetLayer.js +95 -83
  3. package/dist/components/builders/Sheet/hooks/index.d.ts +1 -0
  4. package/dist/components/builders/Sheet/hooks/useMotionValueStyle.d.ts +8 -0
  5. package/dist/components/builders/Sheet/hooks/useMotionValueStyle.js +14 -0
  6. package/dist/components/builders/Table/TablePagination/TablePagination.d.ts +10 -4
  7. package/dist/components/builders/Table/TablePagination/TablePagination.js +230 -177
  8. package/dist/components/builders/Text/Text.d.ts +4 -1
  9. package/dist/components/builders/Text/Text.js +78 -76
  10. package/dist/components/controls/Button/Button.d.ts +1 -1
  11. package/dist/components/controls/Button/Button.js +47 -46
  12. package/dist/components/controls/OtpInput/OtpInput.js +121 -143
  13. package/dist/components/controls/OtpInput/styles.d.ts +1 -0
  14. package/dist/components/controls/OtpInput/styles.js +9 -3
  15. package/dist/components/controls/Select/Select.js +72 -70
  16. package/dist/components/shared/Toast/ToastContainer.d.ts +1 -1
  17. package/dist/components/shared/Toast/ToastContainer.js +25 -23
  18. package/dist/fonts/inter-cyrillic-ext-400.woff2 +0 -0
  19. package/dist/fonts/inter-cyrillic-ext-500.woff2 +0 -0
  20. package/dist/fonts/inter-cyrillic-ext-600.woff2 +0 -0
  21. package/dist/fonts/inter-cyrillic-ext-700.woff2 +0 -0
  22. package/dist/fonts/inter-cyrillic-ext-800.woff2 +0 -0
  23. package/dist/fonts/inter-latin-cyrillic-400.woff2 +0 -0
  24. package/dist/fonts/inter-latin-cyrillic-500.woff2 +0 -0
  25. package/dist/fonts/inter-latin-cyrillic-600.woff2 +0 -0
  26. package/dist/fonts/inter-latin-cyrillic-700.woff2 +0 -0
  27. package/dist/fonts/inter-latin-cyrillic-800.woff2 +0 -0
  28. package/dist/fonts/inter-latin-ext-400.woff2 +0 -0
  29. package/dist/fonts/inter-latin-ext-500.woff2 +0 -0
  30. package/dist/fonts/inter-latin-ext-600.woff2 +0 -0
  31. package/dist/fonts/inter-latin-ext-700.woff2 +0 -0
  32. package/dist/fonts/inter-latin-ext-800.woff2 +0 -0
  33. package/dist/index.js +34 -32
  34. package/dist/providers/MotionProvider/MotionProvider.d.ts +9 -0
  35. package/dist/providers/MotionProvider/MotionProvider.js +21 -0
  36. package/dist/providers/MotionProvider/MotionProvider.types.d.ts +12 -0
  37. package/dist/providers/MotionProvider/features.d.ts +1 -0
  38. package/dist/providers/MotionProvider/features.js +4 -0
  39. package/dist/providers/MotionProvider/index.d.ts +2 -0
  40. package/dist/providers/MotionProvider/loadMotionFeatures.d.ts +13 -0
  41. package/dist/providers/MotionProvider/loadMotionFeatures.js +9 -0
  42. package/dist/providers/index.d.ts +1 -0
  43. package/dist/styles/utils/breakpoints.d.ts +12 -0
  44. package/dist/styles/utils/breakpoints.js +20 -13
  45. package/dist/styles/utils/breakpoints.ts +32 -0
  46. package/dist/ui-kit.cjs +8 -8
  47. package/dist/ui-kit.css +1 -1
  48. package/package.json +3 -1
  49. package/dist/fonts/inter-normal-200.woff2 +0 -0
  50. package/dist/fonts/inter-normal-300.woff2 +0 -0
  51. package/dist/fonts/inter-normal-400.woff2 +0 -0
  52. package/dist/fonts/inter-normal-500.woff2 +0 -0
  53. package/dist/fonts/inter-normal-600.woff2 +0 -0
  54. package/dist/fonts/inter-normal-700.woff2 +0 -0
  55. 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 o, jsxs as y } from "react/jsx-runtime";
2
- import { css as A, cx as t } from "@emotion/css";
3
- import { useMergeRefs as F } from "@floating-ui/react";
4
- import { motion as v } from "framer-motion";
5
- import { forwardRef as G, useRef as L, useState as q, useMemo as J } from "react";
6
- import { SHEET_POSITION_CONFIG as K, SHEET_SNAP_POINT_VAR as Q } from "./Sheet.const.js";
7
- import { getClosestSnapPoint as U } from "./Sheet.utils.js";
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 { DialogCloseButton as $ } from "../Dialog/DialogCloseButton/DialogCloseButton.js";
13
- const ee = G(
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: n,
16
- onClose: m,
17
- onExited: P,
18
- position: c,
19
- backgroundColor: d,
20
- sizing: k,
21
- snapPoints: r,
22
- defaultSnapPoint: C,
23
- onSnapPointChange: M,
24
- closeThreshold: R,
25
- closeOnDrag: g,
26
- closeOnBackdropClick: x,
27
- showAbsoluteCloseButton: _,
28
- overlayClassName: b,
29
- sheetClassName: w,
30
- handleClassName: B,
31
- absoluteCloseButtonClassName: D,
32
- children: E
33
- }, H) => {
34
- const { axis: p, direction: i } = K[c], a = W[c], u = L(null), I = F([u, H]), [T, O] = q(
35
- C ?? r[0] ?? 1
36
- ), f = U(r, T), s = X({
37
- isOpen: n,
38
- onExited: P,
39
- direction: i,
40
- snapPoint: f
41
- }), { onPointerDown: V } = Y({
42
- axis: p,
43
- direction: i,
44
- panelRef: u,
45
- isOpen: n,
46
- snapPoints: r,
47
- closeOnDrag: g,
48
- closeThreshold: R,
49
- motion: s,
50
- onClose: m,
51
- onSnapPointSettle: (l) => {
52
- l !== f && (O(l), M?.(l));
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
- }), S = Z(x, m), j = J(
55
- () => A({ backgroundColor: d }),
56
- [d]
57
- ), h = i === 1, z = {
58
- [p]: s.translate,
59
- [Q]: s.snapSize
60
- }, N = /* @__PURE__ */ o(
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: t(e.handle, a.handle, B),
66
- children: /* @__PURE__ */ o("div", { className: t(e.handleBar, a.handleBar) })
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__ */ y("div", { className: t(e.root, !n && e.rootClosing), children: [
70
- /* @__PURE__ */ o(
71
- v.div,
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: t(e.backdrop, b),
75
- style: { opacity: s.backdropOpacity },
76
- onMouseDown: S.onMouseDown,
77
- onClick: S.onClick
88
+ className: a(o.backdrop, D),
89
+ onMouseDown: N.onMouseDown,
90
+ onClick: N.onClick
78
91
  }
79
92
  ),
80
- /* @__PURE__ */ y(
81
- v.div,
93
+ /* @__PURE__ */ k(
94
+ "div",
82
95
  {
83
- ref: I,
96
+ ref: F,
84
97
  role: "dialog",
85
98
  "aria-modal": "true",
86
- className: t(
87
- e.panel,
88
- a.panel,
89
- a.sizing[k],
90
- j,
91
- w
99
+ className: a(
100
+ o.panel,
101
+ r.panel,
102
+ r.sizing[M],
103
+ A,
104
+ E
92
105
  ),
93
- style: z,
94
- onPointerDown: V,
106
+ onPointerDown: z,
95
107
  children: [
96
- h && N,
97
- /* @__PURE__ */ o("div", { className: e.content, children: E }),
98
- !h && N,
99
- _ && /* @__PURE__ */ o(
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: D
115
+ className: I
104
116
  }
105
117
  )
106
118
  ]
@@ -109,7 +121,7 @@ const ee = G(
109
121
  ] });
110
122
  }
111
123
  );
112
- ee.displayName = "SheetLayer";
124
+ oe.displayName = "SheetLayer";
113
125
  export {
114
- ee as SheetLayer
126
+ oe as SheetLayer
115
127
  };
@@ -1,2 +1,3 @@
1
+ export { useMotionValueStyle } from './useMotionValueStyle';
1
2
  export { useSheetGesture } from './useSheetGesture';
2
3
  export { useSheetMotion } from './useSheetMotion';
@@ -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
- /** Подписи кнопок навигации (используется в варианте `simple`) */
31
- /** @default { prev: "Previous", next: "Next" } */
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
- /** @default undefined */
48
+ /**
49
+ * Функция для рендера значения селектора размера страницы.
50
+ * Когда пагинация уже 576px, вместо неё в поле показывается только число.
51
+ * @default undefined
52
+ */
47
53
  renderPageSizeSelectorInputItem?: (selectedItem: {
48
54
  value: string;
49
55
  label: string;