@mpxjs/webpack-plugin 2.10.6-beta.7 → 2.10.6-beta.8

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 (79) hide show
  1. package/lib/runtime/components/react/context.ts +8 -3
  2. package/lib/runtime/components/react/dist/AsyncSuspense.d.ts +16 -0
  3. package/lib/runtime/components/react/dist/context.d.ts +74 -0
  4. package/lib/runtime/components/react/dist/event.config.d.ts +7 -0
  5. package/lib/runtime/components/react/dist/getInnerListeners.d.ts +7 -0
  6. package/lib/runtime/components/react/dist/mpx-button.d.ts +68 -0
  7. package/lib/runtime/components/react/dist/mpx-canvas/Bus.d.ts +23 -0
  8. package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.d.ts +7 -0
  9. package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.d.ts +6 -0
  10. package/lib/runtime/components/react/dist/mpx-canvas/Image.d.ts +20 -0
  11. package/lib/runtime/components/react/dist/mpx-canvas/ImageData.d.ts +8 -0
  12. package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.d.ts +10 -0
  13. package/lib/runtime/components/react/dist/mpx-canvas/html.d.ts +2 -0
  14. package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts +32 -0
  15. package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts +52 -0
  16. package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts +20 -0
  17. package/lib/runtime/components/react/dist/mpx-checkbox.d.ts +32 -0
  18. package/lib/runtime/components/react/dist/mpx-form.d.ts +27 -0
  19. package/lib/runtime/components/react/dist/mpx-icon/index.d.ts +18 -0
  20. package/lib/runtime/components/react/dist/mpx-image.d.ts +21 -0
  21. package/lib/runtime/components/react/dist/mpx-inline-text.d.ts +7 -0
  22. package/lib/runtime/components/react/dist/mpx-input.d.ts +49 -0
  23. package/lib/runtime/components/react/dist/mpx-input.jsx +30 -9
  24. package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.d.ts +13 -0
  25. package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.jsx +63 -28
  26. package/lib/runtime/components/react/dist/mpx-label.d.ts +20 -0
  27. package/lib/runtime/components/react/dist/mpx-movable-area.d.ts +20 -0
  28. package/lib/runtime/components/react/dist/mpx-movable-view.d.ts +61 -0
  29. package/lib/runtime/components/react/dist/mpx-navigator.d.ts +9 -0
  30. package/lib/runtime/components/react/dist/mpx-picker/date.d.ts +6 -0
  31. package/lib/runtime/components/react/dist/mpx-picker/dateData.d.ts +7 -0
  32. package/lib/runtime/components/react/dist/mpx-picker/index.d.ts +6 -0
  33. package/lib/runtime/components/react/dist/mpx-picker/multiSelector.d.ts +6 -0
  34. package/lib/runtime/components/react/dist/mpx-picker/region.d.ts +6 -0
  35. package/lib/runtime/components/react/dist/mpx-picker/regionData.d.ts +2 -0
  36. package/lib/runtime/components/react/dist/mpx-picker/selector.d.ts +6 -0
  37. package/lib/runtime/components/react/dist/mpx-picker/time.d.ts +6 -0
  38. package/lib/runtime/components/react/dist/mpx-picker/type.d.ts +106 -0
  39. package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts +31 -0
  40. package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts +8 -0
  41. package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts +22 -0
  42. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts +14 -0
  43. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewFaces.d.ts +16 -0
  44. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewIndicator.d.ts +12 -0
  45. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewMask.d.ts +11 -0
  46. package/lib/runtime/components/react/dist/mpx-popup/index.d.ts +22 -0
  47. package/lib/runtime/components/react/dist/mpx-popup/popupBase.d.ts +16 -0
  48. package/lib/runtime/components/react/dist/mpx-portal/index.d.ts +15 -0
  49. package/lib/runtime/components/react/dist/mpx-portal/portal-host.d.ts +29 -0
  50. package/lib/runtime/components/react/dist/mpx-portal/portal-manager.d.ts +9 -0
  51. package/lib/runtime/components/react/dist/mpx-radio-group.d.ts +20 -0
  52. package/lib/runtime/components/react/dist/mpx-radio.d.ts +26 -0
  53. package/lib/runtime/components/react/dist/mpx-rich-text/html.d.ts +1 -0
  54. package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts +24 -0
  55. package/lib/runtime/components/react/dist/mpx-root-portal.d.ts +14 -0
  56. package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts +53 -0
  57. package/lib/runtime/components/react/dist/mpx-simple-text.d.ts +7 -0
  58. package/lib/runtime/components/react/dist/mpx-simple-view.d.ts +7 -0
  59. package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts +17 -0
  60. package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts +15 -0
  61. package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts +18 -0
  62. package/lib/runtime/components/react/dist/mpx-swiper.d.ts +53 -0
  63. package/lib/runtime/components/react/dist/mpx-switch.d.ts +26 -0
  64. package/lib/runtime/components/react/dist/mpx-text.d.ts +21 -0
  65. package/lib/runtime/components/react/dist/mpx-textarea.d.ts +7 -0
  66. package/lib/runtime/components/react/dist/mpx-video.d.ts +101 -0
  67. package/lib/runtime/components/react/dist/mpx-view.d.ts +34 -0
  68. package/lib/runtime/components/react/dist/mpx-web-view.d.ts +22 -0
  69. package/lib/runtime/components/react/dist/nav.d.ts +11 -0
  70. package/lib/runtime/components/react/dist/nav.jsx +189 -0
  71. package/lib/runtime/components/react/dist/parser.d.ts +39 -0
  72. package/lib/runtime/components/react/dist/useAnimationHooks.d.ts +32 -0
  73. package/lib/runtime/components/react/dist/useNodesRef.d.ts +11 -0
  74. package/lib/runtime/components/react/dist/utils.d.ts +121 -0
  75. package/lib/runtime/components/react/mpx-input.tsx +36 -16
  76. package/lib/runtime/components/react/mpx-keyboard-avoiding-view.tsx +68 -28
  77. package/lib/runtime/components/react/nav.tsx +219 -0
  78. package/lib/runtime/components/react/types/common.d.ts +19 -0
  79. package/package.json +1 -1
@@ -1,9 +1,10 @@
1
1
  import React, { useContext, useEffect } from 'react';
2
2
  import { Keyboard, View } from 'react-native';
3
3
  import Animated, { useSharedValue, useAnimatedStyle, withTiming, Easing } from 'react-native-reanimated';
4
+ import { getWindowInfo } from '@mpxjs/api-proxy';
4
5
  import { KeyboardAvoidContext } from './context';
5
6
  import { isIOS } from './utils';
6
- const KeyboardAvoidingView = ({ children, style, contentContainerStyle }) => {
7
+ const KeyboardAvoidingView = ({ children, style, contentContainerStyle, navigation }) => {
7
8
  const duration = isIOS ? 250 : 300;
8
9
  const easing = isIOS ? Easing.inOut(Easing.ease) : Easing.out(Easing.quad);
9
10
  const offset = useSharedValue(0);
@@ -15,7 +16,17 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }) => {
15
16
  }));
16
17
  const resetKeyboard = () => {
17
18
  if (keyboardAvoid?.current) {
19
+ const inputRef = keyboardAvoid.current.ref?.current;
20
+ if (inputRef && inputRef.isFocused()) {
21
+ // 修复 Android 点击键盘收起按钮时当前 input 没触发失焦的问题
22
+ inputRef.blur();
23
+ }
18
24
  keyboardAvoid.current = null;
25
+ navigation.setPageConfig({
26
+ animatedNavStyle: {
27
+ top: withTiming(0, { duration: 100, easing: Easing.in(Easing.bezierFn(0.51, 1.18, 0.97, 0.94)) })
28
+ }
29
+ });
19
30
  }
20
31
  offset.value = withTiming(0, { duration, easing });
21
32
  basic.value = 'auto';
@@ -33,21 +44,25 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }) => {
33
44
  if (!keyboardAvoid?.current)
34
45
  return;
35
46
  const { endCoordinates } = evt;
36
- const { ref, cursorSpacing = 0 } = keyboardAvoid.current;
37
- setTimeout(() => {
38
- ref?.current?.measure((x, y, width, height, pageX, pageY) => {
39
- const aboveOffset = offset.value + pageY + height - endCoordinates.screenY;
40
- const aboveValue = -aboveOffset >= cursorSpacing ? 0 : aboveOffset + cursorSpacing;
41
- const belowValue = Math.min(endCoordinates.height, aboveOffset + cursorSpacing);
42
- const value = aboveOffset > 0 ? belowValue : aboveValue;
43
- offset.value = withTiming(value, { duration, easing }, (finished) => {
44
- if (finished) {
45
- // Set flexBasic after animation to trigger re-layout and reset layout information
46
- basic.value = '99.99%';
47
- }
47
+ const { ref, cursorSpacing = 0, adjustPosition, onKeyboardShow } = keyboardAvoid.current;
48
+ keyboardAvoid.current.keyboardHeight = endCoordinates.height;
49
+ onKeyboardShow?.();
50
+ if (adjustPosition) {
51
+ setTimeout(() => {
52
+ ref?.current?.measure((x, y, width, height, pageX, pageY) => {
53
+ const aboveOffset = offset.value + pageY + height - endCoordinates.screenY;
54
+ const aboveValue = -aboveOffset >= cursorSpacing ? 0 : aboveOffset + cursorSpacing;
55
+ const belowValue = Math.min(endCoordinates.height, aboveOffset + cursorSpacing);
56
+ const value = aboveOffset > 0 ? belowValue : aboveValue;
57
+ offset.value = withTiming(value, { duration, easing }, (finished) => {
58
+ if (finished) {
59
+ // Set flexBasic after animation to trigger re-layout and reset layout information
60
+ basic.value = '99.99%';
61
+ }
62
+ });
48
63
  });
49
64
  });
50
- });
65
+ }
51
66
  }),
52
67
  Keyboard.addListener('keyboardWillHide', resetKeyboard)
53
68
  ];
@@ -58,20 +73,40 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }) => {
58
73
  if (!keyboardAvoid?.current)
59
74
  return;
60
75
  const { endCoordinates } = evt;
61
- const { ref, cursorSpacing = 0 } = keyboardAvoid.current;
62
- ref?.current?.measure((x, y, width, height, pageX, pageY) => {
63
- const aboveOffset = pageY + height - endCoordinates.screenY;
64
- const belowOffset = endCoordinates.height - aboveOffset;
65
- const aboveValue = -aboveOffset >= cursorSpacing ? 0 : aboveOffset + cursorSpacing;
66
- const belowValue = Math.min(belowOffset, cursorSpacing);
67
- const value = aboveOffset > 0 ? belowValue : aboveValue;
68
- offset.value = withTiming(value, { duration, easing }, (finished) => {
69
- if (finished) {
70
- // Set flexBasic after animation to trigger re-layout and reset layout information
71
- basic.value = '99.99%';
72
- }
76
+ const { ref, cursorSpacing = 0, adjustPosition, onKeyboardShow } = keyboardAvoid.current;
77
+ // android 上键盘消失只能使用 keyboardDidHide 事件,对于需要和键盘一起改变位置的 nav 来说
78
+ // keyboardDidHide 是比较晚的,从动画上看也并不同步,因此采用比较早的blur
79
+ keyboardAvoid.current.blurCallbacks.push(resetKeyboard);
80
+ keyboardAvoid.current.keyboardHeight = endCoordinates.height;
81
+ onKeyboardShow?.();
82
+ if (adjustPosition) {
83
+ ref?.current?.measure((x, y, width, height, pageX, pageY) => {
84
+ const screenHeightRatio = getWindowInfo().screenHeight /
85
+ (endCoordinates.screenY + endCoordinates.height);
86
+ const navAboveOffset = pageY + height - Math.floor(endCoordinates.screenY * screenHeightRatio);
87
+ const aboveOffset = pageY + height - endCoordinates.screenY;
88
+ const belowOffset = endCoordinates.height - aboveOffset;
89
+ const aboveValue = -aboveOffset >= cursorSpacing ? 0 : aboveOffset + cursorSpacing;
90
+ const belowValue = Math.min(belowOffset, cursorSpacing);
91
+ const value = aboveOffset > 0 ? belowValue : aboveValue;
92
+ navigation.setPageConfig({
93
+ animatedNavStyle: {
94
+ // android 手机本身支持将页面整体上移(包含 nav 和 body)
95
+ // mpx-keyboard-avoiding-view 和 nav 使用 transform 时互不影响,因此这里只需要计算 android 键盘出现导致上移的高度即可
96
+ top: withTiming(navAboveOffset, {
97
+ duration: 100,
98
+ easing
99
+ })
100
+ }
101
+ });
102
+ offset.value = withTiming(value, { duration, easing }, (finished) => {
103
+ if (finished) {
104
+ // Set flexBasic after animation to trigger re-layout and reset layout information
105
+ basic.value = '99.99%';
106
+ }
107
+ });
73
108
  });
74
- });
109
+ }
75
110
  }),
76
111
  Keyboard.addListener('keyboardDidHide', resetKeyboard)
77
112
  ];
@@ -80,7 +115,7 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }) => {
80
115
  subscriptions.forEach(subscription => subscription.remove());
81
116
  };
82
117
  }, [keyboardAvoid]);
83
- return (<View style={style} onTouchEnd={onTouchEnd}>
118
+ return (<View style={style} onTouchEnd={onTouchEnd} onTouchMove={onTouchEnd}>
84
119
  <Animated.View style={[
85
120
  contentContainerStyle,
86
121
  animatedStyle
@@ -0,0 +1,20 @@
1
+ /**
2
+ * ✘ for
3
+ */
4
+ import { ReactNode } from 'react';
5
+ import { View, ViewStyle, NativeSyntheticEvent } from 'react-native';
6
+ import { HandlerRef } from './useNodesRef';
7
+ export interface LabelProps {
8
+ for?: string;
9
+ style?: ViewStyle & Record<string, any>;
10
+ 'enable-offset'?: boolean;
11
+ 'enable-var'?: boolean;
12
+ 'external-var-context'?: Record<string, any>;
13
+ 'parent-font-size'?: number;
14
+ 'parent-width'?: number;
15
+ 'parent-height'?: number;
16
+ children: ReactNode;
17
+ bindtap?: (evt: NativeSyntheticEvent<TouchEvent> | unknown) => void;
18
+ }
19
+ declare const Label: import("react").ForwardRefExoticComponent<LabelProps & import("react").RefAttributes<HandlerRef<View, LabelProps>>>;
20
+ export default Label;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * ✘ scale-area
3
+ */
4
+ import { View } from 'react-native';
5
+ import { ReactNode } from 'react';
6
+ import { HandlerRef } from './useNodesRef';
7
+ interface MovableAreaProps {
8
+ style?: Record<string, any>;
9
+ children: ReactNode;
10
+ width?: number;
11
+ height?: number;
12
+ 'enable-offset'?: boolean;
13
+ 'enable-var'?: boolean;
14
+ 'external-var-context'?: Record<string, any>;
15
+ 'parent-font-size'?: number;
16
+ 'parent-width'?: number;
17
+ 'parent-height'?: number;
18
+ }
19
+ declare const _MovableArea: import("react").ForwardRefExoticComponent<MovableAreaProps & import("react").RefAttributes<HandlerRef<View, MovableAreaProps>>>;
20
+ export default _MovableArea;
@@ -0,0 +1,61 @@
1
+ /**
2
+ * ✔ direction
3
+ * ✔ inertia
4
+ * ✔ out-of-bounds
5
+ * ✔ x
6
+ * ✔ y
7
+ * ✘ damping
8
+ * ✘ friction
9
+ * ✔ disabled
10
+ * ✘ scale
11
+ * ✘ scale-min
12
+ * ✘ scale-max
13
+ * ✘ scale-value
14
+ * ✔ animation
15
+ * ✔ bindchange
16
+ * ✘ bindscale
17
+ * ✔ htouchmove
18
+ * ✔ vtouchmove
19
+ */
20
+ import { ReactNode } from 'react';
21
+ import { View, LayoutChangeEvent } from 'react-native';
22
+ import { HandlerRef } from './useNodesRef';
23
+ import { GestureHandler } from './utils';
24
+ import { GestureTouchEvent } from 'react-native-gesture-handler';
25
+ interface MovableViewProps {
26
+ children: ReactNode;
27
+ style?: Record<string, any>;
28
+ direction: 'all' | 'vertical' | 'horizontal' | 'none';
29
+ x?: number;
30
+ y?: number;
31
+ disabled?: boolean;
32
+ animation?: boolean;
33
+ id?: string;
34
+ bindchange?: (event: unknown) => void;
35
+ bindtouchstart?: (event: GestureTouchEvent) => void;
36
+ catchtouchstart?: (event: GestureTouchEvent) => void;
37
+ bindtouchmove?: (event: GestureTouchEvent) => void;
38
+ catchtouchmove?: (event: GestureTouchEvent) => void;
39
+ catchtouchend?: (event: GestureTouchEvent) => void;
40
+ bindtouchend?: (event: GestureTouchEvent) => void;
41
+ bindhtouchmove?: (event: GestureTouchEvent) => void;
42
+ bindvtouchmove?: (event: GestureTouchEvent) => void;
43
+ catchhtouchmove?: (event: GestureTouchEvent) => void;
44
+ catchvtouchmove?: (event: GestureTouchEvent) => void;
45
+ bindlongpress?: (event: GestureTouchEvent) => void;
46
+ catchlongpress?: (event: GestureTouchEvent) => void;
47
+ bindtap?: (event: GestureTouchEvent) => void;
48
+ catchtap?: (event: GestureTouchEvent) => void;
49
+ onLayout?: (event: LayoutChangeEvent) => void;
50
+ 'out-of-bounds'?: boolean;
51
+ 'wait-for'?: Array<GestureHandler>;
52
+ 'simultaneous-handlers'?: Array<GestureHandler>;
53
+ inertia?: boolean;
54
+ 'enable-var'?: boolean;
55
+ 'external-var-context'?: Record<string, any>;
56
+ 'parent-font-size'?: number;
57
+ 'parent-width'?: number;
58
+ 'parent-height'?: number;
59
+ }
60
+ declare const _MovableView: import("react").ForwardRefExoticComponent<MovableViewProps & import("react").RefAttributes<HandlerRef<View, MovableViewProps>>>;
61
+ export default _MovableView;
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ import { _ViewProps } from './mpx-view';
3
+ interface _NavigatorProps extends _ViewProps {
4
+ ['open-type']: 'navigate' | 'redirect' | 'switchTab' | 'reLaunch' | 'navigateBack';
5
+ url: string;
6
+ delta: number;
7
+ }
8
+ declare const _Navigator: import("react").ForwardRefExoticComponent<_NavigatorProps & import("react").RefAttributes<any>>;
9
+ export default _Navigator;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { View } from 'react-native';
3
+ import { DateProps } from './type';
4
+ import { HandlerRef } from '../useNodesRef';
5
+ declare const PickerDate: React.ForwardRefExoticComponent<Omit<DateProps, "ref"> & React.RefAttributes<HandlerRef<View, DateProps>>>;
6
+ export default PickerDate;
@@ -0,0 +1,7 @@
1
+ export declare const wrapDate: (union?: string) => (num: number) => string;
2
+ export declare const START_YEAR = 1900;
3
+ export declare const END_YEAR = 2099;
4
+ export declare const years: string[];
5
+ export declare const months: string[];
6
+ export declare const daysInMonthLength: (year: number, month: number) => 30 | 28 | 29 | 31;
7
+ export declare const daysInMonth: (year: number, month: number) => string[];
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { View } from 'react-native';
3
+ import { HandlerRef } from '../useNodesRef';
4
+ import { PickerProps } from './type';
5
+ declare const Picker: React.ForwardRefExoticComponent<(Omit<import("./type").DateProps, "ref"> | Omit<import("./type").SelectorProps, "ref"> | Omit<import("./type").MultiSelectorProps, "ref"> | Omit<import("./type").TimeProps, "ref"> | Omit<import("./type").RegionProps, "ref">) & React.RefAttributes<HandlerRef<View, PickerProps>>>;
6
+ export default Picker;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { View } from 'react-native';
3
+ import { MultiSelectorProps } from './type';
4
+ import { HandlerRef } from '../useNodesRef';
5
+ declare const PickerMultiSelector: React.ForwardRefExoticComponent<Omit<MultiSelectorProps, "ref"> & React.RefAttributes<HandlerRef<View, MultiSelectorProps>>>;
6
+ export default PickerMultiSelector;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { View } from 'react-native';
3
+ import { RegionProps } from './type';
4
+ import { HandlerRef } from '../useNodesRef';
5
+ declare const PickerRegion: React.ForwardRefExoticComponent<Omit<RegionProps, "ref"> & React.RefAttributes<HandlerRef<View, RegionProps>>>;
6
+ export default PickerRegion;
@@ -0,0 +1,2 @@
1
+ import { RegionObj } from './type';
2
+ export declare const regionData: RegionObj[];
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { View } from 'react-native';
3
+ import { SelectorProps } from './type';
4
+ import { HandlerRef } from '../useNodesRef';
5
+ declare const PickerSelector: React.ForwardRefExoticComponent<Omit<SelectorProps, "ref"> & React.RefAttributes<HandlerRef<View, SelectorProps>>>;
6
+ export default PickerSelector;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { View } from 'react-native';
3
+ import { TimeProps } from './type';
4
+ import { HandlerRef } from '../useNodesRef';
5
+ declare const PickerTime: React.ForwardRefExoticComponent<Omit<TimeProps, "ref"> & React.RefAttributes<HandlerRef<View, TimeProps>>>;
6
+ export default PickerTime;
@@ -0,0 +1,106 @@
1
+ import React from 'react';
2
+ export declare const enum PickerMode {
3
+ SELECTOR = "selector",
4
+ MULTI_SELECTOR = "multiSelector",
5
+ TIME = "time",
6
+ DATE = "date",
7
+ REGION = "region"
8
+ }
9
+ export type PickerValue = number;
10
+ export type Obj = Record<string, any>;
11
+ export type RangeItem = Obj | number | string;
12
+ export type TimeValue = `${number}-${number}-${number}` | '';
13
+ /** 通用属性 */
14
+ export interface BasePickerProps {
15
+ /** --- 小程序属性 --- */
16
+ /** 选择器类型, 默认值 selector */
17
+ mode?: PickerMode;
18
+ /** 是否禁用, 默认值 false */
19
+ disabled?: boolean;
20
+ /** 点击取消按钮时触发 */
21
+ bindcancel?: Function;
22
+ /** 头部标题 */
23
+ 'header-text'?: string;
24
+ /** --- 内部组件属性 --- */
25
+ /** 作为表单组件时的名称 */
26
+ name?: string;
27
+ style?: Record<string, any>;
28
+ children?: React.ReactNode;
29
+ range?: RangeItem[];
30
+ ref?: any;
31
+ }
32
+ export interface SelectorProps extends BasePickerProps {
33
+ mode: PickerMode.SELECTOR;
34
+ /** 默认值 0 */
35
+ value?: number;
36
+ /** 默认值 [] */
37
+ range?: RangeItem[];
38
+ 'range-key'?: string;
39
+ /** 点击确认按钮后触发 change 事件, event.detail = {value} */
40
+ bindchange?: Function;
41
+ }
42
+ export interface MultiSelectorProps extends BasePickerProps {
43
+ mode: PickerMode.MULTI_SELECTOR;
44
+ /** 默认值 [] */
45
+ value?: number[];
46
+ range?: RangeItem[];
47
+ 'range-key'?: string;
48
+ bindchange?: Function;
49
+ bindcolumnchange?: Function;
50
+ }
51
+ export interface TimeProps extends BasePickerProps {
52
+ mode: PickerMode.TIME;
53
+ /** 表示选中的时间,格式为"hh:mm" */
54
+ value?: string;
55
+ start?: string;
56
+ end?: string;
57
+ bindchange?: Function;
58
+ }
59
+ export interface DateProps extends BasePickerProps {
60
+ mode: PickerMode.DATE;
61
+ /** 默认值 '' */
62
+ value?: TimeValue;
63
+ start?: TimeValue;
64
+ end?: TimeValue;
65
+ /** 有效值 year,month,day,表示选择器的粒度 */
66
+ fields?: 'day' | 'month' | 'year';
67
+ bindchange?: Function;
68
+ }
69
+ export interface RegionProps extends BasePickerProps {
70
+ mode: PickerMode.REGION;
71
+ /** 表示选中的省市区,默认选中每一列的第一个值, 默认值 [] */
72
+ value?: string[];
73
+ /** 默认值 region */
74
+ level?: 'province' | 'city' | 'region' | 'sub-district';
75
+ /** 可为每一列的顶部添加一个自定义的项 */
76
+ 'custom-item'?: string;
77
+ /** value 改变时触发 change 事件, event.detail = {value, code, postcode},
78
+ * 其中字段 code 是统计用区划代码, postcode 是邮政编码 */
79
+ bindchange?: Function;
80
+ }
81
+ export interface RegionObj {
82
+ value: string;
83
+ code: string;
84
+ postcode?: string;
85
+ children?: RegionObj[];
86
+ }
87
+ export interface PickerData {
88
+ value: string;
89
+ label: string;
90
+ children?: Object[];
91
+ }
92
+ export interface EventType {
93
+ detail: {
94
+ value: PickerValue[];
95
+ };
96
+ }
97
+ export interface LayoutType {
98
+ nativeEvent: {
99
+ layout: Obj;
100
+ };
101
+ }
102
+ export interface FormType {
103
+ name: string;
104
+ }
105
+ export type PickerProps = SelectorProps | MultiSelectorProps | TimeProps | DateProps | RegionProps;
106
+ export type LanguageCode = 'zh-CN' | 'en-US';
@@ -0,0 +1,31 @@
1
+ import { View } from 'react-native';
2
+ import React from 'react';
3
+ import { HandlerRef } from '../useNodesRef';
4
+ import type { AnyFunc } from '../types/common';
5
+ /**
6
+ * ✔ value
7
+ * ✔ bindchange
8
+ * ✘ bindpickstart
9
+ * ✘ bindpickend
10
+ * ✔ mask-class
11
+ * ✔ indicator-style: 优先级indicator-style.height > pick-view-column中的子元素设置的height
12
+ * WebView Only:
13
+ * ✔ indicator-class
14
+ * ✔ mask-style
15
+ * ✘ immediate-change
16
+ */
17
+ interface PickerViewProps {
18
+ children: React.ReactNode;
19
+ value?: Array<number>;
20
+ bindchange?: AnyFunc;
21
+ style?: {
22
+ [key: string]: any;
23
+ };
24
+ 'indicator-style'?: Record<string, any>;
25
+ 'mask-style'?: Record<string, any>;
26
+ 'enable-var'?: boolean;
27
+ 'external-var-context'?: Record<string, any>;
28
+ 'enable-offset'?: boolean;
29
+ }
30
+ declare const _PickerView: React.ForwardRefExoticComponent<PickerViewProps & React.RefAttributes<HandlerRef<View, PickerViewProps>>>;
31
+ export default _PickerView;
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ import { SharedValue } from 'react-native-reanimated';
3
+ type ContextValue = SharedValue<number>;
4
+ export declare const PickerViewColumnAnimationContext: import("react").Context<ContextValue | undefined>;
5
+ export declare const usePickerViewColumnAnimationContext: () => ContextValue;
6
+ export declare const PickerViewStyleContext: import("react").Context<Record<string, any> | undefined>;
7
+ export declare const usePickerViewStyleContext: () => Record<string, any> | undefined;
8
+ export {};
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+ import { ScrollView, View } from 'react-native';
3
+ import { HandlerRef } from '../useNodesRef';
4
+ interface ColumnProps {
5
+ columnIndex: number;
6
+ columnData: React.ReactNode[];
7
+ initialIndex: number;
8
+ onSelectChange: Function;
9
+ style: {
10
+ [key: string]: any;
11
+ };
12
+ 'enable-var'?: boolean;
13
+ 'external-var-context'?: Record<string, any>;
14
+ wrapperStyle: {
15
+ height: number;
16
+ itemHeight: number;
17
+ };
18
+ pickerMaskStyle: Record<string, any>;
19
+ pickerIndicatorStyle: Record<string, any>;
20
+ }
21
+ declare const _PickerViewColumn: React.ForwardRefExoticComponent<ColumnProps & React.RefAttributes<HandlerRef<ScrollView & View, ColumnProps>>>;
22
+ export default _PickerViewColumn;
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import { LayoutChangeEvent } from 'react-native';
3
+ interface PickerColumnItemProps {
4
+ item: React.ReactElement;
5
+ index: number;
6
+ itemHeight: number;
7
+ itemWidth?: number | '100%';
8
+ textStyle: Record<string, any>;
9
+ visibleCount: number;
10
+ textProps?: any;
11
+ onItemLayout?: (e: LayoutChangeEvent) => void;
12
+ }
13
+ declare const PickerViewColumnItem: React.FC<PickerColumnItemProps>;
14
+ export default PickerViewColumnItem;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Borrowed from open-source code: https://github.com/quidone/react-native-wheel-picker
3
+ * Special thanks to the authors for their contribution to the open-source community.
4
+ */
5
+ export type Faces = {
6
+ index: number;
7
+ deg: number;
8
+ offsetY: number;
9
+ opacity: number;
10
+ scale: number;
11
+ screenHeight: number;
12
+ };
13
+ export declare const degToRad: (deg: number) => number;
14
+ export declare const calcPickerHeight: (faces: Faces[], itemHeight: number) => number;
15
+ export declare const calcHeightOffsets: (itemHeight: number) => number[];
16
+ export declare const createFaces: (itemHeight: number, visibleCount: number) => Faces[];
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import { StyleProp, ViewStyle } from 'react-native';
3
+ type IndicatorProps = {
4
+ itemHeight: number;
5
+ indicatorItemStyle?: StyleProp<ViewStyle>;
6
+ indicatorContainerStyle?: StyleProp<ViewStyle>;
7
+ };
8
+ declare const _PickerViewIndicator: {
9
+ ({ itemHeight, indicatorItemStyle, indicatorContainerStyle }: IndicatorProps): React.JSX.Element;
10
+ displayName: string;
11
+ };
12
+ export default _PickerViewIndicator;
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { StyleProp, ViewStyle } from 'react-native';
3
+ type MaskProps = {
4
+ itemHeight: number;
5
+ maskContainerStyle?: StyleProp<ViewStyle>;
6
+ };
7
+ declare const _PickerViewMask: {
8
+ ({ itemHeight, maskContainerStyle }: MaskProps): React.JSX.Element;
9
+ displayName: string;
10
+ };
11
+ export default _PickerViewMask;
@@ -0,0 +1,22 @@
1
+ import { ReactElement } from 'react';
2
+ import { PopupBaseProps } from './popupBase';
3
+ export declare const enum PopupType {
4
+ PICKER = "picker"
5
+ }
6
+ export interface IUsePopupOptions {
7
+ modal?: React.ComponentType<PopupBaseProps>;
8
+ type?: PopupType;
9
+ }
10
+ /**
11
+ * 基于 Portal 封装的 Popup 弹窗组件管理 Hooks
12
+ */
13
+ declare const createPopupManager: (options?: IUsePopupOptions) => {
14
+ open: (childComponent: React.ReactNode, pageId: number | undefined, options?: {
15
+ contentHeight?: number;
16
+ }) => void;
17
+ show: () => void;
18
+ hide: () => void;
19
+ update: (updatedChild: ReactElement | null) => void;
20
+ remove: () => void;
21
+ };
22
+ export { createPopupManager };
@@ -0,0 +1,16 @@
1
+ /// <reference types="react" />
2
+ export interface PopupBaseProps {
3
+ children?: React.ReactNode;
4
+ hide?: () => void;
5
+ contentHeight?: number;
6
+ visible?: boolean;
7
+ }
8
+ /**
9
+ * 类似微信 picker 弹窗的动画效果都可以复用此类容器
10
+ * 其他特定类型的弹窗容器组件可以在此基础上封装,或者扩展实现
11
+ */
12
+ declare const PopupBase: {
13
+ (props?: PopupBaseProps): import("react").JSX.Element;
14
+ displayName: string;
15
+ };
16
+ export default PopupBase;
@@ -0,0 +1,15 @@
1
+ import { ReactNode } from 'react';
2
+ export type PortalProps = {
3
+ children?: ReactNode;
4
+ };
5
+ declare const Portal: {
6
+ ({ children }: PortalProps): null;
7
+ Host: ({ children }: {
8
+ children: ReactNode;
9
+ pageId: number;
10
+ }) => JSX.Element;
11
+ add: (e: ReactNode, id: number | null) => number;
12
+ remove: (key: number) => void;
13
+ update: (key: number, e: ReactNode) => void;
14
+ };
15
+ export default Portal;
@@ -0,0 +1,29 @@
1
+ import { ReactNode } from 'react';
2
+ type PortalHostProps = {
3
+ children: ReactNode;
4
+ pageId: number;
5
+ };
6
+ export type Operation = {
7
+ type: 'mount';
8
+ key: number;
9
+ children: ReactNode;
10
+ } | {
11
+ type: 'update';
12
+ key: number;
13
+ children: ReactNode;
14
+ } | {
15
+ type: 'unmount';
16
+ key: number;
17
+ };
18
+ declare class PortalGuard {
19
+ private nextKey;
20
+ add: (e: ReactNode, id: number | null) => number;
21
+ remove: (key: number) => void;
22
+ update: (key: number, e: ReactNode) => void;
23
+ }
24
+ /**
25
+ * portal
26
+ */
27
+ export declare const portal: PortalGuard;
28
+ declare const PortalHost: ({ children }: PortalHostProps) => JSX.Element;
29
+ export default PortalHost;
@@ -0,0 +1,9 @@
1
+ import { ReactNode } from 'react';
2
+ export type State = {
3
+ portals: Array<{
4
+ key: number;
5
+ children: ReactNode;
6
+ }>;
7
+ };
8
+ declare const _PortalManager: import("react").ForwardRefExoticComponent<import("react").RefAttributes<unknown>>;
9
+ export default _PortalManager;