@pisell/materials 6.8.9 → 6.8.10

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.
Files changed (73) hide show
  1. package/build/lowcode/assets-daily.json +11 -11
  2. package/build/lowcode/assets-dev.json +2 -2
  3. package/build/lowcode/assets-prod.json +11 -11
  4. package/build/lowcode/index.js +1 -1
  5. package/build/lowcode/meta.js +1 -1
  6. package/build/lowcode/preview.js +8 -8
  7. package/build/lowcode/render/default/view.js +16 -16
  8. package/build/lowcode/view.js +16 -16
  9. package/es/components/PisellProcedure/PisellProcedure.stories.d.ts +163 -0
  10. package/es/components/PisellProcedure/PisellProcedure.stories.js +1611 -0
  11. package/es/components/PisellScrollView/PisellScrollView.stories.d.ts +87 -0
  12. package/es/components/PisellScrollView/PisellScrollView.stories.js +772 -0
  13. package/es/components/PisellScrollView/hooks/useScrollEvents.js +18 -3
  14. package/es/components/PisellScrollView/index.d.ts +2 -1
  15. package/es/components/PisellScrollView/index.js +2 -1
  16. package/es/components/PisellSteps/PisellSteps.stories.d.ts +155 -0
  17. package/es/components/PisellSteps/PisellSteps.stories.js +851 -0
  18. package/es/components/PisellSuperTabs/PisellSuperTabs.d.ts +6 -10
  19. package/es/components/PisellSuperTabs/PisellSuperTabs.js +28 -8
  20. package/es/components/PisellSuperTabs/types.d.ts +1 -0
  21. package/es/components/PisellTabbar/PisellTabbar.d.ts +2 -19
  22. package/es/components/PisellTabbar/PisellTabbar.js +2 -1
  23. package/es/components/PisellTabbar/constants.d.ts +4 -4
  24. package/es/components/PisellTabbar/constants.js +5 -5
  25. package/es/components/PisellTabbar/index.d.ts +2 -0
  26. package/es/components/PisellTabbar/index.js +2 -0
  27. package/es/components/PisellTabbar/template/Template1/PisellTabbar.d.ts +20 -0
  28. package/es/components/PisellTabbar/template/Template1/PisellTabbar.js +426 -0
  29. package/es/components/PisellTabbar/template/Template1/constants.d.ts +10 -0
  30. package/es/components/PisellTabbar/template/Template1/constants.js +33 -0
  31. package/es/components/PisellTabbar/template/Template1/index.d.ts +6 -0
  32. package/es/components/PisellTabbar/template/Template1/index.js +7 -0
  33. package/es/components/PisellTabbar/template/Template1/utils/index.d.ts +35 -0
  34. package/es/components/PisellTabbar/template/Template1/utils/index.js +96 -0
  35. package/es/components/PisellTabbar/utils/index.d.ts +33 -0
  36. package/es/components/PisellTabbar/utils/index.js +3 -2
  37. package/es/components/productCard/cartSkuCard/components/packages/utils.d.ts +1 -1
  38. package/es/components/productCard/components/Packages/utils.d.ts +1 -1
  39. package/es/index.d.ts +2 -1
  40. package/es/index.js +2 -1
  41. package/lib/components/PisellProcedure/PisellProcedure.stories.d.ts +163 -0
  42. package/lib/components/PisellProcedure/PisellProcedure.stories.js +925 -0
  43. package/lib/components/PisellScrollView/PisellScrollView.stories.d.ts +87 -0
  44. package/lib/components/PisellScrollView/PisellScrollView.stories.js +535 -0
  45. package/lib/components/PisellScrollView/hooks/useScrollEvents.js +13 -3
  46. package/lib/components/PisellScrollView/index.d.ts +2 -1
  47. package/lib/components/PisellScrollView/index.js +2 -5
  48. package/lib/components/PisellSteps/PisellSteps.stories.d.ts +155 -0
  49. package/lib/components/PisellSteps/PisellSteps.stories.js +570 -0
  50. package/lib/components/PisellSuperTabs/PisellSuperTabs.d.ts +6 -10
  51. package/lib/components/PisellSuperTabs/PisellSuperTabs.js +25 -6
  52. package/lib/components/PisellSuperTabs/types.d.ts +1 -0
  53. package/lib/components/PisellTabbar/PisellTabbar.d.ts +2 -19
  54. package/lib/components/PisellTabbar/PisellTabbar.js +2 -1
  55. package/lib/components/PisellTabbar/constants.d.ts +4 -4
  56. package/lib/components/PisellTabbar/constants.js +5 -5
  57. package/lib/components/PisellTabbar/index.d.ts +2 -0
  58. package/lib/components/PisellTabbar/index.js +6 -0
  59. package/lib/components/PisellTabbar/template/Template1/PisellTabbar.d.ts +20 -0
  60. package/lib/components/PisellTabbar/template/Template1/PisellTabbar.js +437 -0
  61. package/lib/components/PisellTabbar/template/Template1/constants.d.ts +10 -0
  62. package/lib/components/PisellTabbar/template/Template1/constants.js +60 -0
  63. package/lib/components/PisellTabbar/template/Template1/index.d.ts +6 -0
  64. package/lib/components/PisellTabbar/template/Template1/index.js +36 -0
  65. package/lib/components/PisellTabbar/template/Template1/utils/index.d.ts +35 -0
  66. package/lib/components/PisellTabbar/template/Template1/utils/index.js +68 -0
  67. package/lib/components/PisellTabbar/utils/index.d.ts +33 -0
  68. package/lib/components/PisellTabbar/utils/index.js +4 -1
  69. package/lib/components/productCard/cartSkuCard/components/packages/utils.d.ts +1 -1
  70. package/lib/components/productCard/components/Packages/utils.d.ts +1 -1
  71. package/lib/index.d.ts +2 -1
  72. package/lib/index.js +5 -2
  73. package/package.json +21 -2
@@ -0,0 +1,87 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import PisellScrollView from './PisellScrollView';
3
+ /**
4
+ * PisellScrollView 滚动视图组件
5
+ *
6
+ * 提供丰富的滚动功能,包括滚动方向控制、滚动条样式、滚动按钮、滚动事件监听、
7
+ * 视图监听、吸附滚动等功能
8
+ */
9
+ declare const meta: Meta<typeof PisellScrollView>;
10
+ export default meta;
11
+ declare type Story = StoryObj<typeof PisellScrollView>;
12
+ /**
13
+ * 基础用法 - 垂直滚动
14
+ */
15
+ export declare const Default: Story;
16
+ /**
17
+ * 水平滚动
18
+ */
19
+ export declare const HorizontalScroll: Story;
20
+ /**
21
+ * 双向滚动
22
+ */
23
+ export declare const BothDirections: Story;
24
+ /**
25
+ * 滚动条样式 - 细滚动条
26
+ */
27
+ export declare const ThinScrollbar: Story;
28
+ /**
29
+ * 滚动条样式 - 隐藏滚动条
30
+ */
31
+ export declare const HiddenScrollbar: Story;
32
+ /**
33
+ * 滚动按钮 - 右侧箭头
34
+ */
35
+ export declare const RightArrows: Story;
36
+ /**
37
+ * 滚动按钮 - 左右箭头
38
+ */
39
+ export declare const LeftRightArrows: Story;
40
+ /**
41
+ * 滚动按钮 - 返回顶部
42
+ */
43
+ export declare const BackToTop: Story;
44
+ /**
45
+ * 滚动事件监听
46
+ */
47
+ export declare const ScrollEvents: Story;
48
+ /**
49
+ * 吸附滚动 - 垂直方向
50
+ */
51
+ export declare const SnapScrollVertical: Story;
52
+ /**
53
+ * 吸附滚动 - 水平方向
54
+ */
55
+ export declare const SnapScrollHorizontal: Story;
56
+ /**
57
+ * 视图监听 - IntersectionObserver
58
+ */
59
+ export declare const IntersectionObserver: Story;
60
+ /**
61
+ * Ref 方法调用
62
+ */
63
+ export declare const RefMethods: Story;
64
+ /**
65
+ * 滚动到指定元素
66
+ */
67
+ export declare const ScrollToElement: Story;
68
+ /**
69
+ * 自定义尺寸
70
+ */
71
+ export declare const CustomSize: Story;
72
+ /**
73
+ * 综合示例 - 商品列表
74
+ */
75
+ export declare const ProductList: Story;
76
+ /**
77
+ * 综合示例 - 横向标签页
78
+ */
79
+ export declare const HorizontalTabs: Story;
80
+ /**
81
+ * 交互测试 - 验证组件渲染
82
+ */
83
+ export declare const RenderTest: Story;
84
+ /**
85
+ * 交互测试 - 滚动按钮点击
86
+ */
87
+ export declare const ScrollButtonTest: Story;
@@ -0,0 +1,535 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/components/PisellScrollView/PisellScrollView.stories.tsx
30
+ var PisellScrollView_stories_exports = {};
31
+ __export(PisellScrollView_stories_exports, {
32
+ BackToTop: () => BackToTop,
33
+ BothDirections: () => BothDirections,
34
+ CustomSize: () => CustomSize,
35
+ Default: () => Default,
36
+ HiddenScrollbar: () => HiddenScrollbar,
37
+ HorizontalScroll: () => HorizontalScroll,
38
+ HorizontalTabs: () => HorizontalTabs,
39
+ IntersectionObserver: () => IntersectionObserver,
40
+ LeftRightArrows: () => LeftRightArrows,
41
+ ProductList: () => ProductList,
42
+ RefMethods: () => RefMethods,
43
+ RenderTest: () => RenderTest,
44
+ RightArrows: () => RightArrows,
45
+ ScrollButtonTest: () => ScrollButtonTest,
46
+ ScrollEvents: () => ScrollEvents,
47
+ ScrollToElement: () => ScrollToElement,
48
+ SnapScrollHorizontal: () => SnapScrollHorizontal,
49
+ SnapScrollVertical: () => SnapScrollVertical,
50
+ ThinScrollbar: () => ThinScrollbar,
51
+ default: () => PisellScrollView_stories_default
52
+ });
53
+ module.exports = __toCommonJS(PisellScrollView_stories_exports);
54
+ var import_test = require("@storybook/test");
55
+ var import_antd = require("antd");
56
+ var import_react = require("react");
57
+ var import_PisellScrollView = __toESM(require("./PisellScrollView"));
58
+ var meta = {
59
+ title: "Pro Components/PisellScrollView",
60
+ component: import_PisellScrollView.default,
61
+ parameters: {
62
+ layout: "padded",
63
+ docs: {
64
+ description: {
65
+ component: "滚动视图组件,提供丰富的滚动功能,支持多种滚动方向、滚动条样式、滚动按钮和滚动事件监听。"
66
+ }
67
+ }
68
+ },
69
+ tags: ["autodocs"],
70
+ argTypes: {
71
+ overflow: {
72
+ control: "select",
73
+ options: ["auto", "scroll", "hidden", "x", "y", "both"],
74
+ description: "滚动方向"
75
+ },
76
+ scrollbarStyle: {
77
+ control: "select",
78
+ options: ["default", "thin", "minimal", "rounded", "overlay", "custom", "none"],
79
+ description: "滚动条样式"
80
+ },
81
+ width: {
82
+ control: "text",
83
+ description: "容器宽度"
84
+ },
85
+ height: {
86
+ control: "text",
87
+ description: "容器高度"
88
+ }
89
+ }
90
+ };
91
+ var PisellScrollView_stories_default = meta;
92
+ var Default = {
93
+ args: {
94
+ width: "100%",
95
+ height: 400,
96
+ overflow: "y",
97
+ children: /* @__PURE__ */ React.createElement("div", { style: { padding: 20 } }, Array.from({ length: 20 }, (_, i) => /* @__PURE__ */ React.createElement(import_antd.Card, { key: i, style: { marginBottom: 16 } }, /* @__PURE__ */ React.createElement("h3", null, "卡片 ", i + 1), /* @__PURE__ */ React.createElement("p", null, "这是第 ", i + 1, " 个卡片内容,用于演示垂直滚动效果。"))))
98
+ }
99
+ };
100
+ var HorizontalScroll = {
101
+ args: {
102
+ width: "100%",
103
+ height: 300,
104
+ overflow: "x",
105
+ children: /* @__PURE__ */ React.createElement("div", { style: { display: "flex", padding: 20, gap: 16 } }, Array.from({ length: 10 }, (_, i) => /* @__PURE__ */ React.createElement(
106
+ import_antd.Card,
107
+ {
108
+ key: i,
109
+ style: {
110
+ minWidth: 300,
111
+ flexShrink: 0
112
+ }
113
+ },
114
+ /* @__PURE__ */ React.createElement("h3", null, "卡片 ", i + 1),
115
+ /* @__PURE__ */ React.createElement("p", null, "这是第 ", i + 1, " 个卡片,用于演示水平滚动效果。")
116
+ )))
117
+ }
118
+ };
119
+ var BothDirections = {
120
+ args: {
121
+ width: "100%",
122
+ height: 400,
123
+ overflow: "both",
124
+ children: /* @__PURE__ */ React.createElement("div", { style: { padding: 20, width: 2e3, height: 2e3 } }, /* @__PURE__ */ React.createElement("h2", null, "双向滚动内容"), /* @__PURE__ */ React.createElement("p", null, "这个区域可以同时进行水平和垂直滚动。"), /* @__PURE__ */ React.createElement("div", { style: { marginTop: 100, marginLeft: 500 } }, /* @__PURE__ */ React.createElement(import_antd.Card, null, /* @__PURE__ */ React.createElement("h3", null, "右下角内容"), /* @__PURE__ */ React.createElement("p", null, "滚动到这里可以看到双向滚动的效果。"))))
125
+ }
126
+ };
127
+ var ThinScrollbar = {
128
+ args: {
129
+ width: "100%",
130
+ height: 400,
131
+ overflow: "y",
132
+ scrollbarStyle: "thin",
133
+ children: /* @__PURE__ */ React.createElement("div", { style: { padding: 20 } }, Array.from({ length: 15 }, (_, i) => /* @__PURE__ */ React.createElement(import_antd.Card, { key: i, style: { marginBottom: 16 } }, /* @__PURE__ */ React.createElement("h3", null, "卡片 ", i + 1), /* @__PURE__ */ React.createElement("p", null, "使用细滚动条样式。"))))
134
+ }
135
+ };
136
+ var HiddenScrollbar = {
137
+ args: {
138
+ width: "100%",
139
+ height: 400,
140
+ overflow: "y",
141
+ scrollbarStyle: "none",
142
+ children: /* @__PURE__ */ React.createElement("div", { style: { padding: 20 } }, Array.from({ length: 15 }, (_, i) => /* @__PURE__ */ React.createElement(import_antd.Card, { key: i, style: { marginBottom: 16 } }, /* @__PURE__ */ React.createElement("h3", null, "卡片 ", i + 1), /* @__PURE__ */ React.createElement("p", null, "滚动条已隐藏,但仍可滚动。"))))
143
+ }
144
+ };
145
+ var RightArrows = {
146
+ args: {
147
+ width: "100%",
148
+ height: 400,
149
+ overflow: "x",
150
+ scrollActionsConfig: {
151
+ show: true,
152
+ type: "rArrows",
153
+ scrollDistance: 300
154
+ },
155
+ children: /* @__PURE__ */ React.createElement("div", { style: { display: "flex", padding: 20, gap: 16 } }, Array.from({ length: 10 }, (_, i) => /* @__PURE__ */ React.createElement(
156
+ import_antd.Card,
157
+ {
158
+ key: i,
159
+ style: {
160
+ minWidth: 300,
161
+ flexShrink: 0
162
+ }
163
+ },
164
+ /* @__PURE__ */ React.createElement("h3", null, "卡片 ", i + 1),
165
+ /* @__PURE__ */ React.createElement("p", null, "点击右侧箭头按钮可以滚动。")
166
+ )))
167
+ }
168
+ };
169
+ var LeftRightArrows = {
170
+ args: {
171
+ width: "100%",
172
+ height: 400,
173
+ overflow: "x",
174
+ scrollActionsConfig: {
175
+ show: true,
176
+ type: "lrArrows",
177
+ scrollDistance: 300
178
+ },
179
+ children: /* @__PURE__ */ React.createElement("div", { style: { display: "flex", padding: 20, gap: 16 } }, Array.from({ length: 10 }, (_, i) => /* @__PURE__ */ React.createElement(
180
+ import_antd.Card,
181
+ {
182
+ key: i,
183
+ style: {
184
+ minWidth: 300,
185
+ flexShrink: 0
186
+ }
187
+ },
188
+ /* @__PURE__ */ React.createElement("h3", null, "卡片 ", i + 1),
189
+ /* @__PURE__ */ React.createElement("p", null, "点击左右箭头按钮可以滚动。")
190
+ )))
191
+ }
192
+ };
193
+ var BackToTop = {
194
+ args: {
195
+ width: "100%",
196
+ height: 400,
197
+ overflow: "y",
198
+ scrollActionsConfig: {
199
+ show: true,
200
+ type: "backTop"
201
+ },
202
+ children: /* @__PURE__ */ React.createElement("div", { style: { padding: 20 } }, Array.from({ length: 30 }, (_, i) => /* @__PURE__ */ React.createElement(import_antd.Card, { key: i, style: { marginBottom: 16 } }, /* @__PURE__ */ React.createElement("h3", null, "卡片 ", i + 1), /* @__PURE__ */ React.createElement("p", null, "滚动到底部后,点击返回顶部按钮可以快速回到顶部。"))))
203
+ }
204
+ };
205
+ var ScrollEvents = {
206
+ args: {
207
+ width: "100%",
208
+ height: 400,
209
+ overflow: "y",
210
+ onScroll: (data) => {
211
+ console.log("滚动中:", data);
212
+ },
213
+ onScrollStart: (data) => {
214
+ console.log("开始滚动:", data);
215
+ },
216
+ onScrollEnd: (data) => {
217
+ console.log("滚动结束:", data);
218
+ },
219
+ onReachTop: (data) => {
220
+ console.log("到达顶部:", data);
221
+ },
222
+ onReachBottom: (data) => {
223
+ console.log("到达底部:", data);
224
+ },
225
+ children: /* @__PURE__ */ React.createElement("div", { style: { padding: 20 } }, Array.from({ length: 20 }, (_, i) => /* @__PURE__ */ React.createElement(import_antd.Card, { key: i, style: { marginBottom: 16 } }, /* @__PURE__ */ React.createElement("h3", null, "卡片 ", i + 1), /* @__PURE__ */ React.createElement("p", null, "滚动时查看控制台输出,可以看到滚动事件数据。"))))
226
+ }
227
+ };
228
+ var SnapScrollVertical = {
229
+ args: {
230
+ width: "100%",
231
+ height: 400,
232
+ overflow: "y",
233
+ snapScroll: {
234
+ enabled: true,
235
+ type: "mandatory"
236
+ },
237
+ scrollActionsConfig: {
238
+ show: true,
239
+ type: "tbArrows"
240
+ },
241
+ children: /* @__PURE__ */ React.createElement("div", { style: { padding: 20 } }, Array.from({ length: 5 }, (_, i) => /* @__PURE__ */ React.createElement(
242
+ import_antd.Card,
243
+ {
244
+ key: i,
245
+ id: `snap-item-${i}`,
246
+ style: {
247
+ marginBottom: 16,
248
+ height: 350,
249
+ scrollSnapAlign: "start"
250
+ }
251
+ },
252
+ /* @__PURE__ */ React.createElement("h2", null, "吸附卡片 ", i + 1),
253
+ /* @__PURE__ */ React.createElement("p", null, "滚动时会自动吸附到每个卡片的开始位置。")
254
+ )))
255
+ }
256
+ };
257
+ var SnapScrollHorizontal = {
258
+ args: {
259
+ width: "100%",
260
+ height: 400,
261
+ overflow: "x",
262
+ snapScroll: {
263
+ enabled: true,
264
+ type: "mandatory"
265
+ },
266
+ scrollActionsConfig: {
267
+ show: true,
268
+ type: "lrArrows"
269
+ },
270
+ children: /* @__PURE__ */ React.createElement("div", { style: { display: "flex", padding: 20, gap: 16 } }, Array.from({ length: 5 }, (_, i) => /* @__PURE__ */ React.createElement(
271
+ import_antd.Card,
272
+ {
273
+ key: i,
274
+ id: `snap-item-${i}`,
275
+ style: {
276
+ minWidth: "calc(100% - 40px)",
277
+ flexShrink: 0,
278
+ scrollSnapAlign: "start"
279
+ }
280
+ },
281
+ /* @__PURE__ */ React.createElement("h2", null, "吸附卡片 ", i + 1),
282
+ /* @__PURE__ */ React.createElement("p", null, "滚动时会自动吸附到每个卡片的开始位置。")
283
+ )))
284
+ }
285
+ };
286
+ var IntersectionObserver = {
287
+ args: {
288
+ width: "100%",
289
+ height: 400,
290
+ overflow: "y",
291
+ intersection: {
292
+ enabled: true,
293
+ threshold: 0.5,
294
+ onEnterViewport: (entry, element) => {
295
+ console.log("元素进入视图:", element.id);
296
+ },
297
+ onLeaveViewport: (entry, element) => {
298
+ console.log("元素离开视图:", element.id);
299
+ },
300
+ targetSelector: ".observe-item"
301
+ },
302
+ children: /* @__PURE__ */ React.createElement("div", { style: { padding: 20 } }, Array.from({ length: 10 }, (_, i) => /* @__PURE__ */ React.createElement(
303
+ import_antd.Card,
304
+ {
305
+ key: i,
306
+ id: `observe-item-${i}`,
307
+ className: "observe-item",
308
+ style: { marginBottom: 16, minHeight: 200 }
309
+ },
310
+ /* @__PURE__ */ React.createElement("h3", null, "可观察卡片 ", i + 1),
311
+ /* @__PURE__ */ React.createElement("p", null, "当这个卡片进入或离开视图时,会在控制台输出日志。")
312
+ )))
313
+ }
314
+ };
315
+ var RefMethods = {
316
+ render: () => {
317
+ const scrollViewRef = (0, import_react.useRef)(null);
318
+ const handleScrollToTop = () => {
319
+ var _a;
320
+ (_a = scrollViewRef.current) == null ? void 0 : _a.scrollToTop("smooth");
321
+ };
322
+ const handleScrollToBottom = () => {
323
+ var _a;
324
+ (_a = scrollViewRef.current) == null ? void 0 : _a.scrollToBottom("smooth");
325
+ };
326
+ const handleScrollTo50Percent = () => {
327
+ var _a;
328
+ (_a = scrollViewRef.current) == null ? void 0 : _a.scrollToPercentage({ percentY: 50, behavior: "smooth" });
329
+ };
330
+ const handleGetScrollData = () => {
331
+ var _a;
332
+ const data = (_a = scrollViewRef.current) == null ? void 0 : _a.getScrollData();
333
+ console.log("当前滚动数据:", data);
334
+ alert(`滚动位置: ${(data == null ? void 0 : data.scrollTop) || 0}px
335
+ 滚动百分比: ${(data == null ? void 0 : data.percentY) || 0}%`);
336
+ };
337
+ return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(import_antd.Space, { style: { marginBottom: 16 } }, /* @__PURE__ */ React.createElement(import_antd.Button, { onClick: handleScrollToTop }, "滚动到顶部"), /* @__PURE__ */ React.createElement(import_antd.Button, { onClick: handleScrollToBottom }, "滚动到底部"), /* @__PURE__ */ React.createElement(import_antd.Button, { onClick: handleScrollTo50Percent }, "滚动到 50%"), /* @__PURE__ */ React.createElement(import_antd.Button, { onClick: handleGetScrollData }, "获取滚动数据")), /* @__PURE__ */ React.createElement(
338
+ import_PisellScrollView.default,
339
+ {
340
+ ref: scrollViewRef,
341
+ width: "100%",
342
+ height: 400,
343
+ overflow: "y"
344
+ },
345
+ /* @__PURE__ */ React.createElement("div", { style: { padding: 20 } }, Array.from({ length: 20 }, (_, i) => /* @__PURE__ */ React.createElement(import_antd.Card, { key: i, style: { marginBottom: 16 } }, /* @__PURE__ */ React.createElement("h3", null, "卡片 ", i + 1), /* @__PURE__ */ React.createElement("p", null, "使用上方的按钮可以控制滚动位置。"))))
346
+ ));
347
+ }
348
+ };
349
+ var ScrollToElement = {
350
+ render: () => {
351
+ const scrollViewRef = (0, import_react.useRef)(null);
352
+ const handleScrollToElement = (index) => {
353
+ var _a;
354
+ (_a = scrollViewRef.current) == null ? void 0 : _a.scrollToElement({
355
+ targetId: `target-item-${index}`,
356
+ align: "start",
357
+ behavior: "smooth"
358
+ });
359
+ };
360
+ return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(import_antd.Space, { style: { marginBottom: 16 } }, /* @__PURE__ */ React.createElement(import_antd.Button, { onClick: () => handleScrollToElement(0) }, "滚动到第 1 项"), /* @__PURE__ */ React.createElement(import_antd.Button, { onClick: () => handleScrollToElement(4) }, "滚动到第 5 项"), /* @__PURE__ */ React.createElement(import_antd.Button, { onClick: () => handleScrollToElement(9) }, "滚动到第 10 项")), /* @__PURE__ */ React.createElement(
361
+ import_PisellScrollView.default,
362
+ {
363
+ ref: scrollViewRef,
364
+ width: "100%",
365
+ height: 400,
366
+ overflow: "y"
367
+ },
368
+ /* @__PURE__ */ React.createElement("div", { style: { padding: 20 } }, Array.from({ length: 15 }, (_, i) => /* @__PURE__ */ React.createElement(
369
+ import_antd.Card,
370
+ {
371
+ key: i,
372
+ id: `target-item-${i}`,
373
+ style: { marginBottom: 16, minHeight: 150 }
374
+ },
375
+ /* @__PURE__ */ React.createElement("h3", null, "目标卡片 ", i + 1),
376
+ /* @__PURE__ */ React.createElement("p", null, "点击上方按钮可以滚动到这个卡片。")
377
+ )))
378
+ ));
379
+ }
380
+ };
381
+ var CustomSize = {
382
+ args: {
383
+ width: 600,
384
+ height: 300,
385
+ maxWidth: "100%",
386
+ maxHeight: 500,
387
+ overflow: "y",
388
+ children: /* @__PURE__ */ React.createElement("div", { style: { padding: 20 } }, Array.from({ length: 10 }, (_, i) => /* @__PURE__ */ React.createElement(import_antd.Card, { key: i, style: { marginBottom: 16 } }, /* @__PURE__ */ React.createElement("h3", null, "卡片 ", i + 1), /* @__PURE__ */ React.createElement("p", null, "自定义尺寸的滚动容器。"))))
389
+ }
390
+ };
391
+ var ProductList = {
392
+ args: {
393
+ width: "100%",
394
+ height: 500,
395
+ overflow: "y",
396
+ scrollbarStyle: "thin",
397
+ scrollActionsConfig: {
398
+ show: true,
399
+ type: "backTop"
400
+ },
401
+ onReachBottom: (data) => {
402
+ console.log("已滚动到底部,可以加载更多商品");
403
+ },
404
+ children: /* @__PURE__ */ React.createElement("div", { style: { padding: 20 } }, /* @__PURE__ */ React.createElement("h2", { style: { marginBottom: 16 } }, "商品列表"), /* @__PURE__ */ React.createElement("div", { style: { display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: 16 } }, Array.from({ length: 30 }, (_, i) => /* @__PURE__ */ React.createElement(
405
+ import_antd.Card,
406
+ {
407
+ key: i,
408
+ hoverable: true,
409
+ cover: /* @__PURE__ */ React.createElement(
410
+ "div",
411
+ {
412
+ style: {
413
+ height: 200,
414
+ background: `linear-gradient(135deg, #667eea 0%, #764ba2 100%)`,
415
+ display: "flex",
416
+ alignItems: "center",
417
+ justifyContent: "center",
418
+ color: "white",
419
+ fontSize: 24
420
+ }
421
+ },
422
+ "商品 ",
423
+ i + 1
424
+ )
425
+ },
426
+ /* @__PURE__ */ React.createElement(
427
+ import_antd.Card.Meta,
428
+ {
429
+ title: `商品标题 ${i + 1}`,
430
+ description: `这是商品 ${i + 1} 的描述信息,价格 ¥${(i + 1) * 10}`
431
+ }
432
+ )
433
+ ))))
434
+ }
435
+ };
436
+ var HorizontalTabs = {
437
+ args: {
438
+ width: "100%",
439
+ height: 400,
440
+ overflow: "x",
441
+ scrollbarStyle: "none",
442
+ scrollActionsConfig: {
443
+ show: true,
444
+ type: "lrArrows",
445
+ scrollDistance: 200
446
+ },
447
+ snapScroll: {
448
+ enabled: true,
449
+ type: "proximity"
450
+ },
451
+ children: /* @__PURE__ */ React.createElement("div", { style: { display: "flex", padding: 20, gap: 16 } }, ["全部", "推荐", "热门", "最新", "科技", "设计", "开发", "产品", "运营", "市场"].map(
452
+ (tab, i) => /* @__PURE__ */ React.createElement(
453
+ import_antd.Card,
454
+ {
455
+ key: i,
456
+ hoverable: true,
457
+ style: {
458
+ minWidth: 200,
459
+ flexShrink: 0,
460
+ scrollSnapAlign: "start"
461
+ }
462
+ },
463
+ /* @__PURE__ */ React.createElement("h3", null, tab),
464
+ /* @__PURE__ */ React.createElement("p", null, "这是 ", tab, " 标签页的内容")
465
+ )
466
+ ))
467
+ }
468
+ };
469
+ var RenderTest = {
470
+ args: {
471
+ width: "100%",
472
+ height: 400,
473
+ overflow: "y",
474
+ children: /* @__PURE__ */ React.createElement("div", { style: { padding: 20 } }, Array.from({ length: 10 }, (_, i) => /* @__PURE__ */ React.createElement(import_antd.Card, { key: i, style: { marginBottom: 16 } }, /* @__PURE__ */ React.createElement("h3", null, "卡片 ", i + 1), /* @__PURE__ */ React.createElement("p", null, "这是第 ", i + 1, " 个卡片内容"))))
475
+ },
476
+ play: async ({ canvasElement }) => {
477
+ const canvas = (0, import_test.within)(canvasElement);
478
+ const scrollView = canvasElement.querySelector(".pisell-scroll-view");
479
+ await (0, import_test.expect)(scrollView).toBeInTheDocument();
480
+ await (0, import_test.expect)(canvas.getByText("卡片 1")).toBeInTheDocument();
481
+ await (0, import_test.expect)(canvas.getByText("卡片 10")).toBeInTheDocument();
482
+ }
483
+ };
484
+ var ScrollButtonTest = {
485
+ args: {
486
+ width: "100%",
487
+ height: 400,
488
+ overflow: "x",
489
+ scrollActionsConfig: {
490
+ show: true,
491
+ type: "lrArrows",
492
+ scrollDistance: 300
493
+ },
494
+ children: /* @__PURE__ */ React.createElement("div", { style: { display: "flex", padding: 20, gap: 16 } }, Array.from({ length: 10 }, (_, i) => /* @__PURE__ */ React.createElement(
495
+ import_antd.Card,
496
+ {
497
+ key: i,
498
+ style: {
499
+ minWidth: 300,
500
+ flexShrink: 0
501
+ }
502
+ },
503
+ /* @__PURE__ */ React.createElement("h3", null, "卡片 ", i + 1),
504
+ /* @__PURE__ */ React.createElement("p", null, "这是第 ", i + 1, " 个卡片")
505
+ )))
506
+ },
507
+ play: async ({ canvasElement }) => {
508
+ const canvas = (0, import_test.within)(canvasElement);
509
+ const actions = canvasElement.querySelector(".pisell-scroll-view-actions");
510
+ await (0, import_test.expect)(actions).toBeInTheDocument();
511
+ await (0, import_test.expect)(canvas.getByText("卡片 1")).toBeInTheDocument();
512
+ }
513
+ };
514
+ // Annotate the CommonJS export names for ESM import in node:
515
+ 0 && (module.exports = {
516
+ BackToTop,
517
+ BothDirections,
518
+ CustomSize,
519
+ Default,
520
+ HiddenScrollbar,
521
+ HorizontalScroll,
522
+ HorizontalTabs,
523
+ IntersectionObserver,
524
+ LeftRightArrows,
525
+ ProductList,
526
+ RefMethods,
527
+ RenderTest,
528
+ RightArrows,
529
+ ScrollButtonTest,
530
+ ScrollEvents,
531
+ ScrollToElement,
532
+ SnapScrollHorizontal,
533
+ SnapScrollVertical,
534
+ ThinScrollbar
535
+ });
@@ -58,10 +58,15 @@ var useScrollEvents = ({
58
58
  clientHeight,
59
59
  clientWidth
60
60
  } = container;
61
- const maxScrollTop = scrollHeight - clientHeight;
62
- const maxScrollLeft = scrollWidth - clientWidth;
61
+ const maxScrollTop = Math.max(0, scrollHeight - clientHeight);
62
+ const maxScrollLeft = Math.max(0, scrollWidth - clientWidth);
63
63
  const percentY = maxScrollTop > 0 ? scrollTop / maxScrollTop * 100 : 0;
64
64
  const percentX = maxScrollLeft > 0 ? scrollLeft / maxScrollLeft * 100 : 0;
65
+ const isScrollToTop = scrollTop <= reachThreshold;
66
+ const isScrollToBottom = scrollTop + clientHeight >= scrollHeight - reachThreshold;
67
+ const isScrollToLeft = scrollLeft <= reachThreshold;
68
+ const isScrollToRight = scrollLeft + clientWidth >= scrollWidth - reachThreshold;
69
+ const isOverflows = scrollHeight > clientHeight || scrollWidth > clientWidth;
65
70
  const currentData = {
66
71
  scrollTop,
67
72
  scrollLeft,
@@ -71,8 +76,13 @@ var useScrollEvents = ({
71
76
  clientWidth,
72
77
  percentY,
73
78
  percentX,
74
- direction: null
79
+ direction: null,
75
80
  // 在这里计算方向比较麻烦,可以使用 scrollState 中的(虽然有一点延迟)
81
+ isScrollToTop,
82
+ isScrollToBottom,
83
+ isScrollToLeft,
84
+ isScrollToRight,
85
+ isOverflows
76
86
  };
77
87
  if (!isScrolling.current) {
78
88
  isScrolling.current = true;
@@ -1,2 +1,3 @@
1
- export { default as PisellScrollView } from './PisellScrollView';
1
+ import PisellScrollView from './PisellScrollView';
2
2
  export type { PisellScrollViewProps, PisellScrollViewRef } from './types';
3
+ export default PisellScrollView;
@@ -29,11 +29,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
29
29
  // src/components/PisellScrollView/index.tsx
30
30
  var PisellScrollView_exports = {};
31
31
  __export(PisellScrollView_exports, {
32
- PisellScrollView: () => import_PisellScrollView.default
32
+ default: () => PisellScrollView_default
33
33
  });
34
34
  module.exports = __toCommonJS(PisellScrollView_exports);
35
35
  var import_PisellScrollView = __toESM(require("./PisellScrollView"));
36
- // Annotate the CommonJS export names for ESM import in node:
37
- 0 && (module.exports = {
38
- PisellScrollView
39
- });
36
+ var PisellScrollView_default = import_PisellScrollView.default;