@mpxjs/webpack-plugin 2.10.14-beta.6 → 2.10.14-beta.7

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 (177) hide show
  1. package/lib/platform/template/wx/component-config/button.js +12 -3
  2. package/lib/runtime/components/react/dist/context.d.ts +3 -5
  3. package/lib/runtime/components/react/dist/context.d.ts.map +1 -0
  4. package/lib/runtime/components/react/dist/context.js +1 -1
  5. package/lib/runtime/components/react/dist/event.config.d.ts +1 -0
  6. package/lib/runtime/components/react/dist/event.config.d.ts.map +1 -0
  7. package/lib/runtime/components/react/dist/getInnerListeners.d.ts +1 -0
  8. package/lib/runtime/components/react/dist/getInnerListeners.d.ts.map +1 -0
  9. package/lib/runtime/components/react/dist/getInnerListeners.js +35 -21
  10. package/lib/runtime/components/react/dist/mpx-async-suspense.d.ts +1 -0
  11. package/lib/runtime/components/react/dist/mpx-async-suspense.d.ts.map +1 -0
  12. package/lib/runtime/components/react/dist/mpx-async-suspense.jsx +2 -2
  13. package/lib/runtime/components/react/dist/mpx-button.d.ts +1 -0
  14. package/lib/runtime/components/react/dist/mpx-button.d.ts.map +1 -0
  15. package/lib/runtime/components/react/dist/mpx-camera.d.ts +27 -0
  16. package/lib/runtime/components/react/dist/mpx-camera.d.ts.map +1 -0
  17. package/lib/runtime/components/react/dist/mpx-camera.jsx +197 -0
  18. package/lib/runtime/components/react/dist/mpx-canvas/Bus.d.ts +1 -0
  19. package/lib/runtime/components/react/dist/mpx-canvas/Bus.d.ts.map +1 -0
  20. package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.d.ts +1 -0
  21. package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.d.ts.map +1 -0
  22. package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.d.ts +1 -0
  23. package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.d.ts.map +1 -0
  24. package/lib/runtime/components/react/dist/mpx-canvas/Image.d.ts +1 -0
  25. package/lib/runtime/components/react/dist/mpx-canvas/Image.d.ts.map +1 -0
  26. package/lib/runtime/components/react/dist/mpx-canvas/ImageData.d.ts +1 -0
  27. package/lib/runtime/components/react/dist/mpx-canvas/ImageData.d.ts.map +1 -0
  28. package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.d.ts +1 -0
  29. package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.d.ts.map +1 -0
  30. package/lib/runtime/components/react/dist/mpx-canvas/html.d.ts +1 -0
  31. package/lib/runtime/components/react/dist/mpx-canvas/html.d.ts.map +1 -0
  32. package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts +1 -0
  33. package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts.map +1 -0
  34. package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts +1 -0
  35. package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts.map +1 -0
  36. package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts +1 -0
  37. package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts.map +1 -0
  38. package/lib/runtime/components/react/dist/mpx-checkbox.d.ts +1 -0
  39. package/lib/runtime/components/react/dist/mpx-checkbox.d.ts.map +1 -0
  40. package/lib/runtime/components/react/dist/mpx-form.d.ts +1 -0
  41. package/lib/runtime/components/react/dist/mpx-form.d.ts.map +1 -0
  42. package/lib/runtime/components/react/dist/mpx-icon/index.d.ts +1 -0
  43. package/lib/runtime/components/react/dist/mpx-icon/index.d.ts.map +1 -0
  44. package/lib/runtime/components/react/dist/mpx-image.d.ts +1 -0
  45. package/lib/runtime/components/react/dist/mpx-image.d.ts.map +1 -0
  46. package/lib/runtime/components/react/dist/mpx-image.jsx +81 -37
  47. package/lib/runtime/components/react/dist/mpx-inline-text.d.ts +1 -0
  48. package/lib/runtime/components/react/dist/mpx-inline-text.d.ts.map +1 -0
  49. package/lib/runtime/components/react/dist/mpx-input.d.ts +2 -0
  50. package/lib/runtime/components/react/dist/mpx-input.d.ts.map +1 -0
  51. package/lib/runtime/components/react/dist/mpx-input.jsx +19 -12
  52. package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.d.ts +1 -0
  53. package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.d.ts.map +1 -0
  54. package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.jsx +12 -21
  55. package/lib/runtime/components/react/dist/mpx-label.d.ts +1 -0
  56. package/lib/runtime/components/react/dist/mpx-label.d.ts.map +1 -0
  57. package/lib/runtime/components/react/dist/mpx-movable-area.d.ts +1 -0
  58. package/lib/runtime/components/react/dist/mpx-movable-area.d.ts.map +1 -0
  59. package/lib/runtime/components/react/dist/mpx-movable-view.d.ts +5 -2
  60. package/lib/runtime/components/react/dist/mpx-movable-view.d.ts.map +1 -0
  61. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +102 -34
  62. package/lib/runtime/components/react/dist/{nav.d.ts → mpx-nav.d.ts} +1 -0
  63. package/lib/runtime/components/react/dist/mpx-nav.d.ts.map +1 -0
  64. package/lib/runtime/components/react/dist/{nav.jsx → mpx-nav.jsx} +1 -6
  65. package/lib/runtime/components/react/dist/mpx-navigator.d.ts +1 -0
  66. package/lib/runtime/components/react/dist/mpx-navigator.d.ts.map +1 -0
  67. package/lib/runtime/components/react/dist/mpx-picker/date.d.ts +1 -0
  68. package/lib/runtime/components/react/dist/mpx-picker/date.d.ts.map +1 -0
  69. package/lib/runtime/components/react/dist/mpx-picker/dateData.d.ts +1 -0
  70. package/lib/runtime/components/react/dist/mpx-picker/dateData.d.ts.map +1 -0
  71. package/lib/runtime/components/react/dist/mpx-picker/index.d.ts +1 -0
  72. package/lib/runtime/components/react/dist/mpx-picker/index.d.ts.map +1 -0
  73. package/lib/runtime/components/react/dist/mpx-picker/multiSelector.d.ts +1 -0
  74. package/lib/runtime/components/react/dist/mpx-picker/multiSelector.d.ts.map +1 -0
  75. package/lib/runtime/components/react/dist/mpx-picker/region.d.ts +1 -0
  76. package/lib/runtime/components/react/dist/mpx-picker/region.d.ts.map +1 -0
  77. package/lib/runtime/components/react/dist/mpx-picker/regionData.d.ts +1 -0
  78. package/lib/runtime/components/react/dist/mpx-picker/regionData.d.ts.map +1 -0
  79. package/lib/runtime/components/react/dist/mpx-picker/selector.d.ts +1 -0
  80. package/lib/runtime/components/react/dist/mpx-picker/selector.d.ts.map +1 -0
  81. package/lib/runtime/components/react/dist/mpx-picker/time.d.ts +1 -0
  82. package/lib/runtime/components/react/dist/mpx-picker/time.d.ts.map +1 -0
  83. package/lib/runtime/components/react/dist/mpx-picker/type.d.ts +1 -0
  84. package/lib/runtime/components/react/dist/mpx-picker/type.d.ts.map +1 -0
  85. package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts +2 -0
  86. package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts.map +1 -0
  87. package/lib/runtime/components/react/dist/mpx-picker-view/index.jsx +4 -3
  88. package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts +1 -0
  89. package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts.map +1 -0
  90. package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts +2 -0
  91. package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts.map +1 -0
  92. package/lib/runtime/components/react/dist/mpx-picker-view-column/index.jsx +15 -21
  93. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts +1 -0
  94. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts.map +1 -0
  95. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.jsx +8 -11
  96. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts +14 -0
  97. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts.map +1 -0
  98. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.jsx +20 -0
  99. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewFaces.d.ts +1 -0
  100. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewFaces.d.ts.map +1 -0
  101. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewIndicator.d.ts +1 -0
  102. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewIndicator.d.ts.map +1 -0
  103. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewMask.d.ts +1 -0
  104. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewMask.d.ts.map +1 -0
  105. package/lib/runtime/components/react/dist/mpx-popup/index.d.ts +1 -0
  106. package/lib/runtime/components/react/dist/mpx-popup/index.d.ts.map +1 -0
  107. package/lib/runtime/components/react/dist/mpx-popup/popupBase.d.ts +1 -0
  108. package/lib/runtime/components/react/dist/mpx-popup/popupBase.d.ts.map +1 -0
  109. package/lib/runtime/components/react/dist/mpx-portal/index.d.ts +1 -0
  110. package/lib/runtime/components/react/dist/mpx-portal/index.d.ts.map +1 -0
  111. package/lib/runtime/components/react/dist/mpx-portal/index.jsx +5 -1
  112. package/lib/runtime/components/react/dist/mpx-portal/portal-host.d.ts +1 -0
  113. package/lib/runtime/components/react/dist/mpx-portal/portal-host.d.ts.map +1 -0
  114. package/lib/runtime/components/react/dist/mpx-portal/portal-manager.d.ts +1 -0
  115. package/lib/runtime/components/react/dist/mpx-portal/portal-manager.d.ts.map +1 -0
  116. package/lib/runtime/components/react/dist/mpx-portal/portal-manager.jsx +3 -5
  117. package/lib/runtime/components/react/dist/mpx-progress.d.ts +24 -0
  118. package/lib/runtime/components/react/dist/mpx-progress.d.ts.map +1 -0
  119. package/lib/runtime/components/react/dist/mpx-progress.jsx +163 -0
  120. package/lib/runtime/components/react/dist/mpx-radio-group.d.ts +1 -0
  121. package/lib/runtime/components/react/dist/mpx-radio-group.d.ts.map +1 -0
  122. package/lib/runtime/components/react/dist/mpx-radio.d.ts +1 -0
  123. package/lib/runtime/components/react/dist/mpx-radio.d.ts.map +1 -0
  124. package/lib/runtime/components/react/dist/mpx-rich-text/html.d.ts +1 -0
  125. package/lib/runtime/components/react/dist/mpx-rich-text/html.d.ts.map +1 -0
  126. package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts +1 -0
  127. package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts.map +1 -0
  128. package/lib/runtime/components/react/dist/mpx-root-portal.d.ts +1 -0
  129. package/lib/runtime/components/react/dist/mpx-root-portal.d.ts.map +1 -0
  130. package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts +1 -0
  131. package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts.map +1 -0
  132. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +69 -51
  133. package/lib/runtime/components/react/dist/mpx-simple-text.d.ts +1 -0
  134. package/lib/runtime/components/react/dist/mpx-simple-text.d.ts.map +1 -0
  135. package/lib/runtime/components/react/dist/mpx-simple-view.d.ts +1 -0
  136. package/lib/runtime/components/react/dist/mpx-simple-view.d.ts.map +1 -0
  137. package/lib/runtime/components/react/dist/mpx-slider.d.ts +31 -0
  138. package/lib/runtime/components/react/dist/mpx-slider.d.ts.map +1 -0
  139. package/lib/runtime/components/react/dist/mpx-slider.jsx +321 -0
  140. package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts +1 -0
  141. package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts.map +1 -0
  142. package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts +1 -0
  143. package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts.map +1 -0
  144. package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts +1 -0
  145. package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts.map +1 -0
  146. package/lib/runtime/components/react/dist/mpx-swiper.d.ts +1 -0
  147. package/lib/runtime/components/react/dist/mpx-swiper.d.ts.map +1 -0
  148. package/lib/runtime/components/react/dist/mpx-swiper.jsx +9 -16
  149. package/lib/runtime/components/react/dist/mpx-switch.d.ts +1 -0
  150. package/lib/runtime/components/react/dist/mpx-switch.d.ts.map +1 -0
  151. package/lib/runtime/components/react/dist/mpx-text.d.ts +3 -1
  152. package/lib/runtime/components/react/dist/mpx-text.d.ts.map +1 -0
  153. package/lib/runtime/components/react/dist/mpx-text.jsx +33 -5
  154. package/lib/runtime/components/react/dist/mpx-textarea.d.ts +1 -0
  155. package/lib/runtime/components/react/dist/mpx-textarea.d.ts.map +1 -0
  156. package/lib/runtime/components/react/dist/mpx-video.d.ts +1 -0
  157. package/lib/runtime/components/react/dist/mpx-video.d.ts.map +1 -0
  158. package/lib/runtime/components/react/dist/mpx-view.d.ts +1 -0
  159. package/lib/runtime/components/react/dist/mpx-view.d.ts.map +1 -0
  160. package/lib/runtime/components/react/dist/mpx-view.jsx +1 -1
  161. package/lib/runtime/components/react/dist/mpx-web-view.d.ts +1 -0
  162. package/lib/runtime/components/react/dist/mpx-web-view.d.ts.map +1 -0
  163. package/lib/runtime/components/react/dist/mpx-web-view.jsx +21 -2
  164. package/lib/runtime/components/react/dist/parser.d.ts +1 -0
  165. package/lib/runtime/components/react/dist/parser.d.ts.map +1 -0
  166. package/lib/runtime/components/react/dist/useAnimationHooks.d.ts +1 -0
  167. package/lib/runtime/components/react/dist/useAnimationHooks.d.ts.map +1 -0
  168. package/lib/runtime/components/react/dist/useNodesRef.d.ts +1 -0
  169. package/lib/runtime/components/react/dist/useNodesRef.d.ts.map +1 -0
  170. package/lib/runtime/components/react/dist/utils.d.ts +1 -0
  171. package/lib/runtime/components/react/dist/utils.d.ts.map +1 -0
  172. package/lib/runtime/components/react/dist/utils.jsx +16 -6
  173. package/package.json +1 -1
  174. package/lib/runtime/components/react/dist/mpx-nav-container.d.ts +0 -9
  175. package/lib/runtime/components/react/dist/mpx-nav-container.jsx +0 -23
  176. package/lib/runtime/components/react/dist/useNavShared.d.ts +0 -2
  177. package/lib/runtime/components/react/dist/useNavShared.js +0 -6
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mpx-slider.d.ts","source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M,uHAqXV,CAAA;AAGF,eAAe,MAAM,CAAA"}
@@ -0,0 +1,321 @@
1
+ /**
2
+ * ✔ min 最小值
3
+ * ✔ max 最大值
4
+ * ✔ step 步长
5
+ * ✔ disabled 是否禁用
6
+ * ✔ value 当前取值
7
+ * ✔ color 背景条的颜色(已废弃,使用 backgroundColor)
8
+ * ✔ selected-color 已选择的颜色(已废弃,使用 activeColor)
9
+ * ✔ activeColor 已选择的颜色
10
+ * ✔ backgroundColor 背景条的颜色
11
+ * ✔ block-size 滑块的大小
12
+ * ✔ block-color 滑块的颜色
13
+ * ✘ show-value 是否显示当前 value
14
+ * ✔ bindchange 完成一次拖动后触发的事件
15
+ * ✔ bindchanging 拖动过程中触发的事件
16
+ */
17
+ import { useRef, forwardRef, useEffect, useState, createElement, useContext, useMemo } from 'react';
18
+ import { View } from 'react-native';
19
+ import { GestureDetector, Gesture } from 'react-native-gesture-handler';
20
+ import Animated, { useSharedValue, useAnimatedStyle, runOnJS } from 'react-native-reanimated';
21
+ import { warn } from '@mpxjs/utils';
22
+ import useInnerProps, { getCustomEvent } from './getInnerListeners';
23
+ import useNodesRef from './useNodesRef';
24
+ import { useLayout, useTransformStyle, extendObject, useRunOnJSCallback } from './utils';
25
+ import Portal from './mpx-portal';
26
+ import { FormContext } from './context';
27
+ const Slider = forwardRef((props, ref) => {
28
+ const { min: rawMin = 0, max: rawMax = 100, step: rawStep = 1, disabled = false, value: rawValue, color, 'selected-color': selectedColor, activeColor = selectedColor || color || '#1aad19', backgroundColor = color || '#e9e9e9', 'block-size': rawBlockSize = 28, 'block-color': blockColor = '#ffffff', name, style = {}, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
29
+ // 确保数值类型正确
30
+ const min = typeof rawMin === 'string' ? parseFloat(rawMin) : rawMin;
31
+ const max = typeof rawMax === 'string' ? parseFloat(rawMax) : rawMax;
32
+ const step = typeof rawStep === 'string' ? parseFloat(rawStep) : rawStep;
33
+ const value = rawValue !== undefined ? (typeof rawValue === 'string' ? parseFloat(rawValue) : rawValue) : undefined;
34
+ const blockSize = typeof rawBlockSize === 'string' ? parseFloat(rawBlockSize) : rawBlockSize;
35
+ // 如果没有提供 value,则使用 min 作为默认值
36
+ const defaultValue = value !== undefined ? value : min;
37
+ const nodeRef = useRef(null);
38
+ const trackRef = useRef(null);
39
+ const [currentValue, setCurrentValue] = useState(defaultValue);
40
+ const [trackWidth, setTrackWidth] = useState(0);
41
+ const thumbPosition = useSharedValue(0);
42
+ const isDragging = useSharedValue(false);
43
+ const startDragPosition = useSharedValue(0); // 记录拖拽开始时的位置
44
+ const startDragValue = useSharedValue(0); // 记录拖拽开始时的值
45
+ let formValuesMap;
46
+ const propsRef = useRef(props);
47
+ propsRef.current = props;
48
+ const formContext = useContext(FormContext);
49
+ if (formContext) {
50
+ formValuesMap = formContext.formValuesMap;
51
+ }
52
+ const { normalStyle, hasSelfPercent, setWidth, setHeight, hasPositionFixed } = useTransformStyle(style, {
53
+ enableVar,
54
+ externalVarContext,
55
+ parentFontSize,
56
+ parentWidth,
57
+ parentHeight
58
+ });
59
+ const { layoutRef, layoutStyle, layoutProps } = useLayout({
60
+ props,
61
+ hasSelfPercent,
62
+ setWidth,
63
+ setHeight,
64
+ nodeRef
65
+ });
66
+ useNodesRef(props, ref, nodeRef, {
67
+ style: normalStyle
68
+ });
69
+ // 使用 useRunOnJSCallback 处理手势回调
70
+ const runOnJSCallbackRef = useRef({
71
+ triggerChangeEvent: (newValue) => {
72
+ setCurrentValue(newValue);
73
+ const currentProps = propsRef.current;
74
+ const changeHandler = currentProps.bindchange || currentProps.catchchange;
75
+ if (changeHandler) {
76
+ changeHandler(getCustomEvent('change', {}, { layoutRef, detail: { value: newValue } }, currentProps));
77
+ }
78
+ },
79
+ triggerChangingEvent: (newValue) => {
80
+ const currentProps = propsRef.current;
81
+ const changingHandler = currentProps.bindchanging || currentProps.catchchanging;
82
+ if (changingHandler) {
83
+ changingHandler(getCustomEvent('changing', {}, { layoutRef, detail: { value: newValue } }, currentProps));
84
+ }
85
+ }
86
+ });
87
+ const runOnJSCallback = useRunOnJSCallback(runOnJSCallbackRef);
88
+ // 限制步长,确保 step 大于 0,并且可被 (max - min) 整除
89
+ const validateStep = (step, min, max) => {
90
+ if (step <= 0)
91
+ return 1;
92
+ if ((max - min) % step !== 0) {
93
+ warn(`Step ${step} is not a divisor of range ${max - min}`);
94
+ }
95
+ return step;
96
+ };
97
+ const validStep = validateStep(step, min, max);
98
+ // 将值约束在 min-max 范围内,并按步长对齐
99
+ const constrainValue = (val, minVal = min, maxVal = max, stepVal = validStep) => {
100
+ const constrained = Math.max(minVal, Math.min(maxVal, val));
101
+ const steps = Math.round((constrained - minVal) / stepVal);
102
+ return minVal + steps * stepVal;
103
+ };
104
+ // 计算滑块位置
105
+ const getThumbPosition = (val, trackW = trackWidth, minVal = min, maxVal = max) => {
106
+ if (trackW === 0)
107
+ return 0;
108
+ const percentage = (val - minVal) / (maxVal - minVal);
109
+ const position = percentage * trackW;
110
+ return position;
111
+ };
112
+ // 手势处理
113
+ const panGesture = useMemo(() => {
114
+ const getThumbPositionWorklet = (val, trackW, minVal, maxVal) => {
115
+ 'worklet';
116
+ if (trackW === 0)
117
+ return 0;
118
+ const percentage = (val - minVal) / (maxVal - minVal);
119
+ return percentage * trackW;
120
+ };
121
+ const constrainValueWorklet = (val, minVal, maxVal, stepVal) => {
122
+ 'worklet';
123
+ const constrained = Math.max(minVal, Math.min(maxVal, val));
124
+ const steps = Math.round((constrained - minVal) / stepVal);
125
+ return minVal + steps * stepVal;
126
+ };
127
+ return Gesture.Pan()
128
+ .enabled(!disabled) // 通过手势启用状态控制是否可拖拽
129
+ .onBegin(() => {
130
+ 'worklet';
131
+ if (trackWidth === 0)
132
+ return;
133
+ isDragging.value = true;
134
+ // 记录拖拽开始时的位置 - 使用当前的动画位置
135
+ startDragPosition.value = thumbPosition.value;
136
+ // 根据当前位置反推值
137
+ const percentage = thumbPosition.value / trackWidth;
138
+ const currentVal = min + percentage * (max - min);
139
+ startDragValue.value = constrainValueWorklet(currentVal, min, max, validStep);
140
+ })
141
+ .onUpdate((event) => {
142
+ 'worklet';
143
+ if (trackWidth === 0)
144
+ return;
145
+ // 基于拖拽开始位置计算新位置
146
+ const newX = startDragPosition.value + event.translationX;
147
+ const clampedX = Math.max(0, Math.min(trackWidth, newX));
148
+ // 计算新值
149
+ const percentage = clampedX / trackWidth;
150
+ const rawValue = min + percentage * (max - min);
151
+ const newValue = constrainValueWorklet(rawValue, min, max, validStep);
152
+ // 更新滑块位置 - 使用约束后的值对应的位置
153
+ const constrainedPosition = getThumbPositionWorklet(newValue, trackWidth, min, max);
154
+ thumbPosition.value = constrainedPosition;
155
+ // 只触发 changing 事件,不更新 currentValue(避免干扰拖拽)
156
+ runOnJS(runOnJSCallback)('triggerChangingEvent', newValue);
157
+ })
158
+ .onEnd((event) => {
159
+ 'worklet';
160
+ isDragging.value = false;
161
+ // 基于拖拽开始位置计算最终位置
162
+ const newX = startDragPosition.value + event.translationX;
163
+ const clampedX = Math.max(0, Math.min(trackWidth, newX));
164
+ const percentage = clampedX / trackWidth;
165
+ const rawValue = min + percentage * (max - min);
166
+ const finalValue = constrainValueWorklet(rawValue, min, max, validStep);
167
+ // 确保滑块位置与最终值匹配
168
+ const finalPosition = getThumbPositionWorklet(finalValue, trackWidth, min, max);
169
+ thumbPosition.value = finalPosition;
170
+ // 更新 currentValue 并触发 change 事件
171
+ runOnJS(runOnJSCallback)('triggerChangeEvent', finalValue);
172
+ });
173
+ }, [disabled, trackWidth, min, max, validStep, runOnJSCallback]);
174
+ // 当 value 属性变化时更新位置
175
+ useEffect(() => {
176
+ const newValue = constrainValue(defaultValue);
177
+ setCurrentValue(newValue);
178
+ // 同时更新动画位置
179
+ thumbPosition.value = getThumbPosition(newValue);
180
+ }, [defaultValue, min, max, validStep]);
181
+ // 当 trackWidth 变化时更新滑块位置
182
+ useEffect(() => {
183
+ // 只在非拖拽状态下更新位置
184
+ if (!isDragging.value) {
185
+ thumbPosition.value = getThumbPosition(currentValue);
186
+ }
187
+ }, [trackWidth, currentValue]);
188
+ // 动画样式
189
+ const animatedThumbStyle = useAnimatedStyle(() => {
190
+ const blockSizeNum = Math.max(12, Math.min(28, blockSize));
191
+ const trackHeight = 4;
192
+ return {
193
+ position: 'absolute',
194
+ top: -((blockSizeNum - trackHeight) / 2),
195
+ left: Math.max(0, Math.min(trackWidth - blockSizeNum, thumbPosition.value - (blockSizeNum / 2))),
196
+ width: blockSizeNum,
197
+ height: blockSizeNum,
198
+ justifyContent: 'center',
199
+ alignItems: 'center'
200
+ };
201
+ });
202
+ // 轨道布局回调
203
+ const onTrackLayout = (event) => {
204
+ const { width } = event.nativeEvent.layout;
205
+ setTrackWidth(width);
206
+ };
207
+ // 表单相关处理
208
+ const resetValue = () => {
209
+ const currentProps = propsRef.current;
210
+ const currentValue = currentProps.value !== undefined ? currentProps.value : currentProps.min || 0;
211
+ const parsedValue = typeof currentValue === 'string' ? parseFloat(currentValue) : currentValue;
212
+ const currentMin = typeof currentProps.min === 'string' ? parseFloat(currentProps.min) : (currentProps.min || 0);
213
+ const currentMax = typeof currentProps.max === 'string' ? parseFloat(currentProps.max) : (currentProps.max || 100);
214
+ const currentStep = typeof currentProps.step === 'string' ? parseFloat(currentProps.step) : (currentProps.step || 1);
215
+ const resetVal = parsedValue !== undefined ? parsedValue : currentMin;
216
+ const validatedStep = validateStep(currentStep, currentMin, currentMax);
217
+ const constrainedVal = constrainValue(resetVal, currentMin, currentMax, validatedStep);
218
+ setCurrentValue(constrainedVal);
219
+ thumbPosition.value = getThumbPosition(constrainedVal, trackWidth, currentMin, currentMax);
220
+ };
221
+ const getValue = () => {
222
+ return currentValue;
223
+ };
224
+ if (formValuesMap) {
225
+ if (!name) {
226
+ warn('If a form component is used, the name attribute is required.');
227
+ }
228
+ else {
229
+ formValuesMap.set(name, { getValue, resetValue });
230
+ }
231
+ }
232
+ useEffect(() => {
233
+ return () => {
234
+ if (formValuesMap && name) {
235
+ formValuesMap.delete(name);
236
+ }
237
+ };
238
+ }, []);
239
+ // 样式定义
240
+ const blockSizeNum = Math.max(12, Math.min(28, blockSize));
241
+ const trackHeight = 4;
242
+ const containerStyle = extendObject({}, {
243
+ flexDirection: 'row',
244
+ alignItems: 'center',
245
+ minHeight: Math.max(blockSizeNum + 8, 40),
246
+ paddingHorizontal: 14 // 固定内边距,不受 block-size 影响
247
+ }, normalStyle, layoutStyle);
248
+ const trackStyle = {
249
+ flex: 1,
250
+ height: trackHeight,
251
+ backgroundColor,
252
+ borderRadius: trackHeight / 2,
253
+ position: 'relative'
254
+ };
255
+ // 动画进度条样式
256
+ const animatedProgressStyle = useAnimatedStyle(() => {
257
+ return {
258
+ height: '100%',
259
+ backgroundColor: activeColor,
260
+ borderRadius: trackHeight / 2,
261
+ width: Math.max(0, thumbPosition.value)
262
+ };
263
+ });
264
+ const thumbStyle = {
265
+ width: blockSizeNum,
266
+ height: blockSizeNum,
267
+ backgroundColor: blockColor,
268
+ borderRadius: blockSizeNum / 2,
269
+ shadowColor: '#000',
270
+ shadowOffset: { width: 0, height: 2 },
271
+ shadowOpacity: 0.2,
272
+ shadowRadius: 4,
273
+ elevation: 4
274
+ };
275
+ const innerProps = useInnerProps(extendObject({}, props, layoutProps, {
276
+ ref: nodeRef
277
+ }), [
278
+ 'min',
279
+ 'max',
280
+ 'step',
281
+ 'disabled',
282
+ 'value',
283
+ 'color',
284
+ 'selected-color',
285
+ 'activeColor',
286
+ 'backgroundColor',
287
+ 'block-size',
288
+ 'block-color',
289
+ 'bindchange',
290
+ 'catchchange',
291
+ 'bindchanging',
292
+ 'catchchanging'
293
+ ], { layoutRef });
294
+ const sliderContent = createElement(View, extendObject({}, innerProps, { style: containerStyle }),
295
+ // 轨道容器
296
+ createElement(View, {
297
+ style: trackStyle,
298
+ onLayout: onTrackLayout,
299
+ ref: trackRef
300
+ },
301
+ // 进度条 - 使用动画样式
302
+ createElement(Animated.View, {
303
+ style: animatedProgressStyle
304
+ }),
305
+ // 滑块容器
306
+ createElement(GestureDetector, {
307
+ gesture: panGesture
308
+ }, createElement(Animated.View, {
309
+ style: [animatedThumbStyle]
310
+ },
311
+ // 滑块
312
+ createElement(View, {
313
+ style: thumbStyle
314
+ })))));
315
+ if (hasPositionFixed) {
316
+ return createElement(Portal, null, sliderContent);
317
+ }
318
+ return sliderContent;
319
+ });
320
+ Slider.displayName = 'MpxSlider';
321
+ export default Slider;
@@ -15,3 +15,4 @@ interface StickyHeaderProps {
15
15
  }
16
16
  declare const _StickyHeader: import("react").ForwardRefExoticComponent<StickyHeaderProps & import("react").RefAttributes<HandlerRef<View, StickyHeaderProps>>>;
17
17
  export default _StickyHeader;
18
+ //# sourceMappingURL=mpx-sticky-header.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mpx-sticky-header.d.ts","sourceRoot":"","sources":["../mpx-sticky-header.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAqE,SAAS,EAAS,MAAM,OAAO,CAAA;AAC3G,OAAO,EAAwB,IAAI,EAAE,oBAAoB,EAAE,SAAS,EAAuC,MAAM,cAAc,CAAA;AAE/H,OAAoB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAKvD,UAAU,iBAAiB;IACzB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,sBAAsB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC7C,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,oBAAoB,CAAC,EAAE,CAAC,CAAC,EAAE,oBAAoB,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC;CACnE;AAED,QAAA,MAAM,aAAa,mIAmJjB,CAAA;AAYF,eAAe,aAAa,CAAA"}
@@ -13,3 +13,4 @@ interface StickySectionProps {
13
13
  }
14
14
  declare const _StickySection: import("react").ForwardRefExoticComponent<StickySectionProps & import("react").RefAttributes<HandlerRef<View, StickySectionProps>>>;
15
15
  export default _StickySection;
16
+ //# sourceMappingURL=mpx-sticky-section.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mpx-sticky-section.d.ts","sourceRoot":"","sources":["../mpx-sticky-section.tsx"],"names":[],"mappings":"AACA,OAAO,EAAqC,SAAS,EAAwB,MAAM,OAAO,CAAA;AAC1F,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAoB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAKvD,UAAU,kBAAkB;IAC1B,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,sBAAsB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC7C,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,QAAA,MAAM,cAAc,qIAyElB,CAAA;AAGF,eAAe,cAAc,CAAA"}
@@ -16,3 +16,4 @@ interface SwiperItemProps {
16
16
  }
17
17
  declare const _SwiperItem: import("react").ForwardRefExoticComponent<SwiperItemProps & import("react").RefAttributes<HandlerRef<View, SwiperItemProps>>>;
18
18
  export default _SwiperItem;
19
+ //# sourceMappingURL=mpx-swiper-item.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mpx-swiper-item.d.ts","sourceRoot":"","sources":["../mpx-swiper-item.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAEnC,OAAO,EAAE,SAAS,EAAiD,MAAM,OAAO,CAAA;AAEhF,OAAoB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAIvD,UAAU,eAAe;IACvB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,YAAY,EAAE,OAAO,CAAA;IACrB,sBAAsB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC5C,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;CAClB;AASD,QAAA,MAAM,WAAW,+HA8Ef,CAAA;AAIF,eAAe,WAAW,CAAA"}
@@ -50,3 +50,4 @@ interface SwiperProps {
50
50
  }
51
51
  declare const SwiperWrapper: React.ForwardRefExoticComponent<SwiperProps & React.RefAttributes<HandlerRef<View, SwiperProps>>>;
52
52
  export default SwiperWrapper;
53
+ //# sourceMappingURL=mpx-swiper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mpx-swiper.d.ts","sourceRoot":"","sources":["../mpx-swiper.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,oBAAoB,EAAqB,MAAM,cAAc,CAAA;AAI5E,OAAO,KAAK,EAAE,EAAsC,SAAS,EAAwC,MAAM,OAAO,CAAA;AAElH,OAAoB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AACvD,OAAO,EAAoF,cAAc,EAAmC,MAAM,SAAS,CAAA;AAG3J;;;;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;AAoED,QAAA,MAAM,aAAa,mGA6uBjB,CAAA;AAGF,eAAe,aAAa,CAAA"}
@@ -120,8 +120,6 @@ const SwiperWrapper = forwardRef((props, ref) => {
120
120
  const strVelocity = 'velocity' + dir.toUpperCase();
121
121
  // 标识手指触摸和抬起, 起点在onBegin
122
122
  const touchfinish = useSharedValue(true);
123
- // 记录onUpdate时的方向,用于进行onFinalize中的值修正
124
- const preUpdateTransDir = useSharedValue(0);
125
123
  // 记录上一帧的绝对定位坐标
126
124
  const preAbsolutePos = useSharedValue(0);
127
125
  // 记录从onBegin 到 onTouchesUp 时移动的距离
@@ -327,9 +325,11 @@ const SwiperWrapper = forwardRef((props, ref) => {
327
325
  resumeLoop
328
326
  };
329
327
  }, []);
330
- function handleSwiperChange(current) {
331
- const eventData = getCustomEvent('change', {}, { detail: { current, source: 'touch' }, layoutRef: layoutRef });
332
- bindchange && bindchange(eventData);
328
+ function handleSwiperChange(current, pCurrent) {
329
+ if (pCurrent !== currentIndex.value) {
330
+ const eventData = getCustomEvent('change', {}, { detail: { current, source: 'touch' }, layoutRef: layoutRef });
331
+ bindchange && bindchange(eventData);
332
+ }
333
333
  }
334
334
  const runOnJSCallbackRef = useRef({
335
335
  loop,
@@ -379,7 +379,7 @@ const SwiperWrapper = forwardRef((props, ref) => {
379
379
  // 1. 用户在当前页切换选中项,动画;用户携带选中index打开到swiper页直接选中不走动画
380
380
  useAnimatedReaction(() => currentIndex.value, (newIndex, preIndex) => {
381
381
  // 这里必须传递函数名, 直接写()=> {}形式会报 访问了未sharedValue信息
382
- if (newIndex !== preIndex && preIndex !== null && preIndex !== undefined && bindchange) {
382
+ if (newIndex !== preIndex && bindchange) {
383
383
  runOnJS(runOnJSCallback)('handleSwiperChange', newIndex, propCurrent);
384
384
  }
385
385
  });
@@ -411,9 +411,9 @@ const SwiperWrapper = forwardRef((props, ref) => {
411
411
  }
412
412
  }, [children.length]);
413
413
  useEffect(() => {
414
- // 1. 如果用户在touch的过程中, 外部更新了current以内部为准(小程序表现)
414
+ // 1. 如果用户在touch的过程中, 外部更新了current以外部为准(小程序表现)
415
415
  // 2. 手指滑动过程中更新索引,外部会把current再传入进来,导致offset直接更新,增加判断不同才更新
416
- if (propCurrent !== currentIndex.value && touchfinish.value) {
416
+ if (propCurrent !== currentIndex.value) {
417
417
  updateCurrent(propCurrent, step.value);
418
418
  }
419
419
  }, [propCurrent]);
@@ -662,7 +662,6 @@ const SwiperWrapper = forwardRef((props, ref) => {
662
662
  translation: moveDistance,
663
663
  transdir: moveDistance
664
664
  };
665
- preUpdateTransDir.value = moveDistance;
666
665
  // 1. 支持滑动中超出一半更新索引的能力:只更新索引并不会影响onFinalize依据当前offset计算的索引
667
666
  const { half } = computeHalf(eventData);
668
667
  if (childrenLength.value > 1 && half) {
@@ -703,17 +702,11 @@ const SwiperWrapper = forwardRef((props, ref) => {
703
702
  if (touchfinish.value)
704
703
  return;
705
704
  touchfinish.value = true;
706
- /**
707
- * 安卓修正
708
- * 问题:部分安卓机型onFinalize中拿到的absoluteX 有问题
709
- * 案例:比如手指从右向左滑的时候,onUpdate拿到的是241.64346313476562, 而onFinalize中拿到的是241.81817626953125,理论上onFinalize中应该比onUpdate小才对吧
710
- * 解决方式:修正
711
- */
712
705
  // 触发过onUpdate正常情况下e[strAbso] - preAbsolutePos.value=0; 未触发过onUpdate的情况下e[strAbso] - preAbsolutePos.value 不为0
713
706
  const moveDistance = e[strAbso] - preAbsolutePos.value;
714
707
  const eventData = {
715
708
  translation: moveDistance,
716
- transdir: Math.abs(moveDistance) > 1 ? moveDistance : preUpdateTransDir.value
709
+ transdir: moveDistance !== 0 ? moveDistance : e[strAbso] - moveTranstion.value
717
710
  };
718
711
  // 1. 只有一个元素:循环 和 非循环状态,都走回弹效果
719
712
  if (childrenLength.value === 1) {
@@ -24,3 +24,4 @@ interface _SwitchProps extends SwitchProps {
24
24
  }
25
25
  declare const _Switch: import("react").ForwardRefExoticComponent<_SwitchProps & import("react").RefAttributes<HandlerRef<Switch, _SwitchProps>>>;
26
26
  export default _Switch;
27
+ //# sourceMappingURL=mpx-switch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mpx-switch.d.ts","sourceRoot":"","sources":["../mpx-switch.tsx"],"names":[],"mappings":";AAAA;;;;;GAKG;AACH,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAGnF,OAAoB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAQvD,UAAU,YAAa,SAAQ,WAAW;IACxC,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,IAAI,EAAE,QAAQ,GAAG,UAAU,CAAA;IAC3B,QAAQ,EAAE,OAAO,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,sBAAsB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC5C,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,CAAC,UAAU,CAAC,GAAG,OAAO,KAAK,IAAI,CAAA;IACxE,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,CAAC,UAAU,CAAC,GAAG,OAAO,KAAK,IAAI,CAAA;CAC1E;AAED,QAAA,MAAM,OAAO,2HA0IX,CAAA;AAIF,eAAe,OAAO,CAAA"}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * ✔ selectable
3
3
  * ✘ space
4
- * decode
4
+ * decode
5
5
  */
6
6
  import { Text, TextStyle, TextProps } from 'react-native';
7
7
  import { ReactNode } from 'react';
@@ -16,6 +16,8 @@ interface _TextProps extends TextProps {
16
16
  'parent-font-size'?: number;
17
17
  'parent-width'?: number;
18
18
  'parent-height'?: number;
19
+ decode?: boolean;
19
20
  }
20
21
  declare const _Text: import("react").ForwardRefExoticComponent<_TextProps & import("react").RefAttributes<HandlerRef<Text, _TextProps>>>;
21
22
  export default _Text;
23
+ //# sourceMappingURL=mpx-text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mpx-text.d.ts","sourceRoot":"","sources":["../mpx-text.tsx"],"names":[],"mappings":"AACA;;;;GAIG;AACH,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACzD,OAAO,EAAsB,SAAS,EAAgC,MAAM,OAAO,CAAA;AAGnF,OAAoB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AA6BvD,UAAU,UAAW,SAAQ,SAAS;IACpC,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,sBAAsB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC5C,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB;AAED,QAAA,MAAM,KAAK,qHAkET,CAAA;AAIF,eAAe,KAAK,CAAA"}
@@ -1,16 +1,40 @@
1
1
  /**
2
2
  * ✔ selectable
3
3
  * ✘ space
4
- * decode
4
+ * decode
5
5
  */
6
6
  import { Text } from 'react-native';
7
- import { useRef, forwardRef, createElement } from 'react';
7
+ import { useRef, forwardRef, createElement, Children } from 'react';
8
8
  import Portal from './mpx-portal';
9
9
  import useInnerProps from './getInnerListeners';
10
10
  import useNodesRef from './useNodesRef'; // 引入辅助函数
11
11
  import { useTransformStyle, wrapChildren, extendObject } from './utils';
12
+ const decodeMap = {
13
+ '&lt;': '<',
14
+ '&gt;': '>',
15
+ '&quot;': '"',
16
+ '&amp;': '&',
17
+ '&#39;': '\'',
18
+ '&nbsp;': ' '
19
+ };
20
+ const encodedRe = /&(?:lt|gt|quot|amp|#39|nbsp);/g;
21
+ function decode(value) {
22
+ if (value != null) {
23
+ return value.replace(encodedRe, function (match) {
24
+ return decodeMap[match];
25
+ });
26
+ }
27
+ }
28
+ function getDecodedChildren(children) {
29
+ return Children.map(children, (child) => {
30
+ if (typeof child === 'string') {
31
+ return decode(child);
32
+ }
33
+ return child;
34
+ });
35
+ }
12
36
  const _Text = forwardRef((props, ref) => {
13
- const { style = {}, allowFontScaling = false, selectable, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'user-select': userSelect, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
37
+ const { style = {}, allowFontScaling = false, selectable, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'user-select': userSelect, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, decode } = props;
14
38
  const { normalStyle, hasVarDec, varContextRef, hasPositionFixed } = useTransformStyle(style, {
15
39
  enableVar,
16
40
  externalVarContext,
@@ -28,9 +52,13 @@ const _Text = forwardRef((props, ref) => {
28
52
  selectable: !!selectable || !!userSelect,
29
53
  allowFontScaling
30
54
  }), [
31
- 'user-select'
55
+ 'user-select',
56
+ 'decode'
32
57
  ]);
33
- let finalComponent = createElement(Text, innerProps, wrapChildren(props, {
58
+ const children = decode ? getDecodedChildren(props.children) : props.children;
59
+ let finalComponent = createElement(Text, innerProps, wrapChildren(extendObject({}, props, {
60
+ children
61
+ }), {
34
62
  hasVarDec,
35
63
  varContext: varContextRef.current
36
64
  }));
@@ -5,3 +5,4 @@ import { HandlerRef } from './useNodesRef';
5
5
  export type TextareProps = Omit<InputProps & PrivateInputProps, 'type' | 'password' | 'multiline' | 'confirm-hold'>;
6
6
  declare const Textarea: import("react").ForwardRefExoticComponent<TextareProps & import("react").RefAttributes<HandlerRef<TextInput, TextareProps>>>;
7
7
  export default Textarea;
8
+ //# sourceMappingURL=mpx-textarea.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mpx-textarea.d.ts","sourceRoot":"","sources":["../mpx-textarea.tsx"],"names":[],"mappings":";AAYA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAc,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAElE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAE1C,MAAM,MAAM,YAAY,GAAG,IAAI,CAC7B,UAAU,GAAG,iBAAiB,EAC9B,MAAM,GAAG,UAAU,GAAG,WAAW,GAAG,cAAc,CACnD,CAAA;AAKD,QAAA,MAAM,QAAQ,8HA+Bb,CAAA;AAID,eAAe,QAAQ,CAAA"}
@@ -99,3 +99,4 @@ interface VideoProps {
99
99
  }
100
100
  declare const MpxVideo: import("react").ForwardRefExoticComponent<VideoProps & import("react").RefAttributes<HandlerRef<View, VideoProps>>>;
101
101
  export default MpxVideo;
102
+ //# sourceMappingURL=mpx-video.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mpx-video.d.ts","sourceRoot":"","sources":["../mpx-video.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DG;;AAIH,OAAO,EAAc,IAAI,EAAY,SAAS,EAAE,MAAM,cAAc,CAAA;AAQpE,OAAoB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAGvD,UAAU,UAAU;IAClB,GAAG,EAAE,MAAM,CAAA;IACX,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,QAA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AA;IAClD,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,CAAA;IAChD,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,CAAA;IACzD,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,CAAA;IACzD,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,CAAA;CACxD;AAmBD,QAAA,MAAM,QAAQ,qHAuQZ,CAAA;AAEF,eAAe,QAAQ,CAAA"}
@@ -32,3 +32,4 @@ export interface _ViewProps extends ViewProps {
32
32
  }
33
33
  declare const _View: import("react").ForwardRefExoticComponent<_ViewProps & import("react").RefAttributes<HandlerRef<View, _ViewProps>>>;
34
34
  export default _View;
35
+ //# sourceMappingURL=mpx-view.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mpx-view.d.ts","sourceRoot":"","sources":["../mpx-view.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,IAAI,EAAa,oBAAoB,EAAE,SAAS,EAAoD,MAAM,cAAc,CAAA;AACjI,OAAO,EAA2C,SAAS,EAAsB,MAAM,OAAO,CAAA;AAI9F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAClD,OAAoB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAOvD,MAAM,WAAW,UAAW,SAAQ,SAAS;IAC3C,KAAK,CAAC,EAAE,iBAAiB,CAAA;IACzB,SAAS,CAAC,EAAE,aAAa,CAAA;IACzB,QAAQ,CAAC,EAAE,SAAS,GAAG,SAAS,EAAE,CAAA;IAClC,aAAa,CAAC,EAAE,iBAAiB,CAAA;IACjC,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,sBAAsB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC5C,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,CAAC,UAAU,CAAC,GAAG,OAAO,KAAK,IAAI,CAAA;IAC5E,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,CAAC,UAAU,CAAC,GAAG,OAAO,KAAK,IAAI,CAAA;IAC3E,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,CAAC,UAAU,CAAC,GAAG,OAAO,KAAK,IAAI,CAAA;IAC1E,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,CAAC,UAAU,CAAC,GAAG,OAAO,KAAK,IAAI,CAAA;IAC/E,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,CAAC,UAAU,CAAC,GAAG,OAAO,KAAK,IAAI,CAAA;CACjF;AAsoBD,QAAA,MAAM,KAAK,qHAiIT,CAAA;AAIF,eAAe,KAAK,CAAA"}
@@ -398,7 +398,7 @@ function parseLinearGradient(text) {
398
398
  });
399
399
  }
400
400
  function parseBgImage(text) {
401
- if (!text)
401
+ if (!text || text === 'none')
402
402
  return {};
403
403
  const src = parseUrl(text);
404
404
  if (src)
@@ -20,3 +20,4 @@ interface WebViewProps {
20
20
  }
21
21
  declare const _WebView: import("react").ForwardRefExoticComponent<Omit<WebViewProps, "ref"> & import("react").RefAttributes<HandlerRef<WebView<{}>, WebViewProps>>>;
22
22
  export default _WebView;
23
+ //# sourceMappingURL=mpx-web-view.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mpx-web-view.d.ts","sourceRoot":"","sources":["../mpx-web-view.tsx"],"names":[],"mappings":";AAMA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAC9C,OAAoB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAMvD,KAAK,sBAAsB,GAAG;IAC5B,MAAM,EAAE;QACN,IAAI,EAAE,GAAG,EAAE,CAAA;KACZ,CAAA;CACF,CAAA;AAED,KAAK,mBAAmB,GAAG;IACzB,MAAM,EAAE;QACN,GAAG,CAAC,EAAE,MAAM,CAAA;KACb,CAAA;CACF,CAAA;AAED,UAAU,YAAY;IACpB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,IAAI,CAAA;IACrD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,CAAA;IAC/C,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,CAAA;IAChD,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;CACjB;AAgDD,QAAA,MAAM,QAAQ,6IA0RZ,CAAA;AAIF,eAAe,QAAQ,CAAA"}
@@ -80,9 +80,25 @@ const _WebView = forwardRef((props, ref) => {
80
80
  useNodesRef(props, ref, webViewRef, {
81
81
  style: defaultWebViewStyle
82
82
  });
83
+ const hostValidate = (url) => {
84
+ const host = url && new URL(url).host;
85
+ const hostWhitelists = mpx.config.rnConfig?.webviewConfig?.hostWhitelists || [];
86
+ if (hostWhitelists.length) {
87
+ return hostWhitelists.some((item) => {
88
+ return host.endsWith(item);
89
+ });
90
+ }
91
+ else {
92
+ return true;
93
+ }
94
+ };
83
95
  if (!src) {
84
96
  return null;
85
97
  }
98
+ if (!hostValidate(src)) {
99
+ console.error('访问页面域名不符合domainWhiteLists白名单配置,请确认是否正确配置该域名白名单');
100
+ return null;
101
+ }
86
102
  const _reload = function () {
87
103
  if (__mpx_mode__ !== 'ios') {
88
104
  fristLoaded.current = false; // 安卓需要重新设置
@@ -133,6 +149,9 @@ const _WebView = forwardRef((props, ref) => {
133
149
  }
134
150
  };
135
151
  const _message = function (res) {
152
+ if (!hostValidate(res.nativeEvent?.url)) {
153
+ return;
154
+ }
136
155
  let data = {};
137
156
  let asyncCallback;
138
157
  const navObj = promisify({ redirectTo, navigateTo, navigateBack, reLaunch, switchTab });
@@ -157,7 +176,7 @@ const _WebView = forwardRef((props, ref) => {
157
176
  }
158
177
  break;
159
178
  case 'postMessage':
160
- bindmessage && bindmessage(getCustomEvent('messsage', {}, {
179
+ bindmessage && bindmessage(getCustomEvent('message', {}, {
161
180
  detail: {
162
181
  data: params[0]?.data
163
182
  }
@@ -184,7 +203,7 @@ const _WebView = forwardRef((props, ref) => {
184
203
  break;
185
204
  default:
186
205
  if (type) {
187
- const implement = mpx.config.webviewConfig.apiImplementations && mpx.config.webviewConfig.apiImplementations[type];
206
+ const implement = mpx.config.rnConfig.webviewConfig && mpx.config.rnConfig.webviewConfig.apiImplementations && mpx.config.rnConfig.webviewConfig.apiImplementations[type];
188
207
  if (isFunction(implement)) {
189
208
  asyncCallback = Promise.resolve(implement(...params));
190
209
  }
@@ -37,3 +37,4 @@ export declare class ReplaceSource {
37
37
  source(): string;
38
38
  }
39
39
  export {};
40
+ //# sourceMappingURL=parser.d.ts.map