@mpxjs/webpack-plugin 2.9.69 → 2.9.70-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/README.md +1 -1
  2. package/lib/config.js +14 -0
  3. package/lib/dependencies/AddEntryDependency.js +24 -0
  4. package/lib/dependencies/ResolveDependency.js +5 -0
  5. package/lib/index.js +38 -7
  6. package/lib/json-compiler/helper.js +3 -3
  7. package/lib/loader.js +52 -0
  8. package/lib/platform/template/wx/component-config/button.js +14 -2
  9. package/lib/platform/template/wx/component-config/image.js +4 -0
  10. package/lib/platform/template/wx/component-config/input.js +5 -1
  11. package/lib/platform/template/wx/component-config/rich-text.js +4 -0
  12. package/lib/platform/template/wx/component-config/scroll-view.js +4 -0
  13. package/lib/platform/template/wx/component-config/swiper.js +1 -1
  14. package/lib/platform/template/wx/component-config/switch.js +4 -0
  15. package/lib/platform/template/wx/component-config/text.js +4 -0
  16. package/lib/platform/template/wx/component-config/textarea.js +6 -1
  17. package/lib/platform/template/wx/component-config/view.js +4 -0
  18. package/lib/platform/template/wx/index.js +127 -1
  19. package/lib/react/processTemplate.js +3 -0
  20. package/lib/resolve-loader.js +4 -1
  21. package/lib/runtime/components/react/context.ts +4 -0
  22. package/lib/runtime/components/react/dist/context.js +5 -0
  23. package/lib/runtime/components/react/dist/event.config.js +24 -24
  24. package/lib/runtime/components/react/dist/getInnerListeners.js +183 -166
  25. package/lib/runtime/components/react/dist/locale-provider.jsx +15 -0
  26. package/lib/runtime/components/react/dist/mpx-button.jsx +39 -74
  27. package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +30 -12
  28. package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +13 -19
  29. package/lib/runtime/components/react/dist/mpx-checkbox.jsx +29 -38
  30. package/lib/runtime/components/react/dist/mpx-form.jsx +16 -19
  31. package/lib/runtime/components/react/dist/mpx-icon.jsx +8 -16
  32. package/lib/runtime/components/react/dist/mpx-image.jsx +295 -0
  33. package/lib/runtime/components/react/dist/mpx-input.jsx +54 -27
  34. package/lib/runtime/components/react/dist/mpx-label.jsx +15 -22
  35. package/lib/runtime/components/react/dist/mpx-movable-area.jsx +13 -16
  36. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +14 -14
  37. package/lib/runtime/components/react/dist/mpx-navigator.jsx +2 -4
  38. package/lib/runtime/components/react/dist/mpx-picker/date.jsx +6 -2
  39. package/lib/runtime/components/react/dist/mpx-picker/index.jsx +5 -3
  40. package/lib/runtime/components/react/dist/mpx-picker/multiSelector.jsx +6 -2
  41. package/lib/runtime/components/react/dist/mpx-picker/region.jsx +6 -2
  42. package/lib/runtime/components/react/dist/mpx-picker/selector.jsx +6 -2
  43. package/lib/runtime/components/react/dist/mpx-picker/time.jsx +10 -14
  44. package/lib/runtime/components/react/dist/mpx-picker-view-column-item.jsx +39 -0
  45. package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +126 -112
  46. package/lib/runtime/components/react/dist/mpx-picker-view.jsx +32 -29
  47. package/lib/runtime/components/react/dist/mpx-portal/portal-consumer.jsx +23 -0
  48. package/lib/runtime/components/react/dist/mpx-portal/portal-host.jsx +124 -0
  49. package/lib/runtime/components/react/dist/mpx-portal/portal-manager.jsx +40 -0
  50. package/lib/runtime/components/react/dist/mpx-portal.jsx +12 -0
  51. package/lib/runtime/components/react/dist/mpx-provider.jsx +31 -0
  52. package/lib/runtime/components/react/dist/mpx-radio-group.jsx +11 -19
  53. package/lib/runtime/components/react/dist/mpx-radio.jsx +27 -42
  54. package/lib/runtime/components/react/dist/mpx-rich-text/html.js +39 -0
  55. package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +62 -0
  56. package/lib/runtime/components/react/dist/mpx-root-portal.jsx +7 -5
  57. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +62 -47
  58. package/lib/runtime/components/react/dist/mpx-simple-text.jsx +11 -0
  59. package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +28 -9
  60. package/lib/runtime/components/react/dist/mpx-swiper.jsx +613 -0
  61. package/lib/runtime/components/react/dist/mpx-switch.jsx +20 -10
  62. package/lib/runtime/components/react/dist/mpx-text.jsx +11 -10
  63. package/lib/runtime/components/react/dist/mpx-textarea.jsx +8 -3
  64. package/lib/runtime/components/react/dist/mpx-view.jsx +37 -89
  65. package/lib/runtime/components/react/dist/mpx-web-view.jsx +205 -46
  66. package/lib/runtime/components/react/dist/pickerFaces.js +12 -6
  67. package/lib/runtime/components/react/dist/pickerVIewContext.js +9 -0
  68. package/lib/runtime/components/react/dist/pickerViewMask.jsx +18 -0
  69. package/lib/runtime/components/react/dist/{pickerOverlay.jsx → pickerViewOverlay.jsx} +5 -3
  70. package/lib/runtime/components/react/dist/useAnimationHooks.js +50 -12
  71. package/lib/runtime/components/react/dist/utils.jsx +83 -28
  72. package/lib/runtime/components/react/getInnerListeners.ts +35 -28
  73. package/lib/runtime/components/react/mpx-button.tsx +55 -36
  74. package/lib/runtime/components/react/mpx-canvas/index.tsx +2 -2
  75. package/lib/runtime/components/react/mpx-checkbox-group.tsx +13 -12
  76. package/lib/runtime/components/react/mpx-checkbox.tsx +28 -28
  77. package/lib/runtime/components/react/mpx-form.tsx +10 -8
  78. package/lib/runtime/components/react/mpx-icon.tsx +10 -15
  79. package/lib/runtime/components/react/mpx-image.tsx +396 -0
  80. package/lib/runtime/components/react/mpx-input.tsx +61 -33
  81. package/lib/runtime/components/react/mpx-label.tsx +14 -13
  82. package/lib/runtime/components/react/mpx-movable-area.tsx +8 -7
  83. package/lib/runtime/components/react/mpx-movable-view.tsx +1 -1
  84. package/lib/runtime/components/react/mpx-picker/date.tsx +5 -2
  85. package/lib/runtime/components/react/mpx-picker/index.tsx +3 -2
  86. package/lib/runtime/components/react/mpx-picker/multiSelector.tsx +5 -2
  87. package/lib/runtime/components/react/mpx-picker/region.tsx +5 -2
  88. package/lib/runtime/components/react/mpx-picker/selector.tsx +5 -2
  89. package/lib/runtime/components/react/mpx-picker/time.tsx +10 -15
  90. package/lib/runtime/components/react/mpx-picker/type.ts +48 -43
  91. package/lib/runtime/components/react/mpx-picker-view-column.tsx +4 -1
  92. package/lib/runtime/components/react/mpx-picker-view.tsx +7 -1
  93. package/lib/runtime/components/react/mpx-radio-group.tsx +11 -12
  94. package/lib/runtime/components/react/mpx-radio.tsx +26 -29
  95. package/lib/runtime/components/react/mpx-scroll-view.tsx +32 -30
  96. package/lib/runtime/components/react/mpx-simple-text.tsx +18 -0
  97. package/lib/runtime/components/react/mpx-swiper/carouse.tsx +4 -2
  98. package/lib/runtime/components/react/mpx-swiper-item.tsx +3 -2
  99. package/lib/runtime/components/react/mpx-switch.tsx +10 -8
  100. package/lib/runtime/components/react/mpx-text.tsx +6 -2
  101. package/lib/runtime/components/react/mpx-view.tsx +37 -45
  102. package/lib/runtime/components/react/mpx-web-view.tsx +25 -15
  103. package/lib/runtime/components/react/types/global.d.ts +1 -16
  104. package/lib/runtime/components/react/utils.tsx +24 -24
  105. package/lib/runtime/components/tenon/getInnerListeners.js +334 -0
  106. package/lib/runtime/components/tenon/tenon-button.vue +309 -0
  107. package/lib/runtime/components/tenon/tenon-image.vue +66 -0
  108. package/lib/runtime/components/tenon/tenon-input.vue +171 -0
  109. package/lib/runtime/components/tenon/tenon-rich-text.vue +26 -0
  110. package/lib/runtime/components/tenon/tenon-scroll-view.vue +127 -0
  111. package/lib/runtime/components/tenon/tenon-switch.vue +96 -0
  112. package/lib/runtime/components/tenon/tenon-text.vue +70 -0
  113. package/lib/runtime/components/tenon/tenon-textarea.vue +86 -0
  114. package/lib/runtime/components/tenon/tenon-view.vue +93 -0
  115. package/lib/runtime/components/web/getInnerListeners.js +6 -6
  116. package/lib/runtime/components/web/mpx-movable-view.vue +334 -344
  117. package/lib/runtime/components/web/mpx-picker-view-column.vue +75 -75
  118. package/lib/runtime/components/web/mpx-picker.vue +382 -385
  119. package/lib/runtime/components/web/mpx-web-view.vue +162 -162
  120. package/lib/runtime/optionProcessor.js +7 -16
  121. package/lib/runtime/optionProcessor.tenon.js +84 -0
  122. package/lib/runtime/utils.js +2 -0
  123. package/lib/style-compiler/index.js +1 -1
  124. package/lib/style-compiler/plugins/hm.js +20 -0
  125. package/lib/template-compiler/bind-this.js +7 -2
  126. package/lib/template-compiler/compiler.js +67 -40
  127. package/lib/template-compiler/gen-node-react.js +2 -2
  128. package/lib/tenon/index.js +112 -0
  129. package/lib/tenon/processJSON.js +352 -0
  130. package/lib/tenon/processScript.js +198 -0
  131. package/lib/tenon/processStyles.js +21 -0
  132. package/lib/tenon/processTemplate.js +125 -0
  133. package/lib/tenon/script-helper.js +223 -0
  134. package/lib/utils/env.js +6 -1
  135. package/lib/utils/get-relative-path.js +25 -0
  136. package/package.json +7 -3
  137. package/LICENSE +0 -433
  138. package/lib/runtime/components/react/dist/mpx-image/index.jsx +0 -226
  139. package/lib/runtime/components/react/dist/mpx-image/svg.jsx +0 -7
  140. package/lib/runtime/components/react/dist/mpx-swiper/carouse.jsx +0 -478
  141. package/lib/runtime/components/react/dist/mpx-swiper/index.jsx +0 -68
  142. package/lib/runtime/components/react/dist/mpx-swiper/type.js +0 -1
  143. package/lib/runtime/components/react/mpx-image/index.tsx +0 -345
  144. package/lib/runtime/components/react/mpx-image/svg.tsx +0 -22
@@ -17,7 +17,7 @@
17
17
  * ✔ cursor-color
18
18
  * ✔ selection-start
19
19
  * ✔ selection-end
20
- * adjust-position
20
+ * adjust-position
21
21
  * ✘ hold-keyboard
22
22
  * ✘ safe-password-cert-path
23
23
  * ✘ safe-password-length
@@ -55,10 +55,10 @@ import {
55
55
  TextInputSubmitEditingEventData
56
56
  } from 'react-native'
57
57
  import { warn } from '@mpxjs/utils'
58
- import { parseInlineStyle, useUpdateEffect, useTransformStyle, useLayout } from './utils'
58
+ import { parseInlineStyle, useUpdateEffect, useTransformStyle, useLayout, extendObject } from './utils'
59
59
  import useInnerProps, { getCustomEvent } from './getInnerListeners'
60
60
  import useNodesRef, { HandlerRef } from './useNodesRef'
61
- import { FormContext, FormFieldValue } from './context'
61
+ import { FormContext, FormFieldValue, KeyboardAvoidContext } from './context'
62
62
 
63
63
  type InputStyle = Omit<
64
64
  TextStyle & ViewStyle & Pick<FlexStyle, 'minHeight'>,
@@ -98,6 +98,7 @@ export interface InputProps {
98
98
  'parent-font-size'?: number
99
99
  'parent-width'?: number
100
100
  'parent-height'?: number
101
+ 'adjust-position': boolean,
101
102
  bindinput?: (evt: NativeSyntheticEvent<TextInputTextInputEventData> | unknown) => void
102
103
  bindfocus?: (evt: NativeSyntheticEvent<TextInputFocusEventData> | unknown) => void
103
104
  bindblur?: (evt: NativeSyntheticEvent<TextInputFocusEventData> | unknown) => void
@@ -106,6 +107,7 @@ export interface InputProps {
106
107
  }
107
108
 
108
109
  export interface PrivateInputProps {
110
+ allowFontScaling?: boolean
109
111
  multiline?: boolean
110
112
  'auto-height'?: boolean
111
113
  bindlinechange?: (evt: NativeSyntheticEvent<TextInputContentSizeChangeEventData> | unknown) => void
@@ -127,6 +129,7 @@ const keyboardTypeMap: Record<Type, string> = {
127
129
  const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps>((props: FinalInputProps, ref): JSX.Element => {
128
130
  const {
129
131
  style = {},
132
+ allowFontScaling = false,
130
133
  type = 'text',
131
134
  value,
132
135
  password,
@@ -146,6 +149,7 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
146
149
  'parent-font-size': parentFontSize,
147
150
  'parent-width': parentWidth,
148
151
  'parent-height': parentHeight,
152
+ 'adjust-position': adjustPosition = true,
149
153
  bindinput,
150
154
  bindfocus,
151
155
  bindblur,
@@ -159,6 +163,8 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
159
163
 
160
164
  const formContext = useContext(FormContext)
161
165
 
166
+ const setKeyboardAvoidEnabled = useContext(KeyboardAvoidContext)
167
+
162
168
  let formValuesMap: Map<string, FormFieldValue> | undefined
163
169
 
164
170
  if (formContext) {
@@ -170,20 +176,20 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
170
176
  const placeholderTextColor = parseInlineStyle(placeholderStyle)?.color
171
177
  const textAlignVertical = multiline ? 'top' : 'auto'
172
178
 
173
- const tmpValue = useRef<string>()
179
+ const tmpValue = useRef<string | undefined>(defaultValue)
174
180
  const cursorIndex = useRef<number>(0)
175
181
  const lineCount = useRef<number>(0)
176
182
 
177
183
  const [inputValue, setInputValue] = useState(defaultValue)
178
184
  const [contentHeight, setContentHeight] = useState(0)
179
185
 
180
- const styleObj = {
181
- padding: 0,
182
- ...style,
183
- ...multiline && autoHeight && {
184
- height: Math.max((style as any)?.minHeight || 35, contentHeight)
185
- }
186
- }
186
+ const styleObj = extendObject(
187
+ { padding: 0, backgroundColor: '#fff' },
188
+ style,
189
+ multiline && autoHeight
190
+ ? { height: Math.max((style as any)?.minHeight || 35, contentHeight) }
191
+ : {}
192
+ )
187
193
 
188
194
  const {
189
195
  hasSelfPercent,
@@ -193,7 +199,9 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
193
199
  } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight })
194
200
 
195
201
  const nodeRef = useRef(null)
196
- useNodesRef(props, ref, nodeRef)
202
+ useNodesRef(props, ref, nodeRef, {
203
+ style: normalStyle
204
+ })
197
205
 
198
206
  const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef })
199
207
 
@@ -378,6 +386,10 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
378
386
  }
379
387
  }, [])
380
388
 
389
+ useEffect(() => {
390
+ setKeyboardAvoidEnabled?.(adjustPosition)
391
+ }, [adjustPosition])
392
+
381
393
  useUpdateEffect(() => {
382
394
  if (!nodeRef?.current) {
383
395
  return
@@ -387,28 +399,44 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
387
399
  : (nodeRef.current as TextInput)?.blur()
388
400
  }, [focus])
389
401
 
390
- const composeStyle = { ...normalStyle, ...layoutStyle }
391
-
392
- const innerProps = useInnerProps(props, {
393
- ref: nodeRef,
394
- style: {
395
- padding: 0,
396
- ...composeStyle,
397
- ...multiline && autoHeight && {
398
- height: Math.max((composeStyle as any)?.minHeight || 35, contentHeight)
402
+ const innerProps = useInnerProps(
403
+ props,
404
+ extendObject(
405
+ {
406
+ ref: nodeRef,
407
+ style: extendObject({}, normalStyle, layoutStyle),
408
+ allowFontScaling
409
+ },
410
+ layoutProps,
411
+ {
412
+ onFocus: bindfocus && onInputFocus,
413
+ onBlur: bindblur && onInputBlur,
414
+ onKeyPress: bindconfirm && onKeyPress,
415
+ onSubmitEditing: bindconfirm && multiline && onSubmitEditing,
416
+ onSelectionChange: bindselectionchange && onSelectionChange
399
417
  }
400
- },
401
- ...layoutProps,
402
- onFocus: bindfocus && onInputFocus,
403
- onBlur: bindblur && onInputBlur,
404
- onKeyPress: bindconfirm && onKeyPress,
405
- onSubmitEditing: bindconfirm && multiline && onSubmitEditing,
406
- onSelectionChange: bindselectionchange && onSelectionChange
407
- },
408
- [],
409
- {
410
- layoutRef
411
- })
418
+ ),
419
+ [
420
+ 'type',
421
+ 'keyboardType',
422
+ 'password',
423
+ 'placeholder-style',
424
+ 'disabled',
425
+ 'maxlength',
426
+ 'auto-focus',
427
+ 'focus',
428
+ 'confirm-type',
429
+ 'confirm-hold',
430
+ 'cursor',
431
+ 'cursor-color',
432
+ 'selection-start',
433
+ 'selection-end',
434
+ 'multiline'
435
+ ],
436
+ {
437
+ layoutRef
438
+ }
439
+ )
412
440
 
413
441
  return (
414
442
  <TextInput
@@ -6,7 +6,7 @@ import { View, ViewStyle, NativeSyntheticEvent } from 'react-native'
6
6
  import { noop, warn } from '@mpxjs/utils'
7
7
  import useInnerProps, { getCustomEvent } from './getInnerListeners'
8
8
  import useNodesRef, { HandlerRef } from './useNodesRef'
9
- import { splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren } from './utils'
9
+ import { splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren, extendObject } from './utils'
10
10
  import { LabelContext, LabelContextValue } from './context'
11
11
 
12
12
  export interface LabelProps {
@@ -42,10 +42,7 @@ const Label = forwardRef<HandlerRef<View, LabelProps>, LabelProps>(
42
42
  flexDirection: 'row'
43
43
  }
44
44
 
45
- const styleObj = {
46
- ...defaultStyle,
47
- ...style
48
- }
45
+ const styleObj = extendObject({}, defaultStyle, style)
49
46
 
50
47
  const {
51
48
  hasSelfPercent,
@@ -57,11 +54,11 @@ const Label = forwardRef<HandlerRef<View, LabelProps>, LabelProps>(
57
54
  } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight })
58
55
 
59
56
  const nodeRef = useRef(null)
60
- useNodesRef(props, ref, nodeRef, { defaultStyle })
57
+ useNodesRef(props, ref, nodeRef, { style: normalStyle })
61
58
 
62
59
  const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef })
63
60
 
64
- const { textStyle, backgroundStyle, innerStyle } = splitStyle(normalStyle)
61
+ const { textStyle, backgroundStyle, innerStyle = {} } = splitStyle(normalStyle)
65
62
 
66
63
  if (backgroundStyle) {
67
64
  warn('Label does not support background image-related styles!')
@@ -79,12 +76,16 @@ const Label = forwardRef<HandlerRef<View, LabelProps>, LabelProps>(
79
76
 
80
77
  const innerProps = useInnerProps(
81
78
  props,
82
- {
83
- ref: nodeRef,
84
- style: { ...innerStyle, ...layoutStyle },
85
- ...layoutProps,
86
- bindtap: onTap
87
- },
79
+ extendObject(
80
+ {
81
+ ref: nodeRef,
82
+ style: extendObject({}, innerStyle, layoutStyle)
83
+ },
84
+ layoutProps,
85
+ {
86
+ bindtap: onTap
87
+ }
88
+ ),
88
89
  [],
89
90
  {
90
91
  layoutRef
@@ -7,7 +7,7 @@ import { JSX, forwardRef, ReactNode, useRef, useMemo } from 'react'
7
7
  import useNodesRef, { HandlerRef } from './useNodesRef'
8
8
  import useInnerProps from './getInnerListeners'
9
9
  import { MovableAreaContext } from './context'
10
- import { useTransformStyle, wrapChildren, useLayout } from './utils'
10
+ import { useTransformStyle, wrapChildren, useLayout, extendObject } from './utils'
11
11
 
12
12
  interface MovableAreaProps {
13
13
  style?: Record<string, any>;
@@ -35,7 +35,9 @@ const _MovableArea = forwardRef<HandlerRef<View, MovableAreaProps>, MovableAreaP
35
35
  } = useTransformStyle(style, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight })
36
36
 
37
37
  const movableViewRef = useRef(null)
38
- useNodesRef(props, ref, movableViewRef)
38
+ useNodesRef(props, ref, movableViewRef, {
39
+ style: normalStyle
40
+ })
39
41
 
40
42
  const contextValue = useMemo(() => ({
41
43
  height: normalStyle.height || 10,
@@ -44,11 +46,10 @@ const _MovableArea = forwardRef<HandlerRef<View, MovableAreaProps>, MovableAreaP
44
46
 
45
47
  const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: movableViewRef })
46
48
 
47
- const innerProps = useInnerProps(props, {
48
- style: { height: contextValue.height, width: contextValue.width, overflow: 'hidden', ...normalStyle, ...layoutStyle },
49
- ref: movableViewRef,
50
- ...layoutProps
51
- }, [], { layoutRef })
49
+ const innerProps = useInnerProps(props, extendObject({
50
+ style: extendObject({ height: contextValue.height, width: contextValue.width, overflow: 'hidden' }, normalStyle, layoutStyle),
51
+ ref: movableViewRef
52
+ }, layoutProps), [], { layoutRef })
52
53
 
53
54
  return (
54
55
  <MovableAreaContext.Provider value={contextValue}>
@@ -148,7 +148,7 @@ const _MovableView = forwardRef<HandlerRef<View, MovableViewProps>, MovableViewP
148
148
  const nodeRef = useRef<View>(null)
149
149
 
150
150
  useNodesRef(props, ref, nodeRef, {
151
- defaultStyle: styles.container,
151
+ style: normalStyle,
152
152
  gestureRef: movableGestureRef
153
153
  })
154
154
 
@@ -27,12 +27,14 @@ function dateToString (date: Date, fields: 'day' | 'month' | 'year' = 'day'): st
27
27
  }
28
28
 
29
29
  const _DatePicker = forwardRef<HandlerRef<View, DateProps>, DateProps>((props: DateProps, ref): React.JSX.Element => {
30
- const { children, start = '1970-01-01', end = '2999-01-01', value, bindchange, bindcancel, disabled, fields } = props
30
+ const { children, start = '1970-01-01', end = '2999-01-01', value, bindchange, bindcancel, disabled, fields, style } = props
31
31
  const [datevalue, setDateValue] = useState(value)
32
32
  // 存储layout布局信息
33
33
  const layoutRef = useRef({})
34
34
  const viewRef = useRef<View>(null)
35
- useNodesRef<View, DateProps>(props, ref, viewRef, {
35
+ const nodeRef = useRef<View>(null)
36
+ useNodesRef<View, DateProps>(props, ref, nodeRef, {
37
+ style
36
38
  })
37
39
 
38
40
  useEffect(() => {
@@ -58,6 +60,7 @@ const _DatePicker = forwardRef<HandlerRef<View, DateProps>, DateProps>((props: D
58
60
  }
59
61
 
60
62
  const dateProps = {
63
+ ref: nodeRef,
61
64
  precision: fields,
62
65
  value: formatTimeStr(datevalue),
63
66
  minDate: formatTimeStr(start),
@@ -32,10 +32,11 @@ import { FormContext, FormFieldValue } from '../context'
32
32
  */
33
33
 
34
34
  const _Picker = forwardRef<HandlerRef<View, PickerProps>, PickerProps>((props: PickerProps, ref): React.JSX.Element => {
35
- const { mode = 'selector', value, bindcancel, bindchange, children, bindcolumnchange } = props
35
+ const { mode = 'selector', value, bindcancel, bindchange, children, bindcolumnchange, style } = props
36
36
  const innerLayout = useRef({})
37
37
  const nodeRef = useRef(null)
38
38
  useNodesRef<View, PickerProps>(props, ref, nodeRef, {
39
+ style
39
40
  })
40
41
  const innerProps = useInnerProps(props, {
41
42
  ref: nodeRef
@@ -92,7 +93,7 @@ const _Picker = forwardRef<HandlerRef<View, PickerProps>, PickerProps>((props: P
92
93
  bindcolumnchange && bindcolumnchange(eventData)
93
94
  }
94
95
  const commonProps = {
95
- ...{ innerProps },
96
+ ...innerProps,
96
97
  mode,
97
98
  children,
98
99
  bindchange: onChange,
@@ -80,7 +80,7 @@ function getColumnIndexByValue (range: any[] = [], column: number, value: any[]
80
80
  }
81
81
 
82
82
  const _MultiSelectorPicker = forwardRef<HandlerRef<View, MultiSelectorProps>, MultiSelectorProps>((props: MultiSelectorProps, ref): React.JSX.Element => {
83
- const { range, value, disabled, bindchange, bindcancel, children, bindcolumnchange } = props
83
+ const { range, value, disabled, bindchange, bindcancel, children, bindcolumnchange, style } = props
84
84
  const formatRange = formatRangeFun(range, props['range-key'])
85
85
  const initValue = getInnerValueByIndex(formatRange, value)
86
86
  // 选中的索引值
@@ -90,7 +90,9 @@ const _MultiSelectorPicker = forwardRef<HandlerRef<View, MultiSelectorProps>, Mu
90
90
  // 存储layout布局信息
91
91
  const layoutRef = useRef({})
92
92
  const viewRef = useRef<View>(null)
93
- useNodesRef<View, MultiSelectorProps>(props, ref, viewRef, {
93
+ const nodeRef = useRef<View>(null)
94
+ useNodesRef<View, MultiSelectorProps>(props, ref, nodeRef, {
95
+ style
94
96
  })
95
97
 
96
98
  useEffect(() => {
@@ -126,6 +128,7 @@ const _MultiSelectorPicker = forwardRef<HandlerRef<View, MultiSelectorProps>, Mu
126
128
  }
127
129
 
128
130
  const antPickerProps = {
131
+ ref: nodeRef,
129
132
  data,
130
133
  value: selected,
131
134
  cols: range.length,
@@ -38,14 +38,16 @@ function formateRegionData (clObj: RegionObj[] = [], customItem?: string, depth
38
38
  }
39
39
 
40
40
  const _RegionPicker = forwardRef<HandlerRef<View, RegionProps>, RegionProps>((props: RegionProps, ref): React.JSX.Element => {
41
- const { children, value, bindchange, bindcancel, disabled } = props
41
+ const { children, value, bindchange, bindcancel, disabled, style } = props
42
42
  const formatRegionData = formateRegionData(regionData, props['custom-item'])
43
43
 
44
44
  const [regionvalue, setRegionValue] = useState(value)
45
45
  // 存储layout布局信息
46
46
  const layoutRef = useRef({})
47
47
  const viewRef = useRef<View>(null)
48
- useNodesRef<View, RegionProps>(props, ref, viewRef, {
48
+ const nodeRef = useRef(null)
49
+ useNodesRef<View, RegionProps>(props, ref, nodeRef, {
50
+ style
49
51
  })
50
52
 
51
53
  const onChange = (value: string[]): void => {
@@ -83,6 +85,7 @@ const _RegionPicker = forwardRef<HandlerRef<View, RegionProps>, RegionProps>((pr
83
85
  }
84
86
 
85
87
  const regionProps = {
88
+ ref: nodeRef,
86
89
  data: formatRegionData,
87
90
  value: regionvalue,
88
91
  onChange,
@@ -22,7 +22,7 @@ const formatRangeFun = (range: Array<RangeItemType>, rangeKey = ''): any => {
22
22
  }
23
23
 
24
24
  const _SelectorPicker = forwardRef<HandlerRef<View, SelectorProps>, SelectorProps>((props: SelectorProps, ref): React.JSX.Element => {
25
- const { range, children, value, disabled, bindchange, bindcancel } = props
25
+ const { range, children, value, disabled, bindchange, bindcancel, style } = props
26
26
  // 格式化数据为Array<*>
27
27
  const formatRange: PickerColumn = formatRangeFun(range, props['range-key'])
28
28
  // 选中的索引值
@@ -32,7 +32,9 @@ const _SelectorPicker = forwardRef<HandlerRef<View, SelectorProps>, SelectorProp
32
32
  // 存储layout布局信息
33
33
  const layoutRef = useRef({})
34
34
  const viewRef = useRef<View>(null)
35
- useNodesRef<View, SelectorProps>(props, ref, viewRef, {
35
+ const nodeRef = useRef(null)
36
+ useNodesRef<View, SelectorProps>(props, ref, nodeRef, {
37
+ style
36
38
  })
37
39
 
38
40
  useEffect(() => {
@@ -62,6 +64,7 @@ const _SelectorPicker = forwardRef<HandlerRef<View, SelectorProps>, SelectorProp
62
64
  }
63
65
 
64
66
  const antPickerProps = {
67
+ ref: nodeRef,
65
68
  data,
66
69
  value: [selected],
67
70
  cols: 1,
@@ -1,5 +1,5 @@
1
1
  import { View, Text, Modal, TouchableWithoutFeedback } from 'react-native'
2
- import { PickerView } from '@ant-design/react-native'
2
+ import { PickerView, Portal } from '@ant-design/react-native'
3
3
  import React, { forwardRef, useState, useRef, useEffect } from 'react'
4
4
  import useNodesRef, { HandlerRef } from '../useNodesRef' // 引入辅助函数
5
5
  import { TimeProps } from './type'
@@ -13,8 +13,8 @@ const styles: { [key: string]: Object } = {
13
13
  showModal: {
14
14
  backgroundColor: 'black',
15
15
  opacity: 0.5,
16
- position: 'absolute',
17
- width: '100%'
16
+ width: '100%',
17
+ height: '100%'
18
18
  },
19
19
  hideModal: {
20
20
  opacity: 1,
@@ -125,7 +125,7 @@ function checkSelectedIsValid (strStart: string, strEnd: string, selected: numbe
125
125
  // start="02:10" end = 23:01
126
126
 
127
127
  const _TimePicker = forwardRef<HandlerRef<View, TimeProps>, TimeProps>((props: TimeProps, ref): React.JSX.Element => {
128
- const { children, start, end, value, bindchange, bindcancel, disabled } = props
128
+ const { children, start, end, value, bindchange, bindcancel, style } = props
129
129
  const defaultProps = {
130
130
  start: '00:10',
131
131
  end: '23:59'
@@ -135,11 +135,11 @@ const _TimePicker = forwardRef<HandlerRef<View, TimeProps>, TimeProps>((props: T
135
135
  // 存储layout布局信息
136
136
  const layoutRef = useRef({})
137
137
  const viewRef = useRef<View>(null)
138
- useNodesRef<View, TimeProps>(props, ref, viewRef, {})
138
+ const nodeRef = useRef<View>(null)
139
+ useNodesRef<View, TimeProps>(props, ref, nodeRef, { style })
139
140
  // 存储modal的布局信息
140
141
  const modalLayoutRef = useRef({})
141
142
  const modalRef = useRef<View>(null)
142
- useNodesRef<View, TimeProps>(props, ref, modalRef, {})
143
143
  const [visible, setVisible] = useState(false)
144
144
  const columnData = generateColumns()
145
145
  const [data, setData] = useState(columnData)
@@ -188,12 +188,6 @@ const _TimePicker = forwardRef<HandlerRef<View, TimeProps>, TimeProps>((props: T
188
188
  } else {
189
189
  // [9, 13]
190
190
  setTimeValue(date)
191
- const strDate = formatStr(date)
192
- bindchange && bindchange({
193
- detail: {
194
- value: strDate
195
- }
196
- })
197
191
  }
198
192
  }
199
193
 
@@ -213,6 +207,7 @@ const _TimePicker = forwardRef<HandlerRef<View, TimeProps>, TimeProps>((props: T
213
207
 
214
208
  const renderModalChildren = () => {
215
209
  const pickerProps = {
210
+ ref: nodeRef,
216
211
  data,
217
212
  value: timevalue,
218
213
  defaultValue: timevalue,
@@ -249,12 +244,11 @@ const _TimePicker = forwardRef<HandlerRef<View, TimeProps>, TimeProps>((props: T
249
244
  </TouchableWithoutFeedback>
250
245
  </View>
251
246
  }
252
- const strStyle = visible ? styles.showModal : styles.hideModal
253
- const mheight = Math.floor(offsetTop)
254
247
 
255
248
  // Animated.View
256
249
  return (<>
257
- <View style={{ ...strStyle, height: visible ? mheight : 0, bottom: 0 }}>
250
+ <Portal>
251
+ <View style={visible ? styles.showModal : styles.hideModal}>
258
252
  <Modal
259
253
  animationType="slide"
260
254
  transparent={true}
@@ -263,6 +257,7 @@ const _TimePicker = forwardRef<HandlerRef<View, TimeProps>, TimeProps>((props: T
263
257
  {renderModalChildren()}
264
258
  </Modal>
265
259
  </View>
260
+ </Portal>
266
261
  {renderChildren()}
267
262
  </>)
268
263
  })
@@ -3,87 +3,92 @@ import { PickerValue } from '@ant-design/react-native'
3
3
 
4
4
  export type Obj = Record<string, any>
5
5
  export type SelectorProps = {
6
- mode: string,
6
+ mode: string
7
7
  // 表示选择了 range 中的第几个(下标从 0 开始)
8
8
  value: PickerValue
9
- disabled?: boolean,
10
- children: ReactNode,
11
- bindcancel?: Function,
12
- bindchange: Function,
9
+ disabled?: boolean
10
+ children: ReactNode
11
+ bindcancel?: Function
12
+ bindchange: Function
13
13
  // mode 为 selector 或 multiSelector 时,range 有效
14
- range: Array<number|string|Obj>,
14
+ range: Array<number|string|Obj>
15
15
  // 当 range 是一个 Object Array 时,通过 range-key 来指定 Object 中 key 的值作为选择器《显示内容》 对象中的属性
16
- 'range-key': string,
16
+ 'range-key': string
17
17
  getInnerLayout: Function
18
+ style?: Record<string, any>
18
19
  // bindcolumnchange?: Function
19
20
  }
20
21
 
21
22
  export type MultiSelectorProps = {
22
- mode: string,
23
+ mode: string
23
24
  // 表示选择了 range 中的第几个(下标从 0 开始)
24
- value: Array<number>,
25
- disabled?: boolean,
26
- children: ReactNode,
27
- bindcancel?: Function,
28
- bindchange: Function,
29
- bindcolumnchange?: Function,
25
+ value: Array<number>
26
+ disabled?: boolean
27
+ children: ReactNode
28
+ bindcancel?: Function
29
+ bindchange: Function
30
+ bindcolumnchange?: Function
30
31
  // mode 为 selector 或 multiSelector 时,range 有效
31
- range: Array<Array<any>>,
32
+ range: Array<Array<any>>
32
33
  // 当 range 是一个 Object Array 时,通过 range-key 来指定 Object 中 key 的值作为选择器《显示内容》 对象中的属性
33
- 'range-key': string,
34
+ 'range-key': string
34
35
  getInnerLayout: Function
36
+ style?: Record<string, any>
35
37
  }
36
38
 
37
39
  export type TimeProps = {
38
- mode: string,
40
+ mode: string
39
41
  // 表示选择了 range 中的第几个(下标从 0 开始)
40
- value: string,
41
- disabled?: boolean,
42
- children: ReactNode,
43
- bindcancel?: Function,
44
- bindchange: Function,
45
- start: string,
46
- end: string,
42
+ value: string
43
+ disabled?: boolean
44
+ children: ReactNode
45
+ bindcancel?: Function
46
+ bindchange: Function
47
+ start: string
48
+ end: string
47
49
  getInnerLayout: Function
50
+ style?: Record<string, any>
48
51
  }
49
52
 
50
53
  export type DateProps = {
51
- mode: string,
54
+ mode: string
52
55
  // 表示选择了 range 中的第几个(下标从 0 开始)
53
- value: string,
54
- fields?: 'day' | 'month' | 'year',
55
- disabled?: boolean,
56
- children: ReactNode,
57
- bindcancel?: Function,
58
- bindchange: Function,
59
- start: string,
60
- end: string,
56
+ value: string
57
+ fields?: 'day' | 'month' | 'year'
58
+ disabled?: boolean
59
+ children: ReactNode
60
+ bindcancel?: Function
61
+ bindchange: Function
62
+ start: string
63
+ end: string
61
64
  getInnerLayout: Function
65
+ style?: Record<string, any>
62
66
  }
63
67
 
64
68
  export type RegionProps = {
65
- mode: string,
69
+ mode: string
66
70
  // 表示选择了 range 中的第几个(下标从 0 开始)
67
- value: Array<string>,
71
+ value: Array<string>
68
72
  level: 'province' | 'city' | 'region' | 'sub-district'
69
- 'custom-item'?: string,
70
- disabled?: boolean,
71
- children: ReactNode,
72
- bindcancel?: Function,
73
- bindchange: Function,
73
+ 'custom-item'?: string
74
+ disabled?: boolean
75
+ children: ReactNode
76
+ bindcancel?: Function
77
+ bindchange: Function
74
78
  getInnerLayout: Function
79
+ style?: Record<string, any>
75
80
  }
76
81
 
77
82
  export type RegionObj = {
78
- value: string,
83
+ value: string
79
84
  code: string
80
85
  postcode?: string
81
86
  children?: RegionObj[]
82
87
  }
83
88
 
84
89
  export type PickerData = {
85
- value: string,
86
- label: string,
90
+ value: string
91
+ label: string
87
92
  children?: Array<Object>
88
93
  }
89
94
 
@@ -57,7 +57,10 @@ const _PickerViewColumn = forwardRef<HandlerRef<ScrollView & View, ColumnProps>,
57
57
  const { textStyle } = splitStyle(normalStyle)
58
58
  const { textProps } = splitProps(props)
59
59
  const scrollViewRef = useRef<ScrollView>(null)
60
- useNodesRef(props, ref, scrollViewRef, {})
60
+
61
+ useNodesRef(props, ref, scrollViewRef, {
62
+ style: normalStyle
63
+ })
61
64
 
62
65
  const { height: pickerH, itemHeight = DefaultPickerItemH } = wrapperStyle
63
66
  const [itemRawH, setItemRawH] = useState(0) // 单个选项真实渲染高度
@@ -90,7 +90,11 @@ const _PickerView = forwardRef<HandlerRef<View, PickerViewProps>, PickerViewProp
90
90
  setWidth,
91
91
  setHeight
92
92
  } = useTransformStyle(style, { enableVar, externalVarContext })
93
- useNodesRef<View, PickerViewProps>(props, ref, nodeRef, {})
93
+
94
+ useNodesRef<View, PickerViewProps>(props, ref, nodeRef, {
95
+ style: normalStyle
96
+ })
97
+
94
98
  const {
95
99
  // 存储layout布局信息
96
100
  layoutRef,
@@ -134,6 +138,7 @@ const _PickerView = forwardRef<HandlerRef<View, PickerViewProps>, PickerViewProp
134
138
  extendObject({
135
139
  ref: nodeRef,
136
140
  style: extendObject(
141
+ {},
137
142
  normalStyle,
138
143
  layoutStyle,
139
144
  {
@@ -151,6 +156,7 @@ const _PickerView = forwardRef<HandlerRef<View, PickerViewProps>, PickerViewProp
151
156
  const extraProps = {}
152
157
  const childProps = child?.props || {}
153
158
  const wrappedProps = extendObject(
159
+ {},
154
160
  childProps,
155
161
  {
156
162
  columnData,