@tarojs/taro-h5
Advanced tools
Comparing version 0.0.53 to 0.0.54
{ | ||
"name": "@tarojs/taro-h5", | ||
"version": "0.0.53", | ||
"version": "0.0.54", | ||
"description": "Taro h5 framework", | ||
@@ -30,3 +30,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"@tarojs/taro": "0.0.53", | ||
"@tarojs/taro": "0.0.54", | ||
"jsonp-retry": "^1.0.3", | ||
@@ -33,0 +33,0 @@ "nervjs": "^1.2.18" |
@@ -1,2 +0,2 @@ | ||
import { inlineStyle } from './utils' | ||
import { inlineStyle } from '../utils' | ||
@@ -3,0 +3,0 @@ export default class ActionSheet { |
@@ -1,2 +0,2 @@ | ||
import { errorHandler, getParameterError } from './utils' | ||
import { errorHandler, getParameterError } from '../utils' | ||
import Toast from './toast' | ||
@@ -10,3 +10,2 @@ import Modal from './modal' | ||
function init (doc) { | ||
console.log(status) | ||
if (status === 'ready') return | ||
@@ -39,14 +38,24 @@ | ||
// verify options | ||
const handler = errorHandler(options.fail, options.complete) | ||
if (typeof options.title !== 'string') { | ||
const err = { errMsg: getParameterError('showToast', 'title', 'String', typeof options.title) } | ||
options.fail && options.fail(err) | ||
options.complete && options.complete(err) | ||
return | ||
return handler({ | ||
errMsg: getParameterError({ | ||
name: 'showToast', | ||
para: 'title', | ||
correct: 'String', | ||
wrong: options.title | ||
}) | ||
}) | ||
} | ||
if (options.hasOwnProperty('duration') && typeof options.duration !== 'number') { | ||
const err = { errMsg: getParameterError('showToast', 'duration', 'Number', typeof options.duration) } | ||
options.fail && options.fail(err) | ||
options.complete && options.complete(err) | ||
return | ||
if (typeof options.duration !== 'number') { | ||
return handler({ | ||
errMsg: getParameterError({ | ||
name: 'showToast', | ||
para: 'duration', | ||
correct: 'Number', | ||
wrong: options.duration | ||
}) | ||
}) | ||
} | ||
@@ -59,3 +68,3 @@ | ||
if (!toast.el) return toast.create(options) | ||
toast.show(options) | ||
return toast.show(options) | ||
} | ||
@@ -62,0 +71,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { inlineStyle } from './utils' | ||
import { inlineStyle } from '../utils' | ||
@@ -3,0 +3,0 @@ export default class Modal { |
@@ -1,2 +0,2 @@ | ||
import { inlineStyle } from './utils' | ||
import { inlineStyle } from '../utils' | ||
@@ -100,6 +100,2 @@ export default class Toast { | ||
// toast | ||
const toast = document.createElement('div') | ||
toast.setAttribute('style', inlineStyle(toastStyle)) | ||
// icon | ||
@@ -113,2 +109,3 @@ this.icon = document.createElement('p') | ||
const iconStyle = config.icon === 'loading' ? loadingStyle : successStyle | ||
if (config.icon === 'none') Object.assign(iconStyle, { 'display': 'none' }) | ||
this.icon.setAttribute('style', inlineStyle(iconStyle)) | ||
@@ -118,2 +115,12 @@ if (config.icon !== 'loading') this.icon.textContent = '' | ||
// toast | ||
this.toast = document.createElement('div') | ||
if (config.icon === 'none') { | ||
Object.assign(toastStyle, { | ||
'min-height': '0', | ||
'padding': '10px 15px' | ||
}) | ||
} | ||
this.toast.setAttribute('style', inlineStyle(toastStyle)) | ||
// title | ||
@@ -125,6 +132,6 @@ this.title = document.createElement('p') | ||
// result | ||
toast.appendChild(this.icon) | ||
toast.appendChild(this.title) | ||
this.toast.appendChild(this.icon) | ||
this.toast.appendChild(this.title) | ||
this.el.appendChild(this.mask) | ||
this.el.appendChild(toast) | ||
this.el.appendChild(this.toast) | ||
@@ -135,7 +142,10 @@ // show immediately | ||
this.type = config._type | ||
config.success && config.success({errMsg: 'showToast:ok'}) | ||
config.complete && config.complete({errMsg: 'showToast:ok'}) | ||
// disappear after duration | ||
config.duration >= 0 && this.hide(config.duration, this.type) | ||
const errMsg = 'showToast:ok' | ||
config.success && config.success({ errMsg }) | ||
config.complete && config.complete({ errMsg }) | ||
return Promise.resolve({ errMsg }) | ||
} | ||
@@ -153,3 +163,3 @@ | ||
// image | ||
const { successStyle, loadingStyle, imageStyle } = this.getstyle() | ||
const { toastStyle, successStyle, loadingStyle, imageStyle } = this.getstyle() | ||
if (config.image !== options.image) { | ||
@@ -163,2 +173,3 @@ if (options.image) { | ||
const iconStyle = options.icon === 'loading' ? loadingStyle : successStyle | ||
if (options.icon === 'none') Object.assign(iconStyle, { 'display': 'none' }) | ||
this.icon.setAttribute('style', inlineStyle(iconStyle)) | ||
@@ -170,2 +181,3 @@ this.icon.textContent = options.icon === 'loading' ? '' : '' | ||
const iconStyle = options.icon === 'loading' ? loadingStyle : successStyle | ||
if (options.icon === 'none') Object.assign(iconStyle, { 'display': 'none' }) | ||
this.icon.setAttribute('style', inlineStyle(iconStyle)) | ||
@@ -176,2 +188,11 @@ this.icon.textContent = options.icon === 'loading' ? '' : '' | ||
// toast | ||
if (options.icon === 'none') { | ||
Object.assign(toastStyle, { | ||
'min-height': '0', | ||
'padding': '10px 15px' | ||
}) | ||
} | ||
this.toast.setAttribute('style', inlineStyle(toastStyle)) | ||
Object.assign(config, options) | ||
@@ -183,7 +204,10 @@ | ||
this.type = config._type | ||
config.success && config.success({errMsg: 'showToast:ok'}) | ||
config.complete && config.complete({errMsg: 'showToast:ok'}) | ||
// disappear after duration | ||
config.duration >= 0 && this.hide(config.duration, this.type) | ||
const errMsg = 'showToast:ok' | ||
config.success && config.success({ errMsg }) | ||
config.complete && config.complete({ errMsg }) | ||
return Promise.resolve({ errMsg }) | ||
} | ||
@@ -190,0 +214,0 @@ |
@@ -20,3 +20,3 @@ import { shouleBeObject, getParameterError } from '../utils' | ||
correct: 'String', | ||
wrong: typeof key | ||
wrong: key | ||
}) | ||
@@ -42,3 +42,3 @@ console.error(res.errMsg) | ||
correct: 'String', | ||
wrong: typeof key | ||
wrong: key | ||
})) | ||
@@ -76,3 +76,3 @@ return | ||
correct: 'String', | ||
wrong: typeof key | ||
wrong: key | ||
}) | ||
@@ -106,3 +106,3 @@ console.error(res.errMsg) | ||
correct: 'String', | ||
wrong: typeof key | ||
wrong: key | ||
})) | ||
@@ -171,3 +171,3 @@ return | ||
correct: 'String', | ||
wrong: typeof key | ||
wrong: key | ||
}) | ||
@@ -193,3 +193,3 @@ console.error(res.errMsg) | ||
correct: 'String', | ||
wrong: typeof key | ||
wrong: key | ||
})) | ||
@@ -196,0 +196,0 @@ return |
function shouleBeObject (target) { | ||
const type = typeof target | ||
if (target && type === 'object') return { res: true } | ||
if (target && typeof target === 'object') return { res: true } | ||
return { | ||
@@ -8,3 +7,3 @@ res: false, | ||
correct: 'Object', | ||
wrong: target === null ? 'Null' : type | ||
wrong: target | ||
}) | ||
@@ -16,3 +15,3 @@ } | ||
const parameter = para ? `parameter.${para}` : 'parameter' | ||
const errorType = upperCaseFirstLetter(wrong) | ||
const errorType = upperCaseFirstLetter(wrong === null ? 'Null' : typeof wrong) | ||
return `${name}:fail parameter error: ${parameter} should be ${correct} instead of ${errorType}` | ||
@@ -27,2 +26,22 @@ } | ||
export { shouleBeObject, getParameterError } | ||
function inlineStyle (style) { | ||
let res = '' | ||
for (let attr in style) res += `${attr}: ${style[attr]};` | ||
if (res.includes('display: flex;')) res += 'display: -webkit-box;display: -webkit-flex;' | ||
return res | ||
} | ||
function errorHandler (fail, complete) { | ||
return function (res) { | ||
typeof fail === 'function' && fail(res) | ||
typeof complete === 'function' && complete(res) | ||
return Promise.reject(res) | ||
} | ||
} | ||
export { | ||
shouleBeObject, | ||
getParameterError, | ||
inlineStyle, | ||
errorHandler | ||
} |
@@ -23,4 +23,3 @@ import SocketTask from './socketTask' | ||
// options.url must be String | ||
const urlType = typeof url | ||
if (urlType !== 'string') { | ||
if (typeof url !== 'string') { | ||
res.errMsg = getParameterError({ | ||
@@ -30,3 +29,3 @@ name, | ||
correct: 'String', | ||
wrong: urlType | ||
wrong: url | ||
}) | ||
@@ -33,0 +32,0 @@ console.error(res.errMsg) |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
932526
12571
+ Added@tarojs/taro@0.0.54(transitive)
- Removed@tarojs/taro@0.0.53(transitive)
Updated@tarojs/taro@0.0.54