@yibozhang/pro-table 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3520,6 +3520,72 @@
3520
3520
  ];
3521
3521
  ArrayFormService.ctorParameters = function () { return []; };
3522
3522
 
3523
+ /**
3524
+ * 自动检测 ant-modal-body 的宽度,并添加 narrow-width 类名
3525
+ * 当宽度小于 500px 时添加类名,否则移除
3526
+ */
3527
+ (function initModalWidthDetector() {
3528
+ if (typeof window === 'undefined' || typeof document === 'undefined') {
3529
+ return;
3530
+ }
3531
+ // 检查单个元素的宽度
3532
+ function checkElementWidth(element) {
3533
+ var width = element.offsetWidth;
3534
+ if (width < 500) {
3535
+ element.classList.add('narrow-width');
3536
+ }
3537
+ else {
3538
+ element.classList.remove('narrow-width');
3539
+ }
3540
+ }
3541
+ // 使用 MutationObserver 监听 DOM 变化
3542
+ var observer = new MutationObserver(function (mutations) {
3543
+ mutations.forEach(function (mutation) {
3544
+ mutation.addedNodes.forEach(function (node) {
3545
+ var _a, _b;
3546
+ if (node.nodeType === Node.ELEMENT_NODE) {
3547
+ var element = node;
3548
+ // 检查是否是 modal body
3549
+ if ((_a = element.classList) === null || _a === void 0 ? void 0 : _a.contains('ant-modal-body')) {
3550
+ checkElementWidth(element);
3551
+ observeResize(element);
3552
+ }
3553
+ // 检查子元素中是否有 modal body
3554
+ var modalBodies = (_b = element.querySelectorAll) === null || _b === void 0 ? void 0 : _b.call(element, '.ant-modal-body');
3555
+ modalBodies === null || modalBodies === void 0 ? void 0 : modalBodies.forEach(function (modalBody) {
3556
+ checkElementWidth(modalBody);
3557
+ observeResize(modalBody);
3558
+ });
3559
+ }
3560
+ });
3561
+ });
3562
+ });
3563
+ // 使用 ResizeObserver 监听元素尺寸变化
3564
+ var resizeObserverMap = new WeakMap();
3565
+ function observeResize(element) {
3566
+ if (resizeObserverMap.has(element)) {
3567
+ return;
3568
+ }
3569
+ if (typeof window.ResizeObserver !== 'undefined') {
3570
+ var resizeObserver = new window.ResizeObserver(function () {
3571
+ checkElementWidth(element);
3572
+ });
3573
+ resizeObserver.observe(element);
3574
+ resizeObserverMap.set(element, resizeObserver);
3575
+ }
3576
+ }
3577
+ // 开始监听 DOM 变化
3578
+ observer.observe(document.body, {
3579
+ childList: true,
3580
+ subtree: true,
3581
+ });
3582
+ // 检查已存在的 modal body
3583
+ document.querySelectorAll('.ant-modal-body').forEach(function (element) {
3584
+ checkElementWidth(element);
3585
+ observeResize(element);
3586
+ });
3587
+ })();
3588
+
3523
3589
  /*
3524
3590
  * Public API Surface of pro-table
3525
3591
  */