@snowui-design-system/components 0.3.0-alpha.8 → 0.3.0-alpha.9
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.
|
@@ -412,13 +412,26 @@ export default function Pagination($$anchor, $$props) {
|
|
|
412
412
|
function compactControl(control) {
|
|
413
413
|
const graphicSelector = "svg, img, .snowui-icon, .snowui-icon-wrapper";
|
|
414
414
|
const hasGraphic = !!control.querySelector(graphicSelector);
|
|
415
|
-
const directTextNodes = Array.from(control.childNodes).filter((node) => node.nodeType === Node.TEXT_NODE && !!node.textContent?.trim());
|
|
416
|
-
const fallbackTextElements = Array.from(control.children).filter((element) => element instanceof HTMLElement && !element.matches(".snowui-text") && !element.matches(graphicSelector) && !element.querySelector(graphicSelector) && !!element.textContent?.trim());
|
|
417
|
-
const hasText = !!control.querySelector(".snowui-text")?.textContent?.trim() || directTextNodes.length > 0 || fallbackTextElements.length > 0;
|
|
418
415
|
|
|
419
|
-
if (!hasGraphic
|
|
416
|
+
if (!hasGraphic) return;
|
|
417
|
+
|
|
418
|
+
// 文本可能位于模板的内容包装层;只收集普通文字,保留图标子树。
|
|
419
|
+
const walker = document.createTreeWalker(control, NodeFilter.SHOW_TEXT);
|
|
420
|
+
|
|
421
|
+
const textNodes = [];
|
|
422
|
+
let node;
|
|
423
|
+
|
|
424
|
+
while (node = walker.nextNode()) {
|
|
425
|
+
if (node.textContent?.trim() && !node.parentElement?.closest(graphicSelector)) {
|
|
426
|
+
textNodes.push(node);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
if (textNodes.length === 0) return;
|
|
431
|
+
|
|
432
|
+
for (const textNode of textNodes) {
|
|
433
|
+
if (textNode.parentElement?.closest(".snowui-text")) continue;
|
|
420
434
|
|
|
421
|
-
for (const textNode of directTextNodes) {
|
|
422
435
|
const text = document.createElement("span");
|
|
423
436
|
|
|
424
437
|
text.className = "snowui-pagination-responsive-text";
|
|
@@ -426,10 +439,6 @@ export default function Pagination($$anchor, $$props) {
|
|
|
426
439
|
textNode.replaceWith(text);
|
|
427
440
|
}
|
|
428
441
|
|
|
429
|
-
for (const element of fallbackTextElements) {
|
|
430
|
-
element.classList.add("snowui-pagination-responsive-text");
|
|
431
|
-
}
|
|
432
|
-
|
|
433
442
|
control.setAttribute("data-composition-content", "hidden");
|
|
434
443
|
control.setAttribute("data-responsive-compact", "true");
|
|
435
444
|
control.setAttribute("data-icon-only", "true");
|
|
@@ -968,7 +977,15 @@ export default function Pagination($$anchor, $$props) {
|
|
|
968
977
|
|
|
969
978
|
if (!$.get(itemsEl) || !$.get(templatesEl)) return;
|
|
970
979
|
|
|
971
|
-
|
|
980
|
+
let cancelled = false;
|
|
981
|
+
|
|
982
|
+
tick().then(() => {
|
|
983
|
+
if (!cancelled) renderPaginationItems();
|
|
984
|
+
});
|
|
985
|
+
|
|
986
|
+
return () => {
|
|
987
|
+
cancelled = true;
|
|
988
|
+
};
|
|
972
989
|
});
|
|
973
990
|
|
|
974
991
|
$.user_effect(() => {
|
|
@@ -1003,7 +1020,15 @@ export default function Pagination($$anchor, $$props) {
|
|
|
1003
1020
|
|
|
1004
1021
|
if (!$.get(itemsEl)) return;
|
|
1005
1022
|
|
|
1006
|
-
|
|
1023
|
+
let cancelled = false;
|
|
1024
|
+
|
|
1025
|
+
tick().then(() => {
|
|
1026
|
+
if (!cancelled) requestLayout();
|
|
1027
|
+
});
|
|
1028
|
+
|
|
1029
|
+
return () => {
|
|
1030
|
+
cancelled = true;
|
|
1031
|
+
};
|
|
1007
1032
|
});
|
|
1008
1033
|
|
|
1009
1034
|
$.user_effect(() => {
|
|
@@ -53,8 +53,9 @@ export function toast(input) {
|
|
|
53
53
|
...opts
|
|
54
54
|
};
|
|
55
55
|
|
|
56
|
-
//
|
|
57
|
-
|
|
56
|
+
// 替换队列数组,确保退出标记更新后,后续入队仍使宿主分组重新求值。
|
|
57
|
+
// 最新条目位于数组尾部;Toaster 渲染时将其展示在前。
|
|
58
|
+
toastStore.items = [...toastStore.items, item];
|
|
58
59
|
|
|
59
60
|
return id;
|
|
60
61
|
}
|
|
@@ -93,8 +94,9 @@ export function dismissToast(id, exitFromIndex) {
|
|
|
93
94
|
|
|
94
95
|
if (removeIdx === -1) return;
|
|
95
96
|
|
|
96
|
-
const removed = toastStore.items
|
|
97
|
+
const removed = toastStore.items[removeIdx];
|
|
97
98
|
|
|
99
|
+
toastStore.items = toastStore.items.filter((candidate) => candidate.id !== id);
|
|
98
100
|
removed?.onDismiss?.();
|
|
99
101
|
},
|
|
100
102
|
TOAST_EXIT_DURATION
|
|
@@ -126,8 +128,9 @@ export function pushOutToast(id, exitFromIndex) {
|
|
|
126
128
|
|
|
127
129
|
if (removeIdx === -1) return;
|
|
128
130
|
|
|
129
|
-
const removed = toastStore.items
|
|
131
|
+
const removed = toastStore.items[removeIdx];
|
|
130
132
|
|
|
133
|
+
toastStore.items = toastStore.items.filter((candidate) => candidate.id !== id);
|
|
131
134
|
removed?.onDismiss?.();
|
|
132
135
|
},
|
|
133
136
|
TOAST_EXIT_DURATION
|
|
@@ -385,13 +385,26 @@ export default function Pagination($$renderer, $$props) {
|
|
|
385
385
|
function compactControl(control) {
|
|
386
386
|
const graphicSelector = "svg, img, .snowui-icon, .snowui-icon-wrapper";
|
|
387
387
|
const hasGraphic = !!control.querySelector(graphicSelector);
|
|
388
|
-
const directTextNodes = Array.from(control.childNodes).filter((node) => node.nodeType === Node.TEXT_NODE && !!node.textContent?.trim());
|
|
389
|
-
const fallbackTextElements = Array.from(control.children).filter((element) => element instanceof HTMLElement && !element.matches(".snowui-text") && !element.matches(graphicSelector) && !element.querySelector(graphicSelector) && !!element.textContent?.trim());
|
|
390
|
-
const hasText = !!control.querySelector(".snowui-text")?.textContent?.trim() || directTextNodes.length > 0 || fallbackTextElements.length > 0;
|
|
391
388
|
|
|
392
|
-
if (!hasGraphic
|
|
389
|
+
if (!hasGraphic) return;
|
|
390
|
+
|
|
391
|
+
// 文本可能位于模板的内容包装层;只收集普通文字,保留图标子树。
|
|
392
|
+
const walker = document.createTreeWalker(control, NodeFilter.SHOW_TEXT);
|
|
393
|
+
|
|
394
|
+
const textNodes = [];
|
|
395
|
+
let node;
|
|
396
|
+
|
|
397
|
+
while (node = walker.nextNode()) {
|
|
398
|
+
if (node.textContent?.trim() && !node.parentElement?.closest(graphicSelector)) {
|
|
399
|
+
textNodes.push(node);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
if (textNodes.length === 0) return;
|
|
404
|
+
|
|
405
|
+
for (const textNode of textNodes) {
|
|
406
|
+
if (textNode.parentElement?.closest(".snowui-text")) continue;
|
|
393
407
|
|
|
394
|
-
for (const textNode of directTextNodes) {
|
|
395
408
|
const text = document.createElement("span");
|
|
396
409
|
|
|
397
410
|
text.className = "snowui-pagination-responsive-text";
|
|
@@ -399,10 +412,6 @@ export default function Pagination($$renderer, $$props) {
|
|
|
399
412
|
textNode.replaceWith(text);
|
|
400
413
|
}
|
|
401
414
|
|
|
402
|
-
for (const element of fallbackTextElements) {
|
|
403
|
-
element.classList.add("snowui-pagination-responsive-text");
|
|
404
|
-
}
|
|
405
|
-
|
|
406
415
|
control.setAttribute("data-composition-content", "hidden");
|
|
407
416
|
control.setAttribute("data-responsive-compact", "true");
|
|
408
417
|
control.setAttribute("data-icon-only", "true");
|
|
@@ -53,8 +53,9 @@ export function toast(input) {
|
|
|
53
53
|
...opts
|
|
54
54
|
};
|
|
55
55
|
|
|
56
|
-
//
|
|
57
|
-
|
|
56
|
+
// 替换队列数组,确保退出标记更新后,后续入队仍使宿主分组重新求值。
|
|
57
|
+
// 最新条目位于数组尾部;Toaster 渲染时将其展示在前。
|
|
58
|
+
toastStore.items = [...toastStore.items, item];
|
|
58
59
|
|
|
59
60
|
return id;
|
|
60
61
|
}
|
|
@@ -93,8 +94,9 @@ export function dismissToast(id, exitFromIndex) {
|
|
|
93
94
|
|
|
94
95
|
if (removeIdx === -1) return;
|
|
95
96
|
|
|
96
|
-
const removed = toastStore.items
|
|
97
|
+
const removed = toastStore.items[removeIdx];
|
|
97
98
|
|
|
99
|
+
toastStore.items = toastStore.items.filter((candidate) => candidate.id !== id);
|
|
98
100
|
removed?.onDismiss?.();
|
|
99
101
|
},
|
|
100
102
|
TOAST_EXIT_DURATION
|
|
@@ -126,8 +128,9 @@ export function pushOutToast(id, exitFromIndex) {
|
|
|
126
128
|
|
|
127
129
|
if (removeIdx === -1) return;
|
|
128
130
|
|
|
129
|
-
const removed = toastStore.items
|
|
131
|
+
const removed = toastStore.items[removeIdx];
|
|
130
132
|
|
|
133
|
+
toastStore.items = toastStore.items.filter((candidate) => candidate.id !== id);
|
|
131
134
|
removed?.onDismiss?.();
|
|
132
135
|
},
|
|
133
136
|
TOAST_EXIT_DURATION
|