-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6416 from alibaba/release/next
Release 3.2.9
- Loading branch information
Showing
31 changed files
with
379 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,3 +42,7 @@ export const dataLoader = defineDataLoader(() => { | |
}); | ||
}); | ||
}); | ||
|
||
export const runApp = (render) => { | ||
render(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,14 @@ | ||
import { Children, useRef, useEffect, useCallback } from 'react'; | ||
import type { Ref } from 'react'; | ||
import { isFunction } from './type'; | ||
import { observerElement, VisibilityChangeEvent } from './visibility'; | ||
import type * as React from 'react'; | ||
import WebAppear from './web'; | ||
import WeexAppear from './weex'; | ||
import type { AppearProps } from './typings.js'; | ||
|
||
function VisibilityChange(props: any) { | ||
const { | ||
onAppear, | ||
onDisappear, | ||
children, | ||
} = props; | ||
let Appear: React.ForwardRefExoticComponent<AppearProps & React.RefAttributes<any>>; | ||
|
||
const defaultRef: Ref<Node> = useRef<Node>(); | ||
const ref: Ref<Node> = (children && children.ref) ? children.ref : defaultRef; | ||
|
||
const listen = useCallback((eventName: string, handler: Function) => { | ||
const { current } = ref; | ||
// Rax components will set custom ref by useImperativeHandle. | ||
// So We should get eventTarget by _nativeNode. | ||
// https://github.com/raxjs/rax-components/blob/master/packages/rax-textinput/src/index.tsx#L151 | ||
if (current && isFunction(handler)) { | ||
const eventTarget = current._nativeNode || current; | ||
observerElement(eventTarget as Element); | ||
eventTarget.addEventListener(eventName, handler); | ||
} | ||
return () => { | ||
const { current } = ref; | ||
if (current) { | ||
const eventTarget = current._nativeNode || current; | ||
eventTarget.removeEventListener(eventName, handler); | ||
} | ||
}; | ||
}, [ref]); | ||
|
||
useEffect(() => listen(VisibilityChangeEvent.appear, onAppear), [ref, onAppear, listen]); | ||
useEffect(() => listen(VisibilityChangeEvent.disappear, onDisappear), [ref, onDisappear, listen]); | ||
|
||
return Children.only({ ...children, ref }); | ||
if (import.meta.target === 'weex') { | ||
Appear = WeexAppear; | ||
} else { | ||
Appear = WebAppear as any; | ||
} | ||
|
||
export default VisibilityChange; | ||
export default Appear; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/// <reference types="@ice/pkg/types" /> | ||
|
||
interface ImportMeta { | ||
// The build target | ||
target: 'weex' | 'web'; | ||
} | ||
|
||
|
||
interface Node { | ||
_nativeNode: Node; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import type * as React from 'react'; | ||
|
||
export interface AppearProps { | ||
children: React.ReactElement; | ||
/** | ||
* Triggered when the element enters the visible area. | ||
* @param {CustomEvent} e | ||
* @returns {void} | ||
*/ | ||
onAppear?: (e: CustomEvent) => void; | ||
/** | ||
* Triggered when the element leaves the visible area. | ||
* @param {CustomEvent} e | ||
* @returns {void} | ||
*/ | ||
onDisappear?: (e: CustomEvent) => void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { Children, useRef, useEffect, useCallback } from 'react'; | ||
import type { Ref, RefObject } from 'react'; | ||
import { isFunction } from './type'; | ||
import { observerElement, VisibilityChangeEvent } from './visibility'; | ||
|
||
interface Node { | ||
_nativeNode?: Node; | ||
} | ||
|
||
export default function VisibilityChange(props: any) { | ||
const { onAppear, onDisappear, children } = props; | ||
|
||
const defaultRef: Ref<Node> = useRef<Node>(); | ||
|
||
const ref: RefObject<Node> = children.ref | ||
? typeof children.ref === 'object' | ||
? children.ref | ||
: defaultRef | ||
: defaultRef; | ||
|
||
useEffect(() => { | ||
if (typeof children.ref === 'function') { | ||
children.ref(ref.current); | ||
} | ||
}, [ref, children]); | ||
|
||
const listen = useCallback( | ||
(eventName: string, handler: EventListenerOrEventListenerObject) => { | ||
const { current } = ref; | ||
// Rax components will set custom ref by useImperativeHandle. | ||
// So We should get eventTarget by _nativeNode. | ||
// https://github.com/raxjs/rax-components/blob/master/packages/rax-textinput/src/index.tsx#L151 | ||
if (current && isFunction(handler)) { | ||
const eventTarget = current._nativeNode || current; | ||
observerElement(eventTarget as Element); | ||
eventTarget.addEventListener(eventName, handler); | ||
} | ||
return () => { | ||
const { current } = ref; | ||
if (current) { | ||
const eventTarget = current._nativeNode || current; | ||
eventTarget.removeEventListener(eventName, handler); | ||
} | ||
}; | ||
}, | ||
[ref], | ||
); | ||
|
||
useEffect(() => listen(VisibilityChangeEvent.appear, onAppear), [ref, onAppear, listen]); | ||
useEffect(() => listen(VisibilityChangeEvent.disappear, onDisappear), [ref, onDisappear, listen]); | ||
|
||
return Children.only({ ...children, ref }); | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export function isFunction(obj: any): obj is Function { | ||
return typeof obj === 'function'; | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import type { ForwardedRef } from 'react'; | ||
import { useEffect, useRef, forwardRef, cloneElement, Children } from 'react'; | ||
import type { AppearProps } from '../typings'; | ||
|
||
const WeexAppear = forwardRef<any, AppearProps>((props, ref) => { | ||
const internalRef = useRef<HTMLDivElement>(null); | ||
const childrenRef: ForwardedRef<HTMLDivElement> = ref ?? internalRef; | ||
|
||
const { children, onAppear, onDisappear } = props; | ||
|
||
useEffect(() => { | ||
// Use copy of childrenRef to avoid ref value changed in cleanup phase. | ||
const nodeRef = typeof childrenRef === 'object' ? childrenRef.current : null; | ||
|
||
// Return early if onAppear callback not specified. | ||
onAppear && nodeRef?.addEventListener('appear', (e: CustomEvent) => onAppear(e)); | ||
|
||
return () => { | ||
onAppear && nodeRef?.removeEventListener('appear', (e: CustomEvent) => onAppear(e)); | ||
}; | ||
}, [childrenRef, onAppear]); | ||
|
||
useEffect(() => { | ||
const nodeRef = typeof childrenRef === 'object' ? childrenRef.current : null; | ||
|
||
onDisappear && nodeRef?.addEventListener('disappear', (e: CustomEvent) => onDisappear(e)); | ||
|
||
return () => { | ||
onDisappear && nodeRef?.removeEventListener('disappear', (e: CustomEvent) => onDisappear(e)); | ||
}; | ||
}, [childrenRef, onDisappear]); | ||
|
||
return cloneElement(Children.only(children), { ref: childrenRef }); | ||
}); | ||
|
||
export default WeexAppear; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
import { createRouteLoader, WrapRouteComponent, RouteErrorComponent } from '@ice/runtime'; | ||
import type { CreateRoutes } from '@ice/runtime'; | ||
<%- routeImports.length ? routeImports.join('\n') + '\n\n' : ''; -%> | ||
export default ({ | ||
const createRoutes: CreateRoutes = ({ | ||
requestContext, | ||
renderMode, | ||
}) => ([ | ||
<%- routeDefinition %> | ||
]); | ||
export default createRoutes; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
# Changelog | ||
|
||
## 3.0.3 | ||
|
||
### Patch Changes | ||
|
||
- e40a7cb2: fix: add `bounces` attr | ||
|
||
## 3.0.2 | ||
|
||
### Patch Changes | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.