@mpxjs/webpack-plugin 2.10.7-beta.8 → 2.10.7

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 (35) hide show
  1. package/LICENSE +433 -0
  2. package/lib/dependencies/RecordPageConfigsMapDependency.js +1 -1
  3. package/lib/index.js +5 -6
  4. package/lib/platform/template/wx/component-config/index.js +1 -5
  5. package/lib/platform/template/wx/index.js +2 -1
  6. package/lib/runtime/components/react/context.ts +3 -12
  7. package/lib/runtime/components/react/dist/context.js +1 -4
  8. package/lib/runtime/components/react/dist/getInnerListeners.js +1 -1
  9. package/lib/runtime/components/react/dist/mpx-button.jsx +2 -2
  10. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +2 -2
  11. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +6 -17
  12. package/lib/runtime/components/react/dist/mpx-swiper.jsx +27 -53
  13. package/lib/runtime/components/react/dist/mpx-web-view.jsx +14 -28
  14. package/lib/runtime/components/react/dist/useAnimationHooks.js +2 -87
  15. package/lib/runtime/components/react/getInnerListeners.ts +1 -1
  16. package/lib/runtime/components/react/mpx-button.tsx +2 -3
  17. package/lib/runtime/components/react/mpx-movable-view.tsx +2 -2
  18. package/lib/runtime/components/react/mpx-scroll-view.tsx +50 -68
  19. package/lib/runtime/components/react/mpx-swiper.tsx +25 -53
  20. package/lib/runtime/components/react/mpx-web-view.tsx +13 -33
  21. package/lib/runtime/components/react/types/global.d.ts +15 -0
  22. package/lib/runtime/components/react/useAnimationHooks.ts +2 -85
  23. package/lib/runtime/components/web/mpx-scroll-view.vue +4 -21
  24. package/lib/template-compiler/compiler.js +1 -1
  25. package/package.json +4 -4
  26. package/lib/platform/template/wx/component-config/sticky-header.js +0 -23
  27. package/lib/platform/template/wx/component-config/sticky-section.js +0 -23
  28. package/lib/runtime/components/react/AsyncContainer.tsx +0 -189
  29. package/lib/runtime/components/react/dist/AsyncContainer.jsx +0 -141
  30. package/lib/runtime/components/react/dist/mpx-sticky-header.jsx +0 -115
  31. package/lib/runtime/components/react/dist/mpx-sticky-section.jsx +0 -45
  32. package/lib/runtime/components/react/mpx-sticky-header.tsx +0 -179
  33. package/lib/runtime/components/react/mpx-sticky-section.tsx +0 -96
  34. package/lib/runtime/components/web/mpx-sticky-header.vue +0 -91
  35. package/lib/runtime/components/web/mpx-sticky-section.vue +0 -15
@@ -1,96 +0,0 @@
1
-
2
- import { useRef, forwardRef, createElement, ReactNode, useCallback, useMemo } from 'react'
3
- import { View, ViewStyle } from 'react-native'
4
- import useNodesRef, { HandlerRef } from './useNodesRef'
5
- import { splitProps, splitStyle, useTransformStyle, wrapChildren, useLayout, extendObject } from './utils'
6
- import { StickyContext } from './context'
7
- import useInnerProps from './getInnerListeners'
8
-
9
- interface StickySectionProps {
10
- children?: ReactNode;
11
- style?: ViewStyle;
12
- 'offset-top'?: number;
13
- 'enable-var'?: boolean;
14
- 'external-var-context'?: Record<string, any>;
15
- 'parent-font-size'?: number;
16
- 'parent-width'?: number;
17
- 'parent-height'?: number;
18
- }
19
-
20
- const _StickySection = forwardRef<HandlerRef<View, StickySectionProps>, StickySectionProps>((stickySectionProps: StickySectionProps = {}, ref): JSX.Element => {
21
- const { textProps, innerProps: props = {} } = splitProps(stickySectionProps)
22
- const {
23
- style,
24
- 'enable-var': enableVar,
25
- 'external-var-context': externalVarContext,
26
- 'parent-font-size': parentFontSize,
27
- 'parent-width': parentWidth,
28
- 'parent-height': parentHeight
29
- } = props
30
- const sectionRef = useRef<View>(null)
31
-
32
- const {
33
- normalStyle,
34
- hasVarDec,
35
- varContextRef,
36
- hasSelfPercent,
37
- setWidth,
38
- setHeight
39
- } = useTransformStyle(style, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight })
40
-
41
- const { layoutRef, layoutProps, layoutStyle } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: sectionRef, onLayout })
42
-
43
- const { textStyle, innerStyle = {} } = splitStyle(normalStyle)
44
-
45
- const stickyHeaders = useRef<Map<string, any>>(new Map())
46
-
47
- const registerStickyHeader = useCallback((item: { id: string, updatePosition: Function }) => {
48
- stickyHeaders.current.set(item.id, item)
49
- }, [])
50
-
51
- const unregisterStickyHeader = useCallback((id: string) => {
52
- stickyHeaders.current.delete(id)
53
- }, [])
54
-
55
- const contextValue = useMemo(() => ({
56
- registerStickyHeader,
57
- unregisterStickyHeader
58
- }), [])
59
-
60
- useNodesRef(props, ref, sectionRef, {
61
- style: normalStyle
62
- })
63
-
64
- function onLayout () {
65
- stickyHeaders.current.forEach(item => {
66
- item.updatePosition()
67
- })
68
- }
69
-
70
- const innerProps = useInnerProps(extendObject({}, props, {
71
- style: extendObject(innerStyle, layoutStyle),
72
- ref: sectionRef
73
- }, layoutProps), [], { layoutRef })
74
-
75
- return (
76
- createElement(
77
- View,
78
- innerProps,
79
- createElement(
80
- StickyContext.Provider,
81
- { value: contextValue },
82
- wrapChildren(
83
- props,
84
- {
85
- hasVarDec,
86
- varContext: varContextRef.current,
87
- textStyle,
88
- textProps
89
- }
90
- )
91
- ))
92
- )
93
- })
94
-
95
- _StickySection.displayName = 'MpxStickySection'
96
- export default _StickySection
@@ -1,91 +0,0 @@
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>
@@ -1,15 +0,0 @@
1
- <script>
2
- export default {
3
- name: 'mpx-sticky-section',
4
- render(h) {
5
- const style = {
6
- position: 'relative'
7
- }
8
-
9
- return h('div', {
10
- style,
11
- class: 'mpx-sticky-section'
12
- }, this.$slots.default)
13
- }
14
- }
15
- </script>