@dss-kit/ui-kit 0.3.3 → 0.3.5

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.
@@ -2,12 +2,12 @@ import { jsx as t, jsxs as M } from "react/jsx-runtime";
2
2
  import { cx as i } from "@emotion/css";
3
3
  import { forwardRef as B, useEffect as c, useCallback as f, useRef as D } from "react";
4
4
  import N from "../../../assets/svg/modal/close.svg.js";
5
- import { ModalContext as E } from "./context.js";
5
+ import { ModalContext as z } from "./context.js";
6
6
  import { styles as n } from "./styles.js";
7
- import { Portal as P } from "../Portal/Portal.js";
7
+ import { Portal as E } from "../Portal/Portal.js";
8
8
  import { Box as s } from "../Box/Box.js";
9
- import { IconButton as j } from "../../controls/IconButton/IconButton.js";
10
- import { theme as z } from "../../../utils/theme/index.js";
9
+ import { IconButton as P } from "../../controls/IconButton/IconButton.js";
10
+ import { theme as j } from "../../../utils/theme/index.js";
11
11
  const C = B(
12
12
  ({
13
13
  isOpen: o,
@@ -21,7 +21,7 @@ const C = B(
21
21
  disableBodyScroll: l = !0,
22
22
  showAbsoluteCloseButton: g,
23
23
  children: v
24
- }, k) => {
24
+ }, x) => {
25
25
  c(() => {
26
26
  if (l && o && typeof window < "u" && typeof document < "u") {
27
27
  const e = window.getComputedStyle(document.body).overflow;
@@ -40,7 +40,7 @@ const C = B(
40
40
  if (typeof window < "u" && typeof document < "u" && u && o)
41
41
  return document.addEventListener("keydown", d), () => document.removeEventListener("keydown", d);
42
42
  }, [o, u, d]);
43
- const a = D(!1), x = f((e) => {
43
+ const a = D(!1), k = f((e) => {
44
44
  a.current = e.target === e.currentTarget;
45
45
  }, []), b = f(
46
46
  (e) => {
@@ -48,7 +48,7 @@ const C = B(
48
48
  },
49
49
  [m, r]
50
50
  );
51
- return o ? /* @__PURE__ */ t(P, { children: /* @__PURE__ */ t(E.Provider, { value: { isOpen: o, onClose: r }, children: /* @__PURE__ */ t(
51
+ return o ? /* @__PURE__ */ t(E, { children: /* @__PURE__ */ t(z.Provider, { value: { isOpen: o, onClose: r }, children: /* @__PURE__ */ t(
52
52
  s,
53
53
  {
54
54
  position: "fixed",
@@ -59,15 +59,15 @@ const C = B(
59
59
  row: !0,
60
60
  center: !0,
61
61
  flex: 1,
62
- onMouseDown: x,
62
+ onMouseDown: k,
63
63
  onClick: b,
64
- backgroundColor: z.color.fill.bgOverlayPrimary,
64
+ backgroundColor: j.color.fill.bgOverlayPrimary,
65
65
  className: i(n.overlay, y),
66
66
  zIndex: 1,
67
67
  children: /* @__PURE__ */ M(
68
68
  s,
69
69
  {
70
- ref: k,
70
+ ref: x,
71
71
  className: i(
72
72
  n.modal,
73
73
  n[`size_${h}`],
@@ -76,7 +76,7 @@ const C = B(
76
76
  relative: !0,
77
77
  children: [
78
78
  g && /* @__PURE__ */ t(
79
- j,
79
+ P,
80
80
  {
81
81
  className: i(
82
82
  n.closeButton,
@@ -84,6 +84,7 @@ const C = B(
84
84
  ),
85
85
  onClick: r,
86
86
  color: "neutral",
87
+ size: "xs",
87
88
  children: /* @__PURE__ */ t(N, {})
88
89
  }
89
90
  ),
@@ -1,4 +1,36 @@
1
1
  import { BoxProps } from '../../Box';
2
+ /**
3
+ * Пропсы компонента `ModalFooter`.
4
+ *
5
+ * Наследует все пропсы `Box` (см. {@link BoxProps}); ниже переопределены
6
+ * футер-специфичные пропсы с их значениями по умолчанию.
7
+ */
8
+ export interface ModalFooterProps extends BoxProps {
9
+ /**
10
+ * Дочерние элементы футера (обычно кнопки действий).
11
+ * @default undefined */
12
+ children?: React.ReactNode;
13
+ /**
14
+ * Горизонтальное расположение элементов (flex-direction: row).
15
+ * @default true */
16
+ row?: BoxProps["row"];
17
+ /**
18
+ * Включение flexbox layout.
19
+ * @default true */
20
+ flex?: BoxProps["flex"];
21
+ /**
22
+ * Расстояние между дочерними элементами.
23
+ * @default theme.spacing.lg */
24
+ gap?: BoxProps["gap"];
25
+ /**
26
+ * Внутренние отступы футера.
27
+ * @default theme.spacing["2xl"] */
28
+ p?: BoxProps["p"];
29
+ /**
30
+ * Дополнительный CSS-класс для корневого `Box` футера.
31
+ * @default undefined */
32
+ className?: string;
33
+ }
2
34
  /**
3
35
  * Компонент футера модального окна.
4
36
  *
@@ -27,7 +59,7 @@ import { BoxProps } from '../../Box';
27
59
  * </ModalFooter>
28
60
  * ```
29
61
  */
30
- declare const ModalFooter: import('react').ForwardRefExoticComponent<Omit<BoxProps, "ref"> & import('react').RefAttributes<HTMLDivElement>>;
62
+ declare const ModalFooter: import('react').ForwardRefExoticComponent<Omit<ModalFooterProps, "ref"> & import('react').RefAttributes<HTMLDivElement>>;
31
63
  /**
32
64
  * Экспорт компонента ModalFooter.
33
65
  *
@@ -7,19 +7,13 @@ const x = f({
7
7
  borderTop: `1px solid ${o.color.border.neutralAlphaBasic}`
8
8
  }), u = d(
9
9
  ({
10
- /** Дочерние элементы футера (обычно кнопки) */
11
10
  children: r,
12
- /** Горизонтальное расположение элементов. @default true */
13
11
  row: t = !0,
14
- /** Включение flexbox layout. @default true */
15
12
  flex: e = !0,
16
- /** Расстояние между дочерними элементами. @default spacing.lg */
17
13
  gap: m = o.spacing.lg,
18
- /** Внутренние отступы футера. @default spacing['2xl'] */
19
14
  p: s = o.spacing["2xl"],
20
- /** Дополнительные CSS классы */
21
15
  className: a,
22
- /** Остальные пропсы передаются в компонент Box */
16
+ // Остальные пропсы передаются в компонент Box
23
17
  ...p
24
18
  }, l) => /* @__PURE__ */ i(
25
19
  n,
@@ -1 +1,2 @@
1
+ export type { ModalFooterProps } from './ModalFooter';
1
2
  export { ModalFooter } from './ModalFooter';
@@ -1,5 +1,5 @@
1
1
  import { BoxProps } from '../../Box';
2
- interface ModalHeaderProps extends Pick<BoxProps, "p" | "px" | "py" | "pt" | "pb" | "row" | "justifyContent" | "w"> {
2
+ export interface ModalHeaderProps extends Pick<BoxProps, "p" | "px" | "py" | "pt" | "pb" | "row" | "justifyContent" | "w"> {
3
3
  /**
4
4
  * Основной заголовок, отображаемый в шапке модального окна.
5
5
  * Стилизуется как title-3 с полужирным начертанием.
@@ -1,79 +1,80 @@
1
- import { jsxs as t, jsx as o } from "react/jsx-runtime";
1
+ import { jsxs as e, jsx as r } from "react/jsx-runtime";
2
2
  import { forwardRef as B } from "react";
3
3
  import W from "../../../../assets/svg/modal/close.svg.js";
4
4
  import { useModalContext as v } from "../context.js";
5
- import { Box as e } from "../../Box/Box.js";
6
- import { theme as r } from "../../../../utils/theme/index.js";
7
- import { Text as l } from "../../Text/Text.js";
5
+ import { Box as t } from "../../Box/Box.js";
6
+ import { theme as o } from "../../../../utils/theme/index.js";
7
+ import { Text as a } from "../../Text/Text.js";
8
8
  import { IconButton as M } from "../../../controls/IconButton/IconButton.js";
9
9
  const j = B(
10
10
  ({
11
- title: a,
12
- subtitle: i,
11
+ title: i,
12
+ subtitle: l,
13
13
  w: m = "full",
14
- p: n,
15
- py: s,
16
- px: d = r.spacing["2xl"],
17
- pt: c = r.spacing["2xl"],
18
- pb: p = r.spacing.lg,
14
+ p: s,
15
+ py: n,
16
+ px: d = o.spacing["2xl"],
17
+ pt: c = o.spacing["2xl"],
18
+ pb: p = o.spacing.lg,
19
19
  row: f = !0,
20
20
  justifyContent: h = "space-between",
21
21
  showCloseButton: g = !1,
22
- className: b,
23
- titleClassName: u,
24
- subtitleClassName: x,
22
+ className: x,
23
+ titleClassName: b,
24
+ subtitleClassName: u,
25
25
  closeButtonClassName: N
26
26
  }, y) => {
27
27
  const { onClose: C } = v();
28
- return /* @__PURE__ */ t(
29
- e,
28
+ return /* @__PURE__ */ e(
29
+ t,
30
30
  {
31
31
  w: m,
32
- p: n,
33
- py: s,
32
+ p: s,
33
+ py: n,
34
34
  px: d,
35
35
  pt: c,
36
36
  pb: p,
37
37
  row: f,
38
38
  justifyContent: h,
39
39
  ref: y,
40
- borderColor: r.color.border.neutralAlphaBasic,
40
+ borderColor: o.color.border.neutralAlphaBasic,
41
41
  borderWidth: 0,
42
42
  borderBottomWidth: 1,
43
43
  borderStyle: "solid",
44
- className: b,
44
+ className: x,
45
45
  children: [
46
- /* @__PURE__ */ t(e, { gap: r.spacing.sm, children: [
47
- /* @__PURE__ */ o(
48
- l,
46
+ /* @__PURE__ */ e(t, { gap: o.spacing.sm, children: [
47
+ /* @__PURE__ */ r(
48
+ a,
49
49
  {
50
50
  variant: "title-3",
51
51
  colorName: "primary",
52
52
  fontWeight: "semibold",
53
- className: u,
54
- children: a
53
+ className: b,
54
+ children: i
55
55
  }
56
56
  ),
57
- /* @__PURE__ */ o(
58
- l,
57
+ /* @__PURE__ */ r(
58
+ a,
59
59
  {
60
60
  variant: "body-1",
61
61
  colorName: "tertiary",
62
62
  fontWeight: "medium",
63
- className: x,
64
- children: i
63
+ className: u,
64
+ children: l
65
65
  }
66
66
  )
67
67
  ] }),
68
- g && /* @__PURE__ */ o(e, { children: /* @__PURE__ */ o(
68
+ g && /* @__PURE__ */ r(
69
69
  M,
70
70
  {
71
71
  onClick: C,
72
72
  color: "neutral",
73
73
  className: N,
74
- children: /* @__PURE__ */ o(W, {})
74
+ size: "xs",
75
+ children: /* @__PURE__ */ r(W, {})
75
76
  }
76
- ) })
77
+ )
77
78
  ]
78
79
  }
79
80
  );
@@ -1 +1,2 @@
1
+ export type { ModalHeaderProps } from './ModalHeader';
1
2
  export { ModalHeader } from './ModalHeader';
@@ -24,7 +24,7 @@ interface ModalMainRef {
24
24
  * @interface ModalMainProps
25
25
  * @extends {PropsWithChildren}
26
26
  */
27
- interface ModalMainProps extends PropsWithChildren {
27
+ export interface ModalMainProps extends PropsWithChildren {
28
28
  /**
29
29
  * Направление расположения элементов
30
30
  * Если true, flex-direction будет row, иначе column
@@ -1,2 +1,2 @@
1
- export type { ModalMainRef } from './ModalMain';
1
+ export type { ModalMainProps, ModalMainRef } from './ModalMain';
2
2
  export { ModalMain } from './ModalMain';
@@ -1,12 +1,28 @@
1
+ import { ReactNode, RefAttributes } from 'react';
1
2
  import { ModalProps } from './Modal';
2
3
  import { ModalFooter } from './ModalFooter';
3
4
  import { ModalHeader } from './ModalHeader';
4
5
  import { ModalMain } from './ModalMain';
5
- interface ModalWithSubComponentsProps extends React.ForwardRefExoticComponent<ModalProps & React.RefAttributes<HTMLDivElement>> {
6
+ /**
7
+ * Тип составного компонента `Modal`.
8
+ *
9
+ * Намеренно НЕ наследует `ForwardRefExoticComponent`: это убирает из
10
+ * автодополнения `<Modal.` служебные React-поля ($$typeof, displayName,
11
+ * propTypes, defaultProps), оставляя `Header` / `Main` / `Footer`.
12
+ * Компонент по-прежнему вызывается как `<Modal>` и принимает `ref`.
13
+ *
14
+ * NB: члены `Function` (apply/bind/call/…) TypeScript всё равно подмешивает
15
+ * к любому вызываемому значению — полностью убрать их без отказа от `<Modal>`
16
+ * нельзя.
17
+ */
18
+ type ModalComponent = ((props: ModalProps & RefAttributes<HTMLDivElement>) => ReactNode) & {
6
19
  Header: typeof ModalHeader;
7
20
  Main: typeof ModalMain;
8
21
  Footer: typeof ModalFooter;
9
- }
10
- declare const ModalWithSubComponents: ModalWithSubComponentsProps;
22
+ };
23
+ declare const ModalWithSubComponents: ModalComponent;
11
24
  export { ModalWithSubComponents as Modal };
12
25
  export type { ModalProps };
26
+ export type { ModalFooterProps } from './ModalFooter';
27
+ export type { ModalHeaderProps } from './ModalHeader';
28
+ export type { ModalMainProps } from './ModalMain';
@@ -17,7 +17,7 @@ const p = (s, f, g) => {
17
17
  right: e === "right" ? o : void 0,
18
18
  zIndex: 1,
19
19
  background: g,
20
- boxShadow: l ? `-4px 0 4px -4px ${d.color.effect.shadowL} inset` : e === "right" && i === 0 ? `4px 0 4px -4px ${d.color.effect.shadowL} inset` : void 0
20
+ boxShadow: l ? `-2px 0 2px -2px ${d.color.effect.shadowL} inset` : e === "right" && i === 0 ? `2px 0 2px -2px ${d.color.effect.shadowL} inset` : void 0
21
21
  };
22
22
  };
23
23
  export {
@@ -3,17 +3,31 @@ import { AccentType, NegativeType, NeutralType, PositiveType, Size, TransferType
3
3
  export type BadgeVariant = "filled" | "outline" | "clear";
4
4
  export type BadgeColor = NeutralType | AccentType | WarningType | PositiveType | NegativeType | TransferType;
5
5
  export type BadgeSize = Extract<Size, "sm" | "md" | "lg">;
6
+ export type BadgeTextAlign = "left" | "center" | "right";
6
7
  export interface BadgeProps {
8
+ /** Содержимое лейбла бейджа. Текст всегда центрируется по вертикали внутри бейджа. */
7
9
  label: ReactNode;
10
+ /** Цветовая схема бейджа (фон, рамка и цвет текста берутся из соответствующего токена). @default "neutral" */
8
11
  color?: BadgeColor;
12
+ /** Стиль заливки: "filled" — цветной фон, "outline" — только рамка, "clear" — прозрачный фон без рамки. @default "filled" */
9
13
  variant?: BadgeVariant;
14
+ /** Размер бейджа: "sm" (24px), "md" (32px) или "lg" (40px) — определяет высоту, отступы и вариант текста. @default "md" */
10
15
  size?: BadgeSize;
16
+ /** Фиксированная ширина бейджа (число в px или CSS-строка). Если не задана, ширина определяется содержимым. */
11
17
  width?: number | string;
18
+ /** Расположение текста лейбла по горизонтали внутри бейджа. @default "center" */
19
+ textAlign?: BadgeTextAlign;
20
+ /** Элемент (иконка и т.п.), отображаемый слева от текста лейбла. */
12
21
  leftElement?: ReactNode;
22
+ /** Элемент (иконка и т.п.), отображаемый справа от текста лейбла. */
13
23
  rightElement?: ReactNode;
24
+ /** Переводит бейдж в неактивное состояние: снижает непрозрачность, отключает клик и скрывает кнопку удаления. @default false */
14
25
  disabled?: boolean;
26
+ /** Обработчик клика по бейджу. Если передан (и `disabled` не установлен), бейдж становится кликабельным и получает эффект Ripple. */
15
27
  onClick?: (e: MouseEvent) => void;
28
+ /** Обработчик удаления бейджа. Если передан (и `disabled` не установлен), справа отображается кнопка с иконкой закрытия. */
16
29
  onDelete?: (e: MouseEvent) => void;
30
+ /** Класс для корневого контейнера бейджа (`Box`). */
17
31
  className?: string;
18
32
  /** Класс для текста-лейбла (`Text`). */
19
33
  labelClassName?: string;
@@ -1,39 +1,39 @@
1
- import { jsxs as C, jsx as a } from "react/jsx-runtime";
2
- import { cx as v, css as u } from "@emotion/css";
3
- import k from "../../../assets/svg/shared/close-outline.svg.js";
4
- import { Box as B } from "../../builders/Box/Box.js";
5
- import { theme as L } from "../../../utils/theme/index.js";
6
- import { Ripple as $ } from "../../builders/Ripple/Ripple.js";
7
- import { Text as w } from "../../builders/Text/Text.js";
8
- const { color: r, cornerRadius: g, spacing: l } = L, b = {
1
+ import { jsxs as k, jsx as a } from "react/jsx-runtime";
2
+ import { cx as y, css as u } from "@emotion/css";
3
+ import B from "../../../assets/svg/shared/close-outline.svg.js";
4
+ import { Box as L } from "../../builders/Box/Box.js";
5
+ import { theme as $ } from "../../../utils/theme/index.js";
6
+ import { Ripple as j } from "../../builders/Ripple/Ripple.js";
7
+ import { Text as h } from "../../builders/Text/Text.js";
8
+ const { color: e, cornerRadius: g, spacing: l } = $, b = {
9
9
  neutral: {
10
- border: r.border.neutralAlphaLow,
11
- bg: r.status.neutralTint,
12
- color: r.text.secondary,
10
+ border: e.border.neutralAlphaLow,
11
+ bg: e.status.neutralTint,
12
+ color: e.text.secondary,
13
13
  colorName: "secondary"
14
14
  },
15
15
  accent: {
16
- border: r.border.accentSecondary,
17
- bg: r.status.accentTintLow,
18
- color: r.text.accent,
16
+ border: e.border.accentSecondary,
17
+ bg: e.status.accentTintLow,
18
+ color: e.text.accent,
19
19
  colorName: "accent"
20
20
  },
21
21
  warning: {
22
- border: r.border.warningSecondary,
23
- bg: r.status.warningTintLow,
24
- color: r.text.warning,
22
+ border: e.border.warningSecondary,
23
+ bg: e.status.warningTintLow,
24
+ color: e.text.warning,
25
25
  colorName: "warning"
26
26
  },
27
27
  positive: {
28
- border: r.border.positiveSecondary,
29
- bg: r.status.positiveTintLow,
30
- color: r.text.positive,
28
+ border: e.border.positiveSecondary,
29
+ bg: e.status.positiveTintLow,
30
+ color: e.text.positive,
31
31
  colorName: "positive"
32
32
  },
33
33
  negative: {
34
- border: r.border.negativeSecondary,
35
- bg: r.status.negativeTintLow,
36
- color: r.text.negative,
34
+ border: e.border.negativeSecondary,
35
+ bg: e.status.negativeTintLow,
36
+ color: e.text.negative,
37
37
  colorName: "negative"
38
38
  },
39
39
  transfer: {
@@ -63,17 +63,17 @@ const { color: r, cornerRadius: g, spacing: l } = L, b = {
63
63
  }
64
64
  }, R = (d, n, o, p) => {
65
65
  const t = b[n];
66
- let e = t.bg, s = "none";
66
+ let r = t.bg, s = "none";
67
67
  const c = t.color;
68
68
  switch (d) {
69
69
  case "outline":
70
- e = "transparent", s = `1px solid ${t.border}`;
70
+ r = "transparent", s = `1px solid ${t.border}`;
71
71
  break;
72
72
  case "clear":
73
- e = "transparent";
73
+ r = "transparent";
74
74
  break;
75
75
  default:
76
- e = t.bg;
76
+ r = t.bg;
77
77
  break;
78
78
  }
79
79
  return u({
@@ -82,40 +82,42 @@ const { color: r, cornerRadius: g, spacing: l } = L, b = {
82
82
  userSelect: "none",
83
83
  position: "relative",
84
84
  transition: "background-color 0.2s, opacity 0.2s",
85
- backgroundColor: e,
85
+ backgroundColor: r,
86
86
  color: c,
87
87
  border: s
88
88
  });
89
- }, j = u({
89
+ }, I = u({
90
90
  display: "inline-flex",
91
91
  cursor: "pointer",
92
92
  opacity: 0.6,
93
93
  "&:hover": { opacity: 1 }
94
- }), y = u({
94
+ }), w = u({
95
95
  display: "inline-flex",
96
96
  alignItems: "center",
97
97
  color: "inherit"
98
- }), I = ({
98
+ }), O = ({
99
99
  label: d,
100
100
  color: n = "neutral",
101
101
  size: o = "md",
102
102
  variant: p = "filled",
103
103
  width: t,
104
- leftElement: e,
105
- rightElement: s,
106
- disabled: c,
104
+ textAlign: r = "center",
105
+ leftElement: s,
106
+ rightElement: c,
107
+ disabled: x,
107
108
  onClick: m,
108
- onDelete: x,
109
+ onDelete: f,
109
110
  className: N,
110
- labelClassName: h,
111
+ labelClassName: C,
111
112
  deleteButtonClassName: S
112
113
  }) => {
113
- const T = R(p, n, c, m);
114
- return /* @__PURE__ */ C(
115
- B,
114
+ const T = R(p, n, x, m);
115
+ return /* @__PURE__ */ k(
116
+ L,
116
117
  {
117
118
  row: !0,
118
119
  alignItems: "center",
120
+ justifyContent: "center",
119
121
  gap: l.sm,
120
122
  p: i[o].p,
121
123
  h: i[o].h,
@@ -123,37 +125,41 @@ const { color: r, cornerRadius: g, spacing: l } = L, b = {
123
125
  overflow: "hidden",
124
126
  borderRadius: i[o].corner,
125
127
  onClick: m,
126
- className: v(T, N),
128
+ className: y(T, N),
127
129
  children: [
128
- m && /* @__PURE__ */ a($, {}),
129
- e && /* @__PURE__ */ a("span", { className: y, children: e }),
130
+ m && /* @__PURE__ */ a(j, {}),
131
+ s && /* @__PURE__ */ a("span", { className: w, children: s }),
130
132
  /* @__PURE__ */ a(
131
- w,
133
+ h,
132
134
  {
133
135
  variant: i[o].text,
134
136
  colorName: b[n].colorName,
135
137
  textOverflow: "ellipsis",
136
- className: h,
138
+ left: r === "left",
139
+ center: r === "center",
140
+ right: r === "right",
141
+ flex: t ? 1 : void 0,
142
+ className: C,
137
143
  children: d
138
144
  }
139
145
  ),
140
- s && /* @__PURE__ */ a("span", { className: y, children: s }),
141
- x && !c && /* @__PURE__ */ a(
142
- w,
146
+ c && /* @__PURE__ */ a("span", { className: w, children: c }),
147
+ f && !x && /* @__PURE__ */ a(
148
+ h,
143
149
  {
144
- className: v(j, S),
150
+ className: y(I, S),
145
151
  colorName: b[n].colorName,
146
- onClick: (f) => {
147
- f.stopPropagation(), x(f);
152
+ onClick: (v) => {
153
+ v.stopPropagation(), f(v);
148
154
  },
149
- children: /* @__PURE__ */ a(k, {})
155
+ children: /* @__PURE__ */ a(B, {})
150
156
  }
151
157
  )
152
158
  ]
153
159
  }
154
160
  );
155
161
  };
156
- I.displayName = "Badge";
162
+ O.displayName = "Badge";
157
163
  export {
158
- I as Badge
164
+ O as Badge
159
165
  };