@mpxjs/webpack-plugin 2.10.7 → 2.10.8-beta.3

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 (138) hide show
  1. package/lib/dependencies/RecordPageConfigsMapDependency.js +1 -1
  2. package/lib/dependencies/RequireExternalDependency.js +61 -0
  3. package/lib/file-loader.js +3 -2
  4. package/lib/index.js +55 -9
  5. package/lib/json-compiler/index.js +1 -0
  6. package/lib/parser.js +1 -1
  7. package/lib/platform/json/wx/index.js +43 -25
  8. package/lib/platform/style/wx/index.js +7 -0
  9. package/lib/platform/template/wx/component-config/fix-component-name.js +2 -2
  10. package/lib/platform/template/wx/component-config/index.js +9 -1
  11. package/lib/platform/template/wx/component-config/nav-container.js +27 -0
  12. package/lib/platform/template/wx/component-config/page-container.js +19 -0
  13. package/lib/platform/template/wx/component-config/sticky-header.js +23 -0
  14. package/lib/platform/template/wx/component-config/sticky-section.js +23 -0
  15. package/lib/platform/template/wx/component-config/unsupported.js +1 -1
  16. package/lib/react/LoadAsyncChunkModule.js +74 -0
  17. package/lib/react/index.js +3 -1
  18. package/lib/react/processJSON.js +74 -13
  19. package/lib/react/processScript.js +6 -6
  20. package/lib/react/script-helper.js +100 -41
  21. package/lib/runtime/components/ali/mpx-nav-container.mpx +3 -0
  22. package/lib/runtime/components/react/context.ts +27 -7
  23. package/lib/runtime/components/react/dist/context.d.ts +78 -0
  24. package/lib/runtime/components/react/dist/context.js +5 -1
  25. package/lib/runtime/components/react/dist/event.config.d.ts +7 -0
  26. package/lib/runtime/components/react/dist/getInnerListeners.d.ts +7 -0
  27. package/lib/runtime/components/react/dist/mpx-async-suspense.d.ts +12 -0
  28. package/lib/runtime/components/react/dist/mpx-async-suspense.jsx +135 -0
  29. package/lib/runtime/components/react/dist/mpx-button.d.ts +68 -0
  30. package/lib/runtime/components/react/dist/mpx-button.jsx +2 -2
  31. package/lib/runtime/components/react/dist/mpx-canvas/Bus.d.ts +23 -0
  32. package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.d.ts +7 -0
  33. package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.d.ts +6 -0
  34. package/lib/runtime/components/react/dist/mpx-canvas/Image.d.ts +20 -0
  35. package/lib/runtime/components/react/dist/mpx-canvas/ImageData.d.ts +8 -0
  36. package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.d.ts +10 -0
  37. package/lib/runtime/components/react/dist/mpx-canvas/html.d.ts +2 -0
  38. package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts +32 -0
  39. package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts +52 -0
  40. package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts +20 -0
  41. package/lib/runtime/components/react/dist/mpx-checkbox.d.ts +32 -0
  42. package/lib/runtime/components/react/dist/mpx-form.d.ts +27 -0
  43. package/lib/runtime/components/react/dist/mpx-icon/index.d.ts +18 -0
  44. package/lib/runtime/components/react/dist/mpx-image.d.ts +21 -0
  45. package/lib/runtime/components/react/dist/mpx-inline-text.d.ts +7 -0
  46. package/lib/runtime/components/react/dist/mpx-input.d.ts +49 -0
  47. package/lib/runtime/components/react/dist/mpx-input.jsx +28 -9
  48. package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.d.ts +12 -0
  49. package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.jsx +42 -46
  50. package/lib/runtime/components/react/dist/mpx-label.d.ts +20 -0
  51. package/lib/runtime/components/react/dist/mpx-movable-area.d.ts +20 -0
  52. package/lib/runtime/components/react/dist/mpx-movable-view.d.ts +63 -0
  53. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +8 -6
  54. package/lib/runtime/components/react/dist/mpx-nav-container.d.ts +9 -0
  55. package/lib/runtime/components/react/dist/mpx-nav-container.jsx +23 -0
  56. package/lib/runtime/components/react/dist/mpx-navigator.d.ts +9 -0
  57. package/lib/runtime/components/react/dist/mpx-page-container.d.ts +27 -0
  58. package/lib/runtime/components/react/dist/mpx-page-container.jsx +255 -0
  59. package/lib/runtime/components/react/dist/mpx-picker/date.d.ts +6 -0
  60. package/lib/runtime/components/react/dist/mpx-picker/dateData.d.ts +7 -0
  61. package/lib/runtime/components/react/dist/mpx-picker/index.d.ts +6 -0
  62. package/lib/runtime/components/react/dist/mpx-picker/multiSelector.d.ts +6 -0
  63. package/lib/runtime/components/react/dist/mpx-picker/region.d.ts +6 -0
  64. package/lib/runtime/components/react/dist/mpx-picker/regionData.d.ts +2 -0
  65. package/lib/runtime/components/react/dist/mpx-picker/selector.d.ts +6 -0
  66. package/lib/runtime/components/react/dist/mpx-picker/time.d.ts +6 -0
  67. package/lib/runtime/components/react/dist/mpx-picker/type.d.ts +106 -0
  68. package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts +31 -0
  69. package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts +8 -0
  70. package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts +22 -0
  71. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts +14 -0
  72. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewFaces.d.ts +16 -0
  73. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewIndicator.d.ts +12 -0
  74. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewMask.d.ts +11 -0
  75. package/lib/runtime/components/react/dist/mpx-popup/index.d.ts +22 -0
  76. package/lib/runtime/components/react/dist/mpx-popup/popupBase.d.ts +16 -0
  77. package/lib/runtime/components/react/dist/mpx-portal/index.d.ts +15 -0
  78. package/lib/runtime/components/react/dist/mpx-portal/portal-host.d.ts +29 -0
  79. package/lib/runtime/components/react/dist/mpx-portal/portal-manager.d.ts +9 -0
  80. package/lib/runtime/components/react/dist/mpx-radio-group.d.ts +20 -0
  81. package/lib/runtime/components/react/dist/mpx-radio.d.ts +26 -0
  82. package/lib/runtime/components/react/dist/mpx-rich-text/html.d.ts +1 -0
  83. package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts +24 -0
  84. package/lib/runtime/components/react/dist/mpx-root-portal.d.ts +14 -0
  85. package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts +54 -0
  86. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +31 -15
  87. package/lib/runtime/components/react/dist/mpx-simple-text.d.ts +7 -0
  88. package/lib/runtime/components/react/dist/mpx-simple-view.d.ts +7 -0
  89. package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts +17 -0
  90. package/lib/runtime/components/react/dist/mpx-sticky-header.jsx +117 -0
  91. package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts +15 -0
  92. package/lib/runtime/components/react/dist/mpx-sticky-section.jsx +45 -0
  93. package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts +18 -0
  94. package/lib/runtime/components/react/dist/mpx-swiper.d.ts +52 -0
  95. package/lib/runtime/components/react/dist/mpx-swiper.jsx +3 -2
  96. package/lib/runtime/components/react/dist/mpx-switch.d.ts +26 -0
  97. package/lib/runtime/components/react/dist/mpx-text.d.ts +21 -0
  98. package/lib/runtime/components/react/dist/mpx-textarea.d.ts +7 -0
  99. package/lib/runtime/components/react/dist/mpx-video.d.ts +101 -0
  100. package/lib/runtime/components/react/dist/mpx-view.d.ts +34 -0
  101. package/lib/runtime/components/react/dist/mpx-web-view.d.ts +22 -0
  102. package/lib/runtime/components/react/dist/nav.d.ts +11 -0
  103. package/lib/runtime/components/react/dist/nav.jsx +141 -0
  104. package/lib/runtime/components/react/dist/parser.d.ts +39 -0
  105. package/lib/runtime/components/react/dist/useAnimationHooks.d.ts +32 -0
  106. package/lib/runtime/components/react/dist/useNavShared.d.ts +2 -0
  107. package/lib/runtime/components/react/dist/useNavShared.js +6 -0
  108. package/lib/runtime/components/react/dist/useNodesRef.d.ts +11 -0
  109. package/lib/runtime/components/react/dist/utils.d.ts +121 -0
  110. package/lib/runtime/components/react/mpx-async-suspense.tsx +180 -0
  111. package/lib/runtime/components/react/mpx-button.tsx +3 -2
  112. package/lib/runtime/components/react/mpx-input.tsx +35 -16
  113. package/lib/runtime/components/react/mpx-keyboard-avoiding-view.tsx +46 -45
  114. package/lib/runtime/components/react/mpx-movable-view.tsx +8 -4
  115. package/lib/runtime/components/react/mpx-nav-container.tsx +33 -0
  116. package/lib/runtime/components/react/mpx-page-container.tsx +394 -0
  117. package/lib/runtime/components/react/mpx-scroll-view.tsx +84 -59
  118. package/lib/runtime/components/react/mpx-sticky-header.tsx +181 -0
  119. package/lib/runtime/components/react/mpx-sticky-section.tsx +96 -0
  120. package/lib/runtime/components/react/mpx-swiper.tsx +4 -2
  121. package/lib/runtime/components/react/nav.tsx +172 -0
  122. package/lib/runtime/components/react/types/common.d.ts +19 -0
  123. package/lib/runtime/components/react/useNavShared.ts +8 -0
  124. package/lib/runtime/components/web/mpx-nav-container.vue +13 -0
  125. package/lib/runtime/components/web/mpx-scroll-view.vue +18 -4
  126. package/lib/runtime/components/web/mpx-sticky-header.vue +99 -0
  127. package/lib/runtime/components/web/mpx-sticky-section.vue +15 -0
  128. package/lib/runtime/components/wx/mpx-nav-container.mpx +9 -0
  129. package/lib/runtime/optionProcessorReact.d.ts +18 -0
  130. package/lib/runtime/optionProcessorReact.js +30 -0
  131. package/lib/script-setup-compiler/index.js +27 -5
  132. package/lib/template-compiler/bind-this.js +2 -1
  133. package/lib/template-compiler/compiler.js +27 -6
  134. package/lib/utils/dom-tag-config.js +18 -4
  135. package/lib/utils/trans-async-sub-rules.js +19 -0
  136. package/lib/web/script-helper.js +1 -1
  137. package/package.json +4 -4
  138. package/LICENSE +0 -433
@@ -0,0 +1,117 @@
1
+ import { useEffect, useRef, useContext, forwardRef, useMemo, createElement, useId } from 'react';
2
+ import { Animated, StyleSheet, useAnimatedValue } from 'react-native';
3
+ import { ScrollViewContext, StickyContext } from './context';
4
+ import useNodesRef from './useNodesRef';
5
+ import { splitProps, splitStyle, useTransformStyle, wrapChildren, useLayout, extendObject } from './utils';
6
+ import { error } from '@mpxjs/utils';
7
+ import useInnerProps, { getCustomEvent } from './getInnerListeners';
8
+ const _StickyHeader = forwardRef((stickyHeaderProps = {}, ref) => {
9
+ const { textProps, innerProps: props = {} } = splitProps(stickyHeaderProps);
10
+ const { style, bindstickontopchange, padding = [0, 0, 0, 0], 'offset-top': offsetTop = 0, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
11
+ const scrollViewContext = useContext(ScrollViewContext);
12
+ const stickyContext = useContext(StickyContext);
13
+ const { scrollOffset } = scrollViewContext;
14
+ const { registerStickyHeader, unregisterStickyHeader } = stickyContext;
15
+ const headerRef = useRef(null);
16
+ const isStickOnTopRef = useRef(false);
17
+ const id = useId();
18
+ const { normalStyle, hasVarDec, varContextRef, hasSelfPercent, setWidth, setHeight } = useTransformStyle(style, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
19
+ const { layoutRef, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: headerRef, onLayout });
20
+ const { textStyle, innerStyle = {} } = splitStyle(normalStyle);
21
+ const headerTopAnimated = useAnimatedValue(0);
22
+ // harmony animatedValue 不支持通过 _value 访问
23
+ const headerTopRef = useRef(0);
24
+ useEffect(() => {
25
+ registerStickyHeader({ key: id, updatePosition });
26
+ return () => {
27
+ unregisterStickyHeader(id);
28
+ };
29
+ }, []);
30
+ function updatePosition() {
31
+ if (headerRef.current) {
32
+ const scrollViewRef = scrollViewContext.gestureRef;
33
+ if (scrollViewRef && scrollViewRef.current) {
34
+ headerRef.current.measureLayout(scrollViewRef.current, (left, top) => {
35
+ Animated.timing(headerTopAnimated, {
36
+ toValue: top,
37
+ duration: 0,
38
+ useNativeDriver: true
39
+ }).start();
40
+ headerTopRef.current = top;
41
+ });
42
+ }
43
+ else {
44
+ error('StickyHeader measureLayout error: scrollViewRef is not a valid native component reference');
45
+ }
46
+ }
47
+ }
48
+ function onLayout(e) {
49
+ updatePosition();
50
+ }
51
+ useNodesRef(props, ref, headerRef, {
52
+ style: normalStyle
53
+ });
54
+ useEffect(() => {
55
+ if (!bindstickontopchange)
56
+ return;
57
+ const listener = scrollOffset.addListener((state) => {
58
+ const currentScrollValue = state.value;
59
+ const newIsStickOnTop = currentScrollValue > headerTopRef.current;
60
+ if (newIsStickOnTop !== isStickOnTopRef.current) {
61
+ isStickOnTopRef.current = newIsStickOnTop;
62
+ bindstickontopchange(getCustomEvent('stickontopchange', {}, {
63
+ detail: {
64
+ isStickOnTop: newIsStickOnTop
65
+ },
66
+ layoutRef
67
+ }, props));
68
+ }
69
+ });
70
+ return () => {
71
+ scrollOffset.removeListener(listener);
72
+ };
73
+ }, []);
74
+ const animatedStyle = useMemo(() => {
75
+ const translateY = Animated.subtract(scrollOffset, headerTopAnimated).interpolate({
76
+ inputRange: [0, 1],
77
+ outputRange: [0, 1],
78
+ extrapolateLeft: 'clamp',
79
+ extrapolateRight: 'extend'
80
+ });
81
+ const finalTranslateY = offsetTop === 0
82
+ ? translateY
83
+ : Animated.add(translateY, Animated.subtract(scrollOffset, headerTopAnimated).interpolate({
84
+ inputRange: [0, 1],
85
+ outputRange: [0, offsetTop],
86
+ extrapolate: 'clamp'
87
+ }));
88
+ return {
89
+ transform: [{ translateY: finalTranslateY }]
90
+ };
91
+ }, [scrollOffset, headerTopAnimated, offsetTop]);
92
+ const innerProps = useInnerProps(extendObject({}, props, {
93
+ ref: headerRef,
94
+ style: extendObject({}, styles.content, innerStyle, animatedStyle, {
95
+ paddingTop: padding[0] || 0,
96
+ paddingRight: padding[1] || 0,
97
+ paddingBottom: padding[2] || 0,
98
+ paddingLeft: padding[3] || 0
99
+ })
100
+ }, layoutProps), [], { layoutRef });
101
+ return (createElement(Animated.View, innerProps, wrapChildren(props, {
102
+ hasVarDec,
103
+ varContext: varContextRef.current,
104
+ textStyle,
105
+ textProps
106
+ })));
107
+ });
108
+ const styles = StyleSheet.create({
109
+ content: {
110
+ width: '100%',
111
+ zIndex: 10,
112
+ // harmony 需要手动设置 relative, zIndex 才生效
113
+ position: 'relative'
114
+ }
115
+ });
116
+ _StickyHeader.displayName = 'MpxStickyHeader';
117
+ export default _StickyHeader;
@@ -0,0 +1,15 @@
1
+ import { ReactNode } from 'react';
2
+ import { View, ViewStyle } from 'react-native';
3
+ import { HandlerRef } from './useNodesRef';
4
+ interface StickySectionProps {
5
+ children?: ReactNode;
6
+ style?: ViewStyle;
7
+ 'offset-top'?: number;
8
+ 'enable-var'?: boolean;
9
+ 'external-var-context'?: Record<string, any>;
10
+ 'parent-font-size'?: number;
11
+ 'parent-width'?: number;
12
+ 'parent-height'?: number;
13
+ }
14
+ declare const _StickySection: import("react").ForwardRefExoticComponent<StickySectionProps & import("react").RefAttributes<HandlerRef<View, StickySectionProps>>>;
15
+ export default _StickySection;
@@ -0,0 +1,45 @@
1
+ import { useRef, forwardRef, createElement, useCallback, useMemo } from 'react';
2
+ import { View } from 'react-native';
3
+ import useNodesRef from './useNodesRef';
4
+ import { splitProps, splitStyle, useTransformStyle, wrapChildren, useLayout, extendObject } from './utils';
5
+ import { StickyContext } from './context';
6
+ import useInnerProps from './getInnerListeners';
7
+ const _StickySection = forwardRef((stickySectionProps = {}, ref) => {
8
+ const { textProps, innerProps: props = {} } = splitProps(stickySectionProps);
9
+ const { style, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
10
+ const sectionRef = useRef(null);
11
+ const { normalStyle, hasVarDec, varContextRef, hasSelfPercent, setWidth, setHeight } = useTransformStyle(style, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
12
+ const { layoutRef, layoutProps, layoutStyle } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: sectionRef, onLayout });
13
+ const { textStyle, innerStyle = {} } = splitStyle(normalStyle);
14
+ const stickyHeaders = useRef(new Map());
15
+ const registerStickyHeader = useCallback((item) => {
16
+ stickyHeaders.current.set(item.id, item);
17
+ }, []);
18
+ const unregisterStickyHeader = useCallback((id) => {
19
+ stickyHeaders.current.delete(id);
20
+ }, []);
21
+ const contextValue = useMemo(() => ({
22
+ registerStickyHeader,
23
+ unregisterStickyHeader
24
+ }), []);
25
+ useNodesRef(props, ref, sectionRef, {
26
+ style: normalStyle
27
+ });
28
+ function onLayout() {
29
+ stickyHeaders.current.forEach(item => {
30
+ item.updatePosition();
31
+ });
32
+ }
33
+ const innerProps = useInnerProps(extendObject({}, props, {
34
+ style: extendObject(innerStyle, layoutStyle),
35
+ ref: sectionRef
36
+ }, layoutProps), [], { layoutRef });
37
+ return (createElement(View, innerProps, createElement(StickyContext.Provider, { value: contextValue }, wrapChildren(props, {
38
+ hasVarDec,
39
+ varContext: varContextRef.current,
40
+ textStyle,
41
+ textProps
42
+ }))));
43
+ });
44
+ _StickySection.displayName = 'MpxStickySection';
45
+ export default _StickySection;
@@ -0,0 +1,18 @@
1
+ import { View } from 'react-native';
2
+ import { ReactNode } from 'react';
3
+ import { HandlerRef } from './useNodesRef';
4
+ interface SwiperItemProps {
5
+ 'item-id'?: string;
6
+ 'enable-offset'?: boolean;
7
+ 'enable-var': boolean;
8
+ 'external-var-context'?: Record<string, any>;
9
+ 'parent-font-size'?: number;
10
+ 'parent-width'?: number;
11
+ 'parent-height'?: number;
12
+ children?: ReactNode;
13
+ style?: Object;
14
+ customStyle: Object;
15
+ itemIndex: number;
16
+ }
17
+ declare const _SwiperItem: import("react").ForwardRefExoticComponent<SwiperItemProps & import("react").RefAttributes<HandlerRef<View, SwiperItemProps>>>;
18
+ export default _SwiperItem;
@@ -0,0 +1,52 @@
1
+ import { View, NativeSyntheticEvent } from 'react-native';
2
+ import React, { ReactNode } from 'react';
3
+ import { HandlerRef } from './useNodesRef';
4
+ import { GestureHandler } from './utils';
5
+ /**
6
+ * ✔ indicator-dots
7
+ * ✔ indicator-color
8
+ * ✔ indicator-active-color
9
+ * ✔ autoplay
10
+ * ✔ current
11
+ * ✔ interval
12
+ * ✔ duration
13
+ * ✔ circular
14
+ * ✔ vertical
15
+ * ✔ previous-margin
16
+ * ✔ next-margin
17
+ * ✔ easing-function ="easeOutCubic"
18
+ * ✘ display-multiple-items
19
+ * ✘ snap-to-edge
20
+ */
21
+ type EaseType = 'default' | 'linear' | 'easeInCubic' | 'easeOutCubic' | 'easeInOutCubic';
22
+ interface SwiperProps {
23
+ children?: ReactNode;
24
+ circular?: boolean;
25
+ current?: number;
26
+ interval?: number;
27
+ autoplay?: boolean;
28
+ duration?: number;
29
+ scale?: boolean;
30
+ 'indicator-dots'?: boolean;
31
+ 'indicator-color'?: string;
32
+ 'indicator-active-color'?: string;
33
+ vertical?: boolean;
34
+ style: {
35
+ [key: string]: any;
36
+ };
37
+ 'easing-function'?: EaseType;
38
+ 'previous-margin'?: string;
39
+ 'next-margin'?: string;
40
+ 'enable-offset'?: boolean;
41
+ 'enable-var': boolean;
42
+ 'parent-font-size'?: number;
43
+ 'parent-width'?: number;
44
+ 'parent-height'?: number;
45
+ 'external-var-context'?: Record<string, any>;
46
+ 'wait-for'?: Array<GestureHandler>;
47
+ 'simultaneous-handlers'?: Array<GestureHandler>;
48
+ disableGesture?: boolean;
49
+ bindchange?: (event: NativeSyntheticEvent<TouchEvent> | unknown) => void;
50
+ }
51
+ declare const SwiperWrapper: React.ForwardRefExoticComponent<SwiperProps & React.RefAttributes<HandlerRef<View, SwiperProps>>>;
52
+ export default SwiperWrapper;
@@ -71,7 +71,7 @@ const easeMap = {
71
71
  easeInOutCubic: Easing.inOut(Easing.cubic)
72
72
  };
73
73
  const SwiperWrapper = forwardRef((props, ref) => {
74
- const { 'indicator-dots': showPagination, 'indicator-color': dotColor = 'rgba(0, 0, 0, .3)', 'indicator-active-color': activeDotColor = '#000000', 'enable-var': enableVar = false, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, 'external-var-context': externalVarContext, 'simultaneous-handlers': originSimultaneousHandlers = [], 'wait-for': waitFor = [], style = {}, autoplay = false, circular = false, disableGesture = false } = props;
74
+ const { 'indicator-dots': showPagination, 'indicator-color': dotColor = 'rgba(0, 0, 0, .3)', 'indicator-active-color': activeDotColor = '#000000', 'enable-var': enableVar = false, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, 'external-var-context': externalVarContext, 'simultaneous-handlers': originSimultaneousHandlers = [], 'wait-for': waitFor = [], style = {}, autoplay = false, circular = false, disableGesture = false, bindchange } = props;
75
75
  const easeingFunc = props['easing-function'] || 'default';
76
76
  const easeDuration = props.duration || 500;
77
77
  const horizontal = props.vertical !== undefined ? !props.vertical : true;
@@ -330,6 +330,7 @@ const SwiperWrapper = forwardRef((props, ref) => {
330
330
  if (props.current !== currentIndex.value) {
331
331
  const eventData = getCustomEvent('change', {}, { detail: { current, source: 'touch' }, layoutRef: layoutRef });
332
332
  props.bindchange && props.bindchange(eventData);
333
+ bindchange && bindchange(eventData);
333
334
  }
334
335
  }
335
336
  function getOffset(index, stepValue) {
@@ -373,7 +374,7 @@ const SwiperWrapper = forwardRef((props, ref) => {
373
374
  // 1. 用户在当前页切换选中项,动画;用户携带选中index打开到swiper页直接选中不走动画
374
375
  useAnimatedReaction(() => currentIndex.value, (newIndex, preIndex) => {
375
376
  // 这里必须传递函数名, 直接写()=> {}形式会报 访问了未sharedValue信息
376
- if (newIndex !== preIndex && props.bindchange) {
377
+ if (newIndex !== preIndex && bindchange) {
377
378
  runOnJS(handleSwiperChange)(newIndex);
378
379
  }
379
380
  });
@@ -0,0 +1,26 @@
1
+ /// <reference types="react" />
2
+ /**
3
+ * ✔ checked
4
+ * ✔ type
5
+ * ✔ disabled
6
+ * ✔ color
7
+ */
8
+ import { Switch, SwitchProps, ViewStyle, NativeSyntheticEvent } from 'react-native';
9
+ import { HandlerRef } from './useNodesRef';
10
+ interface _SwitchProps extends SwitchProps {
11
+ style?: ViewStyle;
12
+ name?: string;
13
+ checked?: boolean;
14
+ type: 'switch' | 'checkbox';
15
+ disabled: boolean;
16
+ color: string;
17
+ 'enable-var'?: boolean;
18
+ 'parent-font-size'?: number;
19
+ 'parent-width'?: number;
20
+ 'parent-height'?: number;
21
+ 'external-var-context'?: Record<string, any>;
22
+ bindchange?: (event: NativeSyntheticEvent<TouchEvent> | unknown) => void;
23
+ catchchange?: (event: NativeSyntheticEvent<TouchEvent> | unknown) => void;
24
+ }
25
+ declare const _Switch: import("react").ForwardRefExoticComponent<_SwitchProps & import("react").RefAttributes<HandlerRef<Switch, _SwitchProps>>>;
26
+ export default _Switch;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * ✔ selectable
3
+ * ✘ space
4
+ * ✘ decode
5
+ */
6
+ import { Text, TextStyle, TextProps } from 'react-native';
7
+ import { ReactNode } from 'react';
8
+ import { HandlerRef } from './useNodesRef';
9
+ interface _TextProps extends TextProps {
10
+ style?: TextStyle;
11
+ children?: ReactNode;
12
+ selectable?: boolean;
13
+ 'user-select'?: boolean;
14
+ 'enable-var'?: boolean;
15
+ 'external-var-context'?: Record<string, any>;
16
+ 'parent-font-size'?: number;
17
+ 'parent-width'?: number;
18
+ 'parent-height'?: number;
19
+ }
20
+ declare const _Text: import("react").ForwardRefExoticComponent<_TextProps & import("react").RefAttributes<HandlerRef<Text, _TextProps>>>;
21
+ export default _Text;
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ import { TextInput } from 'react-native';
3
+ import { InputProps, PrivateInputProps } from './mpx-input';
4
+ import { HandlerRef } from './useNodesRef';
5
+ export type TextareProps = Omit<InputProps & PrivateInputProps, 'type' | 'password' | 'multiline' | 'confirm-hold'>;
6
+ declare const Textarea: import("react").ForwardRefExoticComponent<TextareProps & import("react").RefAttributes<HandlerRef<TextInput, TextareProps>>>;
7
+ export default Textarea;
@@ -0,0 +1,101 @@
1
+ /**
2
+ * ✔ src
3
+ * ✘ duration
4
+ * ✔ controls
5
+ * ✘ danmu-list
6
+ * ✘ danmu-btn
7
+ * ✘ enable-danmu
8
+ * ✔ autoplay
9
+ * ✔ loop
10
+ * ✔ muted
11
+ * ✔ initial-time
12
+ * ✘ page-gesture
13
+ * ✘ direction
14
+ * ✘ show-progress
15
+ * ✘ show-fullscreen-btn
16
+ * ✘ show-play-btn
17
+ * ✘ show-center-play-btn
18
+ * ✘ enable-progress-gesture
19
+ * ✔ object-fit
20
+ * ✔ poster
21
+ * ✘ show-mute-btn
22
+ * ✘ title
23
+ * ✘ play-btn-position
24
+ * ✘ enable-play-gesture
25
+ * ✘ auto-pause-if-navigate
26
+ * ✘ auto-pause-if-open-native
27
+ * ✘ vslide-gesture
28
+ * ✘ vslide-gesture-in-fullscreen
29
+ * ✘ show-bottom-progress(use show-progress)
30
+ * ✘ ad-unit-id
31
+ * ✘ poster-for-crawler
32
+ * ✘ show-casting-button
33
+ * ✘ picture-in-picture-mode
34
+ * ✘ picture-in-picture-show-progress
35
+ * ✘ picture-in-picture-init-position
36
+ * ✔ enable-auto-rotation (only ios)
37
+ * ✘ show-screen-lock-button
38
+ * ✘ show-snapshot-button
39
+ * ✘ show-background-playback-button
40
+ * ✘ background-poster
41
+ * ✘ referrer-policy
42
+ * ✔ is-drm
43
+ * ✘ is-live
44
+ * ✔ provision-url(android)
45
+ * ✔ certificate-url(ios)
46
+ * ✔ license-url
47
+ * ✔ preferred-peak-bit-rate
48
+ * ✔ bindplay
49
+ * ✔ bindpause
50
+ * ✔ bindended
51
+ * ✘ bindtimeupdate
52
+ * ✔ bindfullscreenchange
53
+ * ✔ bindwaiting
54
+ * ✔ binderror
55
+ * ✘ bindprogress
56
+ * ✔ bindloadedmetadata
57
+ * ✔ bindcontrolstoggle(only android)
58
+ * ✘ bindenterpictureinpicture
59
+ * ✘ bindleavepictureinpicture
60
+ * ✔ bindseekcomplete
61
+ * ✘ bindcastinguserselect
62
+ * ✘ bindcastingstatechange
63
+ * ✘ bindcastinginterrupt
64
+ */
65
+ /// <reference types="react" />
66
+ import { View, ViewStyle } from 'react-native';
67
+ import { HandlerRef } from './useNodesRef';
68
+ interface VideoProps {
69
+ src: string;
70
+ autoplay?: boolean;
71
+ loop?: boolean;
72
+ muted?: boolean;
73
+ controls?: boolean;
74
+ poster?: string;
75
+ style?: ViewStyle;
76
+ 'initial-time'?: number;
77
+ 'object-fit'?: null | 'contain' | 'fill' | 'cover';
78
+ 'is-drm'?: boolean;
79
+ 'provision-url'?: string;
80
+ 'certificate-url'?: string;
81
+ 'license-url'?: string;
82
+ 'preferred-peak-bit-rate'?: number;
83
+ 'enable-auto-rotation'?: number;
84
+ 'enable-var'?: boolean;
85
+ 'external-var-context'?: Record<string, any>;
86
+ 'parent-font-size'?: number;
87
+ 'parent-width'?: number;
88
+ 'parent-height'?: number;
89
+ bindplay?: (event: Record<string, any>) => void;
90
+ bindpause?: (event: Record<string, any>) => void;
91
+ bindended?: (event: Record<string, any>) => void;
92
+ bindtimeupdate?: (event: Record<string, any>) => void;
93
+ bindfullscreenchange?: (event: Record<string, any>) => void;
94
+ bindwaiting?: (event: Record<string, any>) => void;
95
+ binderror?: (event: Record<string, any>) => void;
96
+ bindloadedmetadata?: (event: Record<string, any>) => void;
97
+ bindcontrolstoggle?: (event: Record<string, any>) => void;
98
+ bindseekcomplete?: (event: Record<string, any>) => void;
99
+ }
100
+ declare const MpxVideo: import("react").ForwardRefExoticComponent<VideoProps & import("react").RefAttributes<HandlerRef<View, VideoProps>>>;
101
+ export default MpxVideo;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * ✔ hover-class
3
+ * ✘ hover-stop-propagation
4
+ * ✔ hover-start-time
5
+ * ✔ hover-stay-time
6
+ */
7
+ import { View, NativeSyntheticEvent, ViewProps } from 'react-native';
8
+ import { ReactNode } from 'react';
9
+ import type { AnimationProp } from './useAnimationHooks';
10
+ import { ExtendedViewStyle } from './types/common';
11
+ import { HandlerRef } from './useNodesRef';
12
+ export interface _ViewProps extends ViewProps {
13
+ style?: ExtendedViewStyle;
14
+ animation?: AnimationProp;
15
+ children?: ReactNode | ReactNode[];
16
+ 'hover-style'?: ExtendedViewStyle;
17
+ 'hover-start-time'?: number;
18
+ 'hover-stay-time'?: number;
19
+ 'enable-background'?: boolean;
20
+ 'enable-var'?: boolean;
21
+ 'enable-fast-image'?: boolean;
22
+ 'external-var-context'?: Record<string, any>;
23
+ 'parent-font-size'?: number;
24
+ 'parent-width'?: number;
25
+ 'parent-height'?: number;
26
+ 'enable-animation'?: boolean;
27
+ bindtouchstart?: (event: NativeSyntheticEvent<TouchEvent> | unknown) => void;
28
+ bindtouchmove?: (event: NativeSyntheticEvent<TouchEvent> | unknown) => void;
29
+ bindtouchend?: (event: NativeSyntheticEvent<TouchEvent> | unknown) => void;
30
+ bindtransitionend?: (event: NativeSyntheticEvent<TouchEvent> | unknown) => void;
31
+ catchtransitionend?: (event: NativeSyntheticEvent<TouchEvent> | unknown) => void;
32
+ }
33
+ declare const _View: import("react").ForwardRefExoticComponent<_ViewProps & import("react").RefAttributes<HandlerRef<View, _ViewProps>>>;
34
+ export default _View;
@@ -0,0 +1,22 @@
1
+ /// <reference types="react" />
2
+ import { WebView } from 'react-native-webview';
3
+ import { HandlerRef } from './useNodesRef';
4
+ type OnMessageCallbackEvent = {
5
+ detail: {
6
+ data: any[];
7
+ };
8
+ };
9
+ type CommonCallbackEvent = {
10
+ detail: {
11
+ src?: string;
12
+ };
13
+ };
14
+ interface WebViewProps {
15
+ src?: string;
16
+ bindmessage?: (event: OnMessageCallbackEvent) => void;
17
+ bindload?: (event: CommonCallbackEvent) => void;
18
+ binderror?: (event: CommonCallbackEvent) => void;
19
+ [x: string]: any;
20
+ }
21
+ declare const _WebView: import("react").ForwardRefExoticComponent<Omit<WebViewProps, "ref"> & import("react").RefAttributes<HandlerRef<WebView<{}>, WebViewProps>>>;
22
+ export default _WebView;
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ export declare function useInnerHeaderHeight(pageConfig: PageConfig): number;
3
+ export interface MpxNavProps {
4
+ pageConfig: PageConfig;
5
+ navigation: any;
6
+ }
7
+ export interface MpxNavFactorOptions {
8
+ Mpx: any;
9
+ }
10
+ declare function createMpxNav(options: MpxNavFactorOptions): import("react").MemoExoticComponent<({ pageConfig, navigation }: MpxNavProps) => import("react").JSX.Element>;
11
+ export default createMpxNav;
@@ -0,0 +1,141 @@
1
+ /* eslint-disable space-before-function-paren */
2
+ import { useState, useMemo, memo } from 'react';
3
+ import { useSafeAreaInsets } from 'react-native-safe-area-context';
4
+ import { StatusBar, processColor, TouchableWithoutFeedback, Image, View, StyleSheet, Text } from 'react-native';
5
+ import { useNavShared } from './useNavShared';
6
+ function convertToHex(color) {
7
+ try {
8
+ const intColor = processColor(color);
9
+ if (intColor === null || intColor === undefined) {
10
+ return null;
11
+ }
12
+ // 将32位整数颜色值转换为RGBA
13
+ const r = (intColor >> 16) & 255;
14
+ const g = (intColor >> 8) & 255;
15
+ const b = intColor & 255;
16
+ // 转换为十六进制
17
+ const hexR = r.toString(16).padStart(2, '0');
18
+ const hexG = g.toString(16).padStart(2, '0');
19
+ const hexB = b.toString(16).padStart(2, '0');
20
+ return `#${hexR}${hexG}${hexB}`;
21
+ }
22
+ catch (error) {
23
+ return null;
24
+ }
25
+ }
26
+ const titleHeight = 44;
27
+ export function useInnerHeaderHeight(pageConfig) {
28
+ const safeArea = useSafeAreaInsets();
29
+ if (pageConfig.navigationStyle === 'custom') {
30
+ return 0;
31
+ }
32
+ else {
33
+ const safeAreaTop = safeArea?.top || 0;
34
+ const headerHeight = safeAreaTop + titleHeight;
35
+ return headerHeight;
36
+ }
37
+ }
38
+ const styles = StyleSheet.create({
39
+ header: {
40
+ elevation: 3
41
+ },
42
+ headerContent: {
43
+ flexDirection: 'row',
44
+ alignItems: 'center',
45
+ justifyContent: 'center'
46
+ },
47
+ backButton: {
48
+ position: 'absolute',
49
+ height: '100%',
50
+ width: 40,
51
+ left: 0,
52
+ top: 0,
53
+ alignItems: 'center',
54
+ justifyContent: 'center'
55
+ },
56
+ backButtonImage: {
57
+ width: 22,
58
+ height: 22
59
+ },
60
+ title: {
61
+ fontSize: 17,
62
+ fontWeight: 600,
63
+ width: '60%',
64
+ textAlign: 'center'
65
+ }
66
+ });
67
+ const NavColor = {
68
+ White: '#ffffff',
69
+ Black: '#000000'
70
+ };
71
+ // navigationBarTextStyle 只支持黑白 'white'/'black
72
+ const validBarTextStyle = (textStyle) => {
73
+ const textStyleColor = convertToHex(textStyle);
74
+ if (textStyle && textStyleColor && [NavColor.White, NavColor.Black].includes(textStyleColor)) {
75
+ return textStyleColor;
76
+ }
77
+ else {
78
+ return NavColor.White;
79
+ }
80
+ };
81
+ const BACK_ICON = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAABICAYAAACqT5alAAAA2UlEQVR4nO3bMQrCUBRE0Yla6AYEN2nnBrTL+izcitW3MRDkEUWSvPzJvfCqgMwhZbAppWhNbbIHzB1g9wATERFRVyvpkj1irlpJ5X326D7WHh1hbdFD2CLpLmmftm7kfsEe09aNHFiBrT+wAlt/YAW2/sAKbP2BFdj6Ayuwy+ufz6XPL893krZ//O6iu2n4LT8kndLWTRTo4EC7BDo40C6BDg60S6CDA+0S6OBAuwQ6uNWiD2nrJmoIfU7cNWkR2hbb1UfbY7uuWhGWiIg+a/iHuHmA3QPs3gu4JW9Gan+OJAAAAABJRU5ErkJggg==';
82
+ function createMpxNav(options) {
83
+ const { Mpx } = options;
84
+ const innerNav = memo(({ pageConfig, navigation }) => {
85
+ const [innerPageConfig, setPageConfig] = useState(pageConfig || {});
86
+ const [customNav] = useNavShared();
87
+ const safeAreaTop = useSafeAreaInsets()?.top || 0;
88
+ navigation.setPageConfig = (config) => {
89
+ setPageConfig(Object.assign({}, innerPageConfig, config));
90
+ };
91
+ const isCustom = innerPageConfig.navigationStyle === 'custom';
92
+ const navigationBarTextStyle = useMemo(() => validBarTextStyle(innerPageConfig.navigationBarTextStyle), [innerPageConfig.navigationBarTextStyle]);
93
+ // 状态栏的颜色
94
+ const statusBarElement = (<StatusBar translucent backgroundColor='transparent' barStyle={navigationBarTextStyle === NavColor.White ? 'light-content' : 'dark-content'}></StatusBar>);
95
+ if (isCustom)
96
+ return (<>
97
+ {statusBarElement}
98
+ {customNav}
99
+ </>);
100
+ // 假设是栈导航,获取栈的长度
101
+ const stackLength = navigation.getState()?.routes?.length;
102
+ const onStackTopBack = Mpx.config?.rnConfig?.onStackTopBack;
103
+ const isHandleStackTopBack = typeof onStackTopBack === 'function';
104
+ // 回退按钮与图标
105
+ // prettier-ignore
106
+ const backElement = stackLength > 1 || isHandleStackTopBack
107
+ ? (<TouchableWithoutFeedback onPress={() => {
108
+ if (stackLength <= 1 && isHandleStackTopBack) {
109
+ onStackTopBack();
110
+ return;
111
+ }
112
+ navigation.goBack();
113
+ }}>
114
+ <View style={[styles.backButton]}>
115
+ <Image style={[styles.backButtonImage, { tintColor: navigationBarTextStyle }]} source={{ uri: BACK_ICON }}></Image>
116
+ </View>
117
+ </TouchableWithoutFeedback>)
118
+ : null;
119
+ return (<View style={[
120
+ styles.header,
121
+ {
122
+ paddingTop: safeAreaTop,
123
+ backgroundColor: innerPageConfig.navigationBarBackgroundColor || '#000000'
124
+ }
125
+ ]}>
126
+ {statusBarElement}
127
+ {/* TODO: 确定 height 的有效性 */}
128
+ {/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */}
129
+ {/* @ts-expect-error */}
130
+ <View style={styles.headerContent} height={titleHeight}>
131
+ {backElement}
132
+ <Text style={[styles.title, { color: navigationBarTextStyle }]} numberOfLines={1}>
133
+ {innerPageConfig.navigationBarTitleText?.trim() || ''}
134
+ </Text>
135
+ </View>
136
+ </View>);
137
+ });
138
+ innerNav.displayName = 'MpxNav';
139
+ return innerNav;
140
+ }
141
+ export default createMpxNav;