@mpxjs/webpack-plugin 2.10.14-beta.1 → 2.10.14-beta.11

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 (107) hide show
  1. package/lib/dependencies/ImportDependency.js +102 -0
  2. package/lib/index.js +9 -9
  3. package/lib/platform/style/wx/index.js +7 -1
  4. package/lib/platform/template/wx/component-config/button.js +13 -4
  5. package/lib/platform/template/wx/component-config/index.js +3 -1
  6. package/lib/platform/template/wx/component-config/nav-container.js +27 -0
  7. package/lib/react/processScript.js +4 -2
  8. package/lib/react/script-helper.js +3 -3
  9. package/lib/runtime/components/ali/mpx-nav-container.mpx +3 -0
  10. package/lib/runtime/components/react/context.ts +17 -6
  11. package/lib/runtime/components/react/dist/context.d.ts +78 -0
  12. package/lib/runtime/components/react/dist/context.js +1 -0
  13. package/lib/runtime/components/react/dist/event.config.d.ts +7 -0
  14. package/lib/runtime/components/react/dist/getInnerListeners.d.ts +7 -0
  15. package/lib/runtime/components/react/dist/mpx-async-suspense.d.ts +12 -0
  16. package/lib/runtime/components/react/dist/mpx-button.d.ts +68 -0
  17. package/lib/runtime/components/react/dist/mpx-canvas/Bus.d.ts +23 -0
  18. package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.d.ts +7 -0
  19. package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.d.ts +6 -0
  20. package/lib/runtime/components/react/dist/mpx-canvas/Image.d.ts +20 -0
  21. package/lib/runtime/components/react/dist/mpx-canvas/ImageData.d.ts +8 -0
  22. package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.d.ts +10 -0
  23. package/lib/runtime/components/react/dist/mpx-canvas/html.d.ts +2 -0
  24. package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts +32 -0
  25. package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts +52 -0
  26. package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts +20 -0
  27. package/lib/runtime/components/react/dist/mpx-checkbox.d.ts +32 -0
  28. package/lib/runtime/components/react/dist/mpx-form.d.ts +27 -0
  29. package/lib/runtime/components/react/dist/mpx-icon/index.d.ts +18 -0
  30. package/lib/runtime/components/react/dist/mpx-image.d.ts +21 -0
  31. package/lib/runtime/components/react/dist/mpx-inline-text.d.ts +7 -0
  32. package/lib/runtime/components/react/dist/mpx-input.d.ts +50 -0
  33. package/lib/runtime/components/react/dist/mpx-input.jsx +36 -17
  34. package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.d.ts +12 -0
  35. package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.jsx +69 -48
  36. package/lib/runtime/components/react/dist/mpx-label.d.ts +20 -0
  37. package/lib/runtime/components/react/dist/mpx-movable-area.d.ts +20 -0
  38. package/lib/runtime/components/react/dist/mpx-movable-view.d.ts +63 -0
  39. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +24 -17
  40. package/lib/runtime/components/react/dist/mpx-nav-container.d.ts +9 -0
  41. package/lib/runtime/components/react/dist/mpx-nav-container.jsx +23 -0
  42. package/lib/runtime/components/react/dist/mpx-navigator.d.ts +9 -0
  43. package/lib/runtime/components/react/dist/mpx-picker/date.d.ts +6 -0
  44. package/lib/runtime/components/react/dist/mpx-picker/dateData.d.ts +7 -0
  45. package/lib/runtime/components/react/dist/mpx-picker/index.d.ts +6 -0
  46. package/lib/runtime/components/react/dist/mpx-picker/multiSelector.d.ts +6 -0
  47. package/lib/runtime/components/react/dist/mpx-picker/region.d.ts +6 -0
  48. package/lib/runtime/components/react/dist/mpx-picker/regionData.d.ts +2 -0
  49. package/lib/runtime/components/react/dist/mpx-picker/selector.d.ts +6 -0
  50. package/lib/runtime/components/react/dist/mpx-picker/time.d.ts +6 -0
  51. package/lib/runtime/components/react/dist/mpx-picker/type.d.ts +106 -0
  52. package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts +31 -0
  53. package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts +8 -0
  54. package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts +22 -0
  55. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts +14 -0
  56. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewFaces.d.ts +16 -0
  57. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewIndicator.d.ts +12 -0
  58. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewMask.d.ts +11 -0
  59. package/lib/runtime/components/react/dist/mpx-popup/index.d.ts +22 -0
  60. package/lib/runtime/components/react/dist/mpx-popup/popupBase.d.ts +16 -0
  61. package/lib/runtime/components/react/dist/mpx-portal/index.d.ts +15 -0
  62. package/lib/runtime/components/react/dist/mpx-portal/portal-host.d.ts +29 -0
  63. package/lib/runtime/components/react/dist/mpx-portal/portal-manager.d.ts +9 -0
  64. package/lib/runtime/components/react/dist/mpx-radio-group.d.ts +20 -0
  65. package/lib/runtime/components/react/dist/mpx-radio.d.ts +26 -0
  66. package/lib/runtime/components/react/dist/mpx-rich-text/html.d.ts +1 -0
  67. package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts +24 -0
  68. package/lib/runtime/components/react/dist/mpx-root-portal.d.ts +14 -0
  69. package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts +54 -0
  70. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +26 -8
  71. package/lib/runtime/components/react/dist/mpx-simple-text.d.ts +7 -0
  72. package/lib/runtime/components/react/dist/mpx-simple-view.d.ts +7 -0
  73. package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts +17 -0
  74. package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts +15 -0
  75. package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts +18 -0
  76. package/lib/runtime/components/react/dist/mpx-swiper.d.ts +52 -0
  77. package/lib/runtime/components/react/dist/mpx-swiper.jsx +48 -39
  78. package/lib/runtime/components/react/dist/mpx-switch.d.ts +26 -0
  79. package/lib/runtime/components/react/dist/mpx-text.d.ts +21 -0
  80. package/lib/runtime/components/react/dist/mpx-textarea.d.ts +7 -0
  81. package/lib/runtime/components/react/dist/mpx-video.d.ts +101 -0
  82. package/lib/runtime/components/react/dist/mpx-view.d.ts +34 -0
  83. package/lib/runtime/components/react/dist/mpx-view.jsx +1 -1
  84. package/lib/runtime/components/react/dist/mpx-web-view.d.ts +22 -0
  85. package/lib/runtime/components/react/dist/nav.d.ts +8 -0
  86. package/lib/runtime/components/react/dist/nav.jsx +137 -0
  87. package/lib/runtime/components/react/dist/parser.d.ts +39 -0
  88. package/lib/runtime/components/react/dist/useAnimationHooks.d.ts +32 -0
  89. package/lib/runtime/components/react/dist/useNavShared.d.ts +2 -0
  90. package/lib/runtime/components/react/dist/useNavShared.js +6 -0
  91. package/lib/runtime/components/react/dist/useNodesRef.d.ts +11 -0
  92. package/lib/runtime/components/react/dist/utils.d.ts +122 -0
  93. package/lib/runtime/components/react/mpx-input.tsx +46 -24
  94. package/lib/runtime/components/react/mpx-keyboard-avoiding-view.tsx +78 -47
  95. package/lib/runtime/components/react/mpx-movable-view.tsx +26 -20
  96. package/lib/runtime/components/react/mpx-nav-container.tsx +33 -0
  97. package/lib/runtime/components/react/mpx-scroll-view.tsx +30 -8
  98. package/lib/runtime/components/react/mpx-swiper.tsx +48 -37
  99. package/lib/runtime/components/react/mpx-view.tsx +1 -1
  100. package/lib/runtime/components/react/nav.tsx +163 -0
  101. package/lib/runtime/components/react/types/common.d.ts +19 -0
  102. package/lib/runtime/components/react/useNavShared.ts +8 -0
  103. package/lib/runtime/components/web/mpx-nav-container.vue +13 -0
  104. package/lib/runtime/components/wx/mpx-nav-container.mpx +9 -0
  105. package/lib/utils/dom-tag-config.js +2 -2
  106. package/package.json +1 -1
  107. package/lib/dependencies/ImportDependencyTemplate.js +0 -50
@@ -0,0 +1,63 @@
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
+ changeThrottleTime?: number;
35
+ bindchange?: (event: unknown) => void;
36
+ bindtouchstart?: (event: GestureTouchEvent) => void;
37
+ catchtouchstart?: (event: GestureTouchEvent) => void;
38
+ bindtouchmove?: (event: GestureTouchEvent) => void;
39
+ catchtouchmove?: (event: GestureTouchEvent) => void;
40
+ catchtouchend?: (event: GestureTouchEvent) => void;
41
+ bindtouchend?: (event: GestureTouchEvent) => void;
42
+ bindhtouchmove?: (event: GestureTouchEvent) => void;
43
+ bindvtouchmove?: (event: GestureTouchEvent) => void;
44
+ catchhtouchmove?: (event: GestureTouchEvent) => void;
45
+ catchvtouchmove?: (event: GestureTouchEvent) => void;
46
+ bindlongpress?: (event: GestureTouchEvent) => void;
47
+ catchlongpress?: (event: GestureTouchEvent) => void;
48
+ bindtap?: (event: GestureTouchEvent) => void;
49
+ catchtap?: (event: GestureTouchEvent) => void;
50
+ onLayout?: (event: LayoutChangeEvent) => void;
51
+ 'out-of-bounds'?: boolean;
52
+ 'wait-for'?: Array<GestureHandler>;
53
+ 'simultaneous-handlers'?: Array<GestureHandler>;
54
+ inertia?: boolean;
55
+ 'enable-var'?: boolean;
56
+ 'external-var-context'?: Record<string, any>;
57
+ 'parent-font-size'?: number;
58
+ 'parent-width'?: number;
59
+ 'parent-height'?: number;
60
+ 'disable-event-passthrough'?: boolean;
61
+ }
62
+ declare const _MovableView: import("react").ForwardRefExoticComponent<MovableViewProps & import("react").RefAttributes<HandlerRef<View, MovableViewProps>>>;
63
+ export default _MovableView;
@@ -22,7 +22,7 @@ import { StyleSheet } from 'react-native';
22
22
  import useInnerProps, { getCustomEvent } from './getInnerListeners';
23
23
  import useNodesRef from './useNodesRef';
24
24
  import { MovableAreaContext } from './context';
25
- import { useTransformStyle, splitProps, splitStyle, HIDDEN_STYLE, wrapChildren, flatGesture, extendObject, omit, useNavigation } from './utils';
25
+ import { useTransformStyle, splitProps, splitStyle, HIDDEN_STYLE, wrapChildren, flatGesture, extendObject, omit, useNavigation, useRunOnJSCallback } from './utils';
26
26
  import { GestureDetector, Gesture } from 'react-native-gesture-handler';
27
27
  import Animated, { useSharedValue, useAnimatedStyle, withDecay, runOnJS, runOnUI, withSpring } from 'react-native-reanimated';
28
28
  import { collectDataset, noop } from '@mpxjs/utils';
@@ -100,15 +100,6 @@ const _MovableView = forwardRef((movableViewProps, ref) => {
100
100
  layoutRef
101
101
  }, propsRef.current));
102
102
  }, []);
103
- // 节流版本的 change 事件触发
104
- const handleTriggerChangeThrottled = useCallback(({ x, y, type }) => {
105
- 'worklet';
106
- const now = Date.now();
107
- if (now - lastChangeTime.value >= changeThrottleTime) {
108
- lastChangeTime.value = now;
109
- runOnJS(handleTriggerChange)({ x, y, type });
110
- }
111
- }, [changeThrottleTime]);
112
103
  useEffect(() => {
113
104
  runOnUI(() => {
114
105
  if (offsetX.value !== x || offsetY.value !== y) {
@@ -130,7 +121,7 @@ const _MovableView = forwardRef((movableViewProps, ref) => {
130
121
  : newY;
131
122
  }
132
123
  if (bindchange) {
133
- runOnJS(handleTriggerChange)({
124
+ runOnJS(runOnJSCallback)('handleTriggerChange', {
134
125
  x: newX,
135
126
  y: newY,
136
127
  type: 'setData'
@@ -295,13 +286,29 @@ const _MovableView = forwardRef((movableViewProps, ref) => {
295
286
  bindtouchend && bindtouchend(e);
296
287
  catchtouchend && catchtouchend(e);
297
288
  };
289
+ const runOnJSCallbackRef = useRef({
290
+ handleTriggerChange,
291
+ triggerStartOnJS,
292
+ triggerMoveOnJS,
293
+ triggerEndOnJS
294
+ });
295
+ const runOnJSCallback = useRunOnJSCallback(runOnJSCallbackRef);
296
+ // 节流版本的 change 事件触发
297
+ const handleTriggerChangeThrottled = useCallback(({ x, y, type }) => {
298
+ 'worklet';
299
+ const now = Date.now();
300
+ if (now - lastChangeTime.value >= changeThrottleTime) {
301
+ lastChangeTime.value = now;
302
+ runOnJS(runOnJSCallback)('handleTriggerChange', { x, y, type });
303
+ }
304
+ }, [changeThrottleTime]);
298
305
  const gesture = useMemo(() => {
299
306
  const handleTriggerMove = (e) => {
300
307
  'worklet';
301
308
  const hasTouchmove = !!bindhtouchmove || !!bindvtouchmove || !!bindtouchmove;
302
309
  const hasCatchTouchmove = !!catchhtouchmove || !!catchvtouchmove || !!catchtouchmove;
303
310
  if (hasTouchmove || hasCatchTouchmove) {
304
- runOnJS(triggerMoveOnJS)({
311
+ runOnJS(runOnJSCallback)('triggerMoveOnJS', {
305
312
  e,
306
313
  touchEvent: touchEvent.value,
307
314
  hasTouchmove,
@@ -319,7 +326,7 @@ const _MovableView = forwardRef((movableViewProps, ref) => {
319
326
  y: changedTouches.y
320
327
  };
321
328
  if (bindtouchstart || catchtouchstart) {
322
- runOnJS(triggerStartOnJS)({ e });
329
+ runOnJS(runOnJSCallback)('triggerStartOnJS', { e });
323
330
  }
324
331
  })
325
332
  .onStart(() => {
@@ -376,7 +383,7 @@ const _MovableView = forwardRef((movableViewProps, ref) => {
376
383
  isFirstTouch.value = true;
377
384
  isMoving.value = false;
378
385
  if (bindtouchend || catchtouchend) {
379
- runOnJS(triggerEndOnJS)({ e });
386
+ runOnJS(runOnJSCallback)('triggerEndOnJS', { e });
380
387
  }
381
388
  })
382
389
  .onEnd((e) => {
@@ -405,7 +412,7 @@ const _MovableView = forwardRef((movableViewProps, ref) => {
405
412
  : y;
406
413
  }
407
414
  if (bindchange) {
408
- runOnJS(handleTriggerChange)({
415
+ runOnJS(runOnJSCallback)('handleTriggerChange', {
409
416
  x,
410
417
  y
411
418
  });
@@ -423,7 +430,7 @@ const _MovableView = forwardRef((movableViewProps, ref) => {
423
430
  }, () => {
424
431
  xInertialMotion.value = false;
425
432
  if (bindchange) {
426
- runOnJS(handleTriggerChange)({
433
+ runOnJS(runOnJSCallback)('handleTriggerChange', {
427
434
  x: offsetX.value,
428
435
  y: offsetY.value
429
436
  });
@@ -439,7 +446,7 @@ const _MovableView = forwardRef((movableViewProps, ref) => {
439
446
  }, () => {
440
447
  yInertialMotion.value = false;
441
448
  if (bindchange) {
442
- runOnJS(handleTriggerChange)({
449
+ runOnJS(runOnJSCallback)('handleTriggerChange', {
443
450
  x: offsetX.value,
444
451
  y: offsetY.value
445
452
  });
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ interface MpxNavContainerProps {
3
+ children?: React.ReactNode;
4
+ }
5
+ export default function MpxNavContainer(props: MpxNavContainerProps): import("react").ReactNode;
6
+ export declare function NavSharedProvider({ children }: {
7
+ children?: React.ReactNode;
8
+ }): import("react").JSX.Element;
9
+ export {};
@@ -0,0 +1,23 @@
1
+ import { useNavShared } from './useNavShared';
2
+ import { NavSharedContext } from './context';
3
+ import { useLayoutEffect, useMemo, useState } from 'react';
4
+ import { isAndroid } from './utils';
5
+ export default function MpxNavContainer(props) {
6
+ const [, setCustomNav] = useNavShared();
7
+ useLayoutEffect(() => {
8
+ if (!isAndroid)
9
+ return;
10
+ if (props.children) {
11
+ setCustomNav(props.children);
12
+ }
13
+ return () => {
14
+ setCustomNav(undefined);
15
+ };
16
+ }, [props.children]);
17
+ return isAndroid ? null : props.children;
18
+ }
19
+ export function NavSharedProvider({ children }) {
20
+ const [customNav, setCustomNav] = useState();
21
+ const value = useMemo(() => ({ customNav, setCustomNav }), [customNav]);
22
+ return <NavSharedContext.Provider value={value}>{children}</NavSharedContext.Provider>;
23
+ }
@@ -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;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * ✔ bindchange
3
+ */
4
+ import { ReactNode } from 'react';
5
+ import { View, NativeSyntheticEvent, ViewStyle } from 'react-native';
6
+ import { HandlerRef } from './useNodesRef';
7
+ export interface RadioGroupProps {
8
+ name: 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
+ bindchange?: (evt: NativeSyntheticEvent<TouchEvent> | unknown) => void;
18
+ }
19
+ declare const radioGroup: import("react").ForwardRefExoticComponent<RadioGroupProps & import("react").RefAttributes<HandlerRef<View, RadioGroupProps>>>;
20
+ export default radioGroup;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * ✔ value
3
+ * ✔ disabled
4
+ * ✔ checked
5
+ * ✔ color
6
+ */
7
+ import { ReactNode } from 'react';
8
+ import { View, ViewStyle, NativeSyntheticEvent } from 'react-native';
9
+ import { HandlerRef } from './useNodesRef';
10
+ export interface RadioProps {
11
+ value?: string;
12
+ checked?: boolean;
13
+ disabled?: boolean;
14
+ color?: string;
15
+ style?: ViewStyle & Record<string, any>;
16
+ 'enable-offset'?: boolean;
17
+ 'enable-var'?: boolean;
18
+ 'external-var-context'?: Record<string, any>;
19
+ 'parent-font-size'?: number;
20
+ 'parent-width'?: number;
21
+ 'parent-height'?: number;
22
+ children: ReactNode;
23
+ bindtap?: (evt: NativeSyntheticEvent<TouchEvent> | unknown) => void;
24
+ }
25
+ declare const Radio: import("react").ForwardRefExoticComponent<RadioProps & import("react").RefAttributes<HandlerRef<View, RadioProps>>>;
26
+ export default Radio;
@@ -0,0 +1 @@
1
+ export declare const generateHTML: (html: string) => string;