@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.
- package/lib/Tabs/index.d.ts +2 -1
- package/lib/Tabs/index.js +80 -42
- package/package.json +7 -7
- package/src/Tabs/index.tsx +46 -7
package/lib/Tabs/index.d.ts
CHANGED
@@ -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
|
2
|
-
import { Tabs as
|
3
|
-
import { styled as
|
4
|
-
const
|
5
|
-
tabs: `${
|
6
|
-
tab: `${
|
7
|
-
},
|
8
|
-
[`& .${
|
9
|
-
[`& .${
|
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
|
-
[
|
11
|
+
[t.breakpoints.up("md")]: {
|
12
12
|
fontSize: "1rem"
|
13
13
|
}
|
14
14
|
}
|
15
15
|
}));
|
16
|
-
function
|
17
|
-
|
18
|
-
|
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:
|
22
|
-
onChange: (a, 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:
|
67
|
-
|
73
|
+
children: t.map((a) => /* @__PURE__ */ r(
|
74
|
+
d,
|
68
75
|
{
|
69
|
-
className:
|
76
|
+
className: u.tab,
|
70
77
|
value: a.value,
|
71
78
|
label: a.label,
|
72
79
|
icon: a.icon,
|
73
|
-
iconPosition:
|
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
|
81
|
-
|
82
|
-
|
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:
|
86
|
-
onChange: (a, 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:
|
136
|
-
|
150
|
+
children: t.map((a) => /* @__PURE__ */ r(
|
151
|
+
d,
|
137
152
|
{
|
138
|
-
className:
|
153
|
+
className: u.tab,
|
139
154
|
value: a.value,
|
140
155
|
label: a.label,
|
141
156
|
icon: a.icon,
|
142
|
-
iconPosition:
|
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:
|
151
|
-
current:
|
152
|
-
onChange:
|
153
|
-
variant:
|
154
|
-
iconPosition:
|
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
|
158
|
-
|
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:
|
163
|
-
onChange: (i,
|
199
|
+
value: n,
|
200
|
+
onChange: (i, p) => !o && e(p),
|
164
201
|
indicatorColor: "primary",
|
165
202
|
...a,
|
166
|
-
className: [
|
167
|
-
children:
|
168
|
-
|
203
|
+
className: [u.tabs, a.className || ""].join(" "),
|
204
|
+
children: t.map((i) => /* @__PURE__ */ r(
|
205
|
+
d,
|
169
206
|
{
|
170
|
-
className:
|
207
|
+
className: u.tab,
|
171
208
|
value: i.value,
|
172
209
|
label: i.label,
|
173
210
|
icon: i.icon,
|
174
|
-
iconPosition:
|
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.
|
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": "
|
63
|
+
"gitHead": "c7886f76502bc62236cc1dd28aa26c050a702d1c",
|
64
64
|
"dependencies": {
|
65
|
-
"@arcblock/bridge": "3.0.
|
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.
|
69
|
-
"@arcblock/nft-display": "3.0.
|
70
|
-
"@arcblock/react-hooks": "3.0.
|
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.
|
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",
|
package/src/Tabs/index.tsx
CHANGED
@@ -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({
|
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({
|
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
|
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
|
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>
|