UNPKG

17.2 kBTypeScriptView Raw
1import { JSX, JSXElement } from 'solid-js'
2import { TaroElement } from '@tarojs/runtime'
3import { AdProps } from '@tarojs/components/types/Ad'
4import { AdCustomProps } from '@tarojs/components/types/AdCustom'
5import { AudioProps } from '@tarojs/components/types/Audio'
6import { ButtonProps } from '@tarojs/components/types/Button'
7import { CameraProps } from '@tarojs/components/types/Camera'
8import { CanvasProps } from '@tarojs/components/types/Canvas'
9import { ChannelLiveProps } from '@tarojs/components/types/ChannelLive'
10import { ChannelVideoProps } from '@tarojs/components/types/ChannelVideo'
11import { CheckboxProps } from '@tarojs/components/types/Checkbox'
12import { CheckboxGroupProps } from '@tarojs/components/types/CheckboxGroup'
13import { StandardProps } from '@tarojs/components/types/common'
14import { CoverImageProps } from '@tarojs/components/types/CoverImage'
15import { CoverViewProps } from '@tarojs/components/types/CoverView'
16import { CustomWrapperProps } from '@tarojs/components/types/CustomWrapper'
17import { EditorProps } from '@tarojs/components/types/Editor'
18import { FormProps } from '@tarojs/components/types/Form'
19import { FunctionalPageNavigatorProps } from '@tarojs/components/types/FunctionalPageNavigator'
20import { GridViewProps } from '@tarojs/components/types/GridView'
21import { IconProps } from '@tarojs/components/types/Icon'
22import { ImageProps } from '@tarojs/components/types/Image'
23import { InputProps } from '@tarojs/components/types/Input'
24import { KeyboardAccessoryProps } from '@tarojs/components/types/KeyboardAccessory'
25import { LabelProps } from '@tarojs/components/types/Label'
26import { ListViewProps } from '@tarojs/components/types/ListView'
27import { LivePlayerProps } from '@tarojs/components/types/LivePlayer'
28import { LivePusherProps } from '@tarojs/components/types/LivePusher'
29import { MapProps } from '@tarojs/components/types/Map'
30import { MatchMediaProps } from '@tarojs/components/types/MatchMedia'
31import { MovableAreaProps } from '@tarojs/components/types/MovableArea'
32import { MovableViewProps } from '@tarojs/components/types/MovableView'
33import { NativeSlotProps } from '@tarojs/components/types/NativeSlot'
34import { NavigationBarProps } from '@tarojs/components/types/NavigationBar'
35import { NavigatorProps } from '@tarojs/components/types/Navigator'
36import { OfficialAccountProps } from '@tarojs/components/types/OfficialAccount'
37import { OpenDataProps } from '@tarojs/components/types/OpenData'
38import { PageContainerProps } from '@tarojs/components/types/PageContainer'
39import { PageMetaProps } from '@tarojs/components/types/PageMeta'
40import {
41 PickerDateProps, PickerMultiSelectorProps,
42 PickerRegionProps, PickerSelectorProps, PickerTimeProps
43} from '@tarojs/components/types/Picker'
44import { PickerViewProps } from '@tarojs/components/types/PickerView'
45import { PickerViewColumnProps } from '@tarojs/components/types/PickerViewColumn'
46import { ProgressProps } from '@tarojs/components/types/Progress'
47import { RadioProps } from '@tarojs/components/types/Radio'
48import { RadioGroupProps } from '@tarojs/components/types/RadioGroup'
49import { RichTextProps } from '@tarojs/components/types/RichText'
50import { RootPortalProps } from '@tarojs/components/types/RootPortal'
51import { ScrollViewProps } from '@tarojs/components/types/ScrollView'
52import { ShareElementProps } from '@tarojs/components/types/ShareElement'
53import { SliderProps } from '@tarojs/components/types/Slider'
54import { SlotProps } from '@tarojs/components/types/Slot'
55import { SnapshotProps } from '@tarojs/components/types/SnapShot'
56import { StickyHeaderProps } from '@tarojs/components/types/StickyHeader'
57import { StickySectionProps } from '@tarojs/components/types/StickySection'
58import { SwiperProps } from '@tarojs/components/types/Swiper'
59import { SwiperItemProps } from '@tarojs/components/types/SwiperItem'
60import { SwitchProps } from '@tarojs/components/types/Switch'
61import { TextProps } from '@tarojs/components/types/Text'
62import { TextareaProps } from '@tarojs/components/types/Textarea'
63import { VideoProps } from '@tarojs/components/types/Video'
64import { ViewProps } from '@tarojs/components/types/View'
65import { VoipRoomProps } from '@tarojs/components/types/VoipRoom'
66import { WebViewProps } from '@tarojs/components/types/WebView'
67
68// 重置react的类型
69interface SlimProps {
70 children?: JSXElement
71 class?: string
72 style?: string | JSX.CSSProperties | undefined
73 innerHTML?: string
74}
75/** 联合类型不能用omit(比如picker) */
76type DistributiveOmit<T, K extends keyof T> = T extends unknown ? Omit<T, K> : never
77
78export type RemoveReactAttribute = 'children' | 'className' | 'style' | 'key' | 'ref' | 'dangerouslySetInnerHTML'
79
80export type TransformReact2SolidType<P extends StandardProps = Record<string, never>> = DistributiveOmit<P, RemoveReactAttribute> & SlimProps & JSX.DirectiveAttributes & JSX.CustomAttributes<TaroElement>
81
82type Components<T> = (props: TransformReact2SolidType<T>) => JSXElement;
83
84
85/** 视图容器 */
86export declare const Block: Components<StandardProps>
87export declare const CoverImage: Components<CoverImageProps>
88export declare const CoverView: Components<CoverViewProps>
89export declare const GridView: Components<GridViewProps>
90export declare const ListView: Components<ListViewProps>
91export declare const MatchMedia: Components<MatchMediaProps>
92export declare const MovableArea: Components<MovableAreaProps>
93export declare const MovableView: Components<MovableViewProps>
94export declare const PageContainer: Components<PageContainerProps>
95export declare const RootPortal: Components<RootPortalProps>
96export declare const ScrollView: Components<ScrollViewProps>
97export declare const ShareElement: Components<ShareElementProps>
98export declare const StickyHeader: Components<StickyHeaderProps>
99export declare const StickySection: Components<StickySectionProps>
100export declare const Swiper: Components<SwiperProps>
101export declare const SwiperItem: Components<SwiperItemProps>
102export declare const View: Components<ViewProps>
103/** 基础内容 */
104export declare const Icon: Components<IconProps>
105export declare const Progress: Components<ProgressProps>
106export declare const RichText: Components<RichTextProps>
107export declare const Text: Components<TextProps>
108/** 表单组件 */
109export declare const Button: Components<ButtonProps>
110export declare const Checkbox: Components<CheckboxProps>
111export declare const CheckboxGroup: Components<CheckboxGroupProps>
112export declare const Editor: Components<EditorProps>
113export declare const Form: Components<FormProps>
114export declare const Input: Components<InputProps>
115export declare const KeyboardAccessory: Components<KeyboardAccessoryProps>
116export declare const Label: Components<LabelProps>
117export declare const Picker: Components<PickerMultiSelectorProps | PickerTimeProps | PickerDateProps | PickerRegionProps | PickerSelectorProps>
118export declare const PickerView: Components<PickerViewProps>
119export declare const PickerViewColumn: Components<PickerViewColumnProps>
120export declare const Radio: Components<RadioProps>
121export declare const RadioGroup: Components<RadioGroupProps>
122export declare const Slider: Components<SliderProps>
123export declare const Switch: Components<SwitchProps>
124export declare const Textarea: Components<TextareaProps>
125/** 导航 */
126export declare const FunctionalPageNavigator: Components<FunctionalPageNavigatorProps>
127export declare const Navigator: Components<NavigatorProps>
128export declare const NavigationBar: Components<NavigationBarProps>
129/** 媒体组件 */
130export declare const Audio: Components<AudioProps>
131export declare const Camera: Components<CameraProps>
132export declare const ChannelLive: Components<ChannelLiveProps>
133export declare const ChannelVideo: Components<ChannelVideoProps>
134export declare const Image: Components<ImageProps>
135export declare const LivePlayer: Components<LivePlayerProps>
136export declare const LivePusher: Components<LivePusherProps>
137export declare const Video: Components<VideoProps>
138export declare const VoipRoom: Components<VoipRoomProps>
139/** 地图 */
140export declare const Map: Components<MapProps>
141/** 画布 */
142export declare const Canvas: Components<CanvasProps>
143/** 开放能力 */
144export declare const Ad: Components<AdProps>
145export declare const AdCustom: Components<AdCustomProps>
146export declare const OfficialAccount: Components<OfficialAccountProps>
147export declare const OpenData: Components<OpenDataProps>
148export declare const WebView: Components<WebViewProps>
149/** 配置节点 */
150export declare const PageMeta: Components<PageMetaProps>
151
152export declare const CustomWrapper: Components<CustomWrapperProps>
153export declare const Slot: Components<SlotProps>
154export declare const NativeSlot: Components<NativeSlotProps>
155
156declare global {
157 namespace JSX {
158 interface IntrinsicElements {
159 /** 视图容器 */
160 block: TransformReact2SolidType<StandardProps>
161 'taro-block-core': TransformReact2SolidType<StandardProps>
162 'cover-image': TransformReact2SolidType<CoverImageProps>
163 'taro-cover-image-core': TransformReact2SolidType<CoverImageProps>
164 'cover-view': TransformReact2SolidType<CoverViewProps>
165 'taro-cover-view-core': TransformReact2SolidType<CoverViewProps>
166 'match-media': TransformReact2SolidType<MatchMediaProps>
167 'taro-match-media-core': TransformReact2SolidType<MatchMediaProps>
168 'movable-area': TransformReact2SolidType<MovableAreaProps>
169 'taro-movable-area-core': TransformReact2SolidType<MovableAreaProps>
170 'movable-view': TransformReact2SolidType<MovableViewProps>
171 'taro-movable-view-core': TransformReact2SolidType<MovableViewProps>
172 'page-container': TransformReact2SolidType<PageContainerProps>
173 'taro-page-container-core': TransformReact2SolidType<PageContainerProps>
174 'root-portal': TransformReact2SolidType<RootPortalProps>
175 'taro-root-portal-core': TransformReact2SolidType<RootPortalProps>
176 'scroll-view': TransformReact2SolidType<ScrollViewProps>
177 'taro-scroll-view-core': TransformReact2SolidType<ScrollViewProps>
178 swiper: TransformReact2SolidType<SwiperProps>
179 'taro-swiper-core': TransformReact2SolidType<SwiperProps>
180 'swiper-item': TransformReact2SolidType<SwiperItemProps>
181 'taro-swiper-item-core': TransformReact2SolidType<SwiperItemProps>
182 view: TransformReact2SolidType<ViewProps>
183 'taro-view-core': TransformReact2SolidType<ViewProps>
184 /** 基础内容 */
185 icon: TransformReact2SolidType<IconProps>
186 'taro-icon-core': TransformReact2SolidType<IconProps>
187 progress: TransformReact2SolidType<ProgressProps>
188 'taro-progress-core': TransformReact2SolidType<ProgressProps>
189 'rich-text': TransformReact2SolidType<RichTextProps>
190 'taro-rich-text-core': TransformReact2SolidType<RichTextProps>
191 text: TransformReact2SolidType<TextProps>
192 'taro-text-core': TransformReact2SolidType<TextProps>
193 /** 表单组件 */
194 button: TransformReact2SolidType<ButtonProps>
195 'taro-button-core': TransformReact2SolidType<ButtonProps>
196 checkbox: TransformReact2SolidType<CheckboxProps>
197 'taro-checkbox-core': TransformReact2SolidType<CheckboxProps>
198 'checkbox-group': TransformReact2SolidType<CheckboxGroupProps>
199 'taro-checkbox-group-core': TransformReact2SolidType<CheckboxGroupProps>
200 editor: TransformReact2SolidType<EditorProps>
201 'taro-editor-core': TransformReact2SolidType<EditorProps>
202 form: TransformReact2SolidType<FormProps>
203 'taro-form-core': TransformReact2SolidType<FormProps>
204 input: TransformReact2SolidType<InputProps>
205 'taro-input-core': TransformReact2SolidType<InputProps>
206 'keyboard-accessory': TransformReact2SolidType<KeyboardAccessoryProps>
207 'taro-keyboard-accessory-core': TransformReact2SolidType<KeyboardAccessoryProps>
208 label: TransformReact2SolidType<LabelProps>
209 'taro-label-core': TransformReact2SolidType<LabelProps>
210 picker: TransformReact2SolidType<PickerMultiSelectorProps | PickerTimeProps | PickerDateProps | PickerRegionProps | PickerSelectorProps>
211 'taro-picker-core': TransformReact2SolidType<PickerMultiSelectorProps | PickerTimeProps | PickerDateProps | PickerRegionProps | PickerSelectorProps>
212 'picker-view': TransformReact2SolidType<PickerViewProps>
213 'taro-picker-view-core': TransformReact2SolidType<PickerViewProps>
214 'picker-view-column': TransformReact2SolidType<PickerViewColumnProps>
215 'taro-picker-view-column-core': TransformReact2SolidType<PickerViewColumnProps>
216 radio: TransformReact2SolidType<RadioProps>
217 'taro-radio-core': TransformReact2SolidType<RadioProps>
218 'radio-group': TransformReact2SolidType<RadioGroupProps>
219 'taro-radio-group-core': TransformReact2SolidType<RadioGroupProps>
220 slider: TransformReact2SolidType<SliderProps>
221 'taro-slider-core': TransformReact2SolidType<SliderProps>
222 switch: TransformReact2SolidType<SwitchProps>
223 'taro-switch-core': TransformReact2SolidType<SwitchProps>
224 textarea: TransformReact2SolidType<TextareaProps>
225 'taro-textarea-core': TransformReact2SolidType<TextareaProps>
226 /** Skyline */
227 'grid-view': TransformReact2SolidType<GridViewProps>
228 'taro-grid-view-core': TransformReact2SolidType<GridViewProps>
229 'list-view': TransformReact2SolidType<ListViewProps>
230 'taro-list-view-core': TransformReact2SolidType<ListViewProps>
231 'share-element': TransformReact2SolidType<ShareElementProps>
232 'taro-share-element-core': TransformReact2SolidType<ShareElementProps>
233 'snapshot': TransformReact2SolidType<SnapshotProps>
234 'taro-snapshot-core': TransformReact2SolidType<SnapshotProps>
235 'sticky-header': TransformReact2SolidType<StickyHeaderProps>
236 'taro-sticky-header-core': TransformReact2SolidType<StickyHeaderProps>
237 'sticky-section': TransformReact2SolidType<StickySectionProps>
238 'taro-sticky-section-core': TransformReact2SolidType<StickySectionProps>
239 /** 导航 */
240 'functional-page-navigator': TransformReact2SolidType<FunctionalPageNavigatorProps>
241 'taro-functional-page-navigator-core': TransformReact2SolidType<FunctionalPageNavigatorProps>
242 navigator: TransformReact2SolidType<NavigatorProps>
243 'taro-navigator-core': TransformReact2SolidType<NavigatorProps>
244 'navigation-bar': TransformReact2SolidType<NavigationBarProps>
245 'taro-navigation-bar-core': TransformReact2SolidType<NavigationBarProps>
246 /** 媒体组件 */
247 audio: TransformReact2SolidType<AudioProps>
248 'taro-audio-core': TransformReact2SolidType<AudioProps>
249 camera: TransformReact2SolidType<CameraProps>
250 'taro-camera-core': TransformReact2SolidType<CameraProps>
251 'channel-live': TransformReact2SolidType<ChannelLiveProps>
252 'taro-channel-live-core': TransformReact2SolidType<ChannelLiveProps>
253 'channel-video': TransformReact2SolidType<ChannelVideoProps>
254 'taro-channel-video-core': TransformReact2SolidType<ChannelVideoProps>
255 image: TransformReact2SolidType<ImageProps>
256 'taro-image-core': TransformReact2SolidType<ImageProps>
257 'live-player': TransformReact2SolidType<LivePlayerProps>
258 'taro-live-player-core': TransformReact2SolidType<LivePlayerProps>
259 'live-pusher': TransformReact2SolidType<LivePusherProps>
260 'taro-live-pusher-core': TransformReact2SolidType<LivePusherProps>
261 video: TransformReact2SolidType<VideoProps>
262 'taro-video-core': TransformReact2SolidType<VideoProps>
263 'voip-room': TransformReact2SolidType<VoipRoomProps>
264 'taro-voip-room-core': TransformReact2SolidType<VoipRoomProps>
265 /** 地图 */
266 map: TransformReact2SolidType<MapProps>
267 'taro-map-core': TransformReact2SolidType<MapProps>
268 /** 画布 */
269 canvas: TransformReact2SolidType<CanvasProps>
270 'taro-canvas-core': TransformReact2SolidType<CanvasProps>
271 /** 开放能力 */
272 ad: TransformReact2SolidType<AdProps>
273 'taro-ad-core': TransformReact2SolidType<AdProps>
274 'ad-custom': TransformReact2SolidType<AdCustomProps>
275 'taro-ad-custom-core': TransformReact2SolidType<AdCustomProps>
276 'official-account': TransformReact2SolidType<OfficialAccountProps>
277 'taro-official-account-core': TransformReact2SolidType<OfficialAccountProps>
278 'open-data': TransformReact2SolidType<OpenDataProps>
279 'taro-open-data-core': TransformReact2SolidType<OpenDataProps>
280 'web-view': TransformReact2SolidType<WebViewProps>
281 'taro-web-view-core': TransformReact2SolidType<WebViewProps>
282 /** 配置节点 */
283 'page-meta': TransformReact2SolidType<PageMetaProps>
284 'taro-page-meta-core': TransformReact2SolidType<PageMetaProps>
285
286 'custom-wrapper': TransformReact2SolidType<CustomWrapperProps>
287 'taro-custom-wrapper-core': TransformReact2SolidType<CustomWrapperProps>
288 /** 为了不与vue3模板默认的slot冲突,增加 Record<string, any> */
289 'slot': TransformReact2SolidType<SlotProps> & Record<string, any>
290 'taro-slot-core': TransformReact2SolidType<SlotProps>
291 'native-slot': TransformReact2SolidType<NativeSlotProps>
292 'taro-native-slot-core': TransformReact2SolidType<NativeSlotProps>
293 }
294 }
295}
296
297