diff --git a/packages/actionsheet/index.tsx b/packages/actionsheet/index.tsx
index 72d12312d..4259b728b 100644
--- a/packages/actionsheet/index.tsx
+++ b/packages/actionsheet/index.tsx
@@ -90,6 +90,8 @@ function Actionsheet(
class={bem()}
value={props.value}
position="bottom"
+ overlay={props.overlay}
+ closeOnClickOverlay={props.closeOnClickOverlay}
onInput={(value: boolean) => {
emit(ctx, 'input', value);
}}
diff --git a/packages/notify/Notify.js b/packages/notify/Notify.js
deleted file mode 100644
index edad5883f..000000000
--- a/packages/notify/Notify.js
+++ /dev/null
@@ -1,44 +0,0 @@
-import { use } from '../utils';
-import { RED, WHITE } from '../utils/color';
-import { PopupMixin } from '../mixins/popup';
-
-const [sfc, bem] = use('notify');
-
-export default sfc({
- mixins: [PopupMixin],
-
- props: {
- className: null,
- message: [String, Number],
- color: {
- type: String,
- value: WHITE
- },
- background: {
- type: String,
- value: RED
- },
- duration: {
- type: Number,
- value: 3000
- },
- lockScroll: {
- type: Boolean,
- default: false
- }
- },
-
- render(h) {
- const style = {
- color: this.color,
- background: this.background
- };
- return (
-
-
- {this.message}
-
-
- );
- }
-});
diff --git a/packages/notify/Notify.tsx b/packages/notify/Notify.tsx
new file mode 100644
index 000000000..70a87a075
--- /dev/null
+++ b/packages/notify/Notify.tsx
@@ -0,0 +1,69 @@
+import { use } from '../utils';
+import { RED, WHITE } from '../utils/color';
+import { emit, inherit } from '../utils/functional';
+import { PopupMixin } from '../mixins/popup';
+import Popup from '../popup';
+
+// Types
+import { CreateElement, RenderContext } from 'vue/types';
+import { DefaultSlots } from '../utils/use/sfc';
+import { PopupMixinProps } from '../mixins/popup/type';
+
+export type NotifyProps = PopupMixinProps & {
+ color: string;
+ message: string | number;
+ duration: number;
+ className?: any;
+ background: string;
+};
+
+const [sfc, bem] = use('notify');
+
+function Notify(
+ h: CreateElement,
+ props: NotifyProps,
+ slots: DefaultSlots,
+ ctx: RenderContext
+) {
+ const style = {
+ color: props.color,
+ background: props.background
+ };
+
+ return (
+ {
+ emit(ctx, 'input', value);
+ }}
+ {...inherit(ctx)}
+ >
+ {props.message}
+
+ );
+}
+
+Notify.props = {
+ ...PopupMixin.props,
+ className: null as any,
+ message: [String, Number],
+ color: {
+ type: String,
+ default: WHITE
+ },
+ background: {
+ type: String,
+ default: RED
+ },
+ duration: {
+ type: Number,
+ default: 3000
+ }
+};
+
+export default sfc(Notify);
diff --git a/packages/notify/index.js b/packages/notify/index.js
deleted file mode 100644
index ed732205d..000000000
--- a/packages/notify/index.js
+++ /dev/null
@@ -1,75 +0,0 @@
-import Vue from 'vue';
-import VanNotify from './Notify';
-import { RED, WHITE } from '../utils/color';
-import { isObj, isServer } from '../utils';
-
-let timer;
-let instance;
-
-const initInstance = () => {
- instance = new (Vue.extend(VanNotify))({
- el: document.createElement('div')
- });
-
- document.body.appendChild(instance.$el);
-};
-
-const parseOptions = message => (isObj(message) ? message : { message });
-
-const Notify = options => {
- /* istanbul ignore if */
- if (isServer) {
- return;
- }
-
- if (!instance) {
- initInstance();
- }
-
- options = {
- ...Notify.currentOptions,
- ...parseOptions(options)
- };
-
- Object.assign(instance, options);
- clearTimeout(timer);
-
- if (options.duration > 0) {
- timer = setTimeout(Notify.clear, options.duration);
- }
-
- return instance;
-};
-
-Notify.clear = () => {
- if (instance) {
- instance.value = false;
- }
-};
-
-Notify.defaultOptions = {
- value: true,
- text: '',
- color: WHITE,
- background: RED,
- duration: 3000,
- className: ''
-};
-
-Notify.setDefaultOptions = options => {
- Object.assign(Notify.currentOptions, options);
-};
-
-Notify.resetDefaultOptions = () => {
- Notify.currentOptions = { ...Notify.defaultOptions };
-};
-
-Notify.install = () => {
- Vue.use(VanNotify);
-};
-
-Notify.resetDefaultOptions();
-
-Vue.prototype.$notify = Notify;
-
-export default Notify;
diff --git a/packages/notify/index.less b/packages/notify/index.less
index a6b44947a..6b1d685a5 100644
--- a/packages/notify/index.less
+++ b/packages/notify/index.less
@@ -1,9 +1,6 @@
@import '../style/var';
.van-notify {
- position: fixed;
- top: 0;
- width: 100%;
text-align: center;
box-sizing: border-box;
padding: @notify-padding;
diff --git a/packages/notify/index.ts b/packages/notify/index.ts
new file mode 100644
index 000000000..a67e731e8
--- /dev/null
+++ b/packages/notify/index.ts
@@ -0,0 +1,73 @@
+import Vue from 'vue';
+import VanNotify from './Notify';
+import { RED, WHITE } from '../utils/color';
+import { isObj, isServer } from '../utils';
+import { mount } from '../utils/functional';
+import { NotifyOptions } from 'types/notify';
+
+let timer: number | NodeJS.Timeout;
+let instance: any;
+
+function parseOptions(message: NotifyOptions): NotifyOptions {
+ return isObj(message) ? message : ({ message } as NotifyOptions);
+}
+
+function Notify(options: NotifyOptions) {
+ /* istanbul ignore if */
+ if (isServer) {
+ return;
+ }
+
+ if (!instance) {
+ instance = mount(VanNotify);
+ }
+
+ options = {
+ ...Notify.currentOptions,
+ ...parseOptions(options)
+ };
+
+ Object.assign(instance, options);
+ clearTimeout(timer as NodeJS.Timeout);
+
+ if (options.duration && options.duration > 0) {
+ timer = setTimeout(Notify.clear, options.duration);
+ }
+
+ return instance;
+}
+
+function defaultOptions(): NotifyOptions {
+ return {
+ value: true,
+ message: '',
+ color: WHITE,
+ background: RED,
+ duration: 3000,
+ className: ''
+ };
+}
+
+Notify.clear = () => {
+ if (instance) {
+ instance.value = false;
+ }
+};
+
+Notify.currentOptions = defaultOptions();
+
+Notify.setDefaultOptions = (options: NotifyOptions) => {
+ Object.assign(Notify.currentOptions, options);
+};
+
+Notify.resetDefaultOptions = () => {
+ Notify.currentOptions = defaultOptions();
+};
+
+Notify.install = () => {
+ Vue.use(VanNotify as any);
+};
+
+Vue.prototype.$notify = Notify;
+
+export default Notify;
diff --git a/packages/notify/test/__snapshots__/index.spec.js.snap b/packages/notify/test/__snapshots__/index.spec.js.snap
index e79130da7..c1354c2ab 100644
--- a/packages/notify/test/__snapshots__/index.spec.js.snap
+++ b/packages/notify/test/__snapshots__/index.spec.js.snap
@@ -1,11 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`create a notify 1`] = `test
`;
+exports[`create a notify 1`] = ``;
-exports[`notify disappear 1`] = `test
`;
+exports[`notify disappear 1`] = ``;
-exports[`notify disappear 2`] = `test
`;
+exports[`notify disappear 2`] = ``;
-exports[`notify disappear 3`] = `text2
`;
+exports[`notify disappear 3`] = ``;
-exports[`notify disappear 4`] = `text2
`;
+exports[`notify disappear 4`] = ``;
diff --git a/packages/sku/type.ts b/packages/sku/type.ts
index b1c817341..a49b23406 100644
--- a/packages/sku/type.ts
+++ b/packages/sku/type.ts
@@ -1,3 +1,5 @@
+/* eslint-disable camelcase */
+
export type SkuData = {
price: string;
none_sku: boolean;
diff --git a/packages/utils/functional.ts b/packages/utils/functional.ts
index 809283d5d..7d121ee94 100644
--- a/packages/utils/functional.ts
+++ b/packages/utils/functional.ts
@@ -1,4 +1,4 @@
-import { RenderContext, VNodeData } from 'vue/types';
+import Vue, { RenderContext, VNodeData } from 'vue';
type ObjectIndex = {
[key: string]: any;
@@ -21,7 +21,10 @@ const inheritKey = [
const mapInheritKey: ObjectIndex = { nativeOn: 'on' };
// inherit partial context, map nativeOn to on
-export function inherit(context: Context, inheritListeners?: boolean): InheritContext {
+export function inherit(
+ context: Context,
+ inheritListeners?: boolean
+): InheritContext {
const result = inheritKey.reduce(
(obj, key) => {
if (context.data[key]) {
@@ -53,3 +56,18 @@ export function emit(context: Context, eventName: string, ...args: any[]) {
}
}
}
+
+// mount functional component
+export function mount(Component: any) {
+ const instance = new Vue({
+ el: document.createElement('div'),
+ props: Component.props,
+ render(h) {
+ return h(Component, { props: this.$props });
+ }
+ });
+
+ document.body.appendChild(instance.$el);
+
+ return instance;
+}
diff --git a/types/notify.d.ts b/types/notify.d.ts
index a647e13ac..974b316f8 100644
--- a/types/notify.d.ts
+++ b/types/notify.d.ts
@@ -1,10 +1,11 @@
import Vue from 'vue';
-type NotifyMessage = string | number;
+export type NotifyMessage = string | number;
export type NotifyOptions = {
- message?: NotifyMessage;
+ value?: boolean;
color?: string;
+ message?: NotifyMessage;
duration?: number;
className?: any;
background?: string;
@@ -21,6 +22,8 @@ export interface Notify {
(message: NotifyOptions | NotifyMessage): VanNotify;
clear(): void;
install(): void;
+ currentOptions: NotifyOptions;
+ defaultOptions: NotifyOptions;
setDefaultOptions(options: NotifyOptions): void;
resetDefaultOptions(): void;
}