util.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.getCloseIconConfig = getCloseIconConfig;
  6. exports.getMotion = getMotion;
  7. exports.getPlacementStyle = getPlacementStyle;
  8. function getPlacementStyle(placement, top, bottom) {
  9. let style;
  10. switch (placement) {
  11. case 'top':
  12. style = {
  13. left: '50%',
  14. transform: 'translateX(-50%)',
  15. right: 'auto',
  16. top,
  17. bottom: 'auto'
  18. };
  19. break;
  20. case 'topLeft':
  21. style = {
  22. left: 0,
  23. top,
  24. bottom: 'auto'
  25. };
  26. break;
  27. case 'topRight':
  28. style = {
  29. right: 0,
  30. top,
  31. bottom: 'auto'
  32. };
  33. break;
  34. case 'bottom':
  35. style = {
  36. left: '50%',
  37. transform: 'translateX(-50%)',
  38. right: 'auto',
  39. top: 'auto',
  40. bottom
  41. };
  42. break;
  43. case 'bottomLeft':
  44. style = {
  45. left: 0,
  46. top: 'auto',
  47. bottom
  48. };
  49. break;
  50. default:
  51. style = {
  52. right: 0,
  53. top: 'auto',
  54. bottom
  55. };
  56. break;
  57. }
  58. return style;
  59. }
  60. function getMotion(prefixCls) {
  61. return {
  62. motionName: `${prefixCls}-fade`
  63. };
  64. }
  65. function getCloseIconConfig(closeIcon, notificationConfig, notification) {
  66. if (typeof closeIcon !== 'undefined') {
  67. return closeIcon;
  68. }
  69. if (typeof (notificationConfig === null || notificationConfig === void 0 ? void 0 : notificationConfig.closeIcon) !== 'undefined') {
  70. return notificationConfig.closeIcon;
  71. }
  72. return notification === null || notification === void 0 ? void 0 : notification.closeIcon;
  73. }