@gojijs/core
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -11,3 +11,2 @@ import { GOJI_ROOT_VDOM } from './constants'; | ||
private applyUpdate; | ||
private inQueue; | ||
requestUpdate(): void; | ||
@@ -14,0 +13,0 @@ registerEventHandler(handlerKey: string, handler: Function): void; |
@@ -28,7 +28,5 @@ var _a; | ||
this[_a] = []; | ||
this.inQueue = false; | ||
this.__context = context; | ||
} | ||
applyUpdate() { | ||
this.inQueue = false; | ||
const children_ = pure(this[GOJI_ROOT_VDOM]); | ||
@@ -50,7 +48,3 @@ const startTime = new Date().getTime(); | ||
requestUpdate() { | ||
if (this.inQueue) { | ||
return; | ||
} | ||
this.inQueue = true; | ||
Promise.resolve().then(() => this.applyUpdate()); | ||
this.applyUpdate(); | ||
} | ||
@@ -57,0 +51,0 @@ registerEventHandler(handlerKey, handler) { |
@@ -1,2 +0,2 @@ | ||
import { Props, CSSProperties } from 'react'; | ||
import { CSSProperties } from 'react'; | ||
export declare type HostComponent = 'view' | 'scroll-view' | 'swiper' | 'swiper-item' | 'movable-view' | 'movable-area' | 'cover-view' | 'cover-image' | 'icon' | 'text' | 'rich-text' | 'progress' | 'button' | 'checkbox-group' | 'checkbox' | 'form' | 'input' | 'label' | 'picker' | 'picker-view' | 'radio-group' | 'radio' | 'slider' | 'switch' | 'textarea' | 'navigator' | 'image' | 'video' | 'camera' | 'live-player' | 'live-pusher' | 'map' | 'canvas' | 'open-data' | 'official-account'; | ||
@@ -63,8 +63,77 @@ interface BaseProps { | ||
} | ||
export declare const View: <T>(props: Props<T> & ViewProps) => import("react").ReactElement<Props<T> & ViewProps, string | ((props: any) => import("react").ReactElement<any, string | any | (new (props: any) => import("react").Component<any, any, any>)> | null) | (new (props: any) => import("react").Component<any, any, any>)>; | ||
export declare const Button: <T>(props: Props<T> & ButtonProps) => import("react").ReactElement<Props<T> & ButtonProps, string | ((props: any) => import("react").ReactElement<any, string | any | (new (props: any) => import("react").Component<any, any, any>)> | null) | (new (props: any) => import("react").Component<any, any, any>)>; | ||
export declare const Radio: <T>(props: Props<T> & RadioProps) => import("react").ReactElement<Props<T> & RadioProps, string | ((props: any) => import("react").ReactElement<any, string | any | (new (props: any) => import("react").Component<any, any, any>)> | null) | (new (props: any) => import("react").Component<any, any, any>)>; | ||
export declare const RadioGroup: <T>(props: Props<T> & RadioGroupProps) => import("react").ReactElement<Props<T> & RadioGroupProps, string | ((props: any) => import("react").ReactElement<any, string | any | (new (props: any) => import("react").Component<any, any, any>)> | null) | (new (props: any) => import("react").Component<any, any, any>)>; | ||
export declare const Label: <T>(props: Props<T> & LabelProps) => import("react").ReactElement<Props<T> & LabelProps, string | ((props: any) => import("react").ReactElement<any, string | any | (new (props: any) => import("react").Component<any, any, any>)> | null) | (new (props: any) => import("react").Component<any, any, any>)>; | ||
export declare const ScrollView: <T>(props: Props<T> & ScrollViewProps) => import("react").ReactElement<Props<T> & ScrollViewProps, string | ((props: any) => import("react").ReactElement<any, string | any | (new (props: any) => import("react").Component<any, any, any>)> | null) | (new (props: any) => import("react").Component<any, any, any>)>; | ||
declare type InputType = 'text' | 'number' | 'idcard' | 'digit'; | ||
declare type InputConfirmType = 'send' | 'search' | 'next' | 'go' | 'done'; | ||
interface InputProps extends BaseProps { | ||
value: string; | ||
type?: InputType; | ||
password?: boolean; | ||
placeholder?: string; | ||
placeholderStyle?: string; | ||
placeholderClass?: string; | ||
disabled?: boolean; | ||
maxlength?: number; | ||
cursorSpacing?: number; | ||
autoFocus?: boolean; | ||
focus?: boolean; | ||
confirmType?: InputConfirmType; | ||
confirmHold?: boolean; | ||
cursor?: number; | ||
selectionStart?: number; | ||
selectionEnd?: number; | ||
adjustPosition?: boolean; | ||
onInput?: (e: any) => void; | ||
onFocus?: (e: any) => void; | ||
onBlur?: (e: any) => void; | ||
onConfirm?: (e: any) => void; | ||
onKeyboardheightchange?: (e: any) => void; | ||
} | ||
interface PickerBaseProps extends BaseProps { | ||
disabled?: boolean; | ||
onCancel?: (e: any) => void; | ||
} | ||
interface PickerSelectorProps extends PickerBaseProps { | ||
mode: 'selector'; | ||
range?: Array<any>; | ||
rangeKey?: string; | ||
value?: number; | ||
onChange?: (e: any) => void; | ||
} | ||
interface PickerMultiSelector extends PickerBaseProps { | ||
mode: 'multiSelector'; | ||
range?: Array<any>; | ||
rangeKey?: string; | ||
value?: number; | ||
onChange?: (e: any) => void; | ||
onColumnchange?: (e: any) => void; | ||
} | ||
interface PickerTimeSelector extends PickerBaseProps { | ||
mode: 'time'; | ||
value?: string; | ||
start?: string; | ||
end?: string; | ||
onChange?: (e: any) => void; | ||
} | ||
declare type PickerDateFields = 'year' | 'month' | 'day'; | ||
interface PickerDateSelector extends PickerBaseProps { | ||
mode: 'date'; | ||
value?: string; | ||
start?: string; | ||
end?: string; | ||
fields?: PickerDateFields; | ||
onChange?: (e: any) => void; | ||
} | ||
interface PickerRegionSelector extends PickerBaseProps { | ||
value?: Array<any>; | ||
customItem?: string; | ||
onChange?: (e: any) => void; | ||
} | ||
declare type PickerProps = PickerSelectorProps | PickerMultiSelector | PickerTimeSelector | PickerDateSelector | PickerRegionSelector; | ||
export declare const View: import("react").FunctionComponent<ViewProps>; | ||
export declare const Button: import("react").FunctionComponent<ButtonProps>; | ||
export declare const Radio: import("react").FunctionComponent<RadioProps>; | ||
export declare const RadioGroup: import("react").FunctionComponent<RadioGroupProps>; | ||
export declare const Label: import("react").FunctionComponent<LabelProps>; | ||
export declare const ScrollView: import("react").FunctionComponent<ScrollViewProps>; | ||
export declare const Input: import("react").FunctionComponent<InputProps>; | ||
export declare const Picker: import("react").FunctionComponent<PickerProps>; | ||
export {}; |
import { createElement } from 'react'; | ||
import capitalize from './utils/capitalize'; | ||
const factoryComponent = (component) => { | ||
return (props) => { | ||
const comp = (props) => { | ||
return createElement(component, props); | ||
}; | ||
comp.displayName = capitalize(component); | ||
return comp; | ||
}; | ||
@@ -13,2 +16,4 @@ export const View = factoryComponent('view'); | ||
export const ScrollView = factoryComponent('scroll-view'); | ||
export const Input = factoryComponent('input'); | ||
export const Picker = factoryComponent('picker'); | ||
//# sourceMappingURL=factoryComponents.js.map |
@@ -51,3 +51,5 @@ import * as scheduler from 'scheduler'; | ||
prepareForCommit: () => { }, | ||
resetAfterCommit: () => { }, | ||
resetAfterCommit: (container) => { | ||
container.requestUpdate(); | ||
}, | ||
getChildHostContext: () => { | ||
@@ -62,3 +64,2 @@ return {}; | ||
textInstance.text = newText; | ||
textInstance.rootContext.requestUpdate(); | ||
}, | ||
@@ -90,3 +91,2 @@ createInstance(type, newProps, rootContainerInstance) { | ||
targetIns.props = props; | ||
targetIns.rootContext.requestUpdate(); | ||
}, | ||
@@ -111,3 +111,2 @@ appendInitialChild: (parent, child) => { | ||
container[GOJI_ROOT_VDOM].push(child); | ||
container.requestUpdate(); | ||
}, | ||
@@ -114,0 +113,0 @@ removeChild(parentInstance, child) { |
{ | ||
"name": "@gojijs/core", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "Goji Core", | ||
@@ -61,3 +61,3 @@ "main": "dist/index.js", | ||
}, | ||
"gitHead": "e165b2080f29c1d0c9221c7e480495d89c39b00e" | ||
"gitHead": "948eaeded4234670f7d174b58a3bb043c84a2a09" | ||
} |
@@ -38,3 +38,2 @@ import { GOJI_ROOT_VDOM } from './constants'; | ||
private applyUpdate() { | ||
this.inQueue = false; | ||
const children_ = pure(this[GOJI_ROOT_VDOM]); | ||
@@ -60,11 +59,5 @@ | ||
} | ||
private inQueue = false; | ||
public requestUpdate() { | ||
if (this.inQueue) { | ||
return; | ||
} | ||
this.inQueue = true; | ||
Promise.resolve().then(() => this.applyUpdate()); | ||
this.applyUpdate(); | ||
} | ||
@@ -71,0 +64,0 @@ |
import { Props, createElement, CSSProperties } from 'react'; | ||
import capitalize from './utils/capitalize'; | ||
@@ -40,6 +41,9 @@ export type HostComponent = | ||
const factoryComponent = <P extends {}>(component: HostComponent) => { | ||
return <T>(props: Props<T> & P) => { | ||
const factoryComponent = <P extends {}>(component: HostComponent): React.FunctionComponent<P> => { | ||
const comp = <T>(props: Props<T> & P) => { | ||
return createElement(component, props); | ||
}; | ||
comp.displayName = capitalize(component); | ||
return comp; | ||
}; | ||
@@ -120,2 +124,84 @@ | ||
type InputType = 'text' | 'number' | 'idcard' | 'digit'; | ||
type InputConfirmType = 'send' | 'search' | 'next' | 'go' | 'done'; | ||
interface InputProps extends BaseProps { | ||
value: string; | ||
type?: InputType; | ||
password?: boolean; | ||
placeholder?: string; | ||
placeholderStyle?: string; | ||
placeholderClass?: string; | ||
disabled?: boolean; | ||
maxlength?: number; | ||
cursorSpacing?: number; | ||
autoFocus?: boolean; | ||
focus?: boolean; | ||
confirmType?: InputConfirmType; | ||
confirmHold?: boolean; | ||
cursor?: number; | ||
selectionStart?: number; | ||
selectionEnd?: number; | ||
adjustPosition?: boolean; | ||
onInput?: (e: any) => void; | ||
onFocus?: (e: any) => void; | ||
onBlur?: (e: any) => void; | ||
onConfirm?: (e: any) => void; | ||
onKeyboardheightchange?: (e: any) => void; | ||
} | ||
interface PickerBaseProps extends BaseProps { | ||
disabled?: boolean; | ||
onCancel?: (e: any) => void; | ||
} | ||
interface PickerSelectorProps extends PickerBaseProps { | ||
mode: 'selector'; | ||
range?: Array<any>; | ||
rangeKey?: string; | ||
value?: number; | ||
onChange?: (e: any) => void; | ||
} | ||
interface PickerMultiSelector extends PickerBaseProps { | ||
mode: 'multiSelector'; | ||
range?: Array<any>; | ||
rangeKey?: string; | ||
value?: number; | ||
onChange?: (e: any) => void; | ||
onColumnchange?: (e: any) => void; | ||
} | ||
interface PickerTimeSelector extends PickerBaseProps { | ||
mode: 'time'; | ||
value?: string; | ||
start?: string; | ||
end?: string; | ||
onChange?: (e: any) => void; | ||
} | ||
type PickerDateFields = 'year' | 'month' | 'day'; | ||
interface PickerDateSelector extends PickerBaseProps { | ||
mode: 'date'; | ||
value?: string; | ||
start?: string; | ||
end?: string; | ||
fields?: PickerDateFields; | ||
onChange?: (e: any) => void; | ||
} | ||
interface PickerRegionSelector extends PickerBaseProps { | ||
value?: Array<any>; | ||
customItem?: string; | ||
onChange?: (e: any) => void; | ||
} | ||
type PickerProps = | ||
| PickerSelectorProps | ||
| PickerMultiSelector | ||
| PickerTimeSelector | ||
| PickerDateSelector | ||
| PickerRegionSelector; | ||
export const View = factoryComponent<ViewProps>('view'); | ||
@@ -127,1 +213,3 @@ export const Button = factoryComponent<ButtonProps>('button'); | ||
export const ScrollView = factoryComponent<ScrollViewProps>('scroll-view'); | ||
export const Input = factoryComponent<InputProps>('input'); | ||
export const Picker = factoryComponent<PickerProps>('picker'); |
@@ -95,3 +95,5 @@ import * as scheduler from 'scheduler'; | ||
resetAfterCommit: () => {}, | ||
resetAfterCommit: (container) => { | ||
container.requestUpdate(); | ||
}, | ||
@@ -109,3 +111,2 @@ getChildHostContext: () => { | ||
textInstance.text = newText; | ||
textInstance.rootContext.requestUpdate(); | ||
}, | ||
@@ -143,3 +144,2 @@ | ||
targetIns.props = props; | ||
targetIns.rootContext.requestUpdate(); | ||
}, | ||
@@ -171,3 +171,2 @@ | ||
container[GOJI_ROOT_VDOM].push(child); | ||
container.requestUpdate(); | ||
}, | ||
@@ -174,0 +173,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
390517
102
2004