How to use the san.createComponentLoader function in san

To help you get started, we’ve selected a few san examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ecomfe / santd / src / modal / ConfirmDialog.js View on Github external
const prefixCls = classCreator('modal')();
const contentPrefixCls = `${prefixCls}-confirm`;

// 判断是否SanComponent, 可能会随着san的版本迭代变更,参考依据如下:
// https://github.com/baidu/san/blob/36085399ab3d84df3ff8b741bb2f57c483b59acb/src/view/node-type.js
// https://github.com/baidu/san/blob/9a7cd2e74ecd4f307afd1733aa5b745707edc0c9/src/view/component.js#L278
// 改成使用传统方式判断 by erik at 2019-10-03
function isValidComponent(content) {
    return content && content.prototype instanceof san.Component;
}

// 动态加载content组件
let contentFun;
const contentLoader = san.createComponentLoader(() => new Promise((resolve, reject) => {
    contentFun = {resolve, reject};
}));

export default san.defineComponent({
    template: `<template>
        </template>
github ecomfe / santd / santd / modal / ConfirmDialog.js View on Github external
const contentPrefixCls = `${prefixCls}-confirm`;

// 判断是否SanComponent, 可能会随着san的版本迭代变更,参考依据如下:
// https://github.com/baidu/san/blob/36085399ab3d84df3ff8b741bb2f57c483b59acb/src/view/node-type.js
// https://github.com/baidu/san/blob/9a7cd2e74ecd4f307afd1733aa5b745707edc0c9/src/view/component.js#L278
function isValidComponent(content) {
    if (typeof content === 'function' &amp;&amp; 5 === content.prototype.nodeType) {
        return true;
    }

    return false;
}

// 动态加载content组件
let contentFun;
const contentLoader = san.createComponentLoader(() =&gt; new Promise((resolve, reject) =&gt; {
    contentFun = {resolve, reject};
}));

export default inherits(san.defineComponent({
    template: `<template>
        </template>
github ecomfe / santd / santd / spin / index.js View on Github external
<span class="san-spin-dot san-spin-dot-spin">
            <i>
            <i>
            <i>
            <i>
        </i></i></i></i></span><i><i><i>
    `
});

const SpinTip = san.defineComponent({
    template: `
        <div class="${prefixCls}-text">{{tip}}</div>
    `
});

const IndicatorLoader = san.createComponentLoader(() =&gt; {
    const promise = new Promise(resolve =&gt; {
        resolve(isValidComponent(defaultIndicator) ? defaultIndicator : SpinDot);
    });
    return promise;
});

const Spin = san.defineComponent({
    template: `
        <div class="{{nestedClassName || spinClassName}}">
            
                
            
            
            <div>
                <div class="{{spinClassName}}">
                    </div></div></div></i></i></i>
github ecomfe / santd / src / spin / index.js View on Github external
return false;
}

const SpinDot = san.defineComponent({
    template: `
        <span class="${prefixCls}-dot ${prefixCls}-dot-spin">
            <i>
            <i>
            <i>
            <i>
        </i></i></i></i></span><i><i><i>
    `
});

const IndicatorLoader = san.createComponentLoader(() =&gt; {
    const promise = new Promise(resolve =&gt; {
        resolve(isValidComponent(defaultIndicator) ? defaultIndicator : SpinDot);
    });
    return promise;
});

const Spin = san.defineComponent({
    template: `
        <div class="{{hasContent ? '${prefixCls}-nested-loading ' + (wrapperClassName ? wrapperClassName : '') : spinClasses}}">
            
                
            
            
            <div>
                <div class="{{spinClasses}}">
                    </div></div></div></i></i></i>