@svton/taro-ui 1.0.0 → 1.0.1
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/dist/index.d.mts +246 -0
- package/dist/index.d.ts +246 -0
- package/dist/index.js +253 -182
- package/dist/index.mjs +239 -169
- package/package.json +7 -8
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// src/components/TabBar/index.tsx
|
|
2
|
-
import
|
|
2
|
+
import { useState, useEffect } from "react";
|
|
3
3
|
import { View, Text } from "@tarojs/components";
|
|
4
4
|
import { usePersistFn } from "@svton/hooks";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
6
|
function TabBar(props) {
|
|
6
|
-
var _a;
|
|
7
7
|
const {
|
|
8
8
|
items,
|
|
9
9
|
activeKey: controlledActiveKey,
|
|
@@ -15,7 +15,7 @@ function TabBar(props) {
|
|
|
15
15
|
showIndicator = true,
|
|
16
16
|
sticky = true
|
|
17
17
|
} = props;
|
|
18
|
-
const [internalActiveKey, setInternalActiveKey] = useState(defaultActiveKey ||
|
|
18
|
+
const [internalActiveKey, setInternalActiveKey] = useState(defaultActiveKey || items[0]?.key);
|
|
19
19
|
const activeKey = controlledActiveKey !== void 0 ? controlledActiveKey : internalActiveKey;
|
|
20
20
|
const activeIndex = items.findIndex((item) => item.key === activeKey);
|
|
21
21
|
const indicatorLeft = items.length > 0 ? `${(activeIndex + 0.5) * (100 / items.length)}%` : "50%";
|
|
@@ -24,38 +24,41 @@ function TabBar(props) {
|
|
|
24
24
|
if (controlledActiveKey === void 0) {
|
|
25
25
|
setInternalActiveKey(key);
|
|
26
26
|
}
|
|
27
|
-
onChange
|
|
27
|
+
onChange?.(key);
|
|
28
28
|
});
|
|
29
29
|
useEffect(() => {
|
|
30
30
|
if (controlledActiveKey !== void 0) {
|
|
31
31
|
setInternalActiveKey(controlledActiveKey);
|
|
32
32
|
}
|
|
33
33
|
}, [controlledActiveKey]);
|
|
34
|
-
return /* @__PURE__ */
|
|
35
|
-
View,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
{
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
34
|
+
return /* @__PURE__ */ jsxs(View, { className: `svton-tab-bar ${sticky ? "sticky" : ""} ${className}`, style, children: [
|
|
35
|
+
/* @__PURE__ */ jsx(View, { className: "svton-tab-bar__list", children: items.map((item) => /* @__PURE__ */ jsx(
|
|
36
|
+
View,
|
|
37
|
+
{
|
|
38
|
+
className: `svton-tab-bar__item ${activeKey === item.key ? "active" : ""} ${item.disabled ? "disabled" : ""}`,
|
|
39
|
+
onClick: () => handleTabChange(item.key, item.disabled),
|
|
40
|
+
children: item.render ? item.render() : /* @__PURE__ */ jsx(Text, { className: "svton-tab-bar__text", children: item.label })
|
|
41
|
+
},
|
|
42
|
+
item.key
|
|
43
|
+
)) }),
|
|
44
|
+
showIndicator && items.length > 0 && /* @__PURE__ */ jsx(View, { className: "svton-tab-bar__indicator-wrapper", children: /* @__PURE__ */ jsx(
|
|
45
|
+
View,
|
|
46
|
+
{
|
|
47
|
+
className: "svton-tab-bar__indicator",
|
|
48
|
+
style: {
|
|
49
|
+
left: indicatorLeft,
|
|
50
|
+
width: `${indicatorWidth}px`,
|
|
51
|
+
marginLeft: `-${indicatorWidth / 2}px`
|
|
52
|
+
}
|
|
50
53
|
}
|
|
51
|
-
}
|
|
52
|
-
)
|
|
54
|
+
) })
|
|
55
|
+
] });
|
|
53
56
|
}
|
|
54
57
|
|
|
55
58
|
// src/components/Button/index.tsx
|
|
56
|
-
import React3 from "react";
|
|
57
59
|
import { View as View2, Text as Text2 } from "@tarojs/components";
|
|
58
60
|
import { usePersistFn as usePersistFn2 } from "@svton/hooks";
|
|
61
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
59
62
|
function Button(props) {
|
|
60
63
|
const {
|
|
61
64
|
type = "default",
|
|
@@ -70,24 +73,26 @@ function Button(props) {
|
|
|
70
73
|
} = props;
|
|
71
74
|
const handleClick = usePersistFn2(() => {
|
|
72
75
|
if (disabled || loading) return;
|
|
73
|
-
onClick
|
|
76
|
+
onClick?.();
|
|
74
77
|
});
|
|
75
|
-
return /* @__PURE__ */
|
|
78
|
+
return /* @__PURE__ */ jsxs2(
|
|
76
79
|
View2,
|
|
77
80
|
{
|
|
78
81
|
className: `svton-button svton-button--${type} svton-button--${size} ${block ? "svton-button--block" : ""} ${disabled ? "svton-button--disabled" : ""} ${loading ? "svton-button--loading" : ""} ${className}`,
|
|
79
82
|
style,
|
|
80
|
-
onClick: handleClick
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
83
|
+
onClick: handleClick,
|
|
84
|
+
children: [
|
|
85
|
+
loading && /* @__PURE__ */ jsx2(View2, { className: "svton-button__loading", children: /* @__PURE__ */ jsx2(Text2, { className: "svton-button__loading-icon", children: "\u23F3" }) }),
|
|
86
|
+
/* @__PURE__ */ jsx2(Text2, { className: "svton-button__text", children })
|
|
87
|
+
]
|
|
88
|
+
}
|
|
84
89
|
);
|
|
85
90
|
}
|
|
86
91
|
|
|
87
92
|
// src/components/List/index.tsx
|
|
88
|
-
import React4 from "react";
|
|
89
93
|
import { View as View3, ScrollView, Text as Text3 } from "@tarojs/components";
|
|
90
94
|
import Taro, { usePullDownRefresh, useReachBottom } from "@tarojs/taro";
|
|
95
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
91
96
|
function List(props) {
|
|
92
97
|
const {
|
|
93
98
|
data,
|
|
@@ -114,42 +119,49 @@ function List(props) {
|
|
|
114
119
|
return;
|
|
115
120
|
}
|
|
116
121
|
try {
|
|
117
|
-
await
|
|
122
|
+
await onRefresh?.();
|
|
118
123
|
} finally {
|
|
119
124
|
Taro.stopPullDownRefresh();
|
|
120
125
|
}
|
|
121
126
|
});
|
|
122
127
|
useReachBottom(async () => {
|
|
123
128
|
if (!enableLoadMore || !hasMore || loading || !onLoadMore) return;
|
|
124
|
-
await
|
|
129
|
+
await onLoadMore?.();
|
|
125
130
|
});
|
|
126
131
|
const renderEmptyContent = () => {
|
|
127
132
|
if (renderEmpty) {
|
|
128
133
|
return renderEmpty();
|
|
129
134
|
}
|
|
130
|
-
return /* @__PURE__ */
|
|
135
|
+
return /* @__PURE__ */ jsx3(View3, { className: "svton-list__empty", children: /* @__PURE__ */ jsx3(Text3, { className: "svton-list__empty-text", children: emptyText }) });
|
|
131
136
|
};
|
|
132
137
|
const renderLoadingTip = () => {
|
|
133
138
|
if (!loading && !hasMore) {
|
|
134
|
-
return /* @__PURE__ */
|
|
139
|
+
return /* @__PURE__ */ jsx3(View3, { className: "svton-list__tip svton-list__tip--no-more", children: /* @__PURE__ */ jsx3(Text3, { children: noMoreText }) });
|
|
135
140
|
}
|
|
136
141
|
if (loading && data.length > 0) {
|
|
137
|
-
return /* @__PURE__ */
|
|
142
|
+
return /* @__PURE__ */ jsx3(View3, { className: "svton-list__tip svton-list__tip--loading", children: /* @__PURE__ */ jsx3(Text3, { children: loadingText }) });
|
|
138
143
|
}
|
|
139
144
|
return null;
|
|
140
145
|
};
|
|
141
|
-
return /* @__PURE__ */
|
|
146
|
+
return /* @__PURE__ */ jsxs3(ScrollView, { className: `svton-list ${className}`, style, scrollY: true, enableBackToTop: true, children: [
|
|
147
|
+
header && /* @__PURE__ */ jsx3(View3, { className: "svton-list__header", children: header }),
|
|
148
|
+
data.length === 0 && !loading ? renderEmptyContent() : /* @__PURE__ */ jsx3(View3, { className: "svton-list__content", children: data.map((item, index) => /* @__PURE__ */ jsx3(View3, { className: "svton-list__item", children: renderItem(item, index) }, keyExtractor(item, index))) }),
|
|
149
|
+
renderLoadingTip(),
|
|
150
|
+
footer && /* @__PURE__ */ jsx3(View3, { className: "svton-list__footer", children: footer })
|
|
151
|
+
] });
|
|
142
152
|
}
|
|
143
153
|
|
|
144
154
|
// src/components/NavBar/index.tsx
|
|
145
|
-
import
|
|
155
|
+
import { useEffect as useEffect3, useState as useState3 } from "react";
|
|
146
156
|
import { View as View5, Text as Text4, Image } from "@tarojs/components";
|
|
147
157
|
import Taro3 from "@tarojs/taro";
|
|
148
158
|
|
|
149
159
|
// src/utils/systemInfo.ts
|
|
150
160
|
import Taro2 from "@tarojs/taro";
|
|
151
161
|
var SystemInfoManager = class {
|
|
152
|
-
|
|
162
|
+
constructor() {
|
|
163
|
+
this.info = null;
|
|
164
|
+
}
|
|
153
165
|
async init() {
|
|
154
166
|
try {
|
|
155
167
|
const systemInfo = await Taro2.getSystemInfo();
|
|
@@ -231,23 +243,21 @@ var SystemInfoManager = class {
|
|
|
231
243
|
return this.info;
|
|
232
244
|
}
|
|
233
245
|
getStatusBarHeight() {
|
|
234
|
-
|
|
235
|
-
return ((_a = this.info) == null ? void 0 : _a.statusBarHeight) || 44;
|
|
246
|
+
return this.info?.statusBarHeight || 44;
|
|
236
247
|
}
|
|
237
248
|
getNavBarHeight() {
|
|
238
|
-
|
|
239
|
-
return ((_a = this.info) == null ? void 0 : _a.navBarHeight) || 88;
|
|
249
|
+
return this.info?.navBarHeight || 88;
|
|
240
250
|
}
|
|
241
251
|
getSafeAreaInsets() {
|
|
242
|
-
|
|
243
|
-
return ((_a = this.info) == null ? void 0 : _a.safeAreaInsets) || { top: 44, right: 0, bottom: 0, left: 0 };
|
|
252
|
+
return this.info?.safeAreaInsets || { top: 44, right: 0, bottom: 0, left: 0 };
|
|
244
253
|
}
|
|
245
254
|
};
|
|
246
255
|
var systemInfoManager = new SystemInfoManager();
|
|
247
256
|
|
|
248
257
|
// src/components/StatusBar/index.tsx
|
|
249
|
-
import
|
|
258
|
+
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
250
259
|
import { View as View4 } from "@tarojs/components";
|
|
260
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
251
261
|
function StatusBar({ backgroundColor, className = "" }) {
|
|
252
262
|
const [height, setHeight] = useState2(44);
|
|
253
263
|
useEffect2(() => {
|
|
@@ -256,7 +266,7 @@ function StatusBar({ backgroundColor, className = "" }) {
|
|
|
256
266
|
setHeight(info.statusBarHeight);
|
|
257
267
|
}
|
|
258
268
|
}, []);
|
|
259
|
-
return /* @__PURE__ */
|
|
269
|
+
return /* @__PURE__ */ jsx4(
|
|
260
270
|
View4,
|
|
261
271
|
{
|
|
262
272
|
className: `status-bar ${className}`,
|
|
@@ -269,6 +279,7 @@ function StatusBar({ backgroundColor, className = "" }) {
|
|
|
269
279
|
}
|
|
270
280
|
|
|
271
281
|
// src/components/NavBar/index.tsx
|
|
282
|
+
import { Fragment, jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
272
283
|
var BACK_ICON_SVG = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICA8cGF0aCBkPSJNMTUgMThMOSAxMkwxNSA2IiBzdHJva2U9IiMzMzMzMzMiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+Cjwvc3ZnPgo=";
|
|
273
284
|
function CustomNavBar({
|
|
274
285
|
title = "",
|
|
@@ -355,42 +366,54 @@ function CustomNavBar({
|
|
|
355
366
|
const navBarClass = `custom-nav-bar ${fixed ? "fixed" : ""}`;
|
|
356
367
|
const actualBgColor = getBackgroundColor();
|
|
357
368
|
const totalHeight = statusBarHeight + navBarContentHeight;
|
|
358
|
-
const navBarContent = /* @__PURE__ */
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
className: "nav-bar-content",
|
|
362
|
-
style: {
|
|
363
|
-
height: `${navBarContentHeight}px`,
|
|
364
|
-
backgroundColor: actualBgColor
|
|
365
|
-
}
|
|
366
|
-
},
|
|
367
|
-
(showBack || showClose) && /* @__PURE__ */ React6.createElement(View5, { className: "nav-left" }, showBack && /* @__PURE__ */ React6.createElement(View5, { className: "nav-btn", onClick: handleBack }, /* @__PURE__ */ React6.createElement(
|
|
368
|
-
Image,
|
|
369
|
-
{
|
|
370
|
-
className: "nav-icon-img back-icon-img",
|
|
371
|
-
src: BACK_ICON_SVG,
|
|
372
|
-
mode: "aspectFit"
|
|
373
|
-
}
|
|
374
|
-
)), showClose && /* @__PURE__ */ React6.createElement(View5, { className: "nav-btn", onClick: handleClose }, /* @__PURE__ */ React6.createElement(Text4, { className: "nav-icon close-icon", style: { color: textColor } }, "\u2715"))),
|
|
375
|
-
title && /* @__PURE__ */ React6.createElement(View5, { className: "nav-title" }, /* @__PURE__ */ React6.createElement(Text4, { className: "title-text", style: { color: textColor } }, title)),
|
|
376
|
-
rightContent && /* @__PURE__ */ React6.createElement(View5, { className: "nav-right", style: { right: `${getRightSafeDistance()}px` } }, rightContent)
|
|
377
|
-
));
|
|
378
|
-
if (fixed) {
|
|
379
|
-
return /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement(
|
|
369
|
+
const navBarContent = /* @__PURE__ */ jsxs4(View5, { className: navBarClass, style: { backgroundColor: actualBgColor }, children: [
|
|
370
|
+
/* @__PURE__ */ jsx5(StatusBar, { backgroundColor: actualBgColor }),
|
|
371
|
+
/* @__PURE__ */ jsxs4(
|
|
380
372
|
View5,
|
|
381
373
|
{
|
|
382
|
-
className: "nav-bar-
|
|
383
|
-
style: {
|
|
374
|
+
className: "nav-bar-content",
|
|
375
|
+
style: {
|
|
376
|
+
height: `${navBarContentHeight}px`,
|
|
377
|
+
backgroundColor: actualBgColor
|
|
378
|
+
},
|
|
379
|
+
children: [
|
|
380
|
+
(showBack || showClose) && /* @__PURE__ */ jsxs4(View5, { className: "nav-left", children: [
|
|
381
|
+
showBack && /* @__PURE__ */ jsx5(View5, { className: "nav-btn", onClick: handleBack, children: /* @__PURE__ */ jsx5(
|
|
382
|
+
Image,
|
|
383
|
+
{
|
|
384
|
+
className: "nav-icon-img back-icon-img",
|
|
385
|
+
src: BACK_ICON_SVG,
|
|
386
|
+
mode: "aspectFit"
|
|
387
|
+
}
|
|
388
|
+
) }),
|
|
389
|
+
showClose && /* @__PURE__ */ jsx5(View5, { className: "nav-btn", onClick: handleClose, children: /* @__PURE__ */ jsx5(Text4, { className: "nav-icon close-icon", style: { color: textColor }, children: "\u2715" }) })
|
|
390
|
+
] }),
|
|
391
|
+
title && /* @__PURE__ */ jsx5(View5, { className: "nav-title", children: /* @__PURE__ */ jsx5(Text4, { className: "title-text", style: { color: textColor }, children: title }) }),
|
|
392
|
+
rightContent && /* @__PURE__ */ jsx5(View5, { className: "nav-right", style: { right: `${getRightSafeDistance()}px` }, children: rightContent })
|
|
393
|
+
]
|
|
384
394
|
}
|
|
385
|
-
)
|
|
395
|
+
)
|
|
396
|
+
] });
|
|
397
|
+
if (fixed) {
|
|
398
|
+
return /* @__PURE__ */ jsxs4(Fragment, { children: [
|
|
399
|
+
/* @__PURE__ */ jsx5(
|
|
400
|
+
View5,
|
|
401
|
+
{
|
|
402
|
+
className: "nav-bar-placeholder",
|
|
403
|
+
style: { height: `${totalHeight}px` }
|
|
404
|
+
}
|
|
405
|
+
),
|
|
406
|
+
navBarContent
|
|
407
|
+
] });
|
|
386
408
|
}
|
|
387
409
|
return navBarContent;
|
|
388
410
|
}
|
|
389
411
|
|
|
390
412
|
// src/components/ImageUploader/index.tsx
|
|
391
|
-
import
|
|
413
|
+
import { useState as useState4 } from "react";
|
|
392
414
|
import { View as View6, Image as Image2 } from "@tarojs/components";
|
|
393
415
|
import Taro4 from "@tarojs/taro";
|
|
416
|
+
import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
394
417
|
function ImageUploader({
|
|
395
418
|
value = [],
|
|
396
419
|
onChange,
|
|
@@ -421,7 +444,7 @@ function ImageUploader({
|
|
|
421
444
|
});
|
|
422
445
|
const urls = await Promise.all(uploadPromises);
|
|
423
446
|
const newImages = [...value, ...urls];
|
|
424
|
-
onChange
|
|
447
|
+
onChange?.(newImages);
|
|
425
448
|
Taro4.showToast({
|
|
426
449
|
title: "\u4E0A\u4F20\u6210\u529F",
|
|
427
450
|
icon: "success"
|
|
@@ -448,33 +471,46 @@ function ImageUploader({
|
|
|
448
471
|
success: (res) => {
|
|
449
472
|
if (res.confirm) {
|
|
450
473
|
const newImages = value.filter((_, i) => i !== index);
|
|
451
|
-
onChange
|
|
474
|
+
onChange?.(newImages);
|
|
452
475
|
}
|
|
453
476
|
}
|
|
454
477
|
});
|
|
455
478
|
};
|
|
456
|
-
return /* @__PURE__ */
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
479
|
+
return /* @__PURE__ */ jsxs5(View6, { className: "image-uploader", children: [
|
|
480
|
+
/* @__PURE__ */ jsxs5(View6, { className: "image-list", children: [
|
|
481
|
+
value.map((url, index) => /* @__PURE__ */ jsxs5(View6, { className: "image-item", children: [
|
|
482
|
+
/* @__PURE__ */ jsx6(
|
|
483
|
+
Image2,
|
|
484
|
+
{
|
|
485
|
+
src: url,
|
|
486
|
+
mode: "aspectFill",
|
|
487
|
+
className: "image",
|
|
488
|
+
onClick: () => handlePreview(index)
|
|
489
|
+
}
|
|
490
|
+
),
|
|
491
|
+
/* @__PURE__ */ jsx6(View6, { className: "delete-btn", onClick: () => handleDelete(index), children: "\xD7" })
|
|
492
|
+
] }, index)),
|
|
493
|
+
value.length < maxCount && /* @__PURE__ */ jsx6(
|
|
494
|
+
View6,
|
|
495
|
+
{
|
|
496
|
+
className: `add-btn ${uploading ? "disabled" : ""}`,
|
|
497
|
+
onClick: uploading ? void 0 : handleChooseImage,
|
|
498
|
+
children: uploading ? /* @__PURE__ */ jsx6(View6, { className: "loading", children: "\u4E0A\u4F20\u4E2D..." }) : /* @__PURE__ */ jsx6(View6, { className: "add-icon", children: "+" })
|
|
499
|
+
}
|
|
500
|
+
)
|
|
501
|
+
] }),
|
|
502
|
+
/* @__PURE__ */ jsxs5(View6, { className: "tip", children: [
|
|
503
|
+
"\u6700\u591A\u4E0A\u4F20 ",
|
|
504
|
+
maxCount,
|
|
505
|
+
" \u5F20\u56FE\u7247"
|
|
506
|
+
] })
|
|
507
|
+
] });
|
|
472
508
|
}
|
|
473
509
|
|
|
474
510
|
// src/components/ImageGrid/index.tsx
|
|
475
|
-
import React8 from "react";
|
|
476
511
|
import { View as View7, Image as Image3 } from "@tarojs/components";
|
|
477
512
|
import Taro5 from "@tarojs/taro";
|
|
513
|
+
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
478
514
|
function ImageGrid({ images, maxCount = 9, onImageClick }) {
|
|
479
515
|
const displayImages = images.slice(0, maxCount);
|
|
480
516
|
const count = displayImages.length;
|
|
@@ -493,19 +529,26 @@ function ImageGrid({ images, maxCount = 9, onImageClick }) {
|
|
|
493
529
|
});
|
|
494
530
|
}
|
|
495
531
|
};
|
|
496
|
-
return /* @__PURE__ */
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
532
|
+
return /* @__PURE__ */ jsx7(View7, { className: `image-grid ${getGridClass()}`, children: displayImages.map((url, index) => /* @__PURE__ */ jsxs6(View7, { className: "image-item", onClick: () => handleImageClick(index), children: [
|
|
533
|
+
/* @__PURE__ */ jsx7(
|
|
534
|
+
Image3,
|
|
535
|
+
{
|
|
536
|
+
src: url,
|
|
537
|
+
mode: count === 1 ? "widthFix" : "aspectFill",
|
|
538
|
+
className: "image",
|
|
539
|
+
lazyLoad: true
|
|
540
|
+
}
|
|
541
|
+
),
|
|
542
|
+
index === maxCount - 1 && images.length > maxCount && /* @__PURE__ */ jsx7(View7, { className: "image-overlay", children: /* @__PURE__ */ jsxs6(View7, { className: "image-count", children: [
|
|
543
|
+
"+",
|
|
544
|
+
images.length - maxCount + 1
|
|
545
|
+
] }) })
|
|
546
|
+
] }, index)) });
|
|
505
547
|
}
|
|
506
548
|
|
|
507
549
|
// src/components/Tabs/index.tsx
|
|
508
550
|
import { View as View8, Text as Text5 } from "@tarojs/components";
|
|
551
|
+
import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
509
552
|
function Tabs({ activeKey, items, onChange, className = "" }) {
|
|
510
553
|
const handleItemClick = (e) => {
|
|
511
554
|
const key = e.currentTarget.dataset.key;
|
|
@@ -513,23 +556,30 @@ function Tabs({ activeKey, items, onChange, className = "" }) {
|
|
|
513
556
|
onChange(key);
|
|
514
557
|
}
|
|
515
558
|
};
|
|
516
|
-
return /* @__PURE__ */
|
|
559
|
+
return /* @__PURE__ */ jsx8(View8, { className: `svton-tabs ${className}`, children: items.map((item) => /* @__PURE__ */ jsxs7(
|
|
517
560
|
View8,
|
|
518
561
|
{
|
|
519
|
-
key: item.key,
|
|
520
562
|
"data-key": item.key,
|
|
521
563
|
className: `svton-tabs__item ${activeKey === item.key ? "svton-tabs__item--active" : ""}`,
|
|
522
|
-
onClick: handleItemClick
|
|
564
|
+
onClick: handleItemClick,
|
|
565
|
+
children: [
|
|
566
|
+
/* @__PURE__ */ jsx8(Text5, { className: "svton-tabs__label", children: item.label }),
|
|
567
|
+
item.count !== void 0 && /* @__PURE__ */ jsxs7(Text5, { className: "svton-tabs__count", children: [
|
|
568
|
+
"(",
|
|
569
|
+
item.count,
|
|
570
|
+
")"
|
|
571
|
+
] })
|
|
572
|
+
]
|
|
523
573
|
},
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
)));
|
|
574
|
+
item.key
|
|
575
|
+
)) });
|
|
527
576
|
}
|
|
528
577
|
var Tabs_default = Tabs;
|
|
529
578
|
|
|
530
579
|
// src/components/ContentActionBar/index.tsx
|
|
531
|
-
import
|
|
580
|
+
import { useState as useState5 } from "react";
|
|
532
581
|
import { View as View9, Text as Text6, Textarea, Image as Image4 } from "@tarojs/components";
|
|
582
|
+
import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
533
583
|
var ICONS = {
|
|
534
584
|
// 点赞图标(未点赞) - 空心心形
|
|
535
585
|
like: "https://miaoduo.fbcontent.cn/private/resource/image/19a9ba374ebbee0-0aa9c734-e868-4861-9bfd-37de7ed3a123.svg",
|
|
@@ -568,7 +618,7 @@ function ContentActionBar({
|
|
|
568
618
|
if (!inputValue.trim() || submitting || disabled) return;
|
|
569
619
|
setSubmitting(true);
|
|
570
620
|
try {
|
|
571
|
-
await
|
|
621
|
+
await onComment?.(inputValue.trim());
|
|
572
622
|
handleCollapse();
|
|
573
623
|
} catch (error) {
|
|
574
624
|
console.error("\u8BC4\u8BBA\u5931\u8D25:", error);
|
|
@@ -579,79 +629,99 @@ function ContentActionBar({
|
|
|
579
629
|
const handleLike = (e) => {
|
|
580
630
|
e.stopPropagation();
|
|
581
631
|
if (disabled) return;
|
|
582
|
-
onLike
|
|
632
|
+
onLike?.();
|
|
583
633
|
};
|
|
584
634
|
const handleFavorite = (e) => {
|
|
585
635
|
e.stopPropagation();
|
|
586
636
|
if (disabled) return;
|
|
587
|
-
onFavorite
|
|
637
|
+
onFavorite?.();
|
|
588
638
|
};
|
|
589
639
|
const handleShare = (e) => {
|
|
590
640
|
e.stopPropagation();
|
|
591
641
|
if (disabled) return;
|
|
592
|
-
onShare
|
|
642
|
+
onShare?.();
|
|
593
643
|
};
|
|
594
|
-
return /* @__PURE__ */
|
|
644
|
+
return /* @__PURE__ */ jsx9(View9, { className: "content-action-bar", children: !isExpanded ? (
|
|
595
645
|
// 收起状态:输入框占位 + 操作按钮
|
|
596
|
-
/* @__PURE__ */
|
|
597
|
-
View9,
|
|
598
|
-
{
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
646
|
+
/* @__PURE__ */ jsxs8(View9, { className: "action-bar-collapsed", children: [
|
|
647
|
+
/* @__PURE__ */ jsx9(View9, { className: "input-placeholder", onClick: handleExpand, children: /* @__PURE__ */ jsx9(Text6, { className: "placeholder-text", children: placeholder }) }),
|
|
648
|
+
/* @__PURE__ */ jsxs8(View9, { className: "action-buttons", children: [
|
|
649
|
+
/* @__PURE__ */ jsx9(
|
|
650
|
+
View9,
|
|
651
|
+
{
|
|
652
|
+
className: `action-btn ${liked ? "active" : ""}`,
|
|
653
|
+
onClick: handleLike,
|
|
654
|
+
children: /* @__PURE__ */ jsx9(
|
|
655
|
+
Image4,
|
|
656
|
+
{
|
|
657
|
+
className: `action-icon-img ${liked ? "liked" : ""}`,
|
|
658
|
+
src: liked ? ICONS.liked : ICONS.like,
|
|
659
|
+
mode: "aspectFit"
|
|
660
|
+
}
|
|
661
|
+
)
|
|
662
|
+
}
|
|
663
|
+
),
|
|
664
|
+
/* @__PURE__ */ jsx9(
|
|
665
|
+
View9,
|
|
666
|
+
{
|
|
667
|
+
className: `action-btn ${favorited ? "active" : ""}`,
|
|
668
|
+
onClick: handleFavorite,
|
|
669
|
+
children: /* @__PURE__ */ jsx9(
|
|
670
|
+
Image4,
|
|
671
|
+
{
|
|
672
|
+
className: `action-icon-img ${favorited ? "favorited" : ""}`,
|
|
673
|
+
src: favorited ? ICONS.favorited : ICONS.favorite,
|
|
674
|
+
mode: "aspectFit"
|
|
675
|
+
}
|
|
676
|
+
)
|
|
677
|
+
}
|
|
678
|
+
),
|
|
679
|
+
/* @__PURE__ */ jsx9(View9, { className: "action-btn", onClick: handleShare, children: /* @__PURE__ */ jsx9(
|
|
680
|
+
Image4,
|
|
681
|
+
{
|
|
682
|
+
className: "action-icon-img",
|
|
683
|
+
src: ICONS.share,
|
|
684
|
+
mode: "aspectFit"
|
|
685
|
+
}
|
|
686
|
+
) })
|
|
687
|
+
] })
|
|
688
|
+
] })
|
|
632
689
|
) : (
|
|
633
690
|
// 展开状态:多行输入框 + 发送按钮
|
|
634
|
-
/* @__PURE__ */
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
{
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
691
|
+
/* @__PURE__ */ jsxs8(View9, { className: "action-bar-expanded", children: [
|
|
692
|
+
/* @__PURE__ */ jsx9(
|
|
693
|
+
Textarea,
|
|
694
|
+
{
|
|
695
|
+
className: "comment-textarea",
|
|
696
|
+
value: inputValue,
|
|
697
|
+
onInput: (e) => setInputValue(e.detail.value),
|
|
698
|
+
placeholder,
|
|
699
|
+
maxlength: maxLength,
|
|
700
|
+
autoHeight: true,
|
|
701
|
+
focus: true,
|
|
702
|
+
disabled
|
|
703
|
+
}
|
|
704
|
+
),
|
|
705
|
+
/* @__PURE__ */ jsxs8(View9, { className: "expanded-actions", children: [
|
|
706
|
+
/* @__PURE__ */ jsxs8(Text6, { className: "char-count", children: [
|
|
707
|
+
inputValue.length,
|
|
708
|
+
"/",
|
|
709
|
+
maxLength
|
|
710
|
+
] }),
|
|
711
|
+
/* @__PURE__ */ jsxs8(View9, { className: "action-btns", children: [
|
|
712
|
+
/* @__PURE__ */ jsx9(View9, { className: "cancel-btn", onClick: handleCollapse, children: /* @__PURE__ */ jsx9(Text6, { className: "btn-text", children: "\u53D6\u6D88" }) }),
|
|
713
|
+
/* @__PURE__ */ jsx9(
|
|
714
|
+
View9,
|
|
715
|
+
{
|
|
716
|
+
className: `send-btn ${inputValue.trim() && !submitting ? "active" : "disabled"}`,
|
|
717
|
+
onClick: handleSubmit,
|
|
718
|
+
children: /* @__PURE__ */ jsx9(Text6, { className: "btn-text", children: submitting ? "\u53D1\u9001\u4E2D..." : "\u53D1\u9001" })
|
|
719
|
+
}
|
|
720
|
+
)
|
|
721
|
+
] })
|
|
722
|
+
] })
|
|
723
|
+
] })
|
|
724
|
+
) });
|
|
655
725
|
}
|
|
656
726
|
|
|
657
727
|
// src/hooks/useScrollOpacity.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@svton/taro-ui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Production-ready Taro UI components library for mini-programs with TypeScript support",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"taro",
|
|
@@ -37,12 +37,6 @@
|
|
|
37
37
|
"require": "./dist/index.js"
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
|
-
"scripts": {
|
|
41
|
-
"build": "tsup",
|
|
42
|
-
"dev": "tsup --watch",
|
|
43
|
-
"type-check": "tsc --noEmit",
|
|
44
|
-
"prepublishOnly": "pnpm build"
|
|
45
|
-
},
|
|
46
40
|
"peerDependencies": {
|
|
47
41
|
"@tarojs/components": "^3.6.0",
|
|
48
42
|
"@tarojs/taro": "^3.6.0",
|
|
@@ -59,5 +53,10 @@
|
|
|
59
53
|
},
|
|
60
54
|
"publishConfig": {
|
|
61
55
|
"access": "public"
|
|
56
|
+
},
|
|
57
|
+
"scripts": {
|
|
58
|
+
"build": "tsup",
|
|
59
|
+
"dev": "tsup --watch",
|
|
60
|
+
"type-check": "tsc --noEmit"
|
|
62
61
|
}
|
|
63
|
-
}
|
|
62
|
+
}
|