Skip to content

Commit

Permalink
es/lib
Browse files Browse the repository at this point in the history
  • Loading branch information
kwingram25 committed Oct 14, 2017
1 parent 3016387 commit 6800909
Show file tree
Hide file tree
Showing 708 changed files with 40,380 additions and 2 deletions.
2 changes: 1 addition & 1 deletion components/affix/demo/min-width.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { Affix, Button } from 'antd';
ReactDOM.render(
<div>
<Affix minWidth={1000}>
<Button type="primary">Affix if window > 1000px</Button>
<Button type="primary">Affix if window &gt; 1000px</Button>
</Affix>
</div>,
mountNode
Expand Down
2 changes: 1 addition & 1 deletion components/affix/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default class Affix extends React.Component<AffixProps, any> {
offsetTop: PropTypes.number,
offsetBottom: PropTypes.number,
target: PropTypes.func,
minWidth: PropTypes.number
minWidth: PropTypes.number,
};

scrollEvent: any;
Expand Down
2 changes: 2 additions & 0 deletions lib/_util/getLocale.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export declare function getComponentLocale(props: any, context: any, componentName: any, getDefaultLocale: any): any;
export declare function getLocaleCode(context: any): any;
37 changes: 37 additions & 0 deletions lib/_util/getLocale.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
});

var _extends2 = require('babel-runtime/helpers/extends');

var _extends3 = _interopRequireDefault(_extends2);

exports.getComponentLocale = getComponentLocale;
exports.getLocaleCode = getLocaleCode;

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

function getComponentLocale(props, context, componentName, getDefaultLocale) {
var locale = {};
if (context && context.antLocale && context.antLocale[componentName]) {
locale = context.antLocale[componentName];
} else {
var defaultLocale = getDefaultLocale();
// TODO: make default lang of antd be English
// https://github.com/ant-design/ant-design/issues/6334
locale = defaultLocale['default'] || defaultLocale;
}
var result = (0, _extends3['default'])({}, locale, props.locale);
result.lang = (0, _extends3['default'])({}, locale.lang, props.locale.lang);
return result;
}
function getLocaleCode(context) {
var localeCode = context.antLocale && context.antLocale.locale;
// Had use LocaleProvide but didn't set locale
if (context.antLocale && context.antLocale.exist && !localeCode) {
return 'zh-cn';
}
return localeCode;
}
2 changes: 2 additions & 0 deletions lib/_util/getRequestAnimationFrame.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export default function getRequestAnimationFrame(): any;
export declare function cancelRequestAnimationFrame(id: any): any;
45 changes: 45 additions & 0 deletions lib/_util/getRequestAnimationFrame.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
});
exports['default'] = getRequestAnimationFrame;
exports.cancelRequestAnimationFrame = cancelRequestAnimationFrame;
var availablePrefixs = ['moz', 'ms', 'webkit'];
function requestAnimationFramePolyfill() {
var lastTime = 0;
return function (callback) {
var currTime = new Date().getTime();
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
var id = window.setTimeout(function () {
callback(currTime + timeToCall);
}, timeToCall);
lastTime = currTime + timeToCall;
return id;
};
}
function getRequestAnimationFrame() {
if (typeof window === 'undefined') {
return function () {};
}
if (window.requestAnimationFrame) {
// https://github.com/vuejs/vue/issues/4465
return window.requestAnimationFrame.bind(window);
}
var prefix = availablePrefixs.filter(function (key) {
return key + 'RequestAnimationFrame' in window;
})[0];
return prefix ? window[prefix + 'RequestAnimationFrame'] : requestAnimationFramePolyfill();
}
function cancelRequestAnimationFrame(id) {
if (typeof window === 'undefined') {
return null;
}
if (window.cancelAnimationFrame) {
return window.cancelAnimationFrame(id);
}
var prefix = availablePrefixs.filter(function (key) {
return key + 'CancelAnimationFrame' in window || key + 'CancelRequestAnimationFrame' in window;
})[0];
return prefix ? (window[prefix + 'CancelAnimationFrame'] || window[prefix + 'CancelRequestAnimationFrame']).call(this, id) : clearTimeout(id);
}
1 change: 1 addition & 0 deletions lib/_util/getScroll.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default function getScroll(target: any, top: any): number;
21 changes: 21 additions & 0 deletions lib/_util/getScroll.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
});
exports['default'] = getScroll;
function getScroll(target, top) {
if (typeof window === 'undefined') {
return 0;
}
var prop = top ? 'pageYOffset' : 'pageXOffset';
var method = top ? 'scrollTop' : 'scrollLeft';
var isWindow = target === window;
var ret = isWindow ? target[prop] : target[method];
// ie6,7,8 standard mode
if (isWindow && typeof ret !== 'number') {
ret = window.document.documentElement[method];
}
return ret;
}
module.exports = exports['default'];
2 changes: 2 additions & 0 deletions lib/_util/isCssAnimationSupported.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare function isCssAnimationSupported(): any;
export default isCssAnimationSupported;
28 changes: 28 additions & 0 deletions lib/_util/isCssAnimationSupported.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
});
var animation = void 0;
function isCssAnimationSupported() {
if (animation !== undefined) {
return animation;
}
var domPrefixes = 'Webkit Moz O ms Khtml'.split(' ');
var elm = document.createElement('div');
if (elm.style.animationName !== undefined) {
animation = true;
}
if (animation !== undefined) {
for (var i = 0; i < domPrefixes.length; i++) {
if (elm.style[domPrefixes[i] + 'AnimationName'] !== undefined) {
animation = true;
break;
}
}
}
animation = animation || false;
return animation;
}
exports['default'] = isCssAnimationSupported;
module.exports = exports['default'];
1 change: 1 addition & 0 deletions lib/_util/isFlexSupported.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default function isFlexSupported(): boolean;
15 changes: 15 additions & 0 deletions lib/_util/isFlexSupported.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
});
exports['default'] = isFlexSupported;
function isFlexSupported() {
if (typeof window !== 'undefined' && window.document && window.document.documentElement) {
var documentElement = window.document.documentElement;

return 'flex' in documentElement.style || 'webkitFlex' in documentElement.style || 'Flex' in documentElement.style || 'msFlex' in documentElement.style;
}
return false;
}
module.exports = exports['default'];
6 changes: 6 additions & 0 deletions lib/_util/openAnimation.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
declare const animation: {
enter(node: any, done: any): any;
leave(node: any, done: any): any;
appear(node: any, done: any): any;
};
export default animation;
63 changes: 63 additions & 0 deletions lib/_util/openAnimation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
});

var _cssAnimation = require('css-animation');

var _cssAnimation2 = _interopRequireDefault(_cssAnimation);

var _getRequestAnimationFrame = require('./getRequestAnimationFrame');

var _getRequestAnimationFrame2 = _interopRequireDefault(_getRequestAnimationFrame);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

var reqAnimFrame = (0, _getRequestAnimationFrame2['default'])();
function animate(node, show, done) {
var height = void 0;
var requestAnimationFrameId = void 0;
return (0, _cssAnimation2['default'])(node, 'ant-motion-collapse', {
start: function start() {
if (!show) {
node.style.height = node.offsetHeight + 'px';
node.style.opacity = 1;
} else {
height = node.offsetHeight;
node.style.height = 0;
node.style.opacity = 0;
}
},
active: function active() {
if (requestAnimationFrameId) {
(0, _getRequestAnimationFrame.cancelRequestAnimationFrame)(requestAnimationFrameId);
}
requestAnimationFrameId = reqAnimFrame(function () {
node.style.height = (show ? height : 0) + 'px';
node.style.opacity = show ? 1 : 0;
});
},
end: function end() {
if (requestAnimationFrameId) {
(0, _getRequestAnimationFrame.cancelRequestAnimationFrame)(requestAnimationFrameId);
}
node.style.height = '';
node.style.opacity = '';
done();
}
});
}
var animation = {
enter: function enter(node, done) {
return animate(node, true, done);
},
leave: function leave(node, done) {
return animate(node, false, done);
},
appear: function appear(node, done) {
return animate(node, true, done);
}
};
exports['default'] = animation;
module.exports = exports['default'];
5 changes: 5 additions & 0 deletions lib/_util/throttleByAnimationFrame.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default function throttleByAnimationFrame(fn: any): (...args: any[]) => void;
export declare function throttleByAnimationFrameDecorator(): (target: any, key: any, descriptor: any) => {
configurable: boolean;
get(): any;
};
65 changes: 65 additions & 0 deletions lib/_util/throttleByAnimationFrame.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
});

var _toConsumableArray2 = require('babel-runtime/helpers/toConsumableArray');

var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);

exports['default'] = throttleByAnimationFrame;
exports.throttleByAnimationFrameDecorator = throttleByAnimationFrameDecorator;

var _getRequestAnimationFrame = require('../_util/getRequestAnimationFrame');

var _getRequestAnimationFrame2 = _interopRequireDefault(_getRequestAnimationFrame);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

var reqAnimFrame = (0, _getRequestAnimationFrame2['default'])();
function throttleByAnimationFrame(fn) {
var requestId = void 0;
var later = function later(args) {
return function () {
requestId = null;
fn.apply(undefined, (0, _toConsumableArray3['default'])(args));
};
};
var throttled = function throttled() {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}

if (requestId == null) {
requestId = reqAnimFrame(later(args));
}
};
throttled.cancel = function () {
return (0, _getRequestAnimationFrame.cancelRequestAnimationFrame)(requestId);
};
return throttled;
}
function throttleByAnimationFrameDecorator() {
return function (target, key, descriptor) {
var fn = descriptor.value;
var definingProperty = false;
return {
configurable: true,
get: function get() {
if (definingProperty || this === target.prototype || this.hasOwnProperty(key)) {
return fn;
}
var boundFn = throttleByAnimationFrame(fn.bind(this));
definingProperty = true;
Object.defineProperty(this, key, {
value: boundFn,
configurable: true,
writable: true
});
definingProperty = false;
return boundFn;
}
};
};
}
1 change: 1 addition & 0 deletions lib/_util/triggerEvent.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default function triggerEvent(el: any, type: any): void;
15 changes: 15 additions & 0 deletions lib/_util/triggerEvent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
});
exports['default'] = triggerEvent;
function triggerEvent(el, type) {
if ('createEvent' in document) {
// modern browsers, IE9+
var e = document.createEvent('HTMLEvents');
e.initEvent(type, false, true);
el.dispatchEvent(e);
}
}
module.exports = exports['default'];
2 changes: 2 additions & 0 deletions lib/_util/warning.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare const _default: (valid: boolean, message: string) => void;
export default _default;
22 changes: 22 additions & 0 deletions lib/_util/warning.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
});

var _warning = require('warning');

var _warning2 = _interopRequireDefault(_warning);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

var warned = {};

exports['default'] = function (valid, message) {
if (!valid && !warned[message]) {
(0, _warning2['default'])(false, message);
warned[message] = true;
}
};

module.exports = exports['default'];
Loading

0 comments on commit 6800909

Please sign in to comment.