@tarojs/components-react 4.2.1-beta.0 → 4.2.1-beta.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/components/image/index.js +5 -3
- package/dist/components/image/index.js.map +1 -1
- package/dist/components/map/MapContext.js +628 -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 +329 -0
- package/dist/components/map/index.js.map +1 -0
- package/dist/components/picker/index.js +76 -35
- package/dist/components/picker/index.js.map +1 -1
- package/dist/components/picker/picker-group.js +477 -127
- package/dist/components/picker/picker-group.js.map +1 -1
- package/dist/components/refresher/index.js +5 -5
- package/dist/components/refresher/index.js.map +1 -1
- package/dist/components/scroll-view/index.js +80 -36
- package/dist/components/scroll-view/index.js.map +1 -1
- package/dist/components/switch/index.js +125 -0
- package/dist/components/switch/index.js.map +1 -0
- package/dist/components/switch/style/index.scss.js +4 -0
- package/dist/components/switch/style/index.scss.js.map +1 -0
- package/dist/contexts/ScrollElementContext.js +6 -0
- package/dist/contexts/ScrollElementContext.js.map +1 -0
- package/dist/index.css +1 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/original/components/image/index.js +5 -3
- package/dist/original/components/image/index.js.map +1 -1
- package/dist/original/components/image/style/index.scss +5 -1
- package/dist/original/components/map/MapContext.js +628 -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 +329 -0
- package/dist/original/components/map/index.js.map +1 -0
- package/dist/original/components/picker/index.js +76 -35
- package/dist/original/components/picker/index.js.map +1 -1
- package/dist/original/components/picker/picker-group.js +477 -127
- package/dist/original/components/picker/picker-group.js.map +1 -1
- package/dist/original/components/picker/style/index.scss +9 -8
- 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 +80 -36
- package/dist/original/components/scroll-view/index.js.map +1 -1
- package/dist/original/components/switch/index.js +125 -0
- package/dist/original/components/switch/index.js.map +1 -0
- package/dist/original/components/switch/style/index.scss +35 -0
- package/dist/original/contexts/ScrollElementContext.js +6 -0
- package/dist/original/contexts/ScrollElementContext.js.map +1 -0
- package/dist/original/index.js +6 -2
- package/dist/original/index.js.map +1 -1
- package/dist/solid/components/image/index.js +5 -3
- package/dist/solid/components/image/index.js.map +1 -1
- package/dist/solid/components/picker/index.js +82 -39
- package/dist/solid/components/picker/index.js.map +1 -1
- package/dist/solid/components/picker/picker-group.js +500 -151
- package/dist/solid/components/picker/picker-group.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 +84 -40
- 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.css +1 -1
- package/dist/solid/index.js +1 -1
- package/package.json +8 -6
|
@@ -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 libraries?: 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 libraries,\n longitude,\n latitude,\n scale,\n minScale,\n maxScale,\n enableRotate,\n rotate,\n skew,\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 // 宽高为 0 时跳过渲染(隐藏 marker,仅保留气泡)\n if (markerWidth === 0 || markerHeight === 0) {\n return\n }\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: Math.round(line.width ?? 3), // 取整,tlbs-map-react 要求 width 为整数\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 ...(typeof rotate === 'number' && { rotation: rotate }), // Taro: rotate;tlbs-map-react: options.rotation\n ...(typeof skew === 'number' && { pitch: skew }), // Taro: skew;tlbs-map-react: options.pitch\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 libraries={libraries}\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: String(id) || '',\n tagName: 'callout',\n dataset: {},\n },\n currentTarget: {\n id: String(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","libraries","longitude","latitude","scale","minScale","maxScale","enableRotate","rotate","skew","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","rotation","alpha","opacity","zIndex","push","position","lat","lng","normalizedPolylines","polylineStyles","polylineGeometries","line","lineIndex","points","length","color","Math","round","dashArray","dottedLine","paths","map","point","hasCenter","mergedOptions","center","zoom","minZoom","maxZoom","rotatable","pitch","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;AAmBA,SAASA,GAAGA,CAAEC,KAAe,EAAA;EAC3B,MAAM;IACJC,YAAY;IACZC,EAAE;IACFC,SAAS;IACTC,KAAK;IACLC,OAAO;IACPC,SAAS;IACTC,SAAS;IACTC,QAAQ;IACRC,KAAK;IACLC,QAAQ;IACRC,QAAQ;IACRC,YAAY;IACZC,MAAM;IACNC,IAAI;IACJC,OAAO;IACPC,QAAQ;IACRC,KAAK;IACLC,aAAa;AACbC,IAAAA;AACD,GAAA,GAAGnB,KAAK;AACT;EACAoB,OAAO,CAACC,GAAG,CAACC,SAAS,EAAE,OAAO,EAAEtB,KAAK,CAAC;AAEtC;AACA,EAAA,MAAMuB,QAAQ,GAAG,OAAOnB,KAAK,KAAK,QAAQ,IAAIA,KAAK,KAAKoB,SAAS,GAAG,EAAE,GAAIpB,KAAgC;AAE1G;AACA,EAAA,MAAMqB,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,CAAC3B,EAAE,MAAA,IAAA,IAAA+B,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,MAAMI,SAAS,GAAIC,IAAiC,IAAY;AAC9D,MAAA,IAAI,OAA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A,OAAO,EAAE;eACV;AACDE,cAAAA,MAAM,EAAE;AAAE3D,gBAAAA,QAAQ,EAAE7B;eAAI;AACxB0F,cAAAA,cAAc,EAAEA,MAAK,EAAG;cACxBC,eAAe,EAAEA,MAAK;AACvB,aAAA,CAAC;AACJ;SACA;AAAAsB,QAAAA,QAAA,EAEDe,KAAK,CAAClI,KAAK,CAACmH;AAAQ,OAAA,EA9BhBpF,QA+BW,CAAC;AAEvB,KAAC,CAAC;AACJ;AACF;AAEA,YAAesH,yBAAyB,CAACtJ,GAAG,CAAC;;;;"}
|
|
@@ -127,12 +127,13 @@ const Picker = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
|
127
127
|
children,
|
|
128
128
|
formType,
|
|
129
129
|
lang,
|
|
130
|
-
theme = 'light'
|
|
130
|
+
theme = 'light',
|
|
131
|
+
enableClickItemScroll = true
|
|
131
132
|
} = props,
|
|
132
|
-
restProps = __rest(props, ["mode", "disabled", "range", "rangeKey", "value", "start", "end", "fields", "headerText", "level", "regionData", "textProps", "colors", "onChange", "onColumnChange", "onCancel", "children", "formType", "lang", "theme"]);
|
|
133
|
+
restProps = __rest(props, ["mode", "disabled", "range", "rangeKey", "value", "start", "end", "fields", "headerText", "level", "regionData", "textProps", "colors", "onChange", "onColumnChange", "onCancel", "children", "formType", "lang", "theme", "enableClickItemScroll"]);
|
|
133
134
|
const indexRef = React__default.useRef([]);
|
|
134
135
|
const pickerDateRef = React__default.useRef();
|
|
135
|
-
//
|
|
136
|
+
// region:首次用户滚动初始化完成前不入库
|
|
136
137
|
const isInitializationCompletedRef = React__default.useRef(false);
|
|
137
138
|
const [state, setState] = React__default.useState({
|
|
138
139
|
pickerValue: value || EMPTY_ARRAY,
|
|
@@ -141,7 +142,8 @@ const Picker = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
|
141
142
|
hidden: true,
|
|
142
143
|
fadeOut: false,
|
|
143
144
|
isWillLoadCalled: false,
|
|
144
|
-
|
|
145
|
+
a11yTimeLimitColumnId: null,
|
|
146
|
+
a11yTimeLimitNonce: 0
|
|
145
147
|
});
|
|
146
148
|
// 在组件内部
|
|
147
149
|
const [columnsCount, setColumnsCount] = React__default.useState(() => getRegionColumnsCount(level));
|
|
@@ -199,25 +201,36 @@ const Picker = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
|
199
201
|
const monthRange = getMonthRange(_start, _end, currentYear);
|
|
200
202
|
const dayRange = getDayRange(_start, _end, currentYear, currentMonth);
|
|
201
203
|
indexRef.current = [yearRange.indexOf(currentYear), monthRange.indexOf(currentMonth), dayRange.indexOf(currentDay)];
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
}
|
|
204
|
+
// 与 props 同步时始终刷新 _updateValue,避免取消后再开时日列草稿与索引不一致
|
|
205
|
+
pickerDateRef.current = {
|
|
206
|
+
_value,
|
|
207
|
+
_start,
|
|
208
|
+
_end,
|
|
209
|
+
_updateValue: [currentYear, currentMonth, currentDay]
|
|
210
|
+
};
|
|
210
211
|
} else if (mode === 'region') {
|
|
211
212
|
// region 模式处理 - 验证数据
|
|
212
213
|
if (!regionData) {
|
|
213
214
|
console.error('Picker: regionData is required for region mode');
|
|
214
|
-
indexRef.current =
|
|
215
|
+
indexRef.current = Array.from({
|
|
216
|
+
length: columnsCount
|
|
217
|
+
}, () => 0);
|
|
218
|
+
setState(prev => Object.assign(Object.assign({}, prev), {
|
|
219
|
+
selectedIndices: [...indexRef.current],
|
|
220
|
+
pickerValue: value || EMPTY_ARRAY
|
|
221
|
+
}));
|
|
215
222
|
return;
|
|
216
223
|
}
|
|
217
224
|
const validation = validateRegionData(regionData, 'Picker');
|
|
218
225
|
if (!validation.valid) {
|
|
219
226
|
console.error(validation.error);
|
|
220
|
-
indexRef.current =
|
|
227
|
+
indexRef.current = Array.from({
|
|
228
|
+
length: columnsCount
|
|
229
|
+
}, () => 0);
|
|
230
|
+
setState(prev => Object.assign(Object.assign({}, prev), {
|
|
231
|
+
selectedIndices: [...indexRef.current],
|
|
232
|
+
pickerValue: value || EMPTY_ARRAY
|
|
233
|
+
}));
|
|
221
234
|
return;
|
|
222
235
|
}
|
|
223
236
|
// 获取列数
|
|
@@ -264,16 +277,16 @@ const Picker = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
|
264
277
|
handleProps();
|
|
265
278
|
}
|
|
266
279
|
}, [handleProps, state.isWillLoadCalled, JSON.stringify(value)]);
|
|
267
|
-
//
|
|
280
|
+
// 打开时按 props 重算索引,避免未确认的滑动与 indexRef 残留导致再开抖动
|
|
268
281
|
const showPicker = React__default.useCallback(() => {
|
|
269
282
|
if (disabled) return;
|
|
270
283
|
isInitializationCompletedRef.current = false;
|
|
271
|
-
|
|
284
|
+
handleProps();
|
|
272
285
|
setState(prev => Object.assign(Object.assign({}, prev), {
|
|
273
|
-
|
|
274
|
-
|
|
286
|
+
hidden: false,
|
|
287
|
+
a11yTimeLimitColumnId: null
|
|
275
288
|
}));
|
|
276
|
-
}, [disabled,
|
|
289
|
+
}, [disabled, handleProps]);
|
|
277
290
|
// 隐藏 Picker
|
|
278
291
|
const hidePicker = React__default.useCallback(() => {
|
|
279
292
|
isInitializationCompletedRef.current = false;
|
|
@@ -348,11 +361,11 @@ const Picker = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
|
348
361
|
finalIndices = [...newIndices];
|
|
349
362
|
hasLimited = true;
|
|
350
363
|
}
|
|
351
|
-
// 触发限位,更新状态,其它状态不用主动触发滚动
|
|
352
364
|
if (hasLimited) {
|
|
353
365
|
setState(prev => Object.assign(Object.assign({}, prev), {
|
|
354
366
|
selectedIndices: finalIndices,
|
|
355
|
-
|
|
367
|
+
a11yTimeLimitColumnId: columnId,
|
|
368
|
+
a11yTimeLimitNonce: prev.a11yTimeLimitNonce + 1
|
|
356
369
|
}));
|
|
357
370
|
} else {
|
|
358
371
|
setState(prev => Object.assign(Object.assign({}, prev), {
|
|
@@ -585,11 +598,17 @@ const Picker = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
|
585
598
|
}
|
|
586
599
|
});
|
|
587
600
|
}, [onColumnChange]);
|
|
588
|
-
|
|
601
|
+
const consumeTimeA11yLimitFocus = React__default.useCallback(() => {
|
|
602
|
+
setState(prev => Object.assign(Object.assign({}, prev), {
|
|
603
|
+
a11yTimeLimitColumnId: null
|
|
604
|
+
}));
|
|
605
|
+
}, []);
|
|
606
|
+
// 取消时按 props 回同步索引,避免与 value 脱节
|
|
589
607
|
const handleCancel = React__default.useCallback(() => {
|
|
608
|
+
handleProps();
|
|
590
609
|
hidePicker();
|
|
591
610
|
onCancel === null || onCancel === void 0 ? void 0 : onCancel();
|
|
592
|
-
}, [hidePicker, onCancel]);
|
|
611
|
+
}, [handleProps, hidePicker, onCancel]);
|
|
593
612
|
// 渲染选择器组
|
|
594
613
|
const renderPickerGroup = React__default.useMemo(() => {
|
|
595
614
|
switch (mode) {
|
|
@@ -603,11 +622,16 @@ const Picker = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
|
603
622
|
columnId: String(index),
|
|
604
623
|
selectedIndex: state.selectedIndices[index] // 传递对应列的selectedIndex
|
|
605
624
|
,
|
|
606
|
-
colors: colors
|
|
625
|
+
colors: colors,
|
|
626
|
+
enableClickItemScroll: enableClickItemScroll
|
|
607
627
|
}, index));
|
|
608
628
|
}
|
|
609
629
|
case 'time':
|
|
610
630
|
{
|
|
631
|
+
const timeA11yLimitFocus = state.a11yTimeLimitColumnId != null ? {
|
|
632
|
+
nonce: state.a11yTimeLimitNonce,
|
|
633
|
+
columnId: state.a11yTimeLimitColumnId
|
|
634
|
+
} : null;
|
|
611
635
|
return [/*#__PURE__*/jsx(PickerGroup, {
|
|
612
636
|
mode: "time",
|
|
613
637
|
range: hoursRange,
|
|
@@ -615,16 +639,24 @@ const Picker = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
|
615
639
|
columnId: "0",
|
|
616
640
|
selectedIndex: state.selectedIndices[0] // 传递小时列的selectedIndex
|
|
617
641
|
,
|
|
618
|
-
colors: colors
|
|
619
|
-
|
|
642
|
+
colors: colors,
|
|
643
|
+
timeA11yLimitFocus: timeA11yLimitFocus,
|
|
644
|
+
onTimeA11yLimitFocusConsumed: consumeTimeA11yLimitFocus,
|
|
645
|
+
timeA11yLimitEventNonce: state.a11yTimeLimitNonce,
|
|
646
|
+
enableClickItemScroll: enableClickItemScroll
|
|
647
|
+
}, "hour"), /*#__PURE__*/jsx(PickerGroup, {
|
|
620
648
|
mode: "time",
|
|
621
649
|
range: minutesRange,
|
|
622
650
|
updateIndex: updateIndex,
|
|
623
651
|
columnId: "1",
|
|
624
652
|
selectedIndex: state.selectedIndices[1] // 传递分钟列的selectedIndex
|
|
625
653
|
,
|
|
626
|
-
colors: colors
|
|
627
|
-
|
|
654
|
+
colors: colors,
|
|
655
|
+
timeA11yLimitFocus: timeA11yLimitFocus,
|
|
656
|
+
onTimeA11yLimitFocusConsumed: consumeTimeA11yLimitFocus,
|
|
657
|
+
timeA11yLimitEventNonce: state.a11yTimeLimitNonce,
|
|
658
|
+
enableClickItemScroll: enableClickItemScroll
|
|
659
|
+
}, "minute")];
|
|
628
660
|
}
|
|
629
661
|
case 'date':
|
|
630
662
|
{
|
|
@@ -649,7 +681,8 @@ const Picker = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
|
649
681
|
columnId: "0",
|
|
650
682
|
selectedIndex: state.selectedIndices[0] // 传递年份列的selectedIndex
|
|
651
683
|
,
|
|
652
|
-
colors: colors
|
|
684
|
+
colors: colors,
|
|
685
|
+
enableClickItemScroll: enableClickItemScroll
|
|
653
686
|
}, `year`)];
|
|
654
687
|
if (fields === 'month' || fields === 'day') {
|
|
655
688
|
renderView.push(/*#__PURE__*/jsx(PickerGroup, {
|
|
@@ -660,7 +693,8 @@ const Picker = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
|
660
693
|
columnId: "1",
|
|
661
694
|
selectedIndex: state.selectedIndices[1] // 传递月份列的selectedIndex
|
|
662
695
|
,
|
|
663
|
-
colors: colors
|
|
696
|
+
colors: colors,
|
|
697
|
+
enableClickItemScroll: enableClickItemScroll
|
|
664
698
|
}, `month`));
|
|
665
699
|
}
|
|
666
700
|
if (fields === 'day') {
|
|
@@ -672,7 +706,8 @@ const Picker = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
|
672
706
|
columnId: "2",
|
|
673
707
|
selectedIndex: state.selectedIndices[2] // 传递日期列的selectedIndex
|
|
674
708
|
,
|
|
675
|
-
colors: colors
|
|
709
|
+
colors: colors,
|
|
710
|
+
enableClickItemScroll: enableClickItemScroll
|
|
676
711
|
}, `day`));
|
|
677
712
|
}
|
|
678
713
|
return renderView;
|
|
@@ -707,7 +742,8 @@ const Picker = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
|
707
742
|
updateIndex: updateIndex,
|
|
708
743
|
columnId: String(i),
|
|
709
744
|
selectedIndex: state.selectedIndices[i],
|
|
710
|
-
colors: colors
|
|
745
|
+
colors: colors,
|
|
746
|
+
enableClickItemScroll: enableClickItemScroll
|
|
711
747
|
}, `region-${i}`));
|
|
712
748
|
}
|
|
713
749
|
return columns;
|
|
@@ -720,10 +756,11 @@ const Picker = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
|
720
756
|
columnId: "0",
|
|
721
757
|
selectedIndex: state.selectedIndices[0] // 传递selector模式的selectedIndex
|
|
722
758
|
,
|
|
723
|
-
colors: colors
|
|
759
|
+
colors: colors,
|
|
760
|
+
enableClickItemScroll: enableClickItemScroll
|
|
724
761
|
});
|
|
725
762
|
}
|
|
726
|
-
}, [mode, range, rangeKey, fields, updateIndex, updateDay, handleColumnChange, pickerDateRef.current, level, regionData, state.selectedIndices, columnsCount, lang, colors]);
|
|
763
|
+
}, [mode, range, rangeKey, fields, updateIndex, updateDay, handleColumnChange, pickerDateRef.current, level, regionData, state.selectedIndices, state.a11yTimeLimitColumnId, state.a11yTimeLimitNonce, consumeTimeA11yLimitFocus, columnsCount, lang, colors, enableClickItemScroll]);
|
|
727
764
|
// 动画类名控制逻辑
|
|
728
765
|
const clsMask = classNames('taro-picker__mask-overlay', 'taro-picker__animate-fade-in', {
|
|
729
766
|
'taro-picker__animate-fade-out': state.fadeOut
|
|
@@ -737,6 +774,9 @@ const Picker = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
|
737
774
|
const titleStyle = colors.titleColor ? {
|
|
738
775
|
color: colors.titleColor
|
|
739
776
|
} : null;
|
|
777
|
+
const maskOverlayStyle = colors.maskColor ? {
|
|
778
|
+
backgroundColor: colors.maskColor
|
|
779
|
+
} : undefined;
|
|
740
780
|
// 暴露方法给外部
|
|
741
781
|
React__default.useImperativeHandle(ref, () => ({
|
|
742
782
|
showPicker,
|
|
@@ -755,9 +795,10 @@ const Picker = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
|
755
795
|
onClick: showPicker,
|
|
756
796
|
children: children
|
|
757
797
|
}), !state.hidden && /*#__PURE__*/jsxs(View, {
|
|
758
|
-
className:
|
|
798
|
+
className: classNames('taro-picker__overlay', `taro-picker__overlay--theme-${theme}`),
|
|
759
799
|
children: [/*#__PURE__*/jsx(View, {
|
|
760
800
|
className: clsMask,
|
|
801
|
+
style: maskOverlayStyle,
|
|
761
802
|
onClick: handleCancel
|
|
762
803
|
}), /*#__PURE__*/jsxs(View, {
|
|
763
804
|
className: clsSlider,
|