Skip to content

Commit

Permalink
fix(skyline): 适配skyline组件及API(非worklet部分)
Browse files Browse the repository at this point in the history
  • Loading branch information
yushijie1 committed Nov 13, 2024
1 parent d1c96b1 commit def9cd8
Show file tree
Hide file tree
Showing 16 changed files with 330 additions and 25 deletions.
2 changes: 1 addition & 1 deletion packages/taro-components/types/Image.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ interface ImageProps extends StandardProps {
*/
ariaLabel?: string
/** 是否渐显
* @supported weapp
* @supported weapp-skyline
* @default false
*/
fadeIn?: boolean
Expand Down
20 changes: 20 additions & 0 deletions packages/taro-components/types/Input.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ interface InputProps extends StandardProps, FormItemProps {
* @supported weapp, alipay, swan, tt, qq, jd, rn, harmony
*/
cursor?: number
/** 光标颜色。iOS 下的格式为十六进制颜色值 #000000,安卓下的只支持 default 和 green,Skyline 下无限制
* @supported weapp
*/
cursorColor?: string
/** 光标起始位置,自动聚集时有效,需与selection-end搭配使用
* @default -1
* @supported weapp, alipay, swan, tt, qq, jd, rn
Expand Down Expand Up @@ -194,6 +198,22 @@ interface InputProps extends StandardProps, FormItemProps {
* @supported weapp
*/
onNickNameReview?: CommonEventFunction
/** 选区改变事件, {selectionStart, selectionEnd}
* @supported weapp-skyline
*/
onSelectionChange?: CommonEventFunction
/** 输入法开始新的输入时触发 (仅当输入法支持时触发)
* @supported weapp-skyline
*/
onKeyboardCompositionStart?: CommonEventFunction
/** 输入法输入字符时触发(仅当输入法支持时触发)
* @supported weapp-skyline
*/
onKeyboardCompositionUpdate?: CommonEventFunction
/** 输入法输入结束时触发(仅当输入法支持时触发)
* @supported weapp-skyline
*/
onKeyboardCompositionEnd?: CommonEventFunction
}
declare namespace InputProps {
/** Input 类型 */
Expand Down
5 changes: 5 additions & 0 deletions packages/taro-components/types/RichText.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ interface RichTextProps extends StandardProps {
* @supported alipay
*/
onLongtap?: CommonEventFunction
/** 布局兼容模式
* @supported weapp-skyline
* @default default
*/
mode?: 'default' | 'compat' | 'aggressive' | 'inline-block' | 'web'
}
/** 节点类型
* > 现支持两种节点,通过type来区分,分别是元素节点和文本节点,默认是元素节点,在富文本区域里显示的HTML节点 元素节点:type = node*
Expand Down
8 changes: 8 additions & 0 deletions packages/taro-components/types/ScrollView.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ interface ScrollViewProps extends StandardProps {
* @default 'list'
*/
type?: 'list' | 'custom' | 'nested'
/** 关联的滚动容器
* draggable-sheet - 关联 draggable-sheet 组件 3.2.0
* nested-scroll-view - 关联 type=nested 嵌套模式 3.2.0
* pop-gesture - 关联 页面手势返回 3.4.0
* @supported weapp
* @default ''
*/
associativeContainer?: 'draggable-sheet' | 'nested-scroll-view' | 'pop-gesture'
/** 是否反向滚动。一般初始滚动位置是在顶部,反向滚动则是在底部。
* @supported weapp
* @default false
Expand Down
2 changes: 1 addition & 1 deletion packages/taro-components/types/ShareElement.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ interface ShareElementProps extends StandardProps {
| 'bounceIn'
| 'bounceOut'
| 'bounceInOut'
| 'cubic-bezier(x1,'
| 'cubic-bezier(x1, y1, x2, y2)'
/** 动画帧回调
* @supported weapp
*/
Expand Down
6 changes: 6 additions & 0 deletions packages/taro-components/types/StickyHeader.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ interface StickyHeaderProps extends StandardProps {
* @default [0, 0, 0, 0]
*/
padding?: [number, number, number, number]
/**
* 吸顶状态变化事件,仅支持非 worklet 的组件方法作为回调。event.detail = { isStickOnTop },当 sticky-header 吸顶时为 true,否则为 false。
* @supported weapp
* @version >=3.6.2
*/
onStickOnTopChange?: CommonEventFunction
}

/**
Expand Down
70 changes: 60 additions & 10 deletions packages/taro-components/types/Swiper.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,6 @@ interface SwiperProps extends StandardProps {
* @supported swan
*/
disableTouchmove?: string
/** 改变 current 时使用动画过渡
* @supported weapp
* @default true
*/
scrollWithAnimation?: boolean
/** 缓存区域大小,值为 1 表示提前渲染上下各一屏区域(swiper 容器大小)
* @supported weapp
* @default 0
*/
cacheExtent?: number
/** swiper11 相关的动效参数,具体见文档 https://swiperjs.com/swiper-api#parameters
* @supported h5
*/
Expand All @@ -171,6 +161,66 @@ interface SwiperProps extends StandardProps {
* @supported alipay
*/
onAnimationEnd?: CommonEventFunction<SwiperProps.onCommonEventDetail>
/** 渲染模式
* @supported weapp-skyline
* @default normal
*/
layoutType?: 'normal' | 'stackLeft' | 'stackRight' | 'tinder' | 'transformer'
/** layout-type 为 transformer 时指定动画类型
* @supported weapp-skyline
* @default scaleAndFade
*/
transformerType?: 'scaleAndFade' | 'accordion' | 'threeD' | 'zoomIn' | 'zoomOut' | 'deepthPage'
/** 指示点动画类型
* @supported weapp-skyline
* @default normal
*/
indicatorType?: 'normal' | 'worm' | 'wormThin' | 'wormUnderground' | 'wormThinUnderground' | 'expand' | 'jump' | 'jumpWithOffset' | 'scroll' | 'scrollFixedCenter' | 'slide' | 'slideUnderground' | 'scale' | 'swap' | 'swapYRotation' | 'color'
/** 指示点四周边距
* @supported weapp-skyline
* @default 10
*/
indicatorMargin?: number
/** 指示点间距
* @supported weapp-skyline
* @default 4
*/
indicatorSpacing?: number
/** 指示点圆角大小
* @supported weapp-skyline
* @default 4
*/
indicatorRadius?: number
/** 指示点宽度
* @supported weapp-skyline
* @default 8
*/
indicatorWidth?: number
/** 指示点高度
* @supported weapp-skyline
* @default 8
*/
indicatorHeight?: number
/** 指示点的相对位置
* @supported weapp-skyline
* @default auto
*/
indicatorAlignment?: [number, number] | string
/** 指示点位置的偏移量
* @supported weapp-skyline
* @default [0, 0]
*/
indicatorOffset?: [number, number]
/** 改变 current 时使用动画过渡
* @supported weapp-skyline
* @default true
*/
scrollWithAnimation?: boolean
/** 缓存区域大小,值为 1 表示提前渲染上下各一屏区域(swiper 容器大小)
* @supported weapp-skyline
* @default 0
*/
cacheExtent?: number
}
declare namespace SwiperProps {
/** 导致变更的原因 */
Expand Down
21 changes: 21 additions & 0 deletions packages/taro-components/types/Textarea.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,27 @@ interface TextareaProps extends StandardProps, FormItemProps {
* @supported weapp, tt, harmony
*/
onKeyboardHeightChange?: CommonEventFunction<TextareaProps.onKeyboardHeightChangeEventDetail>

/** 需传入对象,格式为 { fontSize: number, fontWeight: string, color: string }
* @supported weapp-skyline
*/
placeholderStyle?: string
/** 选区改变事件, {selectionStart, selectionEnd}
* @supported weapp-skyline
*/
onSelectionChange?: CommonEventFunction
/** 输入法开始新的输入时触发 (仅当输入法支持时触发)
* @supported weapp-skyline
*/
onKeyboardCompositionStart?: CommonEventFunction
/** 输入法输入字符时触发(仅当输入法支持时触发)
* @supported weapp-skyline
*/
onKeyboardCompositionUpdate?: CommonEventFunction
/** 输入法输入结束时触发(仅当输入法支持时触发)
* @supported weapp-skyline
*/
onKeyboardCompositionEnd?: CommonEventFunction
}
declare namespace TextareaProps {
interface onFocusEventDetail {
Expand Down
14 changes: 13 additions & 1 deletion packages/taro-h5/src/api/route/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
import { temporarilyNotSupport } from '../../utils'

const router = {
addRouteBuilder: /* @__PURE__ */ temporarilyNotSupport('addRouteBuilder'),
getRouteContext: /* @__PURE__ */ temporarilyNotSupport('getRouteContext'),
removeRouteBuilder: /* @__PURE__ */ temporarilyNotSupport('removeRouteBuilder')
}

// 路由
export {
navigateBack,
navigateTo,
redirectTo,
reLaunch,
switchTab
switchTab,
} from '@tarojs/router'

export {
router
}

// FIXME 方法导出类型未对齐,后续修复
9 changes: 6 additions & 3 deletions packages/taro-h5/src/api/taro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Taro from '@tarojs/api'
import { history } from '@tarojs/router'
import { isFunction, PLATFORM_TYPE } from '@tarojs/shared'

import { getApp, getCurrentInstance, getCurrentPages, navigateBack, navigateTo, nextTick, redirectTo, reLaunch, switchTab } from '../api'
import { getApp, getCurrentInstance, getCurrentPages, navigateBack, navigateTo, nextTick, redirectTo, reLaunch, router, switchTab } from '../api'
import { permanentlyNotSupport } from '../utils'

const {
Expand All @@ -19,7 +19,9 @@ const {
preload
} = Taro as any

const taro: typeof Taro = {
type ModifiedTaro = Omit<typeof Taro, 'router'> & { router: any };

const taro: ModifiedTaro = {
// @ts-ignore
Behavior,
getEnv,
Expand All @@ -40,7 +42,8 @@ const taro: typeof Taro = {
reLaunch,
redirectTo,
getCurrentPages,
switchTab
switchTab,
router,
}

const requirePlugin = /* @__PURE__ */ permanentlyNotSupport('requirePlugin')
Expand Down
41 changes: 35 additions & 6 deletions packages/taro-platform-weapp/src/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ export const components = {
},
RichText: {
space: _empty,
'user-select': _false
'user-select': _false,
mode: "'default'"
},
Text: {
'user-select': _false,
Expand Down Expand Up @@ -85,8 +86,13 @@ export const components = {
'safe-password-salt': '',
'safe-password-custom-hash': '',
'auto-fill': _empty,
'cursor-color': '',
bindKeyboardHeightChange: _empty,
bindNicknameReview: _empty
bindNicknameReview: _empty,
bindSelectionChange: _empty,
bindKeyboardCompositionStart: _empty,
bindKeyboardCompositionUpdate: _empty,
bindKeyboardCompositionEnd: _empty,
},
Picker: {
'header-text': _empty,
Expand All @@ -108,7 +114,12 @@ export const components = {
'disable-default-padding': _false,
'confirm-type': "'return'",
'confirm-hold': _false,
bindKeyboardHeightChange: _empty
'adjust-keyboard-to': "'cursor'",
bindKeyboardHeightChange: _empty,
bindSelectionChange: _empty,
bindKeyboardCompositionStart: _empty,
bindKeyboardCompositionUpdate: _empty,
bindKeyboardCompositionEnd: _empty,
},
ScrollView: {
'enable-flex': _false,
Expand All @@ -126,6 +137,7 @@ export const components = {
'show-scrollbar': _true,
'fast-deceleration': _false,
type: "'list'",
'associative-container': "''",
reverse: _false,
clip: _true,
'enable-back-to-top': _false,
Expand Down Expand Up @@ -194,7 +206,19 @@ export const components = {
},
Swiper: {
'snap-to-edge': _false,
'easing-function': "'default'"
'easing-function': "'default'",
'layout-type': "'normal'",
'transformer-type': "'scaleAndFade'",
'indicator-type': "'normal'",
'indicator-margin': '10',
'indicator-spacing': '4',
'indicator-radius': '4',
'indicator-width': '8',
'indicator-height': '8',
'indicator-alignment': "'auto'",
'indicator-offset': '[0, 0]',
'scroll-with-animation': _true,
'cache-extent': '0',
},
SwiperItem: {
'skip-hidden-item-layout': _false
Expand All @@ -215,7 +239,8 @@ export const components = {
},
Image: {
webp: _false,
'show-menu-by-longpress': _false
'show-menu-by-longpress': _false,
'fade-in': _false
},
LivePlayer: {
mode: "'live'",
Expand Down Expand Up @@ -432,7 +457,11 @@ export const components = {
mapkey: _empty,
transform: _false,
duration: '300',
'easing-function': "'ease-out'"
'easing-function': "'ease-out'",
'transition-on-gesture': _false,
'shuttle-on-push': "'to'",
'shuttle-on-pop': "'to'",
'rect-tween-type': "'materialRectArc'"
},
KeyboardAccessory: {},
RootPortal: {
Expand Down
1 change: 0 additions & 1 deletion packages/taro-runtime/src/dsl/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,6 @@ export function createRecursiveComponentConfig (componentName?: string) {
}
},
options: {
addGlobalClass: true,
virtualHost: !isCustomWrapper
},
methods: {
Expand Down
3 changes: 3 additions & 0 deletions packages/taro-vite-runner/src/mini/emit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ export default function (viteCompilerContext: ViteMiniCompilerContext): PluginOp
// 如微信、QQ 不支持递归模版的小程序,需要使用自定义组件协助递归
const baseCompConfig = {
component: true,
styleIsolation: 'apply-shared',
usingComponents: {
[baseCompName]: `./${baseCompName}`
}
Expand All @@ -139,6 +140,7 @@ export default function (viteCompilerContext: ViteMiniCompilerContext): PluginOp
filePath: customWrapperName,
config: {
component: true,
styleIsolation: 'apply-shared',
usingComponents: {
[customWrapperName]: `./${customWrapperName}`
}
Expand All @@ -151,6 +153,7 @@ export default function (viteCompilerContext: ViteMiniCompilerContext): PluginOp
filePath: customWrapperName,
config: {
component: true,
styleIsolation: 'apply-shared',
usingComponents: {
[customWrapperName]: `./${customWrapperName}`
}
Expand Down
Loading

0 comments on commit def9cd8

Please sign in to comment.