@mpxjs/webpack-plugin 2.10.4 → 2.10.5-beta.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.
- package/lib/index.js +10 -1
- package/lib/json-compiler/helper.js +1 -4
- package/lib/platform/json/wx/index.js +0 -1
- package/lib/platform/style/wx/index.js +22 -21
- package/lib/platform/template/wx/component-config/button.js +1 -1
- package/lib/platform/template/wx/component-config/index.js +5 -1
- package/lib/platform/template/wx/component-config/input.js +1 -1
- package/lib/platform/template/wx/component-config/sticky-header.js +23 -0
- package/lib/platform/template/wx/component-config/sticky-section.js +23 -0
- package/lib/platform/template/wx/index.js +21 -1
- package/lib/react/processJSON.js +7 -6
- package/lib/react/processScript.js +9 -1
- package/lib/react/script-helper.js +5 -1
- package/lib/resolver/PackageEntryPlugin.js +3 -1
- package/lib/runtime/components/react/context.ts +12 -3
- package/lib/runtime/components/react/dist/context.js +4 -1
- package/lib/runtime/components/react/dist/event.config.js +0 -2
- package/lib/runtime/components/react/dist/getInnerListeners.js +127 -153
- package/lib/runtime/components/react/dist/mpx-button.jsx +11 -7
- package/lib/runtime/components/react/dist/mpx-canvas/Image.js +2 -4
- package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +23 -21
- package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +9 -4
- package/lib/runtime/components/react/dist/mpx-checkbox.jsx +9 -5
- package/lib/runtime/components/react/dist/mpx-form.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-icon/index.jsx +9 -4
- package/lib/runtime/components/react/dist/mpx-image.jsx +11 -4
- package/lib/runtime/components/react/dist/mpx-input.jsx +24 -13
- package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.jsx +23 -30
- package/lib/runtime/components/react/dist/mpx-label.jsx +9 -5
- package/lib/runtime/components/react/dist/mpx-movable-area.jsx +9 -4
- package/lib/runtime/components/react/dist/mpx-movable-view.jsx +77 -43
- package/lib/runtime/components/react/dist/mpx-navigator.jsx +11 -3
- package/lib/runtime/components/react/dist/mpx-picker/index.jsx +12 -14
- package/lib/runtime/components/react/dist/mpx-picker-view/index.jsx +10 -10
- package/lib/runtime/components/react/dist/mpx-picker-view-column/index.jsx +28 -10
- package/lib/runtime/components/react/dist/mpx-radio-group.jsx +11 -4
- package/lib/runtime/components/react/dist/mpx-radio.jsx +9 -5
- package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +9 -4
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +31 -11
- package/lib/runtime/components/react/dist/mpx-simple-text.jsx +3 -2
- package/lib/runtime/components/react/dist/mpx-simple-view.jsx +3 -3
- package/lib/runtime/components/react/dist/mpx-sticky-header.jsx +115 -0
- package/lib/runtime/components/react/dist/mpx-sticky-section.jsx +45 -0
- package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +15 -14
- package/lib/runtime/components/react/dist/mpx-swiper.jsx +86 -40
- package/lib/runtime/components/react/dist/mpx-switch.jsx +10 -7
- package/lib/runtime/components/react/dist/mpx-text.jsx +11 -9
- package/lib/runtime/components/react/dist/mpx-video.jsx +9 -4
- package/lib/runtime/components/react/dist/mpx-view.jsx +15 -10
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +13 -13
- package/lib/runtime/components/react/dist/useAnimationHooks.js +27 -4
- package/lib/runtime/components/react/dist/utils.jsx +99 -98
- package/lib/runtime/components/react/event.config.ts +1 -8
- package/lib/runtime/components/react/getInnerListeners.ts +146 -192
- package/lib/runtime/components/react/mpx-button.tsx +16 -8
- package/lib/runtime/components/react/mpx-canvas/Image.ts +4 -4
- package/lib/runtime/components/react/mpx-canvas/index.tsx +47 -32
- package/lib/runtime/components/react/mpx-checkbox-group.tsx +13 -4
- package/lib/runtime/components/react/mpx-checkbox.tsx +17 -10
- package/lib/runtime/components/react/mpx-form.tsx +25 -19
- package/lib/runtime/components/react/mpx-icon/index.tsx +13 -4
- package/lib/runtime/components/react/mpx-image.tsx +42 -22
- package/lib/runtime/components/react/mpx-input.tsx +32 -16
- package/lib/runtime/components/react/mpx-keyboard-avoiding-view.tsx +31 -42
- package/lib/runtime/components/react/mpx-label.tsx +13 -6
- package/lib/runtime/components/react/mpx-movable-area.tsx +29 -14
- package/lib/runtime/components/react/mpx-movable-view.tsx +121 -81
- package/lib/runtime/components/react/mpx-navigator.tsx +4 -6
- package/lib/runtime/components/react/mpx-picker/index.tsx +24 -19
- package/lib/runtime/components/react/mpx-picker-view/index.tsx +39 -22
- package/lib/runtime/components/react/mpx-picker-view-column/index.tsx +36 -32
- package/lib/runtime/components/react/mpx-radio-group.tsx +24 -12
- package/lib/runtime/components/react/mpx-radio.tsx +17 -10
- package/lib/runtime/components/react/mpx-rich-text/index.tsx +25 -8
- package/lib/runtime/components/react/mpx-scroll-view.tsx +95 -60
- package/lib/runtime/components/react/mpx-simple-text.tsx +10 -3
- package/lib/runtime/components/react/mpx-simple-view.tsx +10 -4
- package/lib/runtime/components/react/mpx-sticky-header.tsx +179 -0
- package/lib/runtime/components/react/mpx-sticky-section.tsx +96 -0
- package/lib/runtime/components/react/mpx-swiper-item.tsx +42 -43
- package/lib/runtime/components/react/mpx-swiper.tsx +142 -79
- package/lib/runtime/components/react/mpx-switch.tsx +29 -16
- package/lib/runtime/components/react/mpx-text.tsx +26 -15
- package/lib/runtime/components/react/mpx-video.tsx +41 -35
- package/lib/runtime/components/react/mpx-view.tsx +38 -18
- package/lib/runtime/components/react/mpx-web-view.tsx +12 -12
- package/lib/runtime/components/react/types/getInnerListeners.d.ts +65 -35
- package/lib/runtime/components/react/useAnimationHooks.ts +30 -9
- package/lib/runtime/components/react/utils.tsx +107 -103
- package/lib/runtime/components/web/mpx-scroll-view.vue +21 -4
- package/lib/runtime/components/web/mpx-sticky-header.vue +91 -0
- package/lib/runtime/components/web/mpx-sticky-section.vue +15 -0
- package/lib/runtime/components/web/mpx-web-view.vue +1 -1
- package/lib/runtime/mpxGlobal.js +1 -0
- package/lib/runtime/optionProcessor.d.ts +5 -0
- package/lib/template-compiler/bind-this.js +8 -7
- package/lib/template-compiler/compiler.js +1 -1
- package/lib/wxs/pre-loader.js +1 -0
- package/package.json +3 -3
- package/LICENSE +0 -433
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
enhanced: Boolean,
|
|
45
45
|
refresherEnabled: Boolean,
|
|
46
46
|
refresherTriggered: Boolean,
|
|
47
|
+
enableSticky: Boolean,
|
|
47
48
|
refresherThreshold: {
|
|
48
49
|
type: Number,
|
|
49
50
|
default: 45
|
|
@@ -57,6 +58,16 @@
|
|
|
57
58
|
default: ''
|
|
58
59
|
}
|
|
59
60
|
},
|
|
61
|
+
provide () {
|
|
62
|
+
return {
|
|
63
|
+
scrollOffset: {
|
|
64
|
+
get: () => this.lastY
|
|
65
|
+
},
|
|
66
|
+
refreshVersion: {
|
|
67
|
+
get: () => this.refreshVersion
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
},
|
|
60
71
|
data () {
|
|
61
72
|
return {
|
|
62
73
|
isLoading: false,
|
|
@@ -68,7 +79,8 @@
|
|
|
68
79
|
lastContentWidth: 0,
|
|
69
80
|
lastContentHeight: 0,
|
|
70
81
|
lastWrapperWidth: 0,
|
|
71
|
-
lastWrapperHeight: 0
|
|
82
|
+
lastWrapperHeight: 0,
|
|
83
|
+
refreshVersion: 0
|
|
72
84
|
}
|
|
73
85
|
},
|
|
74
86
|
computed: {
|
|
@@ -222,6 +234,9 @@
|
|
|
222
234
|
stop: 56
|
|
223
235
|
}
|
|
224
236
|
}
|
|
237
|
+
if(this.enableSticky) {
|
|
238
|
+
originBsOptions.useTransition = false
|
|
239
|
+
}
|
|
225
240
|
const bsOptions = Object.assign({}, originBsOptions, this.scrollOptions, { observeDOM: false })
|
|
226
241
|
this.bs = new BScroll(this.$refs.wrapper, bsOptions)
|
|
227
242
|
this.lastX = -this.currentX
|
|
@@ -251,7 +266,7 @@
|
|
|
251
266
|
}
|
|
252
267
|
this.lastX = x
|
|
253
268
|
this.lastY = y
|
|
254
|
-
}, 30, {
|
|
269
|
+
}, this.enableSticky ? 0 : 30, {
|
|
255
270
|
leading: true,
|
|
256
271
|
trailing: true
|
|
257
272
|
}))
|
|
@@ -327,6 +342,7 @@
|
|
|
327
342
|
const scrollWrapperHeight = wrapper?.clientHeight || 0
|
|
328
343
|
if (wrapper) {
|
|
329
344
|
const computedStyle = getComputedStyle(wrapper)
|
|
345
|
+
this.refreshVersion = this.refreshVersion + 1
|
|
330
346
|
// 考虑子元素样式可能会设置100%,如果直接继承 scrollContent 的样式可能会有问题
|
|
331
347
|
// 所以使用 wrapper 作为 innerWrapper 的宽高参考依据
|
|
332
348
|
this.$refs.innerWrapper.style.width = `${scrollWrapperWidth - parseInt(computedStyle.paddingLeft) - parseInt(computedStyle.paddingRight)}px`
|
|
@@ -458,7 +474,8 @@
|
|
|
458
474
|
}
|
|
459
475
|
|
|
460
476
|
const innerWrapper = createElement('div', {
|
|
461
|
-
ref: 'innerWrapper'
|
|
477
|
+
ref: 'innerWrapper',
|
|
478
|
+
class: 'mpx-inner-wrapper'
|
|
462
479
|
}, this.$slots.default)
|
|
463
480
|
|
|
464
481
|
const pullDownContent = this.refresherDefaultStyle !== 'none' ? createElement('div', {
|
|
@@ -568,4 +585,4 @@
|
|
|
568
585
|
background: rgba(255, 255, 255, .7)
|
|
569
586
|
100%
|
|
570
587
|
background: rgba(255, 255, 255, .3)
|
|
571
|
-
</style>
|
|
588
|
+
</style>
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { warn } from '@mpxjs/utils'
|
|
3
|
+
import { getCustomEvent } from './getInnerListeners'
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
name: 'mpx-sticky-header',
|
|
7
|
+
inject: ['scrollOffset', 'refreshVersion'],
|
|
8
|
+
props: {
|
|
9
|
+
'offsetTop': {
|
|
10
|
+
type: Number,
|
|
11
|
+
default: 0
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
data() {
|
|
15
|
+
return {
|
|
16
|
+
headerTop: 0,
|
|
17
|
+
isStickOnTop: false
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
computed: {
|
|
21
|
+
_scrollOffset() {
|
|
22
|
+
return -this.scrollOffset?.get() || 0
|
|
23
|
+
},
|
|
24
|
+
_refreshVersion() {
|
|
25
|
+
return this.refreshVersion?.get() || 0
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
watch: {
|
|
29
|
+
_scrollOffset: {
|
|
30
|
+
handler(newScrollOffset) {
|
|
31
|
+
const newIsStickOnTop = newScrollOffset > this.headerTop
|
|
32
|
+
if (newIsStickOnTop !== this.isStickOnTop) {
|
|
33
|
+
this.isStickOnTop = newIsStickOnTop
|
|
34
|
+
this.$emit('stickontopchange', getCustomEvent('stickontopchange', {
|
|
35
|
+
isStickOnTop: newIsStickOnTop
|
|
36
|
+
}, this))
|
|
37
|
+
}
|
|
38
|
+
const stickyHeader = this.$refs.stickyHeader
|
|
39
|
+
if (!stickyHeader) return
|
|
40
|
+
if (this.isStickOnTop) {
|
|
41
|
+
stickyHeader.style.transform = `translateY(${newScrollOffset - this.headerTop + this.offsetTop}px)`
|
|
42
|
+
} else {
|
|
43
|
+
stickyHeader.style.transform = 'none'
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
immediate: true
|
|
47
|
+
},
|
|
48
|
+
_refreshVersion: {
|
|
49
|
+
handler() {
|
|
50
|
+
const parentElement = this.$el.parentElement
|
|
51
|
+
if (!parentElement) return
|
|
52
|
+
|
|
53
|
+
const parentClass = parentElement.className || ''
|
|
54
|
+
const isStickySection = /mpx-sticky-section/.test(parentClass)
|
|
55
|
+
const isScrollViewWrapper = /mpx-inner-wrapper/.test(parentClass)
|
|
56
|
+
|
|
57
|
+
if (!isStickySection && !isScrollViewWrapper) {
|
|
58
|
+
warn('sticky-header only supports being a direct child of a scroll-view or sticky-section component.')
|
|
59
|
+
return
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
this.headerTop = isStickySection
|
|
63
|
+
? this.$el.offsetTop + parentElement.offsetTop
|
|
64
|
+
: this.$el.offsetTop
|
|
65
|
+
|
|
66
|
+
const stickyHeader = this.$refs.stickyHeader
|
|
67
|
+
if (!stickyHeader) return
|
|
68
|
+
|
|
69
|
+
if (this._scrollOffset > this.headerTop) {
|
|
70
|
+
stickyHeader.style.transform = `translateY(${this._scrollOffset - this.headerTop + this.offsetTop}px)`
|
|
71
|
+
} else {
|
|
72
|
+
stickyHeader.style.transform = 'none'
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
render(h) {
|
|
78
|
+
const style = {
|
|
79
|
+
width: '100%',
|
|
80
|
+
boxSizing: 'border-box',
|
|
81
|
+
position: 'relative',
|
|
82
|
+
zIndex: 10
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return h('div', {
|
|
86
|
+
style,
|
|
87
|
+
ref: 'stickyHeader'
|
|
88
|
+
}, this.$slots.default)
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
</script>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = Object.create(global)
|
|
@@ -4,8 +4,13 @@ declare global {
|
|
|
4
4
|
[key: string]: any
|
|
5
5
|
}
|
|
6
6
|
}
|
|
7
|
+
interface Window {
|
|
8
|
+
mpxGlobal: Record<string, any>
|
|
9
|
+
}
|
|
7
10
|
}
|
|
8
11
|
|
|
12
|
+
declare const mpxGlobal: Record<string, any>
|
|
13
|
+
|
|
9
14
|
export function processComponentOption (...args: any): object
|
|
10
15
|
|
|
11
16
|
export function getComponent (...args: any): object
|
|
@@ -70,7 +70,7 @@ function getCollectPath (path) {
|
|
|
70
70
|
function checkDelAndGetPath (path) {
|
|
71
71
|
let current = path
|
|
72
72
|
let delPath = path
|
|
73
|
-
let canDel = true
|
|
73
|
+
let canDel = true // 是否可删除,优先级比replace高
|
|
74
74
|
let ignore = false
|
|
75
75
|
let replace = false
|
|
76
76
|
|
|
@@ -80,8 +80,13 @@ function checkDelAndGetPath (path) {
|
|
|
80
80
|
if (t.isUnaryExpression(current.parent) && current.key === 'argument') {
|
|
81
81
|
delPath = current.parentPath
|
|
82
82
|
} else if (t.isCallExpression(current.parent)) {
|
|
83
|
-
const args = current.
|
|
84
|
-
if (
|
|
83
|
+
const args = current.parent.arguments || []
|
|
84
|
+
if (
|
|
85
|
+
// case: String(a) || this._p(a)
|
|
86
|
+
args.length === 1 ||
|
|
87
|
+
// 除了自身,参数列表里只能是数字或字符串才能删
|
|
88
|
+
(args.every(node => node === current.node || t.isNumericLiteral(node) || t.isStringLiteral(node)))
|
|
89
|
+
) {
|
|
85
90
|
delPath = current.parentPath
|
|
86
91
|
} else {
|
|
87
92
|
break
|
|
@@ -123,24 +128,20 @@ function checkDelAndGetPath (path) {
|
|
|
123
128
|
|
|
124
129
|
if (t.isCallExpression(parent) && listKey === 'arguments') {
|
|
125
130
|
canDel = false
|
|
126
|
-
break
|
|
127
131
|
}
|
|
128
132
|
|
|
129
133
|
if (t.isMemberExpression(parent) && parent.computed) {
|
|
130
134
|
canDel = false
|
|
131
|
-
break
|
|
132
135
|
}
|
|
133
136
|
|
|
134
137
|
if (t.isLogicalExpression(parent)) { // case: a || ((b || c) && d)
|
|
135
138
|
canDel = false
|
|
136
139
|
ignore = true
|
|
137
|
-
break
|
|
138
140
|
}
|
|
139
141
|
|
|
140
142
|
if (t.isConditionalExpression(parent)) {
|
|
141
143
|
if (key === 'test') {
|
|
142
144
|
canDel = false
|
|
143
|
-
break
|
|
144
145
|
} else {
|
|
145
146
|
ignore = true
|
|
146
147
|
replace = true // 继续往上找,判断是否存在if条件等
|
|
@@ -2725,8 +2725,8 @@ function processElement (el, root, options, meta) {
|
|
|
2725
2725
|
processIf(el)
|
|
2726
2726
|
processFor(el)
|
|
2727
2727
|
processRefReact(el, meta)
|
|
2728
|
+
processStyleReact(el, options)
|
|
2728
2729
|
if (!pass) {
|
|
2729
|
-
processStyleReact(el, options)
|
|
2730
2730
|
processEventReact(el, options)
|
|
2731
2731
|
processComponentGenerics(el, meta)
|
|
2732
2732
|
processComponentIs(el, options)
|
package/lib/wxs/pre-loader.js
CHANGED
|
@@ -54,6 +54,7 @@ module.exports = function (content) {
|
|
|
54
54
|
ExportNamedDeclaration (path) {
|
|
55
55
|
if (
|
|
56
56
|
path.node.declaration &&
|
|
57
|
+
path.node.declaration.declarations &&
|
|
57
58
|
path.node.declaration.declarations.length === 1 &&
|
|
58
59
|
path.node.declaration.declarations[0].id.name === path.node.declaration.declarations[0].init.name
|
|
59
60
|
) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/webpack-plugin",
|
|
3
|
-
"version": "2.10.
|
|
3
|
+
"version": "2.10.5-beta.1",
|
|
4
4
|
"description": "mpx compile core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mpx"
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
85
|
"@d11/react-native-fast-image": "^8.6.12",
|
|
86
|
-
"@mpxjs/api-proxy": "^2.10.
|
|
86
|
+
"@mpxjs/api-proxy": "^2.10.5 | ^2.10.5-beta.1",
|
|
87
87
|
"@types/babel-traverse": "^6.25.4",
|
|
88
88
|
"@types/babel-types": "^7.0.4",
|
|
89
89
|
"@types/react": "^18.2.79",
|
|
@@ -100,5 +100,5 @@
|
|
|
100
100
|
"engines": {
|
|
101
101
|
"node": ">=14.14.0"
|
|
102
102
|
},
|
|
103
|
-
"gitHead": "
|
|
103
|
+
"gitHead": "2d37697869b9bdda3efab92dda8c910b68fd05c0"
|
|
104
104
|
}
|