@arcblock/ux 3.0.16 → 3.0.19

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.
@@ -9,6 +9,7 @@ interface TabsProps extends Omit<MuiTabsProps, 'variant' | 'onChange'> {
9
9
  onChange: (value: string) => void;
10
10
  variant?: 'card' | 'line' | MuiTabsProps['variant'];
11
11
  iconPosition?: TabProps['iconPosition'];
12
+ enableTabClick?: boolean;
12
13
  }
13
- export default function Tabs({ tabs, current, onChange, variant, iconPosition, ...rest }: TabsProps): import("react/jsx-runtime").JSX.Element;
14
+ export default function Tabs({ tabs, current, onChange, variant, iconPosition, enableTabClick, ...rest }: TabsProps): import("react/jsx-runtime").JSX.Element;
14
15
  export {};
package/lib/Tabs/index.js CHANGED
@@ -1,25 +1,32 @@
1
- import { jsx as l } from "react/jsx-runtime";
2
- import { Tabs as u, Tab as c } from "@mui/material";
3
- import { styled as p } from "../Theme/index.js";
4
- const d = "index", s = {
5
- tabs: `${d}-tabs`,
6
- tab: `${d}-tab`
7
- }, m = p(u)(({ theme: e }) => ({
8
- [`& .${s.tabs}`]: {},
9
- [`& .${s.tab}`]: {
1
+ import { jsx as r } from "react/jsx-runtime";
2
+ import { Tabs as c, Tab as d } from "@mui/material";
3
+ import { styled as m } from "../Theme/index.js";
4
+ const b = "index", u = {
5
+ tabs: `${b}-tabs`,
6
+ tab: `${b}-tab`
7
+ }, v = m(c)(({ theme: t }) => ({
8
+ [`& .${u.tabs}`]: {},
9
+ [`& .${u.tab}`]: {
10
10
  fontSize: "0.875rem",
11
- [e.breakpoints.up("md")]: {
11
+ [t.breakpoints.up("md")]: {
12
12
  fontSize: "1rem"
13
13
  }
14
14
  }
15
15
  }));
16
- function v({ tabs: e, current: t, onChange: r, iconPosition: n = void 0, ...o }) {
17
- return /* @__PURE__ */ l(
18
- u,
16
+ function f({
17
+ tabs: t,
18
+ current: n,
19
+ onChange: e,
20
+ iconPosition: s = void 0,
21
+ enableTabClick: l = !1,
22
+ ...o
23
+ }) {
24
+ return /* @__PURE__ */ r(
25
+ c,
19
26
  {
20
27
  scrollButtons: "auto",
21
- value: t,
22
- onChange: (a, i) => r(i),
28
+ value: n,
29
+ onChange: (a, i) => !l && e(i),
23
30
  ...o,
24
31
  variant: "scrollable",
25
32
  sx: {
@@ -63,27 +70,35 @@ function v({ tabs: e, current: t, onChange: r, iconPosition: n = void 0, ...o })
63
70
  },
64
71
  ...o.sx
65
72
  },
66
- children: e.map((a) => /* @__PURE__ */ l(
67
- c,
73
+ children: t.map((a) => /* @__PURE__ */ r(
74
+ d,
68
75
  {
69
- className: s.tab,
76
+ className: u.tab,
70
77
  value: a.value,
71
78
  label: a.label,
72
79
  icon: a.icon,
73
- iconPosition: n
80
+ iconPosition: s,
81
+ onClick: () => l && e(a.value)
74
82
  },
75
83
  a.value
76
84
  ))
77
85
  }
78
86
  );
79
87
  }
80
- function f({ tabs: e, current: t, onChange: r, iconPosition: n = void 0, ...o }) {
81
- return /* @__PURE__ */ l(
82
- u,
88
+ function y({
89
+ tabs: t,
90
+ current: n,
91
+ onChange: e,
92
+ iconPosition: s = void 0,
93
+ enableTabClick: l = !1,
94
+ ...o
95
+ }) {
96
+ return /* @__PURE__ */ r(
97
+ c,
83
98
  {
84
99
  scrollButtons: "auto",
85
- value: t,
86
- onChange: (a, i) => r(i),
100
+ value: n,
101
+ onChange: (a, i) => !l && e(i),
87
102
  ...o,
88
103
  variant: "scrollable",
89
104
  sx: {
@@ -132,14 +147,15 @@ function f({ tabs: e, current: t, onChange: r, iconPosition: n = void 0, ...o })
132
147
  },
133
148
  ...o.sx
134
149
  },
135
- children: e.map((a) => /* @__PURE__ */ l(
136
- c,
150
+ children: t.map((a) => /* @__PURE__ */ r(
151
+ d,
137
152
  {
138
- className: s.tab,
153
+ className: u.tab,
139
154
  value: a.value,
140
155
  label: a.label,
141
156
  icon: a.icon,
142
- iconPosition: n
157
+ iconPosition: s,
158
+ onClick: () => l && e(a.value)
143
159
  },
144
160
  a.value
145
161
  ))
@@ -147,31 +163,53 @@ function f({ tabs: e, current: t, onChange: r, iconPosition: n = void 0, ...o })
147
163
  );
148
164
  }
149
165
  function T({
150
- tabs: e,
151
- current: t,
152
- onChange: r,
153
- variant: n = void 0,
154
- iconPosition: o = void 0,
166
+ tabs: t,
167
+ current: n,
168
+ onChange: e,
169
+ variant: s = void 0,
170
+ iconPosition: l = void 0,
171
+ enableTabClick: o = !1,
155
172
  ...a
156
173
  }) {
157
- return n === "card" ? /* @__PURE__ */ l(v, { ...a, tabs: e, current: t, onChange: r, iconPosition: o }) : n === "line" ? /* @__PURE__ */ l(f, { ...a, tabs: e, current: t, onChange: r, iconPosition: o }) : /* @__PURE__ */ l(
158
- m,
174
+ return s === "card" ? /* @__PURE__ */ r(
175
+ f,
176
+ {
177
+ ...a,
178
+ tabs: t,
179
+ current: n,
180
+ enableTabClick: o,
181
+ onChange: e,
182
+ iconPosition: l
183
+ }
184
+ ) : s === "line" ? /* @__PURE__ */ r(
185
+ y,
186
+ {
187
+ ...a,
188
+ tabs: t,
189
+ current: n,
190
+ enableTabClick: o,
191
+ onChange: e,
192
+ iconPosition: l
193
+ }
194
+ ) : /* @__PURE__ */ r(
195
+ v,
159
196
  {
160
197
  scrollButtons: "auto",
161
198
  variant: "scrollable",
162
- value: t,
163
- onChange: (i, b) => r(b),
199
+ value: n,
200
+ onChange: (i, p) => !o && e(p),
164
201
  indicatorColor: "primary",
165
202
  ...a,
166
- className: [s.tabs, a.className || ""].join(" "),
167
- children: e.map((i) => /* @__PURE__ */ l(
168
- c,
203
+ className: [u.tabs, a.className || ""].join(" "),
204
+ children: t.map((i) => /* @__PURE__ */ r(
205
+ d,
169
206
  {
170
- className: s.tab,
207
+ className: u.tab,
171
208
  value: i.value,
172
209
  label: i.label,
173
210
  icon: i.icon,
174
- iconPosition: o
211
+ iconPosition: l,
212
+ onClick: () => o && e(i.value)
175
213
  },
176
214
  i.value
177
215
  ))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcblock/ux",
3
- "version": "3.0.16",
3
+ "version": "3.0.19",
4
4
  "description": "Common used react components for arcblock products",
5
5
  "keywords": [
6
6
  "react",
@@ -60,16 +60,16 @@
60
60
  "react": "^19.0.0",
61
61
  "react-router-dom": "^6.22.3"
62
62
  },
63
- "gitHead": "b7aaaae0a729d3f600eef2a7c7d479182e15fd4d",
63
+ "gitHead": "c7886f76502bc62236cc1dd28aa26c050a702d1c",
64
64
  "dependencies": {
65
- "@arcblock/bridge": "3.0.16",
65
+ "@arcblock/bridge": "3.0.19",
66
66
  "@arcblock/did": "^1.20.15",
67
67
  "@arcblock/did-motif": "^1.1.14",
68
- "@arcblock/icons": "3.0.16",
69
- "@arcblock/nft-display": "3.0.16",
70
- "@arcblock/react-hooks": "3.0.16",
68
+ "@arcblock/icons": "3.0.19",
69
+ "@arcblock/nft-display": "3.0.19",
70
+ "@arcblock/react-hooks": "3.0.19",
71
71
  "@blocklet/js-sdk": "^1.16.45",
72
- "@blocklet/theme": "3.0.16",
72
+ "@blocklet/theme": "3.0.19",
73
73
  "@fontsource/roboto": "~5.1.1",
74
74
  "@fontsource/ubuntu-mono": "^5.2.6",
75
75
  "@iconify-icons/logos": "^1.2.36",
@@ -25,14 +25,22 @@ interface CardTabsProps extends Omit<MuiTabsProps, 'onChange'> {
25
25
  current: any;
26
26
  onChange: (value: string) => void;
27
27
  iconPosition?: TabProps['iconPosition'];
28
+ enableTabClick?: boolean;
28
29
  }
29
30
 
30
- function CardTabs({ tabs, current, onChange, iconPosition = undefined, ...rest }: CardTabsProps) {
31
+ function CardTabs({
32
+ tabs,
33
+ current,
34
+ onChange,
35
+ iconPosition = undefined,
36
+ enableTabClick = false,
37
+ ...rest
38
+ }: CardTabsProps) {
31
39
  return (
32
40
  <MuiTabs
33
41
  scrollButtons="auto"
34
42
  value={current}
35
- onChange={(_, newValue) => onChange(newValue)}
43
+ onChange={(_, newValue) => !enableTabClick && onChange(newValue)}
36
44
  {...rest}
37
45
  variant="scrollable"
38
46
  sx={{
@@ -84,6 +92,7 @@ function CardTabs({ tabs, current, onChange, iconPosition = undefined, ...rest }
84
92
  label={x.label}
85
93
  icon={x.icon}
86
94
  iconPosition={iconPosition}
95
+ onClick={() => enableTabClick && onChange(x.value)}
87
96
  />
88
97
  ))}
89
98
  </MuiTabs>
@@ -95,14 +104,22 @@ interface LineTabsProps extends Omit<MuiTabsProps, 'onChange'> {
95
104
  current: any;
96
105
  onChange: (value: string) => void;
97
106
  iconPosition?: TabProps['iconPosition'];
107
+ enableTabClick?: boolean;
98
108
  }
99
109
 
100
- function LineTabs({ tabs, current, onChange, iconPosition = undefined, ...rest }: LineTabsProps) {
110
+ function LineTabs({
111
+ tabs,
112
+ current,
113
+ onChange,
114
+ iconPosition = undefined,
115
+ enableTabClick = false,
116
+ ...rest
117
+ }: LineTabsProps) {
101
118
  return (
102
119
  <MuiTabs
103
120
  scrollButtons="auto"
104
121
  value={current}
105
- onChange={(_, newValue) => onChange(newValue)}
122
+ onChange={(_, newValue) => !enableTabClick && onChange(newValue)}
106
123
  {...rest}
107
124
  variant="scrollable"
108
125
  sx={{
@@ -162,6 +179,7 @@ function LineTabs({ tabs, current, onChange, iconPosition = undefined, ...rest }
162
179
  label={x.label}
163
180
  icon={x.icon}
164
181
  iconPosition={iconPosition}
182
+ onClick={() => enableTabClick && onChange(x.value)}
165
183
  />
166
184
  ))}
167
185
  </MuiTabs>
@@ -174,6 +192,7 @@ interface TabsProps extends Omit<MuiTabsProps, 'variant' | 'onChange'> {
174
192
  onChange: (value: string) => void;
175
193
  variant?: 'card' | 'line' | MuiTabsProps['variant'];
176
194
  iconPosition?: TabProps['iconPosition'];
195
+ enableTabClick?: boolean; // 是否启用点击切换 tab,默认不启用,启用后,当前 tab 处于活跃状态下点击 tab 也会触发 onChange 事件,
177
196
  }
178
197
 
179
198
  export default function Tabs({
@@ -182,14 +201,33 @@ export default function Tabs({
182
201
  onChange,
183
202
  variant = undefined,
184
203
  iconPosition = undefined,
204
+ enableTabClick = false,
185
205
  ...rest
186
206
  }: TabsProps) {
187
207
  if (variant === 'card') {
188
- return <CardTabs {...rest} tabs={tabs} current={current} onChange={onChange} iconPosition={iconPosition} />;
208
+ return (
209
+ <CardTabs
210
+ {...rest}
211
+ tabs={tabs}
212
+ current={current}
213
+ enableTabClick={enableTabClick}
214
+ onChange={onChange}
215
+ iconPosition={iconPosition}
216
+ />
217
+ );
189
218
  }
190
219
 
191
220
  if (variant === 'line') {
192
- return <LineTabs {...rest} tabs={tabs} current={current} onChange={onChange} iconPosition={iconPosition} />;
221
+ return (
222
+ <LineTabs
223
+ {...rest}
224
+ tabs={tabs}
225
+ current={current}
226
+ enableTabClick={enableTabClick}
227
+ onChange={onChange}
228
+ iconPosition={iconPosition}
229
+ />
230
+ );
193
231
  }
194
232
 
195
233
  return (
@@ -197,7 +235,7 @@ export default function Tabs({
197
235
  scrollButtons="auto"
198
236
  variant="scrollable"
199
237
  value={current}
200
- onChange={(_, newValue) => onChange(newValue)}
238
+ onChange={(_, newValue) => !enableTabClick && onChange(newValue)}
201
239
  indicatorColor="primary"
202
240
  {...rest}
203
241
  className={[classes.tabs, rest.className || ''].join(' ')}>
@@ -209,6 +247,7 @@ export default function Tabs({
209
247
  label={x.label}
210
248
  icon={x.icon}
211
249
  iconPosition={iconPosition}
250
+ onClick={() => enableTabClick && onChange(x.value)}
212
251
  />
213
252
  ))}
214
253
  </StyledMuiTabs>