skillgrid 0.0.85 → 0.0.87

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,164 +1,165 @@
1
- import { jsx as n, jsxs as V } from "react/jsx-runtime";
2
- import F, { useState as U, createContext as j, useContext as k } from "react";
3
- import { ScrollWrapper as G } from "./ScrollWrapper.js";
4
- import { clsx as d } from "clsx";
1
+ import { jsx as l, jsxs as w } from "react/jsx-runtime";
2
+ import F, { useState as U, createContext as V, useContext as M } from "react";
3
+ import { ScrollWrapper as R } from "./ScrollWrapper.js";
4
+ import { clsx as p } from "clsx";
5
5
  import f from "../../styles/typography.module.css.js";
6
6
  import a from "./Tabs.module.css.js";
7
- import { useIsMobile as M } from "../../hooks/useIsMobile.js";
8
- import { Badge as O } from "../Badge/Badge.js";
9
- const W = "md", R = !1, Y = 8, Z = "top-right-inside", P = j(null), h = () => {
10
- const t = k(P);
7
+ import { useIsMobile as j } from "../../hooks/useIsMobile.js";
8
+ import { Badge as k } from "../Badge/Badge.js";
9
+ const G = "md", W = !1, Y = !1, Z = 8, z = "top-right-inside", P = V(null), h = () => {
10
+ const t = M(P);
11
11
  if (!t) throw new Error("useTabs должен использоваться внутри TabsProvider");
12
12
  return t;
13
- }, z = ({
13
+ }, H = ({
14
14
  children: t,
15
- defaultActiveTab: l,
15
+ defaultActiveTab: i,
16
16
  activeTab: e,
17
- onChange: b
17
+ onChange: c
18
18
  }) => {
19
- const [c, s] = U(l), r = e !== void 0, o = r ? e : c, i = (p) => {
20
- r || s(p), b && b(p);
19
+ const [b, s] = U(i), r = e !== void 0, d = r ? e : b, n = (o) => {
20
+ r || s(o), c && c(o);
21
21
  };
22
- return /* @__PURE__ */ n(P.Provider, { value: { activeTab: o, setTab: i }, children: t });
23
- }, H = ({
22
+ return /* @__PURE__ */ l(P.Provider, { value: { activeTab: d, setTab: n }, children: t });
23
+ }, K = ({
24
24
  mode: t,
25
- item: l,
25
+ item: i,
26
26
  isActive: e,
27
- showBadge: b,
28
- badgeProps: c,
27
+ showBadge: c,
28
+ badgeProps: b,
29
29
  size: s,
30
30
  isDisabled: r,
31
- onSelectTab: o
31
+ onSelectTab: d
32
32
  }) => {
33
33
  const {
34
- value: i,
35
- label: p,
36
- ariaLabel: g,
34
+ value: n,
35
+ label: o,
36
+ ariaLabel: C,
37
37
  prefix: u,
38
- prefixWrapperProps: v = {},
39
- postfix: x,
40
- postfixWrapperProps: y = {}
41
- } = l, { className: A, ...C } = v, { className: N, ..._ } = y, m = {
38
+ prefixWrapperProps: _ = {},
39
+ postfix: T,
40
+ postfixWrapperProps: g = {}
41
+ } = i, { className: v, ...y } = _, { className: A, ...L } = g, m = {
42
42
  primary: f["typography-label-3-medium"],
43
43
  secondary: f["typography-label-3-regular"],
44
44
  prefix: f["typography-label-3-medium"],
45
45
  postfix: f["typography-label-3-medium"]
46
- }, B = {
47
- size: Y,
48
- position: Z,
49
- ...c
50
- }, E = d(a.tab, a[t], a[s], {
46
+ }, N = {
47
+ size: Z,
48
+ position: z,
49
+ ...b
50
+ }, S = p(a.tab, a[t], a[s], {
51
51
  [a.selected]: e,
52
52
  [a.disabled]: r
53
- }), L = d(
53
+ }), E = p(
54
54
  a.tabPrefix,
55
- A,
55
+ v,
56
56
  a[t],
57
57
  m.prefix,
58
58
  {
59
59
  [a.selected]: e,
60
60
  [a.disabled]: r
61
61
  }
62
- ), S = d(
62
+ ), B = p(
63
63
  a.tabPostfix,
64
- N,
64
+ A,
65
65
  a[t],
66
66
  m.postfix,
67
67
  {
68
68
  [a.selected]: e,
69
69
  [a.disabled]: r
70
70
  }
71
- ), I = d(a.tabLabel, a[t], m[t]), $ = g ?? (typeof p == "string" ? p : void 0), w = (D) => {
72
- e || r || (o(i), D.currentTarget.scrollIntoView({ behavior: "smooth", inline: "center", block: "nearest" }));
73
- }, T = /* @__PURE__ */ V(
71
+ ), D = p(a.tabLabel, a[t], m[t]), I = C ?? (typeof o == "string" ? o : void 0), O = ($) => {
72
+ e || r || (d(n), $.currentTarget.scrollIntoView({ behavior: "smooth", inline: "center", block: "nearest" }));
73
+ }, x = /* @__PURE__ */ w(
74
74
  "button",
75
75
  {
76
- className: E,
76
+ className: S,
77
77
  role: "tab",
78
- "aria-label": $,
78
+ "aria-label": I,
79
79
  "aria-selected": e,
80
80
  "aria-disabled": r,
81
- "aria-controls": `tab-panel-${i}`,
82
- "data-testid": `tab-item-${i}`,
83
- onClick: w,
81
+ "aria-controls": `tab-panel-${n}`,
82
+ "data-testid": `tab-item-${n}`,
83
+ onClick: O,
84
84
  children: [
85
- u && /* @__PURE__ */ n(
85
+ u && /* @__PURE__ */ l(
86
86
  "span",
87
87
  {
88
- className: L,
89
- ...C,
90
- "data-testid": `tab-prefix-${i}`,
88
+ className: E,
89
+ ...y,
90
+ "data-testid": `tab-prefix-${n}`,
91
91
  children: u
92
92
  }
93
93
  ),
94
- /* @__PURE__ */ n("span", { className: I, "data-testid": `tab-label-${i}`, children: p }),
95
- x && /* @__PURE__ */ n(
94
+ /* @__PURE__ */ l("span", { className: D, "data-testid": `tab-label-${n}`, children: o }),
95
+ T && /* @__PURE__ */ l(
96
96
  "span",
97
97
  {
98
- className: S,
99
- ..._,
100
- "data-testid": `tab-postfix-${i}`,
101
- children: x
98
+ className: B,
99
+ ...L,
100
+ "data-testid": `tab-postfix-${n}`,
101
+ children: T
102
102
  }
103
103
  )
104
104
  ]
105
105
  }
106
106
  );
107
- return b ? /* @__PURE__ */ n(O, { ...B, "data-testid": `tab-badge-${i}`, children: T }) : T;
107
+ return c ? /* @__PURE__ */ l(k, { ...N, "data-testid": `tab-badge-${n}`, children: x }) : x;
108
108
  }, q = ({
109
109
  mode: t,
110
- items: l,
111
- size: e = W,
112
- isAllItemsDisabled: b = R
110
+ items: i,
111
+ size: e = G,
112
+ isAllItemsDisabled: c = W,
113
+ scrollControlsOnDesktop: b = Y
113
114
  }) => {
114
- const { activeTab: c, setTab: s } = h(), r = M();
115
- return /* @__PURE__ */ n(G, { size: e, withControls: r, children: /* @__PURE__ */ n(
115
+ const { activeTab: s, setTab: r } = h(), n = j() || b;
116
+ return /* @__PURE__ */ l(R, { size: e, withControls: n, children: /* @__PURE__ */ l(
116
117
  "div",
117
118
  {
118
119
  role: "tablist",
119
120
  "data-testid": "tabs-bar",
120
121
  "aria-orientation": "horizontal",
121
- className: d(a.tabBar, a[t]),
122
- children: l.map((o) => /* @__PURE__ */ n(
123
- H,
122
+ className: p(a.tabBar, a[t]),
123
+ children: i.map((o) => /* @__PURE__ */ l(
124
+ K,
124
125
  {
125
126
  size: e,
126
127
  item: o,
127
128
  mode: t,
128
129
  showBadge: o.showBadge,
129
130
  badgeProps: o.badgeProps,
130
- isActive: c === o.value,
131
- isDisabled: b || o.isDisabled,
132
- onSelectTab: s
131
+ isActive: s === o.value,
132
+ isDisabled: c || o.isDisabled,
133
+ onSelectTab: r
133
134
  },
134
135
  o.value
135
136
  ))
136
137
  }
137
138
  ) });
138
- }, J = ({ tabValue: t, children: l, ...e }) => /* @__PURE__ */ n(
139
+ }, J = ({ tabValue: t, children: i, ...e }) => /* @__PURE__ */ l(
139
140
  "div",
140
141
  {
141
142
  role: "tabpanel",
142
143
  "data-testid": `tab-panel-${t}`,
143
144
  "aria-labelledby": `tab-item-${t}`,
144
145
  ...e,
145
- children: l
146
+ children: i
146
147
  }
147
- ), K = ({ children: t, ...l }) => {
148
- const { activeTab: e } = h(), b = Array.isArray(t) ? t : [t], c = (s, r) => F.isValidElement(s) && typeof s.props == "object" && s.props !== null && r in s.props;
149
- return /* @__PURE__ */ n("div", { "data-testid": "tab-content", ...l, children: b.map((s) => c(s, "tabValue") && String(s.props.tabValue) === e ? s : null) });
150
- }, nt = {
151
- Provider: z,
152
- Content: K,
148
+ ), Q = ({ children: t, ...i }) => {
149
+ const { activeTab: e } = h(), c = Array.isArray(t) ? t : [t], b = (s, r) => F.isValidElement(s) && typeof s.props == "object" && s.props !== null && r in s.props;
150
+ return /* @__PURE__ */ l("div", { "data-testid": "tab-content", ...i, children: c.map((s) => b(s, "tabValue") && String(s.props.tabValue) === e ? s : null) });
151
+ }, lt = {
152
+ Provider: H,
153
+ Content: Q,
153
154
  Panel: J,
154
155
  Bar: q
155
156
  };
156
157
  export {
157
158
  q as Bar,
158
159
  J as TabPanel,
159
- nt as Tabs,
160
- K as TabsContent,
161
- z as TabsProvider,
160
+ lt as Tabs,
161
+ Q as TabsContent,
162
+ H as TabsProvider,
162
163
  q as default,
163
164
  h as useTabs
164
165
  };
@@ -127,6 +127,13 @@ export interface TabsBarProps {
127
127
  * @default false
128
128
  */
129
129
  isAllItemsDisabled?: boolean;
130
+ /**
131
+ * scrollControlsOnDesktop — показывать кнопки прокрутки на десктопе при переполнении табов.
132
+ * На мобильной ширине стрелки включены по умолчанию.
133
+ *
134
+ * @default false
135
+ */
136
+ scrollControlsOnDesktop?: boolean;
130
137
  }
131
138
  /**
132
139
  * TabsItemProps - пропсы для одной вкладки (TabElement)