@mpxjs/webpack-plugin 2.9.66 → 2.9.69-beta.0
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.
- package/lib/dependencies/RecordGlobalComponentsDependency.js +11 -12
- package/lib/dependencies/RecordRuntimeInfoDependency.js +1 -1
- package/lib/index.js +29 -8
- package/lib/json-compiler/index.js +2 -11
- package/lib/loader.js +24 -45
- package/lib/native-loader.js +49 -64
- package/lib/platform/json/wx/index.js +24 -18
- package/lib/platform/style/wx/index.js +49 -47
- package/lib/platform/template/wx/component-config/canvas.js +8 -0
- package/lib/platform/template/wx/component-config/fix-component-name.js +15 -12
- package/lib/platform/template/wx/component-config/index.js +1 -1
- package/lib/platform/template/wx/component-config/input.js +1 -1
- package/lib/platform/template/wx/component-config/rich-text.js +8 -0
- package/lib/platform/template/wx/component-config/swiper.js +1 -1
- package/lib/platform/template/wx/component-config/textarea.js +1 -1
- package/lib/platform/template/wx/component-config/unsupported.js +1 -1
- package/lib/react/index.js +4 -3
- package/lib/react/processJSON.js +5 -13
- package/lib/react/processMainScript.js +7 -3
- package/lib/react/processScript.js +3 -4
- package/lib/react/processStyles.js +14 -4
- package/lib/react/processTemplate.js +5 -2
- package/lib/resolver/AddModePlugin.js +20 -7
- package/lib/runtime/components/react/context.ts +6 -0
- package/lib/runtime/components/react/dist/context.js +2 -0
- package/lib/runtime/components/react/dist/event.config.js +24 -24
- package/lib/runtime/components/react/dist/getInnerListeners.js +183 -174
- package/lib/runtime/components/react/dist/mpx-button.jsx +78 -50
- package/lib/runtime/components/react/dist/mpx-canvas/Bus.js +60 -0
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.js +15 -0
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.js +84 -0
- package/lib/runtime/components/react/dist/mpx-canvas/Image.js +87 -0
- package/lib/runtime/components/react/dist/mpx-canvas/ImageData.js +15 -0
- package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.js +28 -0
- package/lib/runtime/components/react/dist/mpx-canvas/html.js +343 -0
- package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +232 -0
- package/lib/runtime/components/react/dist/mpx-canvas/utils.jsx +89 -0
- package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +41 -34
- package/lib/runtime/components/react/dist/mpx-checkbox.jsx +30 -39
- package/lib/runtime/components/react/dist/mpx-form.jsx +47 -41
- package/lib/runtime/components/react/dist/mpx-icon.jsx +9 -17
- package/lib/runtime/components/react/dist/mpx-image.jsx +291 -0
- package/lib/runtime/components/react/dist/mpx-input.jsx +95 -62
- package/lib/runtime/components/react/dist/mpx-label.jsx +24 -28
- package/lib/runtime/components/react/dist/mpx-movable-area.jsx +20 -30
- package/lib/runtime/components/react/dist/mpx-movable-view.jsx +377 -293
- package/lib/runtime/components/react/dist/mpx-navigator.jsx +3 -5
- package/lib/runtime/components/react/dist/mpx-picker/date.jsx +6 -2
- package/lib/runtime/components/react/dist/mpx-picker/index.jsx +5 -3
- package/lib/runtime/components/react/dist/mpx-picker/multiSelector.jsx +6 -2
- package/lib/runtime/components/react/dist/mpx-picker/region.jsx +6 -2
- package/lib/runtime/components/react/dist/mpx-picker/selector.jsx +6 -2
- package/lib/runtime/components/react/dist/mpx-picker/time.jsx +10 -15
- package/lib/runtime/components/react/dist/mpx-picker-view-column-item.jsx +39 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +160 -88
- package/lib/runtime/components/react/dist/mpx-picker-view.jsx +80 -121
- package/lib/runtime/components/react/dist/mpx-radio-group.jsx +39 -34
- package/lib/runtime/components/react/dist/mpx-radio.jsx +28 -43
- package/lib/runtime/components/react/dist/mpx-rich-text/html.js +39 -0
- package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +63 -0
- package/lib/runtime/components/react/dist/mpx-root-portal.jsx +7 -5
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +77 -51
- package/lib/runtime/components/react/dist/mpx-simple-text.jsx +11 -0
- package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +5 -3
- package/lib/runtime/components/react/dist/mpx-swiper.jsx +606 -0
- package/lib/runtime/components/react/dist/mpx-switch.jsx +28 -11
- package/lib/runtime/components/react/dist/mpx-text.jsx +12 -11
- package/lib/runtime/components/react/dist/mpx-textarea.jsx +9 -4
- package/lib/runtime/components/react/dist/mpx-view.jsx +66 -62
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +113 -36
- package/lib/runtime/components/react/dist/pickerFaces.js +81 -0
- package/lib/runtime/components/react/dist/pickerVIewContext.js +9 -0
- package/lib/runtime/components/react/dist/pickerViewMask.jsx +18 -0
- package/lib/runtime/components/react/dist/pickerViewOverlay.jsx +23 -0
- package/lib/runtime/components/react/dist/useAnimationHooks.js +126 -12
- package/lib/runtime/components/react/dist/utils.jsx +80 -24
- package/lib/runtime/components/react/event.config.ts +25 -26
- package/lib/runtime/components/react/getInnerListeners.ts +237 -198
- package/lib/runtime/components/react/mpx-button.tsx +105 -58
- package/lib/runtime/components/react/mpx-canvas/Bus.ts +70 -0
- package/lib/runtime/components/react/mpx-canvas/CanvasGradient.ts +18 -0
- package/lib/runtime/components/react/mpx-canvas/CanvasRenderingContext2D.ts +87 -0
- package/lib/runtime/components/react/mpx-canvas/Image.ts +102 -0
- package/lib/runtime/components/react/mpx-canvas/ImageData.ts +23 -0
- package/lib/runtime/components/react/mpx-canvas/constructorsRegistry.ts +38 -0
- package/lib/runtime/components/react/mpx-canvas/html.ts +343 -0
- package/lib/runtime/components/react/mpx-canvas/index.tsx +296 -0
- package/lib/runtime/components/react/mpx-canvas/utils.tsx +150 -0
- package/lib/runtime/components/react/mpx-checkbox-group.tsx +77 -51
- package/lib/runtime/components/react/mpx-checkbox.tsx +49 -50
- package/lib/runtime/components/react/mpx-form.tsx +62 -57
- package/lib/runtime/components/react/mpx-icon.tsx +13 -18
- package/lib/runtime/components/react/mpx-image.tsx +436 -0
- package/lib/runtime/components/react/mpx-input.tsx +139 -117
- package/lib/runtime/components/react/mpx-label.tsx +36 -34
- package/lib/runtime/components/react/mpx-movable-area.tsx +26 -39
- package/lib/runtime/components/react/mpx-movable-view.tsx +455 -337
- package/lib/runtime/components/react/mpx-navigator.tsx +3 -9
- package/lib/runtime/components/react/mpx-picker/date.tsx +5 -2
- package/lib/runtime/components/react/mpx-picker/index.tsx +3 -2
- package/lib/runtime/components/react/mpx-picker/multiSelector.tsx +5 -2
- package/lib/runtime/components/react/mpx-picker/region.tsx +5 -2
- package/lib/runtime/components/react/mpx-picker/selector.tsx +5 -2
- package/lib/runtime/components/react/mpx-picker/time.tsx +10 -15
- package/lib/runtime/components/react/mpx-picker/type.ts +48 -43
- package/lib/runtime/components/react/mpx-picker-view-column.tsx +236 -104
- package/lib/runtime/components/react/mpx-picker-view.tsx +132 -122
- package/lib/runtime/components/react/mpx-radio-group.tsx +77 -54
- package/lib/runtime/components/react/mpx-radio.tsx +46 -55
- package/lib/runtime/components/react/mpx-rich-text/html.ts +40 -0
- package/lib/runtime/components/react/mpx-rich-text/index.tsx +121 -0
- package/lib/runtime/components/react/mpx-root-portal.tsx +4 -6
- package/lib/runtime/components/react/mpx-scroll-view.tsx +122 -76
- package/lib/runtime/components/react/mpx-simple-text.tsx +18 -0
- package/lib/runtime/components/react/mpx-swiper/carouse.tsx +6 -4
- package/lib/runtime/components/react/mpx-swiper/index.tsx +2 -1
- package/lib/runtime/components/react/mpx-swiper-item.tsx +4 -3
- package/lib/runtime/components/react/mpx-switch.tsx +39 -25
- package/lib/runtime/components/react/mpx-text.tsx +15 -19
- package/lib/runtime/components/react/mpx-textarea.tsx +12 -11
- package/lib/runtime/components/react/mpx-view.tsx +93 -77
- package/lib/runtime/components/react/mpx-web-view.tsx +117 -55
- package/lib/runtime/components/react/pickerFaces.ts +104 -0
- package/lib/runtime/components/react/pickerOverlay.tsx +32 -0
- package/lib/runtime/components/react/types/common.ts +2 -0
- package/lib/runtime/components/react/types/global.d.ts +5 -17
- package/lib/runtime/components/react/useAnimationHooks.ts +127 -18
- package/lib/runtime/components/react/useNodesRef.ts +1 -0
- package/lib/runtime/components/react/utils.tsx +113 -27
- package/lib/runtime/components/web/getInnerListeners.js +6 -6
- package/lib/runtime/components/web/mpx-movable-view.vue +334 -344
- package/lib/runtime/components/web/mpx-picker-view-column.vue +75 -75
- package/lib/runtime/components/web/mpx-picker.vue +382 -385
- package/lib/runtime/components/web/mpx-web-view.vue +175 -161
- package/lib/runtime/optionProcessor.js +7 -38
- package/lib/runtime/optionProcessorReact.js +0 -15
- package/lib/runtime/swanHelper.wxs +1 -1
- package/lib/runtime/utils.js +2 -0
- package/lib/style-compiler/index.js +1 -1
- package/lib/style-compiler/plugins/scope-id.js +31 -2
- package/lib/template-compiler/bind-this.js +7 -2
- package/lib/template-compiler/compiler.js +118 -56
- package/lib/template-compiler/gen-node-react.js +3 -3
- package/lib/template-compiler/index.js +4 -4
- package/lib/utils/pre-process-json.js +117 -0
- package/lib/web/index.js +5 -4
- package/lib/web/processJSON.js +5 -13
- package/lib/web/processTemplate.js +2 -2
- package/package.json +6 -4
- package/LICENSE +0 -433
- package/lib/runtime/components/react/dist/mpx-image/index.jsx +0 -226
- package/lib/runtime/components/react/dist/mpx-image/svg.jsx +0 -7
- package/lib/runtime/components/react/dist/mpx-swiper/carouse.jsx +0 -478
- package/lib/runtime/components/react/dist/mpx-swiper/index.jsx +0 -68
- package/lib/runtime/components/react/dist/mpx-swiper/type.js +0 -1
- package/lib/runtime/components/react/mpx-image/index.tsx +0 -346
- package/lib/runtime/components/react/mpx-image/svg.tsx +0 -22
- package/lib/runtime/components/web/event.js +0 -105
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* ✔ cursor-color
|
|
18
18
|
* ✔ selection-start
|
|
19
19
|
* ✔ selection-end
|
|
20
|
-
*
|
|
20
|
+
* ✔ adjust-position
|
|
21
21
|
* ✘ hold-keyboard
|
|
22
22
|
* ✘ safe-password-cert-path
|
|
23
23
|
* ✘ safe-password-length
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
* ✘ bind:keyboardcompositionend
|
|
38
38
|
* ✘ bind:onkeyboardheightchange
|
|
39
39
|
*/
|
|
40
|
-
import { JSX, forwardRef, useMemo, useRef, useState, useContext, useEffect } from 'react'
|
|
40
|
+
import { JSX, forwardRef, useMemo, useRef, useState, useContext, useEffect, createElement } from 'react'
|
|
41
41
|
import {
|
|
42
42
|
KeyboardTypeOptions,
|
|
43
43
|
Platform,
|
|
@@ -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
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
186
|
+
const styleObj = extendObject(
|
|
187
|
+
{ padding: 0, backgroundColor: '#fff' },
|
|
188
|
+
style,
|
|
189
|
+
multiline && autoHeight
|
|
190
|
+
? { minHeight: 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
|
|
|
@@ -246,44 +254,41 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
|
|
|
246
254
|
}
|
|
247
255
|
|
|
248
256
|
const onInputFocus = (evt: NativeSyntheticEvent<TextInputFocusEventData>) => {
|
|
249
|
-
bindfocus
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
{
|
|
255
|
-
|
|
256
|
-
value: tmpValue.current || ''
|
|
257
|
-
},
|
|
258
|
-
layoutRef
|
|
257
|
+
bindfocus!(
|
|
258
|
+
getCustomEvent(
|
|
259
|
+
'focus',
|
|
260
|
+
evt,
|
|
261
|
+
{
|
|
262
|
+
detail: {
|
|
263
|
+
value: tmpValue.current || ''
|
|
259
264
|
},
|
|
260
|
-
|
|
261
|
-
|
|
265
|
+
layoutRef
|
|
266
|
+
},
|
|
267
|
+
props
|
|
262
268
|
)
|
|
269
|
+
)
|
|
263
270
|
}
|
|
264
271
|
|
|
265
272
|
const onInputBlur = (evt: NativeSyntheticEvent<TextInputFocusEventData>) => {
|
|
266
|
-
bindblur
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
{
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
cursor: cursorIndex.current
|
|
275
|
-
},
|
|
276
|
-
layoutRef
|
|
273
|
+
bindblur!(
|
|
274
|
+
getCustomEvent(
|
|
275
|
+
'blur',
|
|
276
|
+
evt,
|
|
277
|
+
{
|
|
278
|
+
detail: {
|
|
279
|
+
value: tmpValue.current || '',
|
|
280
|
+
cursor: cursorIndex.current
|
|
277
281
|
},
|
|
278
|
-
|
|
279
|
-
|
|
282
|
+
layoutRef
|
|
283
|
+
},
|
|
284
|
+
props
|
|
280
285
|
)
|
|
286
|
+
)
|
|
281
287
|
}
|
|
282
288
|
|
|
283
289
|
const onKeyPress = (evt: NativeSyntheticEvent<TextInputKeyPressEventData>) => {
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
bindconfirm(
|
|
290
|
+
evt.nativeEvent.key === 'Enter' &&
|
|
291
|
+
bindconfirm!(
|
|
287
292
|
getCustomEvent(
|
|
288
293
|
'confirm',
|
|
289
294
|
evt,
|
|
@@ -299,21 +304,36 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
|
|
|
299
304
|
}
|
|
300
305
|
|
|
301
306
|
const onSubmitEditing = (evt: NativeSyntheticEvent<TextInputSubmitEditingEventData>) => {
|
|
302
|
-
bindconfirm
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
detail: {
|
|
310
|
-
value: tmpValue.current || ''
|
|
311
|
-
},
|
|
312
|
-
layoutRef
|
|
307
|
+
bindconfirm!(
|
|
308
|
+
getCustomEvent(
|
|
309
|
+
'confirm',
|
|
310
|
+
evt,
|
|
311
|
+
{
|
|
312
|
+
detail: {
|
|
313
|
+
value: tmpValue.current || ''
|
|
313
314
|
},
|
|
314
|
-
|
|
315
|
-
|
|
315
|
+
layoutRef
|
|
316
|
+
},
|
|
317
|
+
props
|
|
316
318
|
)
|
|
319
|
+
)
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
const onSelectionChange = (evt: NativeSyntheticEvent<TextInputSelectionChangeEventData>) => {
|
|
323
|
+
bindselectionchange!(
|
|
324
|
+
getCustomEvent(
|
|
325
|
+
'selectionchange',
|
|
326
|
+
evt,
|
|
327
|
+
{
|
|
328
|
+
detail: {
|
|
329
|
+
selectionStart: evt.nativeEvent.selection.start,
|
|
330
|
+
selectionEnd: evt.nativeEvent.selection.end
|
|
331
|
+
},
|
|
332
|
+
layoutRef
|
|
333
|
+
},
|
|
334
|
+
props
|
|
335
|
+
)
|
|
336
|
+
)
|
|
317
337
|
}
|
|
318
338
|
|
|
319
339
|
const onContentSizeChange = (evt: NativeSyntheticEvent<TextInputContentSizeChangeEventData>) => {
|
|
@@ -342,24 +362,6 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
|
|
|
342
362
|
}
|
|
343
363
|
}
|
|
344
364
|
|
|
345
|
-
const onSelectionChange = (evt: NativeSyntheticEvent<TextInputSelectionChangeEventData>) => {
|
|
346
|
-
bindselectionchange &&
|
|
347
|
-
bindselectionchange(
|
|
348
|
-
getCustomEvent(
|
|
349
|
-
'selectionchange',
|
|
350
|
-
evt,
|
|
351
|
-
{
|
|
352
|
-
detail: {
|
|
353
|
-
selectionStart: evt.nativeEvent.selection.start,
|
|
354
|
-
selectionEnd: evt.nativeEvent.selection.end
|
|
355
|
-
},
|
|
356
|
-
layoutRef
|
|
357
|
-
},
|
|
358
|
-
props
|
|
359
|
-
)
|
|
360
|
-
)
|
|
361
|
-
}
|
|
362
|
-
|
|
363
365
|
const resetValue = () => {
|
|
364
366
|
setInputValue('')
|
|
365
367
|
}
|
|
@@ -376,6 +378,18 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
|
|
|
376
378
|
}
|
|
377
379
|
}
|
|
378
380
|
|
|
381
|
+
useEffect(() => {
|
|
382
|
+
return () => {
|
|
383
|
+
if (formValuesMap && props.name) {
|
|
384
|
+
formValuesMap.delete(props.name)
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}, [])
|
|
388
|
+
|
|
389
|
+
useEffect(() => {
|
|
390
|
+
setKeyboardAvoidEnabled?.(adjustPosition)
|
|
391
|
+
}, [adjustPosition])
|
|
392
|
+
|
|
379
393
|
useUpdateEffect(() => {
|
|
380
394
|
if (!nodeRef?.current) {
|
|
381
395
|
return
|
|
@@ -385,54 +399,62 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
|
|
|
385
399
|
: (nodeRef.current as TextInput)?.blur()
|
|
386
400
|
}, [focus])
|
|
387
401
|
|
|
388
|
-
const
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
402
|
+
const innerProps = useInnerProps(
|
|
403
|
+
props,
|
|
404
|
+
extendObject(
|
|
405
|
+
{
|
|
406
|
+
ref: nodeRef,
|
|
407
|
+
style: extendObject({}, normalStyle, layoutStyle),
|
|
408
|
+
allowFontScaling,
|
|
409
|
+
keyboardType: keyboardType,
|
|
410
|
+
secureTextEntry: !!password,
|
|
411
|
+
defaultValue: defaultValue,
|
|
412
|
+
value: inputValue,
|
|
413
|
+
maxLength: maxlength === -1 ? undefined : maxlength,
|
|
414
|
+
editable: !disabled,
|
|
415
|
+
autoFocus: !!autoFocus || !!focus,
|
|
416
|
+
returnKeyType: confirmType,
|
|
417
|
+
selection: selection,
|
|
418
|
+
selectionColor: cursorColor,
|
|
419
|
+
blurOnSubmit: !multiline && !confirmHold,
|
|
420
|
+
underlineColorAndroid: 'rgba(0,0,0,0)',
|
|
421
|
+
textAlignVertical: textAlignVertical,
|
|
422
|
+
placeholderTextColor: placeholderTextColor,
|
|
423
|
+
multiline: !!multiline
|
|
424
|
+
},
|
|
425
|
+
layoutProps,
|
|
426
|
+
{
|
|
427
|
+
onFocus: bindfocus && onInputFocus,
|
|
428
|
+
onBlur: bindblur && onInputBlur,
|
|
429
|
+
onKeyPress: bindconfirm && onKeyPress,
|
|
430
|
+
onSubmitEditing: bindconfirm && multiline && onSubmitEditing,
|
|
431
|
+
onSelectionChange: bindselectionchange && onSelectionChange,
|
|
432
|
+
onTextInput: onTextInput,
|
|
433
|
+
onChange: onChange,
|
|
434
|
+
onContentSizeChange: onContentSizeChange
|
|
397
435
|
}
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
returnKeyType={confirmType}
|
|
417
|
-
selection={selection}
|
|
418
|
-
selectionColor={cursorColor}
|
|
419
|
-
blurOnSubmit={!multiline && !confirmHold}
|
|
420
|
-
underlineColorAndroid="rgba(0,0,0,0)"
|
|
421
|
-
textAlignVertical={textAlignVertical}
|
|
422
|
-
placeholderTextColor={placeholderTextColor}
|
|
423
|
-
multiline={!!multiline}
|
|
424
|
-
onTextInput={onTextInput}
|
|
425
|
-
onChange={onChange}
|
|
426
|
-
onFocus={onInputFocus}
|
|
427
|
-
onBlur={onInputBlur}
|
|
428
|
-
onKeyPress={onKeyPress}
|
|
429
|
-
onSubmitEditing={onSubmitEditing}
|
|
430
|
-
onContentSizeChange={onContentSizeChange}
|
|
431
|
-
onSelectionChange={onSelectionChange}
|
|
432
|
-
/>
|
|
436
|
+
),
|
|
437
|
+
[
|
|
438
|
+
'type',
|
|
439
|
+
'password',
|
|
440
|
+
'placeholder-style',
|
|
441
|
+
'disabled',
|
|
442
|
+
'auto-focus',
|
|
443
|
+
'focus',
|
|
444
|
+
'confirm-type',
|
|
445
|
+
'confirm-hold',
|
|
446
|
+
'cursor',
|
|
447
|
+
'cursor-color',
|
|
448
|
+
'selection-start',
|
|
449
|
+
'selection-end'
|
|
450
|
+
],
|
|
451
|
+
{
|
|
452
|
+
layoutRef
|
|
453
|
+
}
|
|
433
454
|
)
|
|
455
|
+
return createElement(TextInput, innerProps)
|
|
434
456
|
})
|
|
435
457
|
|
|
436
|
-
Input.displayName = '
|
|
458
|
+
Input.displayName = 'MpxInput'
|
|
437
459
|
|
|
438
460
|
export default Input
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ✘ for
|
|
3
3
|
*/
|
|
4
|
-
import { JSX, useRef, forwardRef, ReactNode } from 'react'
|
|
4
|
+
import { JSX, useRef, forwardRef, ReactNode, useCallback, createElement } from 'react'
|
|
5
5
|
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 {
|
|
@@ -25,6 +25,7 @@ export interface LabelProps {
|
|
|
25
25
|
const Label = forwardRef<HandlerRef<View, LabelProps>, LabelProps>(
|
|
26
26
|
(labelProps, ref): JSX.Element => {
|
|
27
27
|
const { textProps, innerProps: props = {} } = splitProps(labelProps)
|
|
28
|
+
const propsRef = useRef<any>({})
|
|
28
29
|
|
|
29
30
|
const {
|
|
30
31
|
style = {},
|
|
@@ -32,18 +33,16 @@ const Label = forwardRef<HandlerRef<View, LabelProps>, LabelProps>(
|
|
|
32
33
|
'external-var-context': externalVarContext,
|
|
33
34
|
'parent-font-size': parentFontSize,
|
|
34
35
|
'parent-width': parentWidth,
|
|
35
|
-
'parent-height': parentHeight
|
|
36
|
-
bindtap
|
|
36
|
+
'parent-height': parentHeight
|
|
37
37
|
} = props
|
|
38
38
|
|
|
39
|
+
propsRef.current = props
|
|
40
|
+
|
|
39
41
|
const defaultStyle = {
|
|
40
42
|
flexDirection: 'row'
|
|
41
43
|
}
|
|
42
44
|
|
|
43
|
-
const styleObj = {
|
|
44
|
-
...defaultStyle,
|
|
45
|
-
...style
|
|
46
|
-
}
|
|
45
|
+
const styleObj = extendObject({}, defaultStyle, style)
|
|
47
46
|
|
|
48
47
|
const {
|
|
49
48
|
hasSelfPercent,
|
|
@@ -55,11 +54,11 @@ const Label = forwardRef<HandlerRef<View, LabelProps>, LabelProps>(
|
|
|
55
54
|
} = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight })
|
|
56
55
|
|
|
57
56
|
const nodeRef = useRef(null)
|
|
58
|
-
useNodesRef(props, ref, nodeRef, {
|
|
57
|
+
useNodesRef(props, ref, nodeRef, { style: normalStyle })
|
|
59
58
|
|
|
60
59
|
const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef })
|
|
61
60
|
|
|
62
|
-
const { textStyle, backgroundStyle, innerStyle } = splitStyle(normalStyle)
|
|
61
|
+
const { textStyle, backgroundStyle, innerStyle = {} } = splitStyle(normalStyle)
|
|
63
62
|
|
|
64
63
|
if (backgroundStyle) {
|
|
65
64
|
warn('Label does not support background image-related styles!')
|
|
@@ -69,43 +68,46 @@ const Label = forwardRef<HandlerRef<View, LabelProps>, LabelProps>(
|
|
|
69
68
|
triggerChange: noop
|
|
70
69
|
})
|
|
71
70
|
|
|
72
|
-
const onTap = (evt: NativeSyntheticEvent<TouchEvent>) => {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
71
|
+
const onTap = useCallback((evt: NativeSyntheticEvent<TouchEvent>) => {
|
|
72
|
+
const { bindtap } = propsRef.current
|
|
73
|
+
bindtap && bindtap(getCustomEvent('tap', evt, { layoutRef }, { props: propsRef.current }))
|
|
74
|
+
contextRef.current.triggerChange(evt)
|
|
75
|
+
}, [])
|
|
76
76
|
|
|
77
77
|
const innerProps = useInnerProps(
|
|
78
78
|
props,
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
79
|
+
extendObject(
|
|
80
|
+
{
|
|
81
|
+
ref: nodeRef,
|
|
82
|
+
style: extendObject({}, innerStyle, layoutStyle)
|
|
83
|
+
},
|
|
84
|
+
layoutProps,
|
|
85
|
+
{
|
|
86
|
+
bindtap: onTap
|
|
87
|
+
}
|
|
88
|
+
),
|
|
85
89
|
[],
|
|
86
90
|
{
|
|
87
91
|
layoutRef
|
|
88
92
|
}
|
|
89
93
|
)
|
|
90
94
|
|
|
91
|
-
return
|
|
92
|
-
|
|
95
|
+
return createElement(View, innerProps, createElement(
|
|
96
|
+
LabelContext.Provider,
|
|
97
|
+
{ value: contextRef },
|
|
98
|
+
wrapChildren(
|
|
99
|
+
props,
|
|
93
100
|
{
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
varContext: varContextRef.current,
|
|
99
|
-
textStyle,
|
|
100
|
-
textProps
|
|
101
|
-
}
|
|
102
|
-
)
|
|
101
|
+
hasVarDec,
|
|
102
|
+
varContext: varContextRef.current,
|
|
103
|
+
textStyle,
|
|
104
|
+
textProps
|
|
103
105
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
+
)
|
|
107
|
+
))
|
|
106
108
|
}
|
|
107
109
|
)
|
|
108
110
|
|
|
109
|
-
Label.displayName = '
|
|
111
|
+
Label.displayName = 'MpxLabel'
|
|
110
112
|
|
|
111
113
|
export default Label
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* ✘ scale-area
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import { View
|
|
6
|
-
import { JSX,
|
|
5
|
+
import { View } from 'react-native'
|
|
6
|
+
import { JSX, forwardRef, ReactNode, useRef, useMemo, createElement } 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>;
|
|
@@ -23,14 +23,7 @@ interface MovableAreaProps {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
const _MovableArea = forwardRef<HandlerRef<View, MovableAreaProps>, MovableAreaProps>((props: MovableAreaProps, ref): JSX.Element => {
|
|
26
|
-
const { style = {},
|
|
27
|
-
const [areaWidth, setAreaWidth] = useState(0)
|
|
28
|
-
const [areaHeight, setAreaHeight] = useState(0)
|
|
29
|
-
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
setAreaWidth(width)
|
|
32
|
-
setAreaHeight(height)
|
|
33
|
-
}, [width, height])
|
|
26
|
+
const { style = {}, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight } = props
|
|
34
27
|
|
|
35
28
|
const {
|
|
36
29
|
hasSelfPercent,
|
|
@@ -42,41 +35,35 @@ const _MovableArea = forwardRef<HandlerRef<View, MovableAreaProps>, MovableAreaP
|
|
|
42
35
|
} = useTransformStyle(style, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight })
|
|
43
36
|
|
|
44
37
|
const movableViewRef = useRef(null)
|
|
45
|
-
useNodesRef(props, ref, movableViewRef
|
|
38
|
+
useNodesRef(props, ref, movableViewRef, {
|
|
39
|
+
style: normalStyle
|
|
40
|
+
})
|
|
46
41
|
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
42
|
+
const contextValue = useMemo(() => ({
|
|
43
|
+
height: normalStyle.height || 10,
|
|
44
|
+
width: normalStyle.width || 10
|
|
45
|
+
}), [normalStyle.width, normalStyle.height])
|
|
52
46
|
|
|
53
|
-
const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: movableViewRef
|
|
47
|
+
const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: movableViewRef })
|
|
54
48
|
|
|
55
|
-
const innerProps = useInnerProps(props, {
|
|
56
|
-
style: { height:
|
|
57
|
-
ref: movableViewRef
|
|
58
|
-
|
|
59
|
-
}, [], { 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 })
|
|
60
53
|
|
|
61
|
-
return (
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
54
|
+
return createElement(MovableAreaContext.Provider, { value: contextValue }, createElement(
|
|
55
|
+
View,
|
|
56
|
+
innerProps,
|
|
57
|
+
wrapChildren(
|
|
58
|
+
props,
|
|
66
59
|
{
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
{
|
|
70
|
-
hasVarDec,
|
|
71
|
-
varContext: varContextRef.current
|
|
72
|
-
}
|
|
73
|
-
)
|
|
60
|
+
hasVarDec,
|
|
61
|
+
varContext: varContextRef.current
|
|
74
62
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
)
|
|
63
|
+
)
|
|
64
|
+
))
|
|
78
65
|
})
|
|
79
66
|
|
|
80
|
-
_MovableArea.displayName = '
|
|
67
|
+
_MovableArea.displayName = 'MpxMovableArea'
|
|
81
68
|
|
|
82
69
|
export default _MovableArea
|