skillgrid 0.0.91-dev-68351-trigger-fixes.1793976 → 0.0.91-dev-68351-trigger-fixes.1802697

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.
@@ -1,8 +1,8 @@
1
1
  import { jsx as r } from "react/jsx-runtime";
2
2
  import d from "classnames";
3
- import g from "./AvatarGroup.module.css.js";
4
- import { AvatarGroupProvider as v } from "./AvatarGroupProvider.js";
5
- import { useBackgroundColor as B } from "../../../hooks/useBackgroundColor.js";
3
+ import { useBackgroundColor as g } from "../../../hooks/useBackgroundColor.js";
4
+ import v from "./AvatarGroup.module.css.js";
5
+ import { AvatarGroupProvider as B } from "./AvatarGroupProvider.js";
6
6
  const G = (t) => {
7
7
  const {
8
8
  children: a,
@@ -12,12 +12,12 @@ const G = (t) => {
12
12
  cutoutBackground: u,
13
13
  className: m,
14
14
  style: n
15
- } = t, { ref: p, bgColor: f } = B(), o = u || f || "#ffffff", l = d(g.avatarGroup, m), i = {
15
+ } = t, { ref: p, bgColor: f } = g(), o = u || f || "#ffffff", l = d(v.avatarGroup, m), i = {
16
16
  "--avatar-cutout-bg": o,
17
17
  ...n
18
18
  };
19
19
  return /* @__PURE__ */ r(
20
- v,
20
+ B,
21
21
  {
22
22
  size: s,
23
23
  shape: c,
@@ -2,11 +2,11 @@ import { jsxs as m, jsx as a } from "react/jsx-runtime";
2
2
  import { clsx as p } from "clsx";
3
3
  import Ge from "rc-upload";
4
4
  import { forwardRef as je, useContext as Fe, useState as W, useRef as se, useMemo as we, useLayoutEffect as He } from "react";
5
+ import { useIsMobile as ze } from "../../hooks/useIsMobile.js";
5
6
  import { interpolate as de } from "../../locale/interpolate.js";
6
7
  import t from "./FileUpload.module.css.js";
7
8
  import { isMobileViewport as ve } from "../../utils/adaptive.js";
8
9
  import { useLocale as ue } from "../ConfigProvider/ConfigProvider.hook.js";
9
- import { useIsMobile as ze } from "../../hooks/useIsMobile.js";
10
10
  import { SnackbarContext as We } from "../Snackbar/lib/useSnackbar.js";
11
11
  import { Button as M } from "../Button/Button.js";
12
12
  import { Icon as h } from "../Icon/IconWithCategories.js";
@@ -2,9 +2,9 @@ import { jsx as r, jsxs as W } from "react/jsx-runtime";
2
2
  import { forwardRef as z, useImperativeHandle as P } from "react";
3
3
  import { clsx as f } from "clsx";
4
4
  import e from "./InputBase.module.css.js";
5
- import { useInputSync as Q } from "./lib/useInputSync.js";
6
- import { useTextareaResize as Y } from "./lib/useTextareaResize.js";
7
- import { useCompatId as Z } from "../../hooks/useCompatId.js";
5
+ import { useCompatId as Q } from "../../hooks/useCompatId.js";
6
+ import { useInputSync as Y } from "./lib/useInputSync.js";
7
+ import { useTextareaResize as Z } from "./lib/useTextareaResize.js";
8
8
  import { MAX_HINT_LENGTH as k } from "./lib/constants.js";
9
9
  import { useGripResize as U } from "./lib/useGripResize.js";
10
10
  import { GripIcon as E } from "./assets/GripIcon.js";
@@ -32,8 +32,8 @@ const K = z(
32
32
  resize: c,
33
33
  ...H
34
34
  }, R) => {
35
- const { textareaRef: w, inputRef: j, currentRef: d } = Q(a, t);
36
- if (Y(a, c, w), P(R, () => d.current, [d]), t === "textarea")
35
+ const { textareaRef: w, inputRef: j, currentRef: d } = Y(a, t);
36
+ if (Z(a, c, w), P(R, () => d.current, [d]), t === "textarea")
37
37
  return /* @__PURE__ */ r(
38
38
  "textarea",
39
39
  {
@@ -132,7 +132,7 @@ const K = z(
132
132
  showGrip: T = !1,
133
133
  ...L
134
134
  }, O) => {
135
- const X = Z("input-wrapper"), S = D || X, _ = y && s && (d || p), q = s && s.length > k ? s.substring(0, k) + "..." : s, B = f(
135
+ const X = Q("input-wrapper"), S = D || X, _ = y && s && (d || p), q = s && s.length > k ? s.substring(0, k) + "..." : s, B = f(
136
136
  e.wrapper,
137
137
  e[`size-${m}`],
138
138
  a && e.error,
@@ -1,7 +1,7 @@
1
1
  import { offset as G, flip as H, shift as V, inline as q, size as J, hide as K, useFloating as Q, autoUpdate as Z, useTransitionStyles as M, useClick as ee, useHover as te, useFocus as oe, useDismiss as ne, useRole as se, useInteractions as re } from "@floating-ui/react";
2
2
  import { useState as i, useMemo as v, useCallback as ce, useEffect as ae, useLayoutEffect as ie } from "react";
3
- import { DEFAULT_FLOATING as le, hasMiddleware as fe } from "./utils.js";
4
3
  import { useCompatId as S } from "../../../hooks/useCompatId.js";
4
+ import { DEFAULT_FLOATING as le, hasMiddleware as fe } from "./utils.js";
5
5
  const r = 8, ue = (c) => {
6
6
  switch (c.split("-")[0]) {
7
7
  case "top":
@@ -1,8 +1,8 @@
1
1
  import { jsxs as N, jsx as r } from "react/jsx-runtime";
2
2
  import { useRef as W, useState as g, useEffect as w } from "react";
3
+ import { useBackgroundColor as M } from "../../hooks/useBackgroundColor.js";
3
4
  import { clsx as a } from "clsx";
4
5
  import e from "./ScrollWrapper.module.css.js";
5
- import { useBackgroundColor as M } from "../../hooks/useBackgroundColor.js";
6
6
  const B = "white", G = ({
7
7
  children: b,
8
8
  withControls: i = !0,
@@ -1,10 +1,10 @@
1
1
  import { jsx as l, jsxs as w } from "react/jsx-runtime";
2
2
  import F, { useState as U, createContext as V, useContext as M } from "react";
3
3
  import { ScrollWrapper as R } from "./ScrollWrapper.js";
4
+ import { useIsMobile as j } from "../../hooks/useIsMobile.js";
4
5
  import { clsx as p } from "clsx";
5
6
  import f from "../../styles/typography.module.css.js";
6
7
  import a from "./Tabs.module.css.js";
7
- import { useIsMobile as j } from "../../hooks/useIsMobile.js";
8
8
  import { Badge as k } from "../Badge/Badge.js";
9
9
  const G = "md", W = !1, Y = !1, Z = 8, z = "top-right-inside", P = V(null), h = () => {
10
10
  const t = M(P);
@@ -2,4 +2,4 @@ import { TriggerCommonProps } from './Trigger.type';
2
2
  /**
3
3
  Component Trigger
4
4
  */
5
- export declare const Trigger: ({ content, size, description, label, stretched, selectionStyle, clearable, showClear, showChevron, error, prefixIcon, postfixTitle, disabled, open, onClear, classNames, styles, }: TriggerCommonProps) => import("react/jsx-runtime").JSX.Element;
5
+ export declare const Trigger: ({ "data-testid": testId, content, size, description, label, stretched, truncateContent: contentTruncation, selectionStyle, clearable, showClear, showChevron, error, prefixIcon, postfixTitle, disabled, open, onClear, classNames, styles, }: TriggerCommonProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,91 +1,93 @@
1
1
  import { jsxs as f, jsx as a } from "react/jsx-runtime";
2
2
  import { clsx as n } from "clsx";
3
3
  import { LabelState as H } from "./Trigger.type.js";
4
- import r from "./Trigger.module.css.js";
5
- import { getLabelState as R, getLabelTypographySize as U, truncateContent as V, getContentTypographySize as E, getIconSize as X } from "./lib/utils.js";
4
+ import t from "./Trigger.module.css.js";
5
+ import { getLabelState as V, getLabelTypographySize as Y, truncateContent as Z, getContentTypographySize as E, getIconSize as X } from "./lib/utils.js";
6
6
  import { Typography as y } from "../Typography/Typography.js";
7
- import { XIcon as Y } from "../InputBase/assets/XIcon.js";
8
- import { ChevronIcon as Z } from "./assets/ChevronIcon.js";
9
- import { Helper as _ } from "../Helper/Helper.js";
10
- const lr = ({
7
+ import { XIcon as _ } from "../InputBase/assets/XIcon.js";
8
+ import { ChevronIcon as tt } from "./assets/ChevronIcon.js";
9
+ import { Helper as rt } from "../Helper/Helper.js";
10
+ const pt = ({
11
+ "data-testid": j = "trigger",
11
12
  content: p,
12
13
  size: i = "XL",
13
14
  description: I,
14
15
  label: v,
15
16
  stretched: h = !1,
17
+ truncateContent: z = !0,
16
18
  selectionStyle: x = "selected",
17
- clearable: j = !1,
18
- showClear: z,
19
- showChevron: A,
19
+ clearable: A = !1,
20
+ showClear: D,
21
+ showChevron: F,
20
22
  error: d,
21
- prefixIcon: b,
22
- postfixTitle: N,
23
+ prefixIcon: u,
24
+ postfixTitle: b,
23
25
  disabled: o = !1,
24
- open: S,
26
+ open: N,
25
27
  onClear: m,
26
- classNames: t = {},
28
+ classNames: r = {},
27
29
  styles: e = {}
28
30
  }) => {
29
- const c = !!p, u = !!v, g = !!d, L = x === "applied", w = z ?? (c && (L || j)), D = A ?? !w, F = !!I && (!g || o) || g && !o, W = (g && !o ? d : I) || "", s = g && !o, T = R(i, c), l = u && T === H.FLOATING, k = T === H.HIDDEN, G = n(
30
- r["trigger-wrapper"],
31
- { [r["trigger-stretched"]]: h },
32
- t.wrapper
33
- ), O = n(
34
- r["trigger-container"],
35
- r[`trigger-container-size-${i}`],
31
+ const c = !!p, S = !!v, g = !!d, L = x === "applied", w = D ?? (c && (L || A)), W = F ?? !w, k = !!I && (!g || o) || g && !o, G = (g && !o ? d : I) || "", l = g && !o, T = V(i, c), s = S && T === H.FLOATING, O = T === H.HIDDEN, P = n(
32
+ t["trigger-wrapper"],
33
+ { [t["trigger-stretched"]]: h },
34
+ r.wrapper
35
+ ), $ = n(
36
+ t["trigger-container"],
37
+ t[`trigger-container-size-${i}`],
36
38
  {
37
- [r["trigger-stretched"]]: h,
38
- [r["trigger-container-applied"]]: L && c,
39
- [r["trigger-container-error"]]: g && !o,
40
- [r["trigger-container-open"]]: S,
41
- [r["trigger-container-floating"]]: l
39
+ [t["trigger-stretched"]]: h,
40
+ [t["trigger-container-applied"]]: L && c,
41
+ [t["trigger-container-error"]]: g && !o,
42
+ [t["trigger-container-open"]]: N,
43
+ [t["trigger-container-floating"]]: s
42
44
  },
43
- t.triggerContainer
44
- ), P = n(
45
- r["trigger-content-container"],
45
+ r.triggerContainer
46
+ ), q = n(
47
+ t["trigger-content-container"],
46
48
  {
47
- [r["trigger-content-container-floating"]]: l
49
+ [t["trigger-content-container-floating"]]: s
48
50
  },
49
- t.triggerContent
50
- ), $ = n(
51
- r["trigger-label"],
51
+ r.triggerContent
52
+ ), B = n(
53
+ t["trigger-label"],
52
54
  {
53
- [r["trigger-label-floating"]]: l,
54
- [r["trigger-label-hidden"]]: k
55
+ [t["trigger-label-floating"]]: s,
56
+ [t["trigger-label-hidden"]]: O
55
57
  },
56
- t.label
57
- ), q = n(r["trigger-content"], t.content), B = n(r["trigger-postfix"], t.postfixTitle), J = n(r["trigger-chevron-icon"], t.chevronIcon), K = n(
58
- r["trigger-prefix-icon"],
59
- t.prefixIconContainer
60
- ), M = n(r["trigger-clear-icon"], t.clearIcon), Q = (C) => {
58
+ r.label
59
+ ), J = n(t["trigger-content"], r.content), K = n(t["trigger-postfix"], r.postfixTitle), M = n(t["trigger-chevron-icon"], r.chevronIcon), Q = n(
60
+ t["trigger-prefix-icon"],
61
+ r.prefixIconContainer
62
+ ), R = n(t["trigger-clear-icon"], r.clearIcon), U = (C) => {
61
63
  C == null || C.stopPropagation(), m == null || m();
62
64
  };
63
- return /* @__PURE__ */ f("div", { className: G, style: e.wrapper, children: [
65
+ return /* @__PURE__ */ f("div", { className: P, style: e.wrapper, children: [
64
66
  /* @__PURE__ */ f(
65
67
  "button",
66
68
  {
67
- "data-testid": "trigger",
69
+ "data-testid": j,
68
70
  "aria-invalid": g,
69
71
  "aria-haspopup": "listbox",
70
- "aria-expanded": S,
72
+ "aria-expanded": N,
71
73
  role: "combobox",
72
- className: O,
74
+ className: $,
73
75
  style: e.triggerContainer,
74
76
  disabled: o,
75
77
  type: "button",
76
78
  children: [
77
- b && i !== "XL" && /* @__PURE__ */ a("div", { className: K, style: e.prefixIconContainer, children: b }),
78
- /* @__PURE__ */ f("div", { className: P, style: e.triggerContent, children: [
79
- u && /* @__PURE__ */ a(
79
+ u && i !== "XL" && /* @__PURE__ */ a("div", { className: Q, style: e.prefixIconContainer, children: u }),
80
+ /* @__PURE__ */ f("div", { className: q, style: e.triggerContent, children: [
81
+ S && /* @__PURE__ */ a(
80
82
  y.Label,
81
83
  {
82
84
  "data-testid": "trigger-label",
83
- className: $,
85
+ className: B,
84
86
  style: e.label,
85
- size: U(i, l),
87
+ size: Y(i, s),
86
88
  as: "span",
87
89
  disabled: o,
88
- typographyStyle: l ? "secondary" : "tertiary",
90
+ typographyStyle: s ? "secondary" : "tertiary",
89
91
  children: v
90
92
  }
91
93
  ),
@@ -93,46 +95,46 @@ const lr = ({
93
95
  y.Label,
94
96
  {
95
97
  "data-testid": "trigger-content-container",
96
- className: q,
98
+ className: J,
97
99
  style: e.content,
98
100
  size: E(i),
99
101
  as: "span",
100
102
  disabled: o,
101
- children: h ? p : V(p)
103
+ children: h ? p : Z(p, z)
102
104
  }
103
105
  ),
104
- c && !!N && /* @__PURE__ */ a(
106
+ c && !!b && /* @__PURE__ */ a(
105
107
  y.Label,
106
108
  {
107
109
  "data-testid": "trigger-postfix",
108
- className: B,
110
+ className: K,
109
111
  style: e.postfixTitle,
110
112
  size: E(i),
111
113
  disabled: o,
112
114
  typographyStyle: "secondary",
113
115
  fontWeight: "medium",
114
- children: N
116
+ children: b
115
117
  }
116
118
  )
117
119
  ] }),
118
120
  w && /* @__PURE__ */ a(
119
- Y,
121
+ _,
120
122
  {
121
- className: M,
123
+ className: R,
122
124
  "data-testid": "trigger-clear",
123
125
  size: X(i),
124
126
  tabIndex: -1,
125
- onClick: Q,
127
+ onClick: U,
126
128
  style: { outline: "none", ...e.clearIcon },
127
129
  color: x === "selected" ? "var(--icon-tertiary)" : void 0
128
130
  }
129
131
  ),
130
- D && /* @__PURE__ */ a(
131
- Z,
132
+ W && /* @__PURE__ */ a(
133
+ tt,
132
134
  {
133
135
  "data-testid": "trigger-chevron",
134
136
  size: X(i),
135
- className: J,
137
+ className: M,
136
138
  color: "var(--icon-tertiary)",
137
139
  style: e.chevronIcon
138
140
  }
@@ -140,19 +142,19 @@ const lr = ({
140
142
  ]
141
143
  }
142
144
  ),
143
- F && /* @__PURE__ */ a(
144
- _,
145
+ k && /* @__PURE__ */ a(
146
+ rt,
145
147
  {
146
- title: W,
147
- error: s ? d : void 0,
148
- className: s ? t.error : t.description,
149
- style: s ? e.error : e.description,
148
+ title: G,
149
+ error: l ? d : void 0,
150
+ className: l ? r.error : r.description,
151
+ style: l ? e.error : e.description,
150
152
  disabled: o,
151
- "data-testid": s ? "trigger-error" : "trigger-description"
153
+ "data-testid": l ? "trigger-error" : "trigger-description"
152
154
  }
153
155
  )
154
156
  ] });
155
157
  };
156
158
  export {
157
- lr as Trigger
159
+ pt as Trigger
158
160
  };
@@ -15,6 +15,8 @@ export declare enum LabelState {
15
15
  * Основные пропсы компонента Trigger
16
16
  */
17
17
  export type TriggerCommonProps = {
18
+ /** Идентификатор кнопки триггера для тестов */
19
+ 'data-testid'?: string;
18
20
  /** Состояние триггера */
19
21
  open: boolean;
20
22
  /** Контент, отображаемый в триггере */
@@ -27,6 +29,11 @@ export type TriggerCommonProps = {
27
29
  description?: string;
28
30
  /** Растянуть компонент на всю ширину */
29
31
  stretched?: boolean;
32
+ /** Обрезка content: false — отключить, true (по умолчанию) — 30 символов, число — свой лимит.
33
+ * При stretched=true обрезка отключена. Дробный лимит округляется вниз;
34
+ * отрицательный или не конечный лимит заменяется на 30.
35
+ */
36
+ truncateContent?: number | boolean;
30
37
  /** Стиль выделения: 'selected' - обычное состояние, 'applied' - применённое с возможностью очистки */
31
38
  selectionStyle?: 'selected' | 'applied';
32
39
  /** Показывать иконку очистки при наличии контента и selectionStyle = 'selected' */
@@ -21,9 +21,10 @@ export declare const getContentTypographySize: (size: TriggerSize) => Typography
21
21
  */
22
22
  export declare const getIconSize: (size: TriggerSize) => "xs" | "sm";
23
23
  /**
24
- * Обрезает текст content если он превышает 30 символов
24
+ * Обрезает текст content по заданному лимиту (по умолчанию 30 символов)
25
25
  *
26
26
  * @param content - текст для обрезки
27
+ * @param limit - false отключает обрезку, true задаёт лимит 30, число — свой лимит
27
28
  * @returns обрезанный текст с многоточием или исходный текст
28
29
  */
29
- export declare const truncateContent: (content: string) => string;
30
+ export declare const truncateContent: (content: string, limit?: number | boolean) => string;
@@ -1,9 +1,13 @@
1
- import { LabelState as e } from "../Trigger.type.js";
2
- const L = (r, t) => r === "XL" && t ? e.FLOATING : r !== "XL" && t ? e.HIDDEN : e.NORMAL, u = (r, t) => t ? 3 : r === "XL" || r === "L" ? 2 : 3, o = (r) => r === "XL" || r === "L" ? 2 : 3, a = (r) => r === "XL" || r === "L" ? "sm" : "xs", f = (r) => r.length > 30 ? r.slice(0, 30) + "…" : r;
1
+ import { LabelState as t } from "../Trigger.type.js";
2
+ const L = (r, e) => r === "XL" && e ? t.FLOATING : r !== "XL" && e ? t.HIDDEN : t.NORMAL, o = (r, e) => e ? 3 : r === "XL" || r === "L" ? 2 : 3, f = (r) => r === "XL" || r === "L" ? 2 : 3, a = (r) => r === "XL" || r === "L" ? "sm" : "xs", g = (r, e = !0) => {
3
+ if (e === !1) return r;
4
+ const n = typeof e == "number" && Number.isFinite(e) && e >= 0 ? Math.floor(e) : 30;
5
+ return r.length > n ? r.slice(0, n) + "…" : r;
6
+ };
3
7
  export {
4
- o as getContentTypographySize,
8
+ f as getContentTypographySize,
5
9
  a as getIconSize,
6
10
  L as getLabelState,
7
- u as getLabelTypographySize,
8
- f as truncateContent
11
+ o as getLabelTypographySize,
12
+ g as truncateContent
9
13
  };