@tarojs/components-react 4.1.12-beta.2 → 4.1.12-beta.20
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/components/map/MapContext.js +342 -0
- package/dist/components/map/MapContext.js.map +1 -0
- package/dist/components/map/MapCustomCallout.js +91 -0
- package/dist/components/map/MapCustomCallout.js.map +1 -0
- package/dist/components/map/common.js +4 -0
- package/dist/components/map/common.js.map +1 -0
- package/dist/components/map/createMapContext.js +34 -0
- package/dist/components/map/createMapContext.js.map +1 -0
- package/dist/components/map/handler.js +50 -0
- package/dist/components/map/handler.js.map +1 -0
- package/dist/components/map/index.js +316 -0
- package/dist/components/map/index.js.map +1 -0
- package/dist/components/refresher/index.js +5 -5
- package/dist/components/refresher/index.js.map +1 -1
- package/dist/components/scroll-view/index.js +51 -23
- package/dist/components/scroll-view/index.js.map +1 -1
- package/dist/contexts/ScrollElementContext.js +6 -0
- package/dist/contexts/ScrollElementContext.js.map +1 -0
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/original/components/map/MapContext.js +342 -0
- package/dist/original/components/map/MapContext.js.map +1 -0
- package/dist/original/components/map/MapCustomCallout.js +91 -0
- package/dist/original/components/map/MapCustomCallout.js.map +1 -0
- package/dist/original/components/map/common.js +4 -0
- package/dist/original/components/map/common.js.map +1 -0
- package/dist/original/components/map/createMapContext.js +34 -0
- package/dist/original/components/map/createMapContext.js.map +1 -0
- package/dist/original/components/map/handler.js +50 -0
- package/dist/original/components/map/handler.js.map +1 -0
- package/dist/original/components/map/index.js +316 -0
- package/dist/original/components/map/index.js.map +1 -0
- package/dist/original/components/refresher/index.js +5 -5
- package/dist/original/components/refresher/index.js.map +1 -1
- package/dist/original/components/scroll-view/index.js +51 -23
- package/dist/original/components/scroll-view/index.js.map +1 -1
- package/dist/original/contexts/ScrollElementContext.js +6 -0
- package/dist/original/contexts/ScrollElementContext.js.map +1 -0
- package/dist/original/index.js +5 -2
- package/dist/original/index.js.map +1 -1
- package/dist/solid/components/refresher/index.js +5 -5
- package/dist/solid/components/refresher/index.js.map +1 -1
- package/dist/solid/components/scroll-view/index.js +55 -27
- package/dist/solid/components/scroll-view/index.js.map +1 -1
- package/dist/solid/contexts/ScrollElementContext.js +6 -0
- package/dist/solid/contexts/ScrollElementContext.js.map +1 -0
- package/dist/solid/index.js +1 -1
- package/package.json +8 -6
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.js","sources":["../../../../src/components/map/handler.ts"],"sourcesContent":["import { isFunction } from '@tarojs/shared'\n\ntype TCallback<T = Partial<TaroGeneral.CallbackResult>> = (res: T) => Promise<void> | void\ninterface IMethodParam<T = Partial<TaroGeneral.CallbackResult>> {\n name: string\n success?: TCallback<T & TaroGeneral.CallbackResult>\n fail?: TCallback\n complete?: TCallback\n}\ninterface IMockPromise {\n resolve?: typeof Promise.resolve | TFunc\n reject?: typeof Promise.reject | TFunc\n}\n\nexport class MethodHandler<T = Partial<TaroGeneral.CallbackResult>> {\n methodName: string\n\n protected __success?: TCallback<T>\n protected __fail?: TCallback\n protected __complete?: TCallback\n\n protected isHandlerError = false\n\n constructor ({ name, success, fail, complete }: IMethodParam<T>) {\n this.methodName = name\n this.__success = success\n this.__fail = fail\n this.__complete = complete\n\n this.isHandlerError = isFunction(this.__complete) || isFunction(this.__fail)\n }\n\n success<U = Record<string, unknown>> (res: Partial<T> & Partial<TaroGeneral.CallbackResult> = {}, promise: IMockPromise = {}): Promise<T & U & TaroGeneral.CallbackResult> {\n if (!res.errMsg) {\n res.errMsg = `${this.methodName}:ok`\n }\n isFunction(this.__success) && this.__success(res as T)\n isFunction(this.__complete) && this.__complete(res)\n\n const { resolve = Promise.resolve.bind(Promise) } = promise\n return resolve(res as Required<T & U & TaroGeneral.CallbackResult>)\n }\n\n fail<U = Record<string, unknown>> (res: Partial<T> & Partial<TaroGeneral.CallbackResult> = {}, promise: IMockPromise = {}): Promise<T & U & TaroGeneral.CallbackResult> {\n if (!res.errMsg) {\n res.errMsg = `${this.methodName}:fail`\n } else {\n res.errMsg = `${this.methodName}:fail ${res.errMsg}`\n }\n isFunction(this.__fail) && this.__fail(res)\n isFunction(this.__complete) && this.__complete(res)\n\n const {\n resolve = Promise.resolve.bind(Promise),\n reject = Promise.reject.bind(Promise)\n } = promise\n return this.isHandlerError\n ? resolve(res as Required<T & U & TaroGeneral.CallbackResult>)\n : reject(res)\n }\n}\n\ntype TFunc = (...args: any[]) => any\n"],"names":["MethodHandler","constructor","_ref","name","success","fail","complete","isHandlerError","methodName","__success","__fail","__complete","isFunction","res","arguments","length","undefined","promise","errMsg","resolve","Promise","bind","reject"],"mappings":";;MAcaA,aAAa,CAAA;EASxBC,WAAaA,CAAAC,IAAA,EAAkD;IAAA,IAAlD;MAAEC,IAAI;MAAEC,OAAO;MAAEC,IAAI;AAAEC,MAAAA;AAA2B,KAAA,GAAAJ,IAAA;IAFrD,IAAc,CAAAK,cAAA,GAAG,KAAK;IAG9B,IAAI,CAACC,UAAU,GAAGL,IAAI;IACtB,IAAI,CAACM,SAAS,GAAGL,OAAO;IACxB,IAAI,CAACM,MAAM,GAAGL,IAAI;IAClB,IAAI,CAACM,UAAU,GAAGL,QAAQ;AAE1B,IAAA,IAAI,CAACC,cAAc,GAAGK,UAAU,CAAC,IAAI,CAACD,UAAU,CAAC,IAAIC,UAAU,CAAC,IAAI,CAACF,MAAM,CAAC;AAC9E;AAEAN,EAAAA,OAAOA,GAAqH;AAAA,IAAA,IAAtFS,GAAA,GAAAC,SAAA,CAAAC,MAAA,GAAA,CAAA,IAAAD,SAAA,CAAA,CAAA,CAAA,KAAAE,SAAA,GAAAF,SAAA,CAAA,CAAA,CAAA,GAAwD,EAAE;AAAA,IAAA,IAAEG,8EAAwB,EAAE;AAC1H,IAAA,IAAI,CAACJ,GAAG,CAACK,MAAM,EAAE;AACfL,MAAAA,GAAG,CAACK,MAAM,GAAG,GAAG,IAAI,CAACV,UAAU,CAAK,GAAA,CAAA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DS,MAAM,CAACT,GAAG,CAAC;AACjB;AACD;;;;"}
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import React__default, { useState, useEffect, Children } from 'react';
|
|
2
|
+
import { TMap, MultiMarker, MultiPolyline } from 'tlbs-map-react';
|
|
3
|
+
import { createForwardRefComponent } from '../../utils/index.js';
|
|
4
|
+
import { logPrefix } from './common.js';
|
|
5
|
+
import { registerMapInstance, unregisterMapInstance } from './MapContext.js';
|
|
6
|
+
import MapCustomCallout from './MapCustomCallout.js';
|
|
7
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
8
|
+
export { createMapContext } from './createMapContext.js';
|
|
9
|
+
|
|
10
|
+
/* eslint-disable no-console */
|
|
11
|
+
function Map(props) {
|
|
12
|
+
const {
|
|
13
|
+
forwardedRef,
|
|
14
|
+
id,
|
|
15
|
+
className,
|
|
16
|
+
style,
|
|
17
|
+
authKey,
|
|
18
|
+
longitude,
|
|
19
|
+
latitude,
|
|
20
|
+
scale,
|
|
21
|
+
minScale,
|
|
22
|
+
maxScale,
|
|
23
|
+
enableRotate,
|
|
24
|
+
markers,
|
|
25
|
+
polyline,
|
|
26
|
+
onTap,
|
|
27
|
+
onAuthSuccess,
|
|
28
|
+
onError
|
|
29
|
+
} = props;
|
|
30
|
+
// eslint-disable-next-line no-console
|
|
31
|
+
console.log(logPrefix, 'props', props);
|
|
32
|
+
/** ************************处理 style********************** */
|
|
33
|
+
const styleObj = typeof style === 'string' || style === undefined ? {} : style;
|
|
34
|
+
/** ************************处理 marker********************** */
|
|
35
|
+
const normalizedMarkers = markers !== null && markers !== void 0 ? markers : [];
|
|
36
|
+
const markerStyles = {};
|
|
37
|
+
const markerGeometries = [];
|
|
38
|
+
normalizedMarkers.forEach((m, index) => {
|
|
39
|
+
var _a;
|
|
40
|
+
const markerId = String((_a = m.id) !== null && _a !== void 0 ? _a : index);
|
|
41
|
+
const styleId = `marker-${markerId}`;
|
|
42
|
+
// Taro: iconPath (string);tlbs-map-react: styles 中指定图标
|
|
43
|
+
// Taro: width, height (number|string);tlbs-map-react: width, height
|
|
44
|
+
// Taro: rotate (number);tlbs-map-react: rotation
|
|
45
|
+
// Taro: alpha (number 0-1);tlbs-map-react: opacity (0-1)
|
|
46
|
+
// Taro: zIndex (number);tlbs-map-react: zIndex
|
|
47
|
+
// 解析宽高,支持数字和字符串(如 '20px')
|
|
48
|
+
const parseSize = size => {
|
|
49
|
+
if (typeof size === 'number') return size;
|
|
50
|
+
if (typeof size === 'string') {
|
|
51
|
+
const parsed = parseInt(size, 10);
|
|
52
|
+
return isNaN(parsed) ? 20 : parsed;
|
|
53
|
+
}
|
|
54
|
+
return 20; // 默认宽度
|
|
55
|
+
};
|
|
56
|
+
const markerWidth = parseSize(m.width);
|
|
57
|
+
const markerHeight = parseSize(m.height);
|
|
58
|
+
markerStyles[styleId] = Object.assign(Object.assign(Object.assign(Object.assign({
|
|
59
|
+
width: markerWidth,
|
|
60
|
+
height: markerHeight,
|
|
61
|
+
anchor: {
|
|
62
|
+
x: markerWidth / 2,
|
|
63
|
+
y: markerHeight
|
|
64
|
+
}
|
|
65
|
+
}, m.iconPath && {
|
|
66
|
+
src: m.iconPath
|
|
67
|
+
}), typeof m.rotate === 'number' && {
|
|
68
|
+
rotation: m.rotate
|
|
69
|
+
}), typeof m.alpha === 'number' && {
|
|
70
|
+
opacity: m.alpha
|
|
71
|
+
}), typeof m.zIndex === 'number' && {
|
|
72
|
+
zIndex: m.zIndex
|
|
73
|
+
});
|
|
74
|
+
markerGeometries.push({
|
|
75
|
+
id: markerId,
|
|
76
|
+
styleId,
|
|
77
|
+
position: {
|
|
78
|
+
lat: m.latitude,
|
|
79
|
+
lng: m.longitude
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
/** ************************处理 polyline********************** */
|
|
84
|
+
const normalizedPolylines = polyline !== null && polyline !== void 0 ? polyline : [];
|
|
85
|
+
const polylineStyles = {};
|
|
86
|
+
const polylineGeometries = [];
|
|
87
|
+
normalizedPolylines.forEach((line, lineIndex) => {
|
|
88
|
+
var _a;
|
|
89
|
+
if (!line.points || line.points.length === 0) return;
|
|
90
|
+
const styleId = `polyline-${lineIndex}`;
|
|
91
|
+
// Taro: color (hex);腾讯地图: color
|
|
92
|
+
// Taro: width (number);腾讯地图: width
|
|
93
|
+
// Taro: dottedLine (boolean);腾讯地图: dashArray ([10,10]虚线, [0,0]实线)
|
|
94
|
+
polylineStyles[styleId] = {
|
|
95
|
+
color: line.color || '#3777FF',
|
|
96
|
+
width: (_a = line.width) !== null && _a !== void 0 ? _a : 3,
|
|
97
|
+
// 虚线:[10, 10] 表示10像素实线 + 10像素空白;实线:[0, 0]
|
|
98
|
+
dashArray: line.dottedLine ? [10, 10] : [0, 0]
|
|
99
|
+
};
|
|
100
|
+
// Taro: points 是 {latitude, longitude}[] 数组
|
|
101
|
+
// tlbs-map-react: geometries 需要路径点数组
|
|
102
|
+
polylineGeometries.push({
|
|
103
|
+
id: String(lineIndex),
|
|
104
|
+
styleId,
|
|
105
|
+
paths: line.points.map(point => ({
|
|
106
|
+
lat: point.latitude,
|
|
107
|
+
lng: point.longitude
|
|
108
|
+
}))
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
/** ************************适配options参数********************** */
|
|
112
|
+
const hasCenter = typeof latitude === 'number' && typeof longitude === 'number';
|
|
113
|
+
const mergedOptions = Object.assign(Object.assign({}, hasCenter ? {
|
|
114
|
+
center: {
|
|
115
|
+
lat: latitude,
|
|
116
|
+
lng: longitude
|
|
117
|
+
}
|
|
118
|
+
} : {}), {
|
|
119
|
+
zoom: scale !== null && scale !== void 0 ? scale : 13,
|
|
120
|
+
minZoom: minScale !== null && minScale !== void 0 ? minScale : 3,
|
|
121
|
+
maxZoom: maxScale !== null && maxScale !== void 0 ? maxScale : 20,
|
|
122
|
+
rotatable: enableRotate !== null && enableRotate !== void 0 ? enableRotate : false
|
|
123
|
+
});
|
|
124
|
+
/** ************************处理事件********************** */
|
|
125
|
+
// Taro: onTap;腾讯地图: click
|
|
126
|
+
// 腾讯地图事件返回: MapEvent { latLng: LatLng, point: {x, y}, type, target, originalEvent }
|
|
127
|
+
// Taro 事件格式: BaseEventOrig { type, timeStamp, target, currentTarget, detail, ... }
|
|
128
|
+
const handleMapClick = e => {
|
|
129
|
+
console.log(logPrefix, 'source click e:', e);
|
|
130
|
+
if (typeof onTap === 'function') {
|
|
131
|
+
onTap({
|
|
132
|
+
type: e.type,
|
|
133
|
+
timeStamp: Date.now(),
|
|
134
|
+
target: {
|
|
135
|
+
id: id || '',
|
|
136
|
+
tagName: 'map',
|
|
137
|
+
dataset: {}
|
|
138
|
+
},
|
|
139
|
+
currentTarget: {
|
|
140
|
+
id: id || '',
|
|
141
|
+
tagName: 'map',
|
|
142
|
+
dataset: {}
|
|
143
|
+
},
|
|
144
|
+
detail: {
|
|
145
|
+
latitude: e.latLng.lat,
|
|
146
|
+
longitude: e.latLng.lng
|
|
147
|
+
},
|
|
148
|
+
preventDefault: () => {},
|
|
149
|
+
stopPropagation: () => {}
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
// 存储地图实例,用于 H5 端自定义气泡
|
|
154
|
+
const [mapInstance, setMapInstance] = useState(null);
|
|
155
|
+
// 地图初始化成功
|
|
156
|
+
const handleMapInited = instance => {
|
|
157
|
+
console.log(logPrefix, '地图初始化成功', instance);
|
|
158
|
+
setMapInstance(instance);
|
|
159
|
+
// 注册地图实例到全局存储
|
|
160
|
+
if (id) {
|
|
161
|
+
registerMapInstance(id, instance);
|
|
162
|
+
console.log(logPrefix, '已注册地图实例到 MapContext, id:', id);
|
|
163
|
+
}
|
|
164
|
+
let settled = false;
|
|
165
|
+
instance.on('tilesloaded', _res => {
|
|
166
|
+
// TODO: 临时先这么简单处理鉴权成功
|
|
167
|
+
if (!settled && typeof onAuthSuccess === 'function') {
|
|
168
|
+
settled = true;
|
|
169
|
+
onAuthSuccess({
|
|
170
|
+
type: 'authsuccess',
|
|
171
|
+
timeStamp: Date.now(),
|
|
172
|
+
target: {
|
|
173
|
+
id: id || '',
|
|
174
|
+
tagName: 'map',
|
|
175
|
+
dataset: {}
|
|
176
|
+
},
|
|
177
|
+
currentTarget: {
|
|
178
|
+
id: id || '',
|
|
179
|
+
tagName: 'map',
|
|
180
|
+
dataset: {}
|
|
181
|
+
},
|
|
182
|
+
detail: {
|
|
183
|
+
errCode: 0,
|
|
184
|
+
errMsg: 'ok'
|
|
185
|
+
},
|
|
186
|
+
preventDefault: () => {},
|
|
187
|
+
stopPropagation: () => {}
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
setTimeout(() => {
|
|
192
|
+
if (!settled && typeof onError === 'function') {
|
|
193
|
+
settled = true;
|
|
194
|
+
onError({
|
|
195
|
+
type: 'error',
|
|
196
|
+
timeStamp: Date.now(),
|
|
197
|
+
target: {
|
|
198
|
+
id: id || '',
|
|
199
|
+
tagName: 'map',
|
|
200
|
+
dataset: {}
|
|
201
|
+
},
|
|
202
|
+
currentTarget: {
|
|
203
|
+
id: id || '',
|
|
204
|
+
tagName: 'map',
|
|
205
|
+
dataset: {}
|
|
206
|
+
},
|
|
207
|
+
detail: {
|
|
208
|
+
errCode: 1001,
|
|
209
|
+
errMsg: 'timeout'
|
|
210
|
+
},
|
|
211
|
+
preventDefault: () => {},
|
|
212
|
+
stopPropagation: () => {}
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
}, 3000);
|
|
216
|
+
};
|
|
217
|
+
// 组件卸载时清理地图实例
|
|
218
|
+
useEffect(() => {
|
|
219
|
+
return () => {
|
|
220
|
+
if (id) {
|
|
221
|
+
unregisterMapInstance(id);
|
|
222
|
+
console.log(logPrefix, '已注销地图实例, id:', id);
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
}, [id]);
|
|
226
|
+
return /*#__PURE__*/jsxs(TMap, {
|
|
227
|
+
id: id,
|
|
228
|
+
ref: forwardedRef,
|
|
229
|
+
className: className,
|
|
230
|
+
style: styleObj,
|
|
231
|
+
apiKey: authKey !== null && authKey !== void 0 ? authKey : '',
|
|
232
|
+
options: mergedOptions,
|
|
233
|
+
onClick: handleMapClick,
|
|
234
|
+
onMapInited: handleMapInited,
|
|
235
|
+
children: [normalizedMarkers.length > 0 ? /*#__PURE__*/jsx(MultiMarker, {
|
|
236
|
+
id: "taro-markers",
|
|
237
|
+
styles: markerStyles,
|
|
238
|
+
geometries: markerGeometries
|
|
239
|
+
}) : null, polylineGeometries.length > 0 ? /*#__PURE__*/jsx(MultiPolyline, {
|
|
240
|
+
id: "taro-polylines",
|
|
241
|
+
styles: polylineStyles,
|
|
242
|
+
geometries: polylineGeometries
|
|
243
|
+
}) : null, process.env.TARO_ENV === 'h5' ? renderH5CustomCallouts() : props.children]
|
|
244
|
+
});
|
|
245
|
+
/**
|
|
246
|
+
* H5 端渲染自定义气泡
|
|
247
|
+
* 拦截 slot="callout" 的 CoverView,转换为自定义 Overlay
|
|
248
|
+
*/
|
|
249
|
+
function renderH5CustomCallouts() {
|
|
250
|
+
if (!mapInstance) return null;
|
|
251
|
+
// 1. 遍历 props.children,找到 slot="callout" 的 CoverView
|
|
252
|
+
const childrenArray = Children.toArray(props.children);
|
|
253
|
+
const calloutSlot = childrenArray.find(child => {
|
|
254
|
+
var _a;
|
|
255
|
+
return /*#__PURE__*/React__default.isValidElement(child) && ((_a = child.props) === null || _a === void 0 ? void 0 : _a.slot) === 'callout';
|
|
256
|
+
});
|
|
257
|
+
if (!calloutSlot || ! /*#__PURE__*/React__default.isValidElement(calloutSlot)) {
|
|
258
|
+
return null;
|
|
259
|
+
}
|
|
260
|
+
// 2. 遍历内层的 CoverView,提取 markerId 和内容
|
|
261
|
+
const innerCoverViews = Children.toArray(calloutSlot.props.children);
|
|
262
|
+
return innerCoverViews.map(child => {
|
|
263
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
264
|
+
if (! /*#__PURE__*/React__default.isValidElement(child)) return null;
|
|
265
|
+
const markerId = (_a = child.props) === null || _a === void 0 ? void 0 : _a.markerId;
|
|
266
|
+
if (!markerId) return null;
|
|
267
|
+
// 3. 找到对应的 marker 信息
|
|
268
|
+
const marker = normalizedMarkers.find(m => m.id === markerId);
|
|
269
|
+
if (!marker) {
|
|
270
|
+
console.warn(logPrefix, `未找到 markerId=${markerId} 对应的 marker`);
|
|
271
|
+
return null;
|
|
272
|
+
}
|
|
273
|
+
// 4. 渲染自定义气泡
|
|
274
|
+
return /*#__PURE__*/jsx(MapCustomCallout, {
|
|
275
|
+
map: mapInstance,
|
|
276
|
+
markerId: markerId,
|
|
277
|
+
position: {
|
|
278
|
+
lat: marker.latitude,
|
|
279
|
+
lng: marker.longitude
|
|
280
|
+
},
|
|
281
|
+
anchorX: (_c = (_b = marker.customCallout) === null || _b === void 0 ? void 0 : _b.anchorX) !== null && _c !== void 0 ? _c : 0,
|
|
282
|
+
anchorY: (_e = (_d = marker.customCallout) === null || _d === void 0 ? void 0 : _d.anchorY) !== null && _e !== void 0 ? _e : 0,
|
|
283
|
+
display: (_g = (_f = marker.customCallout) === null || _f === void 0 ? void 0 : _f.display) !== null && _g !== void 0 ? _g : 'ALWAYS',
|
|
284
|
+
onCalloutTap: id => {
|
|
285
|
+
// 触发 onCalloutTap 事件
|
|
286
|
+
if (typeof props.onCalloutTap === 'function') {
|
|
287
|
+
props.onCalloutTap({
|
|
288
|
+
type: 'callouttap',
|
|
289
|
+
timeStamp: Date.now(),
|
|
290
|
+
target: {
|
|
291
|
+
id: id || '',
|
|
292
|
+
tagName: 'callout',
|
|
293
|
+
dataset: {}
|
|
294
|
+
},
|
|
295
|
+
currentTarget: {
|
|
296
|
+
id: id || '',
|
|
297
|
+
tagName: 'callout',
|
|
298
|
+
dataset: {}
|
|
299
|
+
},
|
|
300
|
+
detail: {
|
|
301
|
+
markerId: id
|
|
302
|
+
},
|
|
303
|
+
preventDefault: () => {},
|
|
304
|
+
stopPropagation: () => {}
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
},
|
|
308
|
+
children: child.props.children
|
|
309
|
+
}, markerId);
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
var index = createForwardRefComponent(Map);
|
|
314
|
+
|
|
315
|
+
export { index as default };
|
|
316
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/map/index.tsx"],"sourcesContent":["/* eslint-disable no-console */\nimport React, { Children, useEffect, useState } from 'react'\nimport { MultiMarker, MultiPolyline, TMap } from 'tlbs-map-react'\n\nimport { createForwardRefComponent } from '../../utils'\nimport { logPrefix } from './common'\nimport { registerMapInstance, unregisterMapInstance } from './MapContext'\nimport MapCustomCallout from './MapCustomCallout'\n\nimport type { MapProps as TaroMapProps } from '@tarojs/components'\nimport type MapTypes from 'tmap-gl-types'\n\nexport interface MapProps extends Omit<TaroMapProps, 'onError'> {\n forwardedRef?: React.MutableRefObject<any>\n authKey?: string\n onError?: (e: any) => void\n}\n\nfunction Map (props: MapProps) {\n const {\n forwardedRef,\n id,\n className,\n style,\n authKey,\n longitude,\n latitude,\n scale,\n minScale,\n maxScale,\n enableRotate,\n markers,\n polyline,\n onTap,\n onAuthSuccess,\n onError,\n } = props\n // eslint-disable-next-line no-console\n console.log(logPrefix, 'props', props)\n\n /** ************************处理 style********************** */\n const styleObj = typeof style === 'string' || style === undefined ? {} : (style as Record<string, string>)\n\n /** ************************处理 marker********************** */\n const normalizedMarkers = markers ?? []\n const markerStyles: Record<string, any> = {}\n const markerGeometries: any[] = []\n\n normalizedMarkers.forEach((m, index) => {\n const markerId = String(m.id ?? index)\n const styleId = `marker-${markerId}`\n\n // Taro: iconPath (string);tlbs-map-react: styles 中指定图标\n // Taro: width, height (number|string);tlbs-map-react: width, height\n // Taro: rotate (number);tlbs-map-react: rotation\n // Taro: alpha (number 0-1);tlbs-map-react: opacity (0-1)\n // Taro: zIndex (number);tlbs-map-react: zIndex\n\n // 解析宽高,支持数字和字符串(如 '20px')\n const parseSize = (size: number | string | undefined): number => {\n if (typeof size === 'number') return size\n if (typeof size === 'string') {\n const parsed = parseInt(size, 10)\n return isNaN(parsed) ? 20 : parsed\n }\n return 20 // 默认宽度\n }\n\n const markerWidth = parseSize(m.width)\n const markerHeight = parseSize(m.height)\n\n markerStyles[styleId] = {\n width: markerWidth,\n height: markerHeight,\n anchor: { x: markerWidth / 2, y: markerHeight }, // 默认底部中心为锚点\n ...(m.iconPath && { src: m.iconPath }),\n ...(typeof m.rotate === 'number' && { rotation: m.rotate }),\n ...(typeof m.alpha === 'number' && { opacity: m.alpha }),\n ...(typeof m.zIndex === 'number' && { zIndex: m.zIndex }),\n }\n\n markerGeometries.push({\n id: markerId,\n styleId,\n position: { lat: m.latitude, lng: m.longitude },\n })\n })\n\n /** ************************处理 polyline********************** */\n const normalizedPolylines = polyline ?? []\n const polylineStyles: Record<string, any> = {}\n const polylineGeometries: any[] = []\n\n normalizedPolylines.forEach((line, lineIndex) => {\n if (!line.points || line.points.length === 0) return\n\n const styleId = `polyline-${lineIndex}`\n\n // Taro: color (hex);腾讯地图: color\n // Taro: width (number);腾讯地图: width\n // Taro: dottedLine (boolean);腾讯地图: dashArray ([10,10]虚线, [0,0]实线)\n polylineStyles[styleId] = {\n color: line.color || '#3777FF',\n width: line.width ?? 3,\n // 虚线:[10, 10] 表示10像素实线 + 10像素空白;实线:[0, 0]\n dashArray: line.dottedLine ? [10, 10] : [0, 0],\n }\n\n // Taro: points 是 {latitude, longitude}[] 数组\n // tlbs-map-react: geometries 需要路径点数组\n polylineGeometries.push({\n id: String(lineIndex),\n styleId,\n paths: line.points.map((point) => ({\n lat: point.latitude,\n lng: point.longitude,\n })),\n })\n })\n\n /** ************************适配options参数********************** */\n const hasCenter = typeof latitude === 'number' && typeof longitude === 'number'\n const mergedOptions = {\n ...(hasCenter ? { center: { lat: latitude, lng: longitude } } : {}),\n zoom: scale ?? 13,\n minZoom: minScale ?? 3,\n maxZoom: maxScale ?? 20,\n rotatable: enableRotate ?? false, // Taro: enableRotate;tlbs-map-react: options.rotatable\n }\n\n /** ************************处理事件********************** */\n // Taro: onTap;腾讯地图: click\n // 腾讯地图事件返回: MapEvent { latLng: LatLng, point: {x, y}, type, target, originalEvent }\n // Taro 事件格式: BaseEventOrig { type, timeStamp, target, currentTarget, detail, ... }\n const handleMapClick = (e: MapTypes.MapEvent) => {\n console.log(logPrefix, 'source click e:', e)\n if (typeof onTap === 'function') {\n onTap({\n type: e.type,\n timeStamp: Date.now(),\n target: {\n id: id || '',\n tagName: 'map',\n dataset: {},\n },\n currentTarget: {\n id: id || '',\n tagName: 'map',\n dataset: {},\n },\n detail: {\n latitude: e.latLng.lat,\n longitude: e.latLng.lng,\n },\n preventDefault: () => {},\n stopPropagation: () => {},\n })\n }\n }\n\n // 存储地图实例,用于 H5 端自定义气泡\n const [mapInstance, setMapInstance] = useState<MapTypes.Map | null>(null)\n\n // 地图初始化成功\n const handleMapInited = (instance: MapTypes.Map) => {\n console.log(logPrefix, '地图初始化成功', instance)\n setMapInstance(instance)\n\n // 注册地图实例到全局存储\n if (id) {\n registerMapInstance(id, instance)\n console.log(logPrefix, '已注册地图实例到 MapContext, id:', id)\n }\n\n let settled = false\n instance.on('tilesloaded', (_res) => { /** 瓦片加载完成,地图真正可用 */\n // TODO: 临时先这么简单处理鉴权成功\n if (!settled && typeof onAuthSuccess === 'function') {\n settled = true\n onAuthSuccess({\n type: 'authsuccess',\n timeStamp: Date.now(),\n target: {\n id: id || '',\n tagName: 'map',\n dataset: {},\n },\n currentTarget: {\n id: id || '',\n tagName: 'map',\n dataset: {},\n },\n detail: {\n errCode: 0,\n errMsg: 'ok',\n },\n preventDefault: () => {},\n stopPropagation: () => {},\n })\n }\n })\n setTimeout(() => {\n if (!settled && typeof onError === 'function') {\n settled = true\n onError({\n type: 'error',\n timeStamp: Date.now(),\n target: {\n id: id || '',\n tagName: 'map',\n dataset: {},\n },\n currentTarget: {\n id: id || '',\n tagName: 'map',\n dataset: {},\n },\n detail: {\n errCode: 1001,\n errMsg: 'timeout',\n },\n preventDefault: () => {},\n stopPropagation: () => {},\n })\n }\n }, 3000)\n }\n\n // 组件卸载时清理地图实例\n useEffect(() => {\n return () => {\n if (id) {\n unregisterMapInstance(id)\n console.log(logPrefix, '已注销地图实例, id:', id)\n }\n }\n }, [id])\n\n return (\n <TMap\n id={id}\n ref={forwardedRef}\n className={className}\n style={styleObj}\n apiKey={authKey ?? ''}\n options={mergedOptions}\n onClick={handleMapClick}\n onMapInited={handleMapInited}\n >\n {normalizedMarkers.length > 0 ? (\n <MultiMarker id=\"taro-markers\" styles={markerStyles} geometries={markerGeometries} />\n ) : null}\n {polylineGeometries.length > 0 ? (\n <MultiPolyline id=\"taro-polylines\" styles={polylineStyles} geometries={polylineGeometries} />\n ) : null}\n\n {/* H5 端:自动处理 slot=\"callout\" 的 CoverView */}\n {process.env.TARO_ENV === 'h5' ? renderH5CustomCallouts() : props.children}\n </TMap>\n )\n\n /**\n * H5 端渲染自定义气泡\n * 拦截 slot=\"callout\" 的 CoverView,转换为自定义 Overlay\n */\n function renderH5CustomCallouts() {\n if (!mapInstance) return null\n\n // 1. 遍历 props.children,找到 slot=\"callout\" 的 CoverView\n const childrenArray = Children.toArray(props.children)\n const calloutSlot = childrenArray.find((child: any) =>\n React.isValidElement(child) && child.props?.slot === 'callout'\n )\n\n if (!calloutSlot || !React.isValidElement(calloutSlot)) {\n return null\n }\n\n // 2. 遍历内层的 CoverView,提取 markerId 和内容\n const innerCoverViews = Children.toArray(calloutSlot.props.children)\n\n return innerCoverViews.map((child: any) => {\n if (!React.isValidElement(child)) return null\n\n const markerId = child.props?.markerId\n if (!markerId) return null\n\n // 3. 找到对应的 marker 信息\n const marker = normalizedMarkers.find((m: any) => m.id === markerId)\n if (!marker) {\n console.warn(logPrefix, `未找到 markerId=${markerId} 对应的 marker`)\n return null\n }\n\n // 4. 渲染自定义气泡\n return (\n <MapCustomCallout\n key={markerId}\n map={mapInstance}\n markerId={markerId}\n position={{ lat: marker.latitude, lng: marker.longitude }}\n anchorX={marker.customCallout?.anchorX ?? 0}\n anchorY={marker.customCallout?.anchorY ?? 0}\n display={marker.customCallout?.display ?? 'ALWAYS'}\n onCalloutTap={(id) => {\n // 触发 onCalloutTap 事件\n if (typeof props.onCalloutTap === 'function') {\n props.onCalloutTap({\n type: 'callouttap',\n timeStamp: Date.now(),\n target: {\n id: id || '',\n tagName: 'callout',\n dataset: {},\n },\n currentTarget: {\n id: id || '',\n tagName: 'callout',\n dataset: {},\n },\n detail: { markerId: id },\n preventDefault: () => {},\n stopPropagation: () => {},\n })\n }\n }}\n >\n {child.props.children}\n </MapCustomCallout>\n )\n })\n }\n}\n\nexport default createForwardRefComponent(Map)\n\n/**\n * @deprecated 请使用 Taro.createMapContext 代替\n *\n * 此导出仅用于向后兼容,将在未来版本中移除。\n *\n * 推荐用法:\n * ```tsx\n * import Taro from '@tarojs/taro'\n *\n * const mapCtx = Taro.createMapContext('mapId')\n * ```\n */\nexport { createMapContext } from './createMapContext'\n"],"names":["Map","props","forwardedRef","id","className","style","authKey","longitude","latitude","scale","minScale","maxScale","enableRotate","markers","polyline","onTap","onAuthSuccess","onError","console","log","logPrefix","styleObj","undefined","normalizedMarkers","markerStyles","markerGeometries","forEach","m","index","markerId","String","_a","styleId","parseSize","size","parsed","parseInt","isNaN","markerWidth","width","markerHeight","height","anchor","x","y","iconPath","src","rotate","rotation","alpha","opacity","zIndex","push","position","lat","lng","normalizedPolylines","polylineStyles","polylineGeometries","line","lineIndex","points","length","color","dashArray","dottedLine","paths","map","point","hasCenter","mergedOptions","Object","assign","center","zoom","minZoom","maxZoom","rotatable","handleMapClick","e","type","timeStamp","Date","now","target","tagName","dataset","currentTarget","detail","latLng","preventDefault","stopPropagation","mapInstance","setMapInstance","useState","handleMapInited","instance","registerMapInstance","settled","on","_res","errCode","errMsg","setTimeout","useEffect","unregisterMapInstance","_jsxs","TMap","ref","apiKey","options","onClick","onMapInited","children","_jsx","MultiMarker","styles","geometries","MultiPolyline","process","env","TARO_ENV","renderH5CustomCallouts","childrenArray","Children","toArray","calloutSlot","find","child","React","isValidElement","slot","innerCoverViews","marker","warn","MapCustomCallout","anchorX","_c","_b","customCallout","anchorY","_e","_d","display","_g","_f","onCalloutTap","createForwardRefComponent"],"mappings":";;;;;;;;;AAAA;AAkBA,SAASA,GAAGA,CAAEC,KAAe,EAAA;EAC3B,MAAM;IACJC,YAAY;IACZC,EAAE;IACFC,SAAS;IACTC,KAAK;IACLC,OAAO;IACPC,SAAS;IACTC,QAAQ;IACRC,KAAK;IACLC,QAAQ;IACRC,QAAQ;IACRC,YAAY;IACZC,OAAO;IACPC,QAAQ;IACRC,KAAK;IACLC,aAAa;AACbC,IAAAA;AACD,GAAA,GAAGhB,KAAK;AACT;EACAiB,OAAO,CAACC,GAAG,CAACC,SAAS,EAAE,OAAO,EAAEnB,KAAK,CAAC;AAEtC;AACA,EAAA,MAAMoB,QAAQ,GAAG,OAAOhB,KAAK,KAAK,QAAQ,IAAIA,KAAK,KAAKiB,SAAS,GAAG,EAAE,GAAIjB,KAAgC;AAE1G;AACA,EAAA,MAAMkB,iBAAiB,GAAGV,OAAO,KAAA,IAAA,IAAPA,OAAO,KAAP,KAAA,CAAA,GAAAA,OAAO,GAAI,EAAE;EACvC,MAAMW,YAAY,GAAwB,EAAE;EAC5C,MAAMC,gBAAgB,GAAU,EAAE;AAElCF,EAAAA,iBAAiB,CAACG,OAAO,CAAC,CAACC,CAAC,EAAEC,KAAK,KAAI;;IACrC,MAAMC,QAAQ,GAAGC,MAAM,CAAC,CAAAC,EAAA,GAAAJ,CAAC,CAACxB,EAAE,MAAA,IAAA,IAAA4B,EAAA,KAAA,KAAA,CAAA,GAAAA,EAAA,GAAIH,KAAK,CAAC;AACtC,IAAA,MAAMI,OAAO,GAAG,CAAUH,OAAAA,EAAAA,QAAQ,CAAE,CAAA;AAEpC;AACA;AACA;AACA;AACA;AAEA;IACA,M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QA+BW,CAAC;AAEvB,KAAC,CAAC;AACJ;AACF;AAEA,YAAesH,yBAAyB,CAACnJ,GAAG,CAAC;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
const Refresher = () => {
|
|
2
|
+
return null;
|
|
3
|
+
};
|
|
4
|
+
Refresher.displayName = 'Refresher';
|
|
2
5
|
|
|
3
|
-
|
|
4
|
-
const Refresher = View;
|
|
5
|
-
|
|
6
|
-
export { Refresher as default };
|
|
6
|
+
export { Refresher, Refresher as default };
|
|
7
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/refresher/index.
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/refresher/index.tsx"],"sourcesContent":["import React from 'react'\n\n/**\n * Refresher 组件 - 下拉刷新(标记组件)\n *\n * 以各平台 ScrollView 的 refresher 落地为准:\n * - weapp/jd/tt: ScrollView.refresher-enabled / bindRefresherPulling 等\n * - 本组件为标记组件,不渲染 DOM,仅向 List 等传配置;实际下拉逻辑由 List/ScrollView 内 useRefresher 或原生 refresher 处理。\n *\n * 高度规则:\n * - 无 children:使用默认 50px 高度\n * - 有 children:由 children 内容撑开高度\n *\n * children:用于替换「加载楼层」中间的显示内容;不传则使用默认文案(下拉刷新/释放刷新/加载中...)。\n * 小程序自定义需配合 refresherDefaultStyle=\"none\"。\n *\n * @example 使用默认文案(50px 高度)\n * <Refresher refresherEnabled refresherThreshold={50} onRefresherRefresh={fetchData} />\n *\n * @example 自定义内容(由内容撑开高度)\n * <Refresher refresherEnabled refresherDefaultStyle=\"none\" onRefresherRefresh={fetchData}>\n * <View style={{ height: 60, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>\n * <Text>下拉刷新</Text>\n * </View>\n * </Refresher>\n */\n\n/** 与 ScrollView.d.ts 的 refresher 相关属性、事件对齐 */\nexport interface RefresherProps {\n refresherEnabled?: boolean\n refresherThreshold?: number\n refresherDefaultStyle?: 'black' | 'white' | 'none'\n refresherBackground?: string\n refresherTriggered?: boolean\n /** 自定义刷新内容(替换默认「下拉刷新/释放刷新/加载中...」文案) */\n children?: React.ReactNode\n onRefresherPulling?: (e?: { detail?: { deltaY?: number } }) => void\n onRefresherRefresh?: () => void | Promise<void>\n onRefresherRestore?: () => void\n onRefresherAbort?: () => void\n onRefresherWillRefresh?: () => void\n onRefresherStatusChange?: (e?: { detail?: { status?: number, dy?: number } }) => void\n}\n\nconst Refresher: React.FC<RefresherProps> = () => {\n return null\n}\n\nRefresher.displayName = 'Refresher'\n\nexport { Refresher }\nexport default Refresher\n"],"names":["Refresher","displayName"],"mappings":"AA4CMA,MAAAA,SAAS,GAA6BA,MAAK;AAC/C,EAAA,OAAO,IAAI;AACb;AAEAA,SAAS,CAACC,WAAW,GAAG,WAAW;;;;"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import './style/index.scss';
|
|
2
2
|
import { isFunction } from '@tarojs/shared';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
|
+
import { ScrollElementContext } from '../../contexts/ScrollElementContext.js';
|
|
4
5
|
import { throttle, createForwardRefComponent } from '../../utils/index.js';
|
|
5
|
-
import { useRef, useEffect } from '../../utils/hooks.react.js';
|
|
6
|
+
import { useRef, useState, useEffect } from '../../utils/hooks.react.js';
|
|
6
7
|
import { jsx } from 'react/jsx-runtime';
|
|
7
8
|
|
|
8
9
|
function easeOutScroll() {
|
|
@@ -30,16 +31,18 @@ function easeOutScroll() {
|
|
|
30
31
|
}
|
|
31
32
|
step();
|
|
32
33
|
}
|
|
34
|
+
/** 未开启的滚动轴使用 nearest 避免原生 scrollIntoView 沿该轴滚动整页 */
|
|
33
35
|
function scrollIntoView() {
|
|
34
36
|
let id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
35
|
-
let
|
|
36
|
-
let
|
|
37
|
-
let
|
|
37
|
+
let animated = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
38
|
+
let scrollX = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
39
|
+
let scrollY = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
40
|
+
let scrollIntoViewAlignment = arguments.length > 4 ? arguments[4] : undefined;
|
|
38
41
|
var _a;
|
|
39
42
|
(_a = document.querySelector(`#${id}`)) === null || _a === void 0 ? void 0 : _a.scrollIntoView({
|
|
40
43
|
behavior: animated ? 'smooth' : 'auto',
|
|
41
|
-
block:
|
|
42
|
-
inline:
|
|
44
|
+
block: scrollY ? scrollIntoViewAlignment || 'center' : 'nearest',
|
|
45
|
+
inline: scrollX ? scrollIntoViewAlignment || 'start' : 'nearest'
|
|
43
46
|
});
|
|
44
47
|
}
|
|
45
48
|
function scrollVertical(container, scrollTop, top, isAnimation) {
|
|
@@ -63,12 +66,14 @@ function scrollHorizontal(container, scrollLeft, left, isAnimation) {
|
|
|
63
66
|
scrollLeft.current = left;
|
|
64
67
|
}
|
|
65
68
|
function ScrollView(props) {
|
|
69
|
+
var _a;
|
|
66
70
|
const _scrollTop = useRef(null);
|
|
67
71
|
const _scrollLeft = useRef(null);
|
|
68
72
|
const container = useRef(null);
|
|
69
73
|
const scrollEndTimerRef = useRef(null);
|
|
70
74
|
const isScrollingRef = useRef(false);
|
|
71
75
|
const isInitializedRef = useRef(false);
|
|
76
|
+
const [containerHeight, setContainerHeight] = useState(0);
|
|
72
77
|
const onTouchMove = e => {
|
|
73
78
|
e.stopPropagation();
|
|
74
79
|
};
|
|
@@ -76,11 +81,10 @@ function ScrollView(props) {
|
|
|
76
81
|
let isInit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
77
82
|
// scrollIntoView
|
|
78
83
|
if (props.scrollIntoView && typeof props.scrollIntoView === 'string' && document && document.querySelector && document.querySelector(`#${props.scrollIntoView}`)) {
|
|
79
|
-
const isHorizontal = props.scrollX && !props.scrollY;
|
|
80
84
|
if (isInit) {
|
|
81
|
-
setTimeout(() => scrollIntoView(props.scrollIntoView, props.scrollWithAnimation,
|
|
85
|
+
setTimeout(() => scrollIntoView(props.scrollIntoView, props.scrollWithAnimation, !!props.scrollX, !!props.scrollY, props.scrollIntoViewAlignment), 500);
|
|
82
86
|
} else {
|
|
83
|
-
scrollIntoView(props.scrollIntoView, props.scrollWithAnimation,
|
|
87
|
+
scrollIntoView(props.scrollIntoView, props.scrollWithAnimation, !!props.scrollX, !!props.scrollY, props.scrollIntoViewAlignment);
|
|
84
88
|
}
|
|
85
89
|
} else {
|
|
86
90
|
const isAnimation = !!props.scrollWithAnimation;
|
|
@@ -103,7 +107,7 @@ function ScrollView(props) {
|
|
|
103
107
|
if (isInitializedRef.current && container.current) {
|
|
104
108
|
handleScroll(props, false);
|
|
105
109
|
}
|
|
106
|
-
}, [props.scrollTop, props.scrollLeft, props.scrollIntoView]);
|
|
110
|
+
}, [props.scrollTop, props.scrollLeft, props.scrollIntoView, props.scrollIntoViewAlignment, props.scrollWithAnimation, props.scrollX, props.scrollY]);
|
|
107
111
|
const {
|
|
108
112
|
className,
|
|
109
113
|
style = {},
|
|
@@ -213,20 +217,44 @@ function ScrollView(props) {
|
|
|
213
217
|
}
|
|
214
218
|
};
|
|
215
219
|
}, []);
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
220
|
+
// ScrollElementContext:嵌套滚动时向子组件提供 scrollRef、containerHeight、startOffset
|
|
221
|
+
useEffect(() => {
|
|
222
|
+
const el = container.current;
|
|
223
|
+
if (!el) return;
|
|
224
|
+
const update = () => {
|
|
225
|
+
if (container.current) {
|
|
226
|
+
setContainerHeight(container.current.clientHeight);
|
|
221
227
|
}
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
228
|
+
};
|
|
229
|
+
update();
|
|
230
|
+
const ro = typeof ResizeObserver !== 'undefined' ? new ResizeObserver(update) : null;
|
|
231
|
+
if (ro) {
|
|
232
|
+
ro.observe(el);
|
|
233
|
+
return () => ro.disconnect();
|
|
234
|
+
}
|
|
235
|
+
}, []);
|
|
236
|
+
const scrollElementContextValue = {
|
|
237
|
+
scrollRef: container,
|
|
238
|
+
containerHeight,
|
|
239
|
+
startOffset: (_a = props.startOffset) !== null && _a !== void 0 ? _a : 0
|
|
240
|
+
};
|
|
241
|
+
return /*#__PURE__*/jsx(ScrollElementContext.Provider, {
|
|
242
|
+
value: scrollElementContextValue,
|
|
243
|
+
children: /*#__PURE__*/jsx("div", {
|
|
244
|
+
ref: e => {
|
|
245
|
+
if (e) {
|
|
246
|
+
container.current = e;
|
|
247
|
+
if (props.forwardedRef) props.forwardedRef.current = e;
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
style: style,
|
|
251
|
+
className: cls,
|
|
252
|
+
onScroll: _onScroll,
|
|
253
|
+
onTouchMove: _onTouchMove,
|
|
254
|
+
onTouchStart: _onTouchStart,
|
|
255
|
+
onTouchEnd: _onTouchEnd,
|
|
256
|
+
children: props.children
|
|
257
|
+
})
|
|
230
258
|
});
|
|
231
259
|
}
|
|
232
260
|
var index = createForwardRefComponent(ScrollView);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/scroll-view/index.tsx"],"sourcesContent":["import './style/index.scss'\n\nimport { isFunction } from '@tarojs/shared'\nimport classNames from 'classnames'\n\nimport { createForwardRefComponent, throttle } from '../../utils'\nimport { useEffect, useRef } from '../../utils/hooks'\n\nimport type React from 'react'\n\nfunction easeOutScroll (from = 0, to = 0, callback) {\n if (from === to || typeof from !== 'number') {\n return\n }\n const change = to - from\n const dur = 500\n const sTime = +new Date()\n function linear (t, b, c, d) {\n return (c * t) / d + b\n }\n const isLarger = to >= from\n\n function step () {\n from = linear(+new Date() - sTime, from, change, dur)\n if ((isLarger && from >= to) || (!isLarger && to >= from)) {\n callback(to)\n return\n }\n callback(from)\n requestAnimationFrame(step)\n }\n step()\n}\n\nfunction scrollIntoView (id = '', isHorizontal = false, animated = true, scrollIntoViewAlignment?: ScrollLogicalPosition) {\n document.querySelector(`#${id}`)?.scrollIntoView({\n behavior: animated ? 'smooth' : 'auto',\n block: !isHorizontal ? (scrollIntoViewAlignment || 'center') : 'center',\n inline: isHorizontal ? (scrollIntoViewAlignment || 'start') : 'start'\n })\n}\n\nfunction scrollVertical (container, scrollTop, top, isAnimation) {\n if (isAnimation) {\n easeOutScroll(scrollTop.current, top, pos => {\n if (container.current) container.current.scrollTop = pos\n })\n } else {\n if (container.current) container.current.scrollTop = top\n }\n scrollTop.current = top\n}\n\nfunction scrollHorizontal (container, scrollLeft, left, isAnimation) {\n if (isAnimation) {\n easeOutScroll(scrollLeft.current, left, pos => {\n if (container.current) container.current.scrollLeft = pos\n })\n } else {\n if (container.current) container.current.scrollLeft = left\n }\n scrollLeft.current = left\n}\n\ninterface IProps extends React.HTMLAttributes<HTMLDivElement> {\n scrollX: boolean\n scrollY: boolean\n upperThreshold: number\n lowerThreshold: number\n scrollTop: number\n scrollLeft: number\n scrollIntoView?: string\n scrollIntoViewAlignment?: ScrollLogicalPosition\n scrollWithAnimation: boolean\n enableBackToTop?: boolean\n forwardedRef?: React.MutableRefObject<HTMLDivElement>\n onScrollToUpper: (e: React.SyntheticEvent<HTMLDivElement, Event>) => void\n onScrollToLower: (e: React.SyntheticEvent<HTMLDivElement, Event>) => void\n onScroll: (e: React.SyntheticEvent<HTMLDivElement, Event>) => void\n onScrollStart?: (e: React.SyntheticEvent<HTMLDivElement, Event>) => void\n onScrollEnd?: (e: React.SyntheticEvent<HTMLDivElement, Event>) => void\n onTouchMove: (e: React.SyntheticEvent<HTMLDivElement, Event>) => void\n onTouchStart?: (e: React.SyntheticEvent<HTMLDivElement, Event>) => void\n onTouchEnd?: (e: React.SyntheticEvent<HTMLDivElement, Event>) => void\n showScrollbar?: boolean // 新增参数,默认true\n enhanced?: boolean // 新增参数,默认false\n}\n\nfunction ScrollView (props: IProps) {\n const _scrollTop = useRef<any>(null)\n const _scrollLeft = useRef<any>(null)\n const container = useRef<any>(null)\n const scrollEndTimerRef = useRef<NodeJS.Timeout | null>(null)\n const isScrollingRef = useRef<boolean>(false)\n const isInitializedRef = useRef<boolean>(false)\n const onTouchMove = (e) => {\n e.stopPropagation()\n }\n\n const handleScroll = (props: IProps, isInit = false) => {\n // scrollIntoView\n if (\n props.scrollIntoView &&\n typeof props.scrollIntoView === 'string' &&\n document &&\n document.querySelector &&\n document.querySelector(`#${props.scrollIntoView}`)\n ) {\n const isHorizontal = props.scrollX && !props.scrollY\n if (isInit) {\n setTimeout(() => scrollIntoView(props.scrollIntoView, props.scrollWithAnimation, isHorizontal, props.scrollIntoViewAlignment), 500)\n } else {\n scrollIntoView(props.scrollIntoView, props.scrollWithAnimation, isHorizontal, props.scrollIntoViewAlignment)\n }\n } else {\n const isAnimation = !!props.scrollWithAnimation\n // Y 轴滚动\n if (props.scrollY && typeof props.scrollTop === 'number' && props.scrollTop !== _scrollTop.current) {\n setTimeout(() => scrollVertical(container, _scrollTop, props.scrollTop, isAnimation), 10)\n }\n // X 轴滚动\n if (props.scrollX && typeof props.scrollLeft === 'number' && props.scrollLeft !== _scrollLeft.current) {\n setTimeout(() => scrollHorizontal(container, _scrollLeft, props.scrollLeft, isAnimation), 10)\n }\n }\n }\n\n useEffect(() => {\n handleScroll(props, true)\n isInitializedRef.current = true\n }, [])\n\n // 监听 scrollTop、scrollLeft、scrollIntoView 的变化(排除初始化)\n useEffect(() => {\n if (isInitializedRef.current && container.current) {\n handleScroll(props, false)\n }\n }, [props.scrollTop, props.scrollLeft, props.scrollIntoView])\n\n const {\n className,\n style = {},\n onScroll,\n onScrollToUpper,\n onScrollToLower,\n scrollX,\n scrollY,\n showScrollbar = true, // 默认显示滚动条\n enhanced = false // 默认不增强\n } = props\n let { upperThreshold = 50, lowerThreshold = 50 } = props\n const cls = classNames(\n 'taro-scroll',\n {\n 'taro-scroll-view__scroll-x': scrollX,\n 'taro-scroll-view__scroll-y': scrollY,\n 'taro-scroll--hidebar': enhanced === true && showScrollbar === false,\n 'taro-scroll--enhanced': enhanced === true\n },\n className\n )\n upperThreshold = Number(upperThreshold)\n lowerThreshold = Number(lowerThreshold)\n const upperAndLower = e => {\n if (!container.current) return\n const { offsetWidth, offsetHeight, scrollLeft, scrollTop, scrollHeight, scrollWidth } = container.current\n if (\n onScrollToLower &&\n ((props.scrollY && offsetHeight + scrollTop + lowerThreshold >= scrollHeight) ||\n (props.scrollX && offsetWidth + scrollLeft + lowerThreshold >= scrollWidth))\n ) {\n onScrollToLower(e)\n }\n if (\n onScrollToUpper &&\n ((props.scrollY && scrollTop <= upperThreshold) || (props.scrollX && scrollLeft <= upperThreshold))\n ) {\n onScrollToUpper(e)\n }\n }\n const upperAndLowerThrottle = throttle(upperAndLower, 200)\n const _onScroll = e => {\n const { scrollLeft, scrollTop, scrollHeight, scrollWidth } = container.current\n _scrollLeft.current = scrollLeft\n _scrollTop.current = scrollTop\n Object.defineProperty(e, 'detail', {\n enumerable: true,\n writable: true,\n value: {\n scrollLeft,\n scrollTop,\n scrollHeight,\n scrollWidth\n }\n })\n\n // 处理滚动开始\n if (!isScrollingRef.current) {\n isScrollingRef.current = true\n if (props.onScrollStart) {\n props.onScrollStart(e)\n }\n }\n\n // 清除滚动结束定时器\n if (scrollEndTimerRef.current) {\n clearTimeout(scrollEndTimerRef.current)\n scrollEndTimerRef.current = null\n }\n\n // 设置滚动结束定时器(150ms 无滚动事件后触发)\n if (props.onScrollEnd) {\n scrollEndTimerRef.current = setTimeout(() => {\n if (isScrollingRef.current) {\n isScrollingRef.current = false\n props.onScrollEnd?.(e)\n }\n scrollEndTimerRef.current = null\n }, 150)\n }\n\n upperAndLowerThrottle(e)\n onScroll && onScroll(e)\n }\n const _onTouchMove = e => {\n isFunction(props.onTouchMove) ? props.onTouchMove(e) : onTouchMove(e)\n }\n const _onTouchStart = e => {\n if (isFunction(props.onTouchStart)) {\n props.onTouchStart(e)\n }\n }\n const _onTouchEnd = e => {\n if (isFunction(props.onTouchEnd)) {\n props.onTouchEnd(e)\n }\n }\n // 清理定时器\n useEffect(() => {\n return () => {\n if (scrollEndTimerRef.current) {\n clearTimeout(scrollEndTimerRef.current)\n scrollEndTimerRef.current = null\n }\n }\n }, [])\n\n return (\n <div\n ref={e => {\n if (e) {\n container.current = e\n if (props.forwardedRef) props.forwardedRef.current = e\n }\n }}\n style={style}\n className={cls}\n onScroll={_onScroll}\n onTouchMove={_onTouchMove}\n onTouchStart={_onTouchStart}\n onTouchEnd={_onTouchEnd}\n >\n {props.children}\n </div>\n )\n}\n\nexport default createForwardRefComponent(ScrollView)\n"],"names":["easeOutScroll","from","arguments","length","undefined","to","callback","change","dur","sTime","Date","linear","t","b","c","d","isLarger","step","requestAnimationFrame","scrollIntoView","id","isHorizontal","animated","scrollIntoViewAlignment","_a","document","querySelector","behavior","block","inline","scrollVertical","container","scrollTop","top","isAnimation","current","pos","scrollHorizontal","scrollLeft","left","ScrollView","props","_scrollTop","useRef","_scrollLeft","scrollEndTimerRef","isScrollingRef","isInitializedRef","onTouchMove","e","stopPropagation","handleScroll","isInit","scrollX","scrollY","setTimeout","scrollWithAnimation","useEffect","className","style","onScroll","onScrollToUpper","onScrollToLower","showScrollbar","enhanced","upperThreshold","lowerThreshold","cls","classNames","Number","upperAndLower","offsetWidth","offsetHeight","scrollHeight","scrollWidth","upperAndLowerThrottle","throttle","_onScroll","Object","defineProperty","enumerable","writable","value","onScrollStart","clearTimeout","onScrollEnd","call","_onTouchMove","isFunction","_onTouchStart","onTouchStart","_onTouchEnd","onTouchEnd","_jsx","ref","forwardedRef","children","createForwardRefComponent"],"mappings":";;;;;;;AAUA,SAASA,aAAaA,GAA4B;AAAA,EAAA,IAA1BC,IAAI,GAAAC,SAAA,CAAAC,MAAA,GAAA,CAAA,IAAAD,SAAA,CAAA,CAAA,CAAA,KAAAE,SAAA,GAAAF,SAAA,CAAA,CAAA,CAAA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AAIZ,iBAAiB,CAACV,OAAO,EAAE;AAC7BiD,QAAAA,YAAY,CAACvC,iBAAiB,CAACV,OAAO,CAAC;QACvCU,iBAAiB,CAACV,OAAO,GAAG,IAAI;AAClC;KACD;GACF,EAAE,EAAE,CAAC;AAEN,EAAA,oBACE0D,GAAA,CAAA,KAAA,EAAA;IACEC,GAAG,EAAE7C,CAAC,IAAG;AACP,MAAA,IAAIA,CAAC,EAAE;QACLlB,SAAS,CAACI,OAAO,GAAGc,CAAC;QACrB,IAAIR,KAAK,CAACsD,YAAY,EAAEtD,KAAK,CAACsD,YAAY,CAAC5D,OAAO,GAAGc,CAAC;AACxD;KACA;AACFU,IAAAA,KAAK,EAAEA,KAAM;AACbD,IAAAA,SAAS,EAAES,GAAI;AACfP,IAAAA,QAAQ,EAAEiB,SAAU;AACpB7B,IAAAA,WAAW,EAAEuC,YAAa;AAC1BG,IAAAA,YAAY,EAAED,aAAc;AAC5BG,IAAAA,UAAU,EAAED,WAAY;IAAAK,QAAA,EAEvBvD,KAAK,CAACuD;AAAQ,GACZ,CAAC;AAEV;AAEA,YAAeC,yBAAyB,CAACzD,UAAU,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/scroll-view/index.tsx"],"sourcesContent":["import './style/index.scss'\n\nimport { isFunction } from '@tarojs/shared'\nimport classNames from 'classnames'\n\nimport { ScrollElementContext } from '../../contexts/ScrollElementContext'\nimport { createForwardRefComponent, throttle } from '../../utils'\nimport { useEffect, useRef, useState } from '../../utils/hooks'\n\nimport type React from 'react'\n\nfunction easeOutScroll (from = 0, to = 0, callback) {\n if (from === to || typeof from !== 'number') {\n return\n }\n const change = to - from\n const dur = 500\n const sTime = +new Date()\n function linear (t, b, c, d) {\n return (c * t) / d + b\n }\n const isLarger = to >= from\n\n function step () {\n from = linear(+new Date() - sTime, from, change, dur)\n if ((isLarger && from >= to) || (!isLarger && to >= from)) {\n callback(to)\n return\n }\n callback(from)\n requestAnimationFrame(step)\n }\n step()\n}\n\n/** 未开启的滚动轴使用 nearest 避免原生 scrollIntoView 沿该轴滚动整页 */\nfunction scrollIntoView (\n id = '',\n animated = true,\n scrollX = false,\n scrollY = false,\n scrollIntoViewAlignment?: ScrollLogicalPosition\n) {\n document.querySelector(`#${id}`)?.scrollIntoView({\n behavior: animated ? 'smooth' : 'auto',\n block: scrollY ? (scrollIntoViewAlignment || 'center') : 'nearest',\n inline: scrollX ? (scrollIntoViewAlignment || 'start') : 'nearest'\n })\n}\n\nfunction scrollVertical (container, scrollTop, top, isAnimation) {\n if (isAnimation) {\n easeOutScroll(scrollTop.current, top, pos => {\n if (container.current) container.current.scrollTop = pos\n })\n } else {\n if (container.current) container.current.scrollTop = top\n }\n scrollTop.current = top\n}\n\nfunction scrollHorizontal (container, scrollLeft, left, isAnimation) {\n if (isAnimation) {\n easeOutScroll(scrollLeft.current, left, pos => {\n if (container.current) container.current.scrollLeft = pos\n })\n } else {\n if (container.current) container.current.scrollLeft = left\n }\n scrollLeft.current = left\n}\n\ninterface IProps extends React.HTMLAttributes<HTMLDivElement> {\n scrollX: boolean\n scrollY: boolean\n upperThreshold: number\n lowerThreshold: number\n scrollTop: number\n scrollLeft: number\n scrollIntoView?: string\n scrollIntoViewAlignment?: ScrollLogicalPosition\n scrollWithAnimation: boolean\n enableBackToTop?: boolean\n forwardedRef?: React.MutableRefObject<HTMLDivElement>\n onScrollToUpper: (e: React.SyntheticEvent<HTMLDivElement, Event>) => void\n onScrollToLower: (e: React.SyntheticEvent<HTMLDivElement, Event>) => void\n onScroll: (e: React.SyntheticEvent<HTMLDivElement, Event>) => void\n onScrollStart?: (e: React.SyntheticEvent<HTMLDivElement, Event>) => void\n onScrollEnd?: (e: React.SyntheticEvent<HTMLDivElement, Event>) => void\n onTouchMove: (e: React.SyntheticEvent<HTMLDivElement, Event>) => void\n onTouchStart?: (e: React.SyntheticEvent<HTMLDivElement, Event>) => void\n onTouchEnd?: (e: React.SyntheticEvent<HTMLDivElement, Event>) => void\n showScrollbar?: boolean // 新增参数,默认true\n enhanced?: boolean // 新增参数,默认false\n /** 嵌套滚动:内容在滚动容器中的起始偏移(固定头部等场景) */\n startOffset?: number\n}\n\nfunction ScrollView (props: IProps) {\n const _scrollTop = useRef<any>(null)\n const _scrollLeft = useRef<any>(null)\n const container = useRef<any>(null)\n const scrollEndTimerRef = useRef<NodeJS.Timeout | null>(null)\n const isScrollingRef = useRef<boolean>(false)\n const isInitializedRef = useRef<boolean>(false)\n const [containerHeight, setContainerHeight] = useState(0)\n const onTouchMove = (e) => {\n e.stopPropagation()\n }\n\n const handleScroll = (props: IProps, isInit = false) => {\n // scrollIntoView\n if (\n props.scrollIntoView &&\n typeof props.scrollIntoView === 'string' &&\n document &&\n document.querySelector &&\n document.querySelector(`#${props.scrollIntoView}`)\n ) {\n if (isInit) {\n setTimeout(\n () =>\n scrollIntoView(\n props.scrollIntoView,\n props.scrollWithAnimation,\n !!props.scrollX,\n !!props.scrollY,\n props.scrollIntoViewAlignment\n ),\n 500\n )\n } else {\n scrollIntoView(\n props.scrollIntoView,\n props.scrollWithAnimation,\n !!props.scrollX,\n !!props.scrollY,\n props.scrollIntoViewAlignment\n )\n }\n } else {\n const isAnimation = !!props.scrollWithAnimation\n // Y 轴滚动\n if (props.scrollY && typeof props.scrollTop === 'number' && props.scrollTop !== _scrollTop.current) {\n setTimeout(() => scrollVertical(container, _scrollTop, props.scrollTop, isAnimation), 10)\n }\n // X 轴滚动\n if (props.scrollX && typeof props.scrollLeft === 'number' && props.scrollLeft !== _scrollLeft.current) {\n setTimeout(() => scrollHorizontal(container, _scrollLeft, props.scrollLeft, isAnimation), 10)\n }\n }\n }\n\n useEffect(() => {\n handleScroll(props, true)\n isInitializedRef.current = true\n }, [])\n\n // 监听 scrollTop、scrollLeft、scrollIntoView 的变化(排除初始化)\n useEffect(() => {\n if (isInitializedRef.current && container.current) {\n handleScroll(props, false)\n }\n }, [\n props.scrollTop,\n props.scrollLeft,\n props.scrollIntoView,\n props.scrollIntoViewAlignment,\n props.scrollWithAnimation,\n props.scrollX,\n props.scrollY\n ])\n\n const {\n className,\n style = {},\n onScroll,\n onScrollToUpper,\n onScrollToLower,\n scrollX,\n scrollY,\n showScrollbar = true, // 默认显示滚动条\n enhanced = false // 默认不增强\n } = props\n let { upperThreshold = 50, lowerThreshold = 50 } = props\n const cls = classNames(\n 'taro-scroll',\n {\n 'taro-scroll-view__scroll-x': scrollX,\n 'taro-scroll-view__scroll-y': scrollY,\n 'taro-scroll--hidebar': enhanced === true && showScrollbar === false,\n 'taro-scroll--enhanced': enhanced === true\n },\n className\n )\n upperThreshold = Number(upperThreshold)\n lowerThreshold = Number(lowerThreshold)\n const upperAndLower = e => {\n if (!container.current) return\n const { offsetWidth, offsetHeight, scrollLeft, scrollTop, scrollHeight, scrollWidth } = container.current\n if (\n onScrollToLower &&\n ((props.scrollY && offsetHeight + scrollTop + lowerThreshold >= scrollHeight) ||\n (props.scrollX && offsetWidth + scrollLeft + lowerThreshold >= scrollWidth))\n ) {\n onScrollToLower(e)\n }\n if (\n onScrollToUpper &&\n ((props.scrollY && scrollTop <= upperThreshold) || (props.scrollX && scrollLeft <= upperThreshold))\n ) {\n onScrollToUpper(e)\n }\n }\n const upperAndLowerThrottle = throttle(upperAndLower, 200)\n const _onScroll = e => {\n const { scrollLeft, scrollTop, scrollHeight, scrollWidth } = container.current\n _scrollLeft.current = scrollLeft\n _scrollTop.current = scrollTop\n Object.defineProperty(e, 'detail', {\n enumerable: true,\n writable: true,\n value: {\n scrollLeft,\n scrollTop,\n scrollHeight,\n scrollWidth\n }\n })\n\n // 处理滚动开始\n if (!isScrollingRef.current) {\n isScrollingRef.current = true\n if (props.onScrollStart) {\n props.onScrollStart(e)\n }\n }\n\n // 清除滚动结束定时器\n if (scrollEndTimerRef.current) {\n clearTimeout(scrollEndTimerRef.current)\n scrollEndTimerRef.current = null\n }\n\n // 设置滚动结束定时器(150ms 无滚动事件后触发)\n if (props.onScrollEnd) {\n scrollEndTimerRef.current = setTimeout(() => {\n if (isScrollingRef.current) {\n isScrollingRef.current = false\n props.onScrollEnd?.(e)\n }\n scrollEndTimerRef.current = null\n }, 150)\n }\n\n upperAndLowerThrottle(e)\n onScroll && onScroll(e)\n }\n const _onTouchMove = e => {\n isFunction(props.onTouchMove) ? props.onTouchMove(e) : onTouchMove(e)\n }\n const _onTouchStart = e => {\n if (isFunction(props.onTouchStart)) {\n props.onTouchStart(e)\n }\n }\n const _onTouchEnd = e => {\n if (isFunction(props.onTouchEnd)) {\n props.onTouchEnd(e)\n }\n }\n // 清理定时器\n useEffect(() => {\n return () => {\n if (scrollEndTimerRef.current) {\n clearTimeout(scrollEndTimerRef.current)\n scrollEndTimerRef.current = null\n }\n }\n }, [])\n\n // ScrollElementContext:嵌套滚动时向子组件提供 scrollRef、containerHeight、startOffset\n useEffect(() => {\n const el = container.current\n if (!el) return\n const update = () => {\n if (container.current) {\n setContainerHeight(container.current.clientHeight)\n }\n }\n update()\n const ro = typeof ResizeObserver !== 'undefined' ? new ResizeObserver(update) : null\n if (ro) {\n ro.observe(el)\n return () => ro.disconnect()\n }\n }, [])\n\n const scrollElementContextValue = {\n scrollRef: container,\n containerHeight,\n startOffset: props.startOffset ?? 0,\n }\n\n return (\n <ScrollElementContext.Provider value={scrollElementContextValue}>\n <div\n ref={e => {\n if (e) {\n container.current = e\n if (props.forwardedRef) props.forwardedRef.current = e\n }\n }}\n style={style}\n className={cls}\n onScroll={_onScroll}\n onTouchMove={_onTouchMove}\n onTouchStart={_onTouchStart}\n onTouchEnd={_onTouchEnd}\n >\n {props.children}\n </div>\n </ScrollElementContext.Provider>\n )\n}\n\nexport default createForwardRefComponent(ScrollView)\n"],"names":["easeOutScroll","from","arguments","length","undefined","to","callback","change","dur","sTime","Date","linear","t","b","c","d","isLarger","step","requestAnimationFrame","scrollIntoView","id","animated","scrollX","scrollY","scrollIntoViewAlignment","_a","document","querySelector","behavior","block","inline","scrollVertical","container","scrollTop","top","isAnimation","current","pos","scrollHorizontal","scrollLeft","left","ScrollView","props","_scrollTop","useRef","_scrollLeft","scrollEndTimerRef","isScrollingRef","isInitializedRef","containerHeight","setContainerHeight","useState","onTouchMove","e","stopPropagation","handleScroll","isInit","setTimeout","scrollWithAnimation","useEffect","className","style","onScroll","onScrollToUpper","onScrollToLower","showScrollbar","enhanced","upperThreshold","lowerThreshold","cls","classNames","Number","upperAndLower","offsetWidth","offsetHeight","scrollHeight","scrollWidth","upperAndLowerThrottle","throttle","_onScroll","Object","defineProperty","enumerable","writable","value","onScrollStart","clearTimeout","onScrollEnd","call","_onTouchMove","isFunction","_onTouchStart","onTouchStart","_onTouchEnd","onTouchEnd","el","update","clientHeight","ro","ResizeObserver","observe","disconnect","scrollElementContextValue","scrollRef","startOffset","_jsx","ScrollElementContext","Provider","children","ref","forwardedRef","createForwardRefComponent"],"mappings":";;;;;;;;AAWA,SAASA,aAAaA,GAA4B;AAAA,EAAA,IAA1BC,IAAI,GAAAC,SAAA,CAAAC,MAAA,GAAA,CAAA,IAAAD,SAAA,CAAA,CAAA,CAAA,KAAAE,SAAA,GAAAF,SAAA,CAAA,CAAA,CAAA,GAAG,CAAC;AAAA,EAAA,IAAEG,EAAE,GAAAH,SAAA,CAAAC,MAAA,GAAA,CAAA,IAAAD,SAAA,CAAA,CAAA,CAAA,KAAAE,SAAA,GAAAF,SAAA,CAAA,CAAA,CAAA,GAAG,CAAC;EAAA,IAAEI,QAAQ,GAAAJ,SAAA,CAAAC,MAAA,GAAAD,CAAAA,GAAAA,SAAA,MAAAE,SAAA;EAChD,IAAIH,IAAI,KAAKI,EAAE,IAAI,OAAOJ,IAAI,KAAK,QAAQ,EAAE;AAC3C,IAAA;AACF;AACA,EAAA,MAAMM,MAAM,GAAGF,EAAE,GAAGJ,IAAI;EACxB,MAAMO,GAAG,GAAG,GAAG;AACf,EAAA,MAAMC,KAAK,GAAG,CAAC,IAAIC,IAAI,EAAE;EACzB,SAASC,MAAMA,CAAEC,CAAC,EAAEC,CAAC,EAAEC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