tdesign-react
Version:
TDesign Component for React
40 lines (34 loc) • 1.32 kB
JavaScript
/**
* tdesign v1.15.1
* (c) 2025 tdesign
* @license MIT
*/
;
Object.defineProperty(exports, '__esModule', { value: true });
var React = require('react');
var log = require('../_chunks/dep-59671c87.js');
var DefaultAlign = {
vertical: ["left", "right"],
horizontal: ["top", "bottom"]
};
var useAlign = function useAlign(align) {
var layout = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "vertical";
return React.useMemo(function () {
var renderAlign = layout === "vertical" ? "left" : "top";
if (layout === "vertical" && align) {
var index = DefaultAlign.horizontal.indexOf(align);
var isError = index !== -1;
isError && log.log.warn("Timeline", 'If layout is vertical, align should be "left","alternate" or "right" ');
renderAlign = isError ? DefaultAlign.vertical[index] : align;
}
if (layout === "horizontal" && align) {
var _index = DefaultAlign.vertical.indexOf(align);
var _isError = _index !== -1;
_isError && log.log.warn("Timeline", 'If layout is horizontal, align should be "top","alternate" or "bottom" ');
renderAlign = _isError ? DefaultAlign.horizontal[_index] : align;
}
return renderAlign;
}, [align, layout]);
};
exports.useAlign = useAlign;
//# sourceMappingURL=useAlign.js.map