@snowui-design-system/components 0.3.0-alpha.2 → 0.3.0-alpha.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.
- package/THIRD_PARTY_NOTICES.md +14 -0
- package/dist/client/blocks/Sidebar.js +56 -41
- package/dist/client/blocks/SidebarSection.js +3 -1
- package/dist/client/components/BarChart.js +1 -1
- package/dist/client/components/Breadcrumb.js +17 -11
- package/dist/client/components/CircularChart.js +2 -2
- package/dist/client/components/CodeBlock.js +278 -225
- package/dist/client/components/CopyButton.js +5 -2
- package/dist/client/components/ExpandButton.js +10 -3
- package/dist/client/components/Frame.js +15 -9
- package/dist/client/components/GaugeChart.js +2 -2
- package/dist/client/components/ImageViewer.js +51 -27
- package/dist/client/components/Indicator.js +5 -3
- package/dist/client/components/Input.js +27 -17
- package/dist/client/components/LineChart.js +1 -1
- package/dist/client/components/Link.d.ts +1 -1
- package/dist/client/components/Link.js +43 -22
- package/dist/client/components/Listbox.js +26 -15
- package/dist/client/components/OverflowAction.d.ts +2 -0
- package/dist/client/components/OverflowAction.js +146 -65
- package/dist/client/components/OverflowActions.d.ts +2 -0
- package/dist/client/components/OverflowActions.js +67 -16
- package/dist/client/components/Pagination.js +71 -48
- package/dist/client/components/Select.js +29 -18
- package/dist/client/components/SidePanel.js +76 -50
- package/dist/client/components/Tab.js +30 -31
- package/dist/client/components/TableBody.js +10 -4
- package/dist/client/components/TableCell.js +57 -32
- package/dist/client/components/TableHead.js +69 -38
- package/dist/client/components/TableToolbar.js +112 -79
- package/dist/client/components/Text.js +99 -59
- package/dist/client/components/Textarea.js +7 -1
- package/dist/client/components/Toast.js +8 -1
- package/dist/client/i18n/messages.d.ts +1 -1
- package/dist/client/i18n/messages.js +114 -0
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/lib/number-format.js +6 -0
- package/dist/client/lib/progressive-blur.d.ts +13 -0
- package/dist/client/lib/progressive-blur.js +54 -0
- package/dist/client/logic/ComponentPartsBoundary.d.ts +7 -0
- package/dist/client/logic/ComponentPartsBoundary.js +15 -0
- package/dist/client/logic/overflow-actions.d.ts +3 -2
- package/dist/client/styles/layout.css +12 -2
- package/dist/server/blocks/Sidebar.js +19 -5
- package/dist/server/blocks/SidebarSection.js +3 -1
- package/dist/server/components/BarChart.js +1 -1
- package/dist/server/components/Breadcrumb.js +9 -2
- package/dist/server/components/CircularChart.js +2 -2
- package/dist/server/components/CodeBlock.js +25 -13
- package/dist/server/components/CopyButton.js +6 -2
- package/dist/server/components/ExpandButton.js +7 -3
- package/dist/server/components/Frame.js +10 -3
- package/dist/server/components/GaugeChart.js +2 -2
- package/dist/server/components/ImageViewer.js +6 -3
- package/dist/server/components/Indicator.js +5 -3
- package/dist/server/components/Input.js +14 -17
- package/dist/server/components/LineChart.js +1 -1
- package/dist/server/components/Link.d.ts +1 -1
- package/dist/server/components/Link.js +20 -3
- package/dist/server/components/Listbox.js +17 -4
- package/dist/server/components/OverflowAction.d.ts +2 -0
- package/dist/server/components/OverflowAction.js +70 -26
- package/dist/server/components/OverflowActions.d.ts +2 -0
- package/dist/server/components/OverflowActions.js +49 -14
- package/dist/server/components/Pagination.js +21 -10
- package/dist/server/components/Select.js +23 -11
- package/dist/server/components/SidePanel.js +28 -8
- package/dist/server/components/Tab.js +61 -52
- package/dist/server/components/TableBody.js +9 -2
- package/dist/server/components/TableCell.js +28 -7
- package/dist/server/components/TableHead.js +31 -7
- package/dist/server/components/TableToolbar.js +57 -30
- package/dist/server/components/Text.js +46 -10
- package/dist/server/components/Textarea.js +4 -1
- package/dist/server/components/Toast.js +4 -1
- package/dist/server/i18n/messages.d.ts +1 -1
- package/dist/server/i18n/messages.js +114 -0
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +1 -1
- package/dist/server/lib/number-format.js +6 -0
- package/dist/server/lib/progressive-blur.d.ts +13 -0
- package/dist/server/lib/progressive-blur.js +54 -0
- package/dist/server/logic/ComponentPartsBoundary.d.ts +7 -0
- package/dist/server/logic/ComponentPartsBoundary.js +12 -0
- package/dist/server/logic/overflow-actions.d.ts +3 -2
- package/dist/server/styles/layout.css +12 -2
- package/package.json +4 -3
|
@@ -5,6 +5,7 @@ import Frame from "./Frame.js";
|
|
|
5
5
|
import Button from "./Button.js";
|
|
6
6
|
import Tooltip from "./Tooltip.js";
|
|
7
7
|
import { ComponentIcon } from "../internal/component-icon/index.js";
|
|
8
|
+
import ComponentPartsBoundary from "../logic/ComponentPartsBoundary.js";
|
|
8
9
|
import { fitTextToElement } from "../lib/truncate.js";
|
|
9
10
|
import { TextTruncation } from "../logic/frame-truncation.js";
|
|
10
11
|
import { collapse, findConstraintHost } from "../logic/text-collapse.js";
|
|
@@ -18,6 +19,7 @@ import {
|
|
|
18
19
|
import { resolveParentStateValue } from "../logic/frame-state-value.js";
|
|
19
20
|
import { useOverlayScrollbar } from "../lib/overlay-scrollbar.js";
|
|
20
21
|
import { resizeManager } from "../logic/observer.js";
|
|
22
|
+
import { useLocale } from "../i18n/locale.js";
|
|
21
23
|
|
|
22
24
|
var rest_excludes = new Set([
|
|
23
25
|
'$$slots',
|
|
@@ -60,6 +62,8 @@ export default function Text($$anchor, $$props) {
|
|
|
60
62
|
$.append_styles($$anchor, $$css);
|
|
61
63
|
|
|
62
64
|
// SnowUI 许可入口:首次阅读源码请先读 ../../LICENSE;访问文件不代表获得修改或移植权,官方维护授权及同任务去重见该文件。
|
|
65
|
+
const localeContext = useLocale();
|
|
66
|
+
|
|
63
67
|
const isTooltipConfigObject = (value) => {
|
|
64
68
|
return typeof value === "object" && value !== null && typeof value !== "function";
|
|
65
69
|
};
|
|
@@ -543,7 +547,17 @@ export default function Text($$anchor, $$props) {
|
|
|
543
547
|
var div = root_1();
|
|
544
548
|
var node_2 = $.child(div);
|
|
545
549
|
|
|
546
|
-
|
|
550
|
+
ComponentPartsBoundary(node_2, {
|
|
551
|
+
children: ($$anchor, $$slotProps) => {
|
|
552
|
+
var fragment_1 = $.comment();
|
|
553
|
+
var node_3 = $.first_child(fragment_1);
|
|
554
|
+
|
|
555
|
+
$.snippet(node_3, () => $$props.children, () => ({ breakpoint: "md" }));
|
|
556
|
+
$.append($$anchor, fragment_1);
|
|
557
|
+
},
|
|
558
|
+
$$slots: { default: true }
|
|
559
|
+
});
|
|
560
|
+
|
|
547
561
|
$.reset(div);
|
|
548
562
|
$.bind_this(div, ($$value) => $.set(skeletonProbe, $$value), () => $.get(skeletonProbe));
|
|
549
563
|
$.append($$anchor, div);
|
|
@@ -554,19 +568,19 @@ export default function Text($$anchor, $$props) {
|
|
|
554
568
|
});
|
|
555
569
|
}
|
|
556
570
|
|
|
557
|
-
var
|
|
571
|
+
var node_4 = $.sibling(node_1, 2);
|
|
558
572
|
|
|
559
573
|
{
|
|
560
574
|
const children = ($$anchor, $$arg0) => {
|
|
561
575
|
let breakpoint = () => ($$arg0?.()).breakpoint;
|
|
562
|
-
var
|
|
563
|
-
var
|
|
576
|
+
var fragment_2 = root_7();
|
|
577
|
+
var node_5 = $.first_child(fragment_2);
|
|
564
578
|
|
|
565
579
|
{
|
|
566
580
|
var consequent_5 = ($$anchor) => {
|
|
567
|
-
var
|
|
568
|
-
var div_1 = $.first_child(
|
|
569
|
-
var
|
|
581
|
+
var fragment_3 = root_3();
|
|
582
|
+
var div_1 = $.first_child(fragment_3);
|
|
583
|
+
var node_6 = $.child(div_1);
|
|
570
584
|
|
|
571
585
|
{
|
|
572
586
|
var consequent_1 = ($$anchor) => {
|
|
@@ -577,36 +591,47 @@ export default function Text($$anchor, $$props) {
|
|
|
577
591
|
};
|
|
578
592
|
|
|
579
593
|
var consequent_2 = ($$anchor) => {
|
|
580
|
-
|
|
581
|
-
|
|
594
|
+
ComponentPartsBoundary($$anchor, {
|
|
595
|
+
children: ($$anchor, $$slotProps) => {
|
|
596
|
+
var fragment_6 = $.comment();
|
|
597
|
+
var node_7 = $.first_child(fragment_6);
|
|
582
598
|
|
|
583
|
-
|
|
584
|
-
|
|
599
|
+
$.snippet(node_7, () => $$props.children, () => ({ breakpoint: breakpoint() }));
|
|
600
|
+
$.append($$anchor, fragment_6);
|
|
601
|
+
},
|
|
602
|
+
$$slots: { default: true }
|
|
603
|
+
});
|
|
585
604
|
};
|
|
586
605
|
|
|
587
|
-
$.if(
|
|
606
|
+
$.if(node_6, ($$render) => {
|
|
588
607
|
if ($.get(resolvedStateText) !== undefined) $$render(consequent_1); else if ($$props.children) $$render(consequent_2, 1);
|
|
589
608
|
});
|
|
590
609
|
}
|
|
591
610
|
|
|
592
|
-
var
|
|
611
|
+
var node_8 = $.sibling(node_6, 2);
|
|
593
612
|
|
|
594
613
|
{
|
|
595
614
|
var consequent_3 = ($$anchor) => {
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
615
|
+
{
|
|
616
|
+
let $0 = $.derived(() => localeContext.t("text.expand"));
|
|
617
|
+
|
|
618
|
+
Button($$anchor, $.spread_props(() => parts()?.Button, {
|
|
619
|
+
as: 'more',
|
|
620
|
+
iconOnly: true,
|
|
621
|
+
get 'aria-label'() {
|
|
622
|
+
return $.get($0);
|
|
623
|
+
},
|
|
624
|
+
backgroundBlur: true,
|
|
625
|
+
class: 'snowui-text-built-in-more',
|
|
626
|
+
children: ($$anchor, $$slotProps) => {
|
|
627
|
+
ComponentIcon($$anchor, { name: 'arrow-line-down', 'aria-hidden': 'true' });
|
|
628
|
+
},
|
|
629
|
+
$$slots: { default: true }
|
|
630
|
+
}));
|
|
631
|
+
}
|
|
607
632
|
};
|
|
608
633
|
|
|
609
|
-
$.if(
|
|
634
|
+
$.if(node_8, ($$render) => {
|
|
610
635
|
if (more()) $$render(consequent_3);
|
|
611
636
|
});
|
|
612
637
|
}
|
|
@@ -614,7 +639,7 @@ export default function Text($$anchor, $$props) {
|
|
|
614
639
|
$.reset(div_1);
|
|
615
640
|
$.bind_this(div_1, ($$value) => $.set(truncateWrapperElement, $$value), () => $.get(truncateWrapperElement));
|
|
616
641
|
|
|
617
|
-
var
|
|
642
|
+
var node_9 = $.sibling(div_1, 2);
|
|
618
643
|
|
|
619
644
|
{
|
|
620
645
|
var consequent_4 = ($$anchor) => {
|
|
@@ -632,7 +657,7 @@ export default function Text($$anchor, $$props) {
|
|
|
632
657
|
$.append($$anchor, div_2);
|
|
633
658
|
};
|
|
634
659
|
|
|
635
|
-
$.if(
|
|
660
|
+
$.if(node_9, ($$render) => {
|
|
636
661
|
if ($.get(scrollMode)) $$render(consequent_4);
|
|
637
662
|
});
|
|
638
663
|
}
|
|
@@ -649,13 +674,13 @@ export default function Text($$anchor, $$props) {
|
|
|
649
674
|
]
|
|
650
675
|
);
|
|
651
676
|
|
|
652
|
-
$.append($$anchor,
|
|
677
|
+
$.append($$anchor, fragment_3);
|
|
653
678
|
};
|
|
654
679
|
|
|
655
680
|
var consequent_9 = ($$anchor) => {
|
|
656
681
|
var span = root_5();
|
|
657
682
|
var span_1 = $.child(span);
|
|
658
|
-
var
|
|
683
|
+
var node_10 = $.child(span_1);
|
|
659
684
|
|
|
660
685
|
{
|
|
661
686
|
var consequent_6 = ($$anchor) => {
|
|
@@ -666,14 +691,19 @@ export default function Text($$anchor, $$props) {
|
|
|
666
691
|
};
|
|
667
692
|
|
|
668
693
|
var consequent_7 = ($$anchor) => {
|
|
669
|
-
|
|
670
|
-
|
|
694
|
+
ComponentPartsBoundary($$anchor, {
|
|
695
|
+
children: ($$anchor, $$slotProps) => {
|
|
696
|
+
var fragment_11 = $.comment();
|
|
697
|
+
var node_11 = $.first_child(fragment_11);
|
|
671
698
|
|
|
672
|
-
|
|
673
|
-
|
|
699
|
+
$.snippet(node_11, () => $$props.children, () => ({ breakpoint: breakpoint() }));
|
|
700
|
+
$.append($$anchor, fragment_11);
|
|
701
|
+
},
|
|
702
|
+
$$slots: { default: true }
|
|
703
|
+
});
|
|
674
704
|
};
|
|
675
705
|
|
|
676
|
-
$.if(
|
|
706
|
+
$.if(node_10, ($$render) => {
|
|
677
707
|
if ($.get(resolvedStateText) !== undefined) $$render(consequent_6); else if ($$props.children) $$render(consequent_7, 1);
|
|
678
708
|
});
|
|
679
709
|
}
|
|
@@ -683,7 +713,7 @@ export default function Text($$anchor, $$props) {
|
|
|
683
713
|
|
|
684
714
|
var span_2 = $.sibling(span_1, 2);
|
|
685
715
|
var text_2 = $.child(span_2, true);
|
|
686
|
-
var
|
|
716
|
+
var node_12 = $.sibling(text_2);
|
|
687
717
|
|
|
688
718
|
{
|
|
689
719
|
var consequent_8 = ($$anchor) => {
|
|
@@ -692,7 +722,7 @@ export default function Text($$anchor, $$props) {
|
|
|
692
722
|
$.append($$anchor, span_3);
|
|
693
723
|
};
|
|
694
724
|
|
|
695
|
-
$.if(
|
|
725
|
+
$.if(node_12, ($$render) => {
|
|
696
726
|
if (truncation.isTruncated) $$render(consequent_8);
|
|
697
727
|
});
|
|
698
728
|
}
|
|
@@ -705,7 +735,7 @@ export default function Text($$anchor, $$props) {
|
|
|
705
735
|
|
|
706
736
|
var consequent_12 = ($$anchor) => {
|
|
707
737
|
var span_4 = root_6();
|
|
708
|
-
var
|
|
738
|
+
var node_13 = $.child(span_4);
|
|
709
739
|
|
|
710
740
|
{
|
|
711
741
|
var consequent_10 = ($$anchor) => {
|
|
@@ -716,14 +746,19 @@ export default function Text($$anchor, $$props) {
|
|
|
716
746
|
};
|
|
717
747
|
|
|
718
748
|
var consequent_11 = ($$anchor) => {
|
|
719
|
-
|
|
720
|
-
|
|
749
|
+
ComponentPartsBoundary($$anchor, {
|
|
750
|
+
children: ($$anchor, $$slotProps) => {
|
|
751
|
+
var fragment_14 = $.comment();
|
|
752
|
+
var node_14 = $.first_child(fragment_14);
|
|
721
753
|
|
|
722
|
-
|
|
723
|
-
|
|
754
|
+
$.snippet(node_14, () => $$props.children, () => ({ breakpoint: breakpoint() }));
|
|
755
|
+
$.append($$anchor, fragment_14);
|
|
756
|
+
},
|
|
757
|
+
$$slots: { default: true }
|
|
758
|
+
});
|
|
724
759
|
};
|
|
725
760
|
|
|
726
|
-
$.if(
|
|
761
|
+
$.if(node_13, ($$render) => {
|
|
727
762
|
if ($.get(resolvedStateText) !== undefined) $$render(consequent_10); else if ($$props.children) $$render(consequent_11, 1);
|
|
728
763
|
});
|
|
729
764
|
}
|
|
@@ -748,26 +783,31 @@ export default function Text($$anchor, $$props) {
|
|
|
748
783
|
};
|
|
749
784
|
|
|
750
785
|
var consequent_14 = ($$anchor) => {
|
|
751
|
-
|
|
752
|
-
|
|
786
|
+
ComponentPartsBoundary($$anchor, {
|
|
787
|
+
children: ($$anchor, $$slotProps) => {
|
|
788
|
+
var fragment_17 = $.comment();
|
|
789
|
+
var node_15 = $.first_child(fragment_17);
|
|
753
790
|
|
|
754
|
-
|
|
755
|
-
|
|
791
|
+
$.snippet(node_15, () => $$props.children, () => ({ breakpoint: breakpoint() }));
|
|
792
|
+
$.append($$anchor, fragment_17);
|
|
793
|
+
},
|
|
794
|
+
$$slots: { default: true }
|
|
795
|
+
});
|
|
756
796
|
};
|
|
757
797
|
|
|
758
|
-
$.if(
|
|
798
|
+
$.if(node_5, ($$render) => {
|
|
759
799
|
if (lines() === 0) $$render(consequent_5); else if (lines() === 1) $$render(consequent_9, 1); else if (lines() === 2 || lines() === 3) $$render(consequent_12, 2); else if ($.get(resolvedStateText) !== undefined) $$render(consequent_13, 3); else if ($$props.children) $$render(consequent_14, 4);
|
|
760
800
|
});
|
|
761
801
|
}
|
|
762
802
|
|
|
763
|
-
var
|
|
803
|
+
var node_16 = $.sibling(node_5, 2);
|
|
764
804
|
|
|
765
805
|
{
|
|
766
806
|
var consequent_17 = ($$anchor) => {
|
|
767
807
|
Tooltip($$anchor, $.spread_props(() => $.get(tooltipConfig), {
|
|
768
808
|
children: ($$anchor, $$slotProps) => {
|
|
769
|
-
var
|
|
770
|
-
var
|
|
809
|
+
var fragment_19 = $.comment();
|
|
810
|
+
var node_17 = $.first_child(fragment_19);
|
|
771
811
|
|
|
772
812
|
{
|
|
773
813
|
var consequent_15 = ($$anchor) => {
|
|
@@ -778,30 +818,30 @@ export default function Text($$anchor, $$props) {
|
|
|
778
818
|
};
|
|
779
819
|
|
|
780
820
|
var consequent_16 = ($$anchor) => {
|
|
781
|
-
var
|
|
782
|
-
var
|
|
821
|
+
var fragment_21 = $.comment();
|
|
822
|
+
var node_18 = $.first_child(fragment_21);
|
|
783
823
|
|
|
784
|
-
$.snippet(
|
|
785
|
-
$.append($$anchor,
|
|
824
|
+
$.snippet(node_18, () => $.get(tooltipContent));
|
|
825
|
+
$.append($$anchor, fragment_21);
|
|
786
826
|
};
|
|
787
827
|
|
|
788
|
-
$.if(
|
|
828
|
+
$.if(node_17, ($$render) => {
|
|
789
829
|
if (typeof $.get(tooltipContent) === "string") $$render(consequent_15); else if (typeof $.get(tooltipContent) === "function") $$render(consequent_16, 1);
|
|
790
830
|
});
|
|
791
831
|
}
|
|
792
832
|
|
|
793
|
-
$.append($$anchor,
|
|
833
|
+
$.append($$anchor, fragment_19);
|
|
794
834
|
},
|
|
795
835
|
$$slots: { default: true }
|
|
796
836
|
}));
|
|
797
837
|
};
|
|
798
838
|
|
|
799
|
-
$.if(
|
|
839
|
+
$.if(node_16, ($$render) => {
|
|
800
840
|
if ($.get(needTooltip)) $$render(consequent_17);
|
|
801
841
|
});
|
|
802
842
|
}
|
|
803
843
|
|
|
804
|
-
$.append($$anchor,
|
|
844
|
+
$.append($$anchor, fragment_2);
|
|
805
845
|
};
|
|
806
846
|
|
|
807
847
|
let $0 = $.derived(() => $.get(shouldTruncate) ? String(lines()) : undefined);
|
|
@@ -810,7 +850,7 @@ export default function Text($$anchor, $$props) {
|
|
|
810
850
|
let $3 = $.derived(() => lines() === 0 ? $.get(isExpanding) ? "true" : "false" : undefined);
|
|
811
851
|
let $4 = $.derived(() => $.get(scrollMode) ? "true" : undefined);
|
|
812
852
|
|
|
813
|
-
Frame(
|
|
853
|
+
Frame(node_4, $.spread_props(
|
|
814
854
|
{
|
|
815
855
|
get enableResponsive() {
|
|
816
856
|
return enableResponsive();
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
import { resizeManager } from "../logic/observer.js";
|
|
14
14
|
import { splitFrameHostProps } from "../logic/frame-prop-filter.js";
|
|
15
15
|
import { useOverlayScrollbar } from "../lib/overlay-scrollbar.js";
|
|
16
|
+
import { useLocale } from "../i18n/locale.js";
|
|
16
17
|
|
|
17
18
|
var rest_excludes = new Set([
|
|
18
19
|
'$$slots',
|
|
@@ -77,6 +78,8 @@ export default function Textarea($$anchor, $$props) {
|
|
|
77
78
|
$.append_styles($$anchor, $$css);
|
|
78
79
|
|
|
79
80
|
// SnowUI 许可入口:首次阅读源码请先读 ../../LICENSE;访问文件不代表获得修改或移植权,官方维护授权及同任务去重见该文件。
|
|
81
|
+
const localeContext = useLocale();
|
|
82
|
+
|
|
80
83
|
let value = $.prop($$props, 'value', 15),
|
|
81
84
|
defaultValue = $.prop($$props, 'defaultValue', 3, undefined),
|
|
82
85
|
placeholder = $.prop($$props, 'placeholder', 3, undefined),
|
|
@@ -429,6 +432,7 @@ export default function Textarea($$anchor, $$props) {
|
|
|
429
432
|
var consequent_1 = ($$anchor) => {
|
|
430
433
|
{
|
|
431
434
|
let $0 = $.derived(() => $.get(indicatorAxis) === "width" ? $.get(resizeWidth) : $.get(resizeHeight));
|
|
435
|
+
let $1 = $.derived(() => localeContext.t("textarea.resize"));
|
|
432
436
|
|
|
433
437
|
Indicator($$anchor, {
|
|
434
438
|
as: 'resize-handle',
|
|
@@ -450,7 +454,9 @@ export default function Textarea($$anchor, $$props) {
|
|
|
450
454
|
minWidth: 120,
|
|
451
455
|
minHeight: 60,
|
|
452
456
|
applySize: false,
|
|
453
|
-
ariaLabel
|
|
457
|
+
get ariaLabel() {
|
|
458
|
+
return $.get($1);
|
|
459
|
+
},
|
|
454
460
|
onSizeChange: handleIndicatorSize
|
|
455
461
|
});
|
|
456
462
|
}
|
|
@@ -5,6 +5,7 @@ import { onMount, onDestroy } from "svelte";
|
|
|
5
5
|
import { Frame } from "../index.js";
|
|
6
6
|
import { GENERIC_SCALE_APPEAR_MOTION } from "../motion/presets/generic.js";
|
|
7
7
|
import { ComponentIcon } from "../internal/component-icon/index.js";
|
|
8
|
+
import { useLocale } from "../i18n/locale.js";
|
|
8
9
|
import { registerToastTemplate, unregisterToastTemplate, showToast } from "../logic/toast.js";
|
|
9
10
|
import { mergeComponentPartProps, useComponentPart } from "../logic/component-parts.js";
|
|
10
11
|
|
|
@@ -23,6 +24,8 @@ export default function Toast($$anchor, $$props) {
|
|
|
23
24
|
$.append_styles($$anchor, $$css);
|
|
24
25
|
|
|
25
26
|
// SnowUI 许可入口:首次阅读源码请先读 ../../LICENSE;访问文件不代表获得修改或移植权,官方维护授权及同任务去重见该文件。
|
|
27
|
+
const localeContext = useLocale();
|
|
28
|
+
|
|
26
29
|
/** 内置图标按钮配置;事件与角色由所属组件控制。 */
|
|
27
30
|
/** 模版模式 id;配合 template=true 后可通过 showToast(id) 触发;Inline 模式自动生成 */
|
|
28
31
|
/** 模版模式:只注册为命令式 Toast 模板,不直接渲染 */
|
|
@@ -287,13 +290,17 @@ export default function Toast($$anchor, $$props) {
|
|
|
287
290
|
var consequent_3 = ($$anchor) => {
|
|
288
291
|
{
|
|
289
292
|
let $0 = $.derived(() => `snowui-clear-icon-btn snowui-toast-close-btn${$.get(parts)?.Button?.class ? ` ${$.get(parts).Button.class}` : ""}`);
|
|
293
|
+
let $1 = $.derived(() => localeContext.t("toast.close"));
|
|
290
294
|
|
|
291
295
|
Button($$anchor, $.spread_props({ bare: true, emphasis: 'muted', size: 'sm' }, () => $.get(parts)?.Button, {
|
|
292
296
|
type: 'button',
|
|
293
297
|
get class() {
|
|
294
298
|
return $.get($0);
|
|
295
299
|
},
|
|
296
|
-
|
|
300
|
+
|
|
301
|
+
get 'aria-label'() {
|
|
302
|
+
return $.get($1);
|
|
303
|
+
},
|
|
297
304
|
onclick: () => $.get(onDismiss)?.(),
|
|
298
305
|
onmousedown: (e) => e.preventDefault(),
|
|
299
306
|
tabindex: -1,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** SnowUI 组件内置 UI 文案 catalog。文档: ../../../specs/maintainers/LocalizationSpec.md */
|
|
2
2
|
export declare const DEFAULT_LOCALE = "zh-CN";
|
|
3
|
-
export type SnowUIMessageKey = "colorSchemeButton.toLight" | "colorSchemeButton.toDark" | "styleButton.toSnowUI" | "styleButton.toApple" | "sidePanel.placement.toInline" | "sidePanel.placement.toFloating" | "sidePanel.previous" | "sidePanel.next" | "sidePanel.copy" | "sidePanel.delete" | "sidePanel.cancel" | "sidePanel.save" | "sidePanel.close" | "dialog.close";
|
|
3
|
+
export type SnowUIMessageKey = "copyButton.copy" | "copyButton.copied" | "codeBlock.copyCode" | "codeBlock.fullscreen" | "codeBlock.exitFullscreen" | "codeBlock.resize" | "codeBlock.fullscreenDialog" | "expandButton.expand" | "expandButton.collapse" | "sidebar.resize" | "pagination.pageSize" | "pagination.previous" | "pagination.next" | "pagination.page" | "input.clear" | "input.increment" | "input.decrement" | "input.openTime" | "input.openDate" | "input.year" | "input.month" | "input.day" | "input.week" | "input.hour" | "input.minute" | "input.second" | "input.yearPlaceholder" | "input.monthPlaceholder" | "input.dayPlaceholder" | "input.weekPlaceholder" | "imageViewer.previous" | "imageViewer.next" | "imageViewer.close" | "toast.close" | "tableHead.selectAll" | "tableHead.resizeColumn" | "tableCell.selectRow" | "text.expand" | "textarea.resize" | "indicator.resizeWidth" | "indicator.resizeHeight" | "indicator.resizeBoth" | "colorSchemeButton.toLight" | "colorSchemeButton.toDark" | "styleButton.toSnowUI" | "styleButton.toApple" | "sidePanel.placement.toInline" | "sidePanel.placement.toFloating" | "sidePanel.previous" | "sidePanel.next" | "sidePanel.copy" | "sidePanel.delete" | "sidePanel.cancel" | "sidePanel.save" | "sidePanel.close" | "sidePanel.resize" | "tableToolbar.name" | "tableToolbar.search" | "tableToolbar.sort" | "tableToolbar.filter" | "tableToolbar.clear" | "tableToolbar.copy" | "tableToolbar.delete" | "tableToolbar.selected" | "tableToolbar.deleting" | "tableToolbar.defaultSort" | "tableToolbar.ascending" | "tableToolbar.descending" | "tableToolbar.defaultFilter" | "overflowActions.more" | "dialog.close";
|
|
4
4
|
export type SnowUIMessageValues = Record<string, string | number>;
|
|
5
5
|
export type SnowUIMessageOverrides = Partial<Record<SnowUIMessageKey, string>>;
|
|
6
6
|
export declare const SNOWUI_MESSAGES: Record<string, Record<SnowUIMessageKey, string>>;
|
|
@@ -4,6 +4,48 @@
|
|
|
4
4
|
export const DEFAULT_LOCALE = "zh-CN";
|
|
5
5
|
export const SNOWUI_MESSAGES = {
|
|
6
6
|
"zh-CN": {
|
|
7
|
+
"copyButton.copy": "复制",
|
|
8
|
+
"copyButton.copied": "已复制",
|
|
9
|
+
"codeBlock.copyCode": "复制代码",
|
|
10
|
+
"codeBlock.fullscreen": "全屏查看",
|
|
11
|
+
"codeBlock.exitFullscreen": "退出全屏",
|
|
12
|
+
"codeBlock.resize": "调整代码块宽度和高度",
|
|
13
|
+
"codeBlock.fullscreenDialog": "全屏代码查看",
|
|
14
|
+
"expandButton.expand": "展开",
|
|
15
|
+
"expandButton.collapse": "收起",
|
|
16
|
+
"sidebar.resize": "调整侧边栏宽度",
|
|
17
|
+
"pagination.pageSize": "每页条数",
|
|
18
|
+
"pagination.previous": "上一页",
|
|
19
|
+
"pagination.next": "下一页",
|
|
20
|
+
"pagination.page": "第 {{page}} 页",
|
|
21
|
+
"input.clear": "清除输入",
|
|
22
|
+
"input.increment": "增加数值",
|
|
23
|
+
"input.decrement": "减少数值",
|
|
24
|
+
"input.openTime": "打开时间选择",
|
|
25
|
+
"input.openDate": "打开日期选择",
|
|
26
|
+
"input.year": "年",
|
|
27
|
+
"input.month": "月",
|
|
28
|
+
"input.day": "日",
|
|
29
|
+
"input.week": "周",
|
|
30
|
+
"input.hour": "时",
|
|
31
|
+
"input.minute": "分",
|
|
32
|
+
"input.second": "秒",
|
|
33
|
+
"input.yearPlaceholder": "年",
|
|
34
|
+
"input.monthPlaceholder": "月",
|
|
35
|
+
"input.dayPlaceholder": "日",
|
|
36
|
+
"input.weekPlaceholder": "周",
|
|
37
|
+
"imageViewer.previous": "上一张",
|
|
38
|
+
"imageViewer.next": "下一张",
|
|
39
|
+
"imageViewer.close": "关闭图片预览",
|
|
40
|
+
"toast.close": "关闭通知",
|
|
41
|
+
"tableHead.selectAll": "选择全部当前行",
|
|
42
|
+
"tableHead.resizeColumn": "调整 {{column}} 列宽",
|
|
43
|
+
"tableCell.selectRow": "选择当前行",
|
|
44
|
+
"text.expand": "展开",
|
|
45
|
+
"textarea.resize": "调整文本域大小",
|
|
46
|
+
"indicator.resizeWidth": "调整宽度",
|
|
47
|
+
"indicator.resizeHeight": "调整高度",
|
|
48
|
+
"indicator.resizeBoth": "调整宽度和高度",
|
|
7
49
|
"colorSchemeButton.toLight": "切换到亮色",
|
|
8
50
|
"colorSchemeButton.toDark": "切换到暗色",
|
|
9
51
|
"styleButton.toSnowUI": "切换到 SnowUI 风格",
|
|
@@ -17,9 +59,66 @@ export const SNOWUI_MESSAGES = {
|
|
|
17
59
|
"sidePanel.cancel": "取消",
|
|
18
60
|
"sidePanel.save": "保存",
|
|
19
61
|
"sidePanel.close": "关闭",
|
|
62
|
+
"sidePanel.resize": "调整弹出窗宽度",
|
|
63
|
+
"tableToolbar.name": "表格工具栏",
|
|
64
|
+
"tableToolbar.search": "搜索",
|
|
65
|
+
"tableToolbar.sort": "排序",
|
|
66
|
+
"tableToolbar.filter": "筛选",
|
|
67
|
+
"tableToolbar.clear": "清除",
|
|
68
|
+
"tableToolbar.copy": "复制",
|
|
69
|
+
"tableToolbar.delete": "删除",
|
|
70
|
+
"tableToolbar.selected": "已选择 {{count}} 项",
|
|
71
|
+
"tableToolbar.deleting": "删除中",
|
|
72
|
+
"tableToolbar.defaultSort": "默认排序",
|
|
73
|
+
"tableToolbar.ascending": "升序",
|
|
74
|
+
"tableToolbar.descending": "降序",
|
|
75
|
+
"tableToolbar.defaultFilter": "默认筛选",
|
|
76
|
+
"overflowActions.more": "更多操作",
|
|
20
77
|
"dialog.close": "关闭",
|
|
21
78
|
},
|
|
22
79
|
"en-US": {
|
|
80
|
+
"copyButton.copy": "Copy",
|
|
81
|
+
"copyButton.copied": "Copied",
|
|
82
|
+
"codeBlock.copyCode": "Copy code",
|
|
83
|
+
"codeBlock.fullscreen": "View fullscreen",
|
|
84
|
+
"codeBlock.exitFullscreen": "Exit fullscreen",
|
|
85
|
+
"codeBlock.resize": "Resize code block",
|
|
86
|
+
"codeBlock.fullscreenDialog": "Fullscreen code view",
|
|
87
|
+
"expandButton.expand": "Expand",
|
|
88
|
+
"expandButton.collapse": "Collapse",
|
|
89
|
+
"sidebar.resize": "Resize sidebar width",
|
|
90
|
+
"pagination.pageSize": "Items per page",
|
|
91
|
+
"pagination.previous": "Previous page",
|
|
92
|
+
"pagination.next": "Next page",
|
|
93
|
+
"pagination.page": "Page {{page}}",
|
|
94
|
+
"input.clear": "Clear input",
|
|
95
|
+
"input.increment": "Increase value",
|
|
96
|
+
"input.decrement": "Decrease value",
|
|
97
|
+
"input.openTime": "Open time picker",
|
|
98
|
+
"input.openDate": "Open date picker",
|
|
99
|
+
"input.year": "Year",
|
|
100
|
+
"input.month": "Month",
|
|
101
|
+
"input.day": "Day",
|
|
102
|
+
"input.week": "Week",
|
|
103
|
+
"input.hour": "Hour",
|
|
104
|
+
"input.minute": "Minute",
|
|
105
|
+
"input.second": "Second",
|
|
106
|
+
"input.yearPlaceholder": "YYYY",
|
|
107
|
+
"input.monthPlaceholder": "MM",
|
|
108
|
+
"input.dayPlaceholder": "DD",
|
|
109
|
+
"input.weekPlaceholder": "WW",
|
|
110
|
+
"imageViewer.previous": "Previous image",
|
|
111
|
+
"imageViewer.next": "Next image",
|
|
112
|
+
"imageViewer.close": "Close image viewer",
|
|
113
|
+
"toast.close": "Close notification",
|
|
114
|
+
"tableHead.selectAll": "Select all current rows",
|
|
115
|
+
"tableHead.resizeColumn": "Resize {{column}} column",
|
|
116
|
+
"tableCell.selectRow": "Select current row",
|
|
117
|
+
"text.expand": "Expand",
|
|
118
|
+
"textarea.resize": "Resize text area",
|
|
119
|
+
"indicator.resizeWidth": "Resize width",
|
|
120
|
+
"indicator.resizeHeight": "Resize height",
|
|
121
|
+
"indicator.resizeBoth": "Resize width and height",
|
|
23
122
|
"colorSchemeButton.toLight": "Switch to light color scheme",
|
|
24
123
|
"colorSchemeButton.toDark": "Switch to dark color scheme",
|
|
25
124
|
"styleButton.toSnowUI": "Switch to SnowUI style",
|
|
@@ -33,6 +132,21 @@ export const SNOWUI_MESSAGES = {
|
|
|
33
132
|
"sidePanel.cancel": "Cancel",
|
|
34
133
|
"sidePanel.save": "Save",
|
|
35
134
|
"sidePanel.close": "Close",
|
|
135
|
+
"sidePanel.resize": "Resize panel width",
|
|
136
|
+
"tableToolbar.name": "Table toolbar",
|
|
137
|
+
"tableToolbar.search": "Search",
|
|
138
|
+
"tableToolbar.sort": "Sort",
|
|
139
|
+
"tableToolbar.filter": "Filter",
|
|
140
|
+
"tableToolbar.clear": "Clear",
|
|
141
|
+
"tableToolbar.copy": "Copy",
|
|
142
|
+
"tableToolbar.delete": "Delete",
|
|
143
|
+
"tableToolbar.selected": "{{count}} selected",
|
|
144
|
+
"tableToolbar.deleting": "Deleting",
|
|
145
|
+
"tableToolbar.defaultSort": "Default sort",
|
|
146
|
+
"tableToolbar.ascending": "Ascending",
|
|
147
|
+
"tableToolbar.descending": "Descending",
|
|
148
|
+
"tableToolbar.defaultFilter": "Default filter",
|
|
149
|
+
"overflowActions.more": "More actions",
|
|
36
150
|
"dialog.close": "Close",
|
|
37
151
|
},
|
|
38
152
|
};
|
package/dist/client/index.d.ts
CHANGED
|
@@ -88,7 +88,7 @@ export { DEFAULT_LOCALE, SNOWUI_MESSAGES, type SnowUIMessageKey, type SnowUIMess
|
|
|
88
88
|
export { createLocaleContext, useLocale, type LocaleContext, } from "./i18n/locale.js";
|
|
89
89
|
export { getTooltipBehaviorEnhancement, registerTooltipBehaviorEnhancement, resetTooltipBehaviorEnhancement, type ResolvedTooltipBehaviorEnhancement, type TooltipBehaviorEnhancement, } from "./lib/tooltip-behavior";
|
|
90
90
|
export { DEFAULT_FLOATING_EDGE_GAP, clampFloatingPosition, clampFloatingValue, constrainFloatingAnchor, getFloatingVisualBounds, getOppositeFloatingSide, hasFloatingCollision, type FloatingBounds, type FloatingPoint, type FloatingSide, } from "./lib/floating-position";
|
|
91
|
-
export { DEFAULT_PROGRESSIVE_BLUR_LAYER_COUNT, DEFAULT_PROGRESSIVE_BLUR_WIDTH, createProgressiveBlurContainerStyle, createProgressiveBlurLayerStyles, createProgressiveBlurStyles, createUniformBlurLayerStyles, createUniformBlurStyles, type ProgressiveBlurDirection, type ProgressiveBlurLayerStyle, type ProgressiveBlurOptions, type ProgressiveBlurStyles, } from "./lib/progressive-blur";
|
|
91
|
+
export { DEFAULT_PROGRESSIVE_BLUR_LAYER_COUNT, DEFAULT_PROGRESSIVE_BLUR_WIDTH, createEdgeProgressiveBlurStyles, createProgressiveBlurContainerStyle, createProgressiveBlurLayerStyles, createProgressiveBlurStyles, createUniformBlurLayerStyles, createUniformBlurStyles, type EdgeProgressiveBlurDirection, type EdgeProgressiveBlurOptions, type ProgressiveBlurDirection, type ProgressiveBlurLayerStyle, type ProgressiveBlurOptions, type ProgressiveBlurStyles, } from "./lib/progressive-blur";
|
|
92
92
|
export { createEdgeFadeMaskImage, createEdgeFadeMaskStyle, type EdgeFadeDirection, type EdgeFadeMaskOptions, } from "./lib/edge-fade";
|
|
93
93
|
export { writeClipboardText } from "./lib/clipboard";
|
|
94
94
|
export { default as CopyLink } from "./components/CopyLink.js";
|
package/dist/client/index.js
CHANGED
|
@@ -78,7 +78,7 @@ export { DEFAULT_LOCALE, SNOWUI_MESSAGES, } from "./i18n/messages.js";
|
|
|
78
78
|
export { createLocaleContext, useLocale, } from "./i18n/locale.js";
|
|
79
79
|
export { getTooltipBehaviorEnhancement, registerTooltipBehaviorEnhancement, resetTooltipBehaviorEnhancement, } from "./lib/tooltip-behavior.js";
|
|
80
80
|
export { DEFAULT_FLOATING_EDGE_GAP, clampFloatingPosition, clampFloatingValue, constrainFloatingAnchor, getFloatingVisualBounds, getOppositeFloatingSide, hasFloatingCollision, } from "./lib/floating-position.js";
|
|
81
|
-
export { DEFAULT_PROGRESSIVE_BLUR_LAYER_COUNT, DEFAULT_PROGRESSIVE_BLUR_WIDTH, createProgressiveBlurContainerStyle, createProgressiveBlurLayerStyles, createProgressiveBlurStyles, createUniformBlurLayerStyles, createUniformBlurStyles, } from "./lib/progressive-blur.js";
|
|
81
|
+
export { DEFAULT_PROGRESSIVE_BLUR_LAYER_COUNT, DEFAULT_PROGRESSIVE_BLUR_WIDTH, createEdgeProgressiveBlurStyles, createProgressiveBlurContainerStyle, createProgressiveBlurLayerStyles, createProgressiveBlurStyles, createUniformBlurLayerStyles, createUniformBlurStyles, } from "./lib/progressive-blur.js";
|
|
82
82
|
export { createEdgeFadeMaskImage, createEdgeFadeMaskStyle, } from "./lib/edge-fade.js";
|
|
83
83
|
export { writeClipboardText } from "./lib/clipboard.js";
|
|
84
84
|
export { default as CopyLink } from "./components/CopyLink.js";
|
|
@@ -74,10 +74,16 @@ export function formatNumberLabel(value, options = {}) {
|
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
76
|
export function formatPercentLabel(value, options = {}) {
|
|
77
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
78
|
+
return options.emptyValue ?? DEFAULT_NUMBER_EMPTY_VALUE;
|
|
79
|
+
}
|
|
80
|
+
const hasExplicitFractionDigits = options.fractionDigits !== undefined ||
|
|
81
|
+
options.percentFractionDigits !== undefined;
|
|
77
82
|
return `${formatNumberLabel(value, {
|
|
78
83
|
...options,
|
|
79
84
|
fractionDigits: options.fractionDigits ??
|
|
80
85
|
options.percentFractionDigits ??
|
|
81
86
|
DEFAULT_NUMBER_PERCENT_FRACTION_DIGITS,
|
|
87
|
+
preserveTrailingZeros: options.preserveTrailingZeros ?? hasExplicitFractionDigits,
|
|
82
88
|
})}%`;
|
|
83
89
|
}
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
export type ProgressiveBlurDirection = "left-to-right" | "right-to-left";
|
|
2
|
+
export type EdgeProgressiveBlurDirection = "top-to-bottom" | "bottom-to-top" | ProgressiveBlurDirection;
|
|
3
|
+
export interface EdgeProgressiveBlurOptions {
|
|
4
|
+
direction?: EdgeProgressiveBlurDirection;
|
|
5
|
+
/** Visible height for vertical directions or width for horizontal directions. */
|
|
6
|
+
extent?: string;
|
|
7
|
+
position?: "absolute" | "fixed";
|
|
8
|
+
zIndex?: number;
|
|
9
|
+
}
|
|
2
10
|
export interface ProgressiveBlurOptions {
|
|
3
11
|
direction?: ProgressiveBlurDirection;
|
|
4
12
|
width?: string;
|
|
@@ -29,6 +37,11 @@ export interface ProgressiveBlurStyles {
|
|
|
29
37
|
containerStyle: string;
|
|
30
38
|
layers: ProgressiveBlurLayerStyle[];
|
|
31
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Decorative full-edge blur. The host supplies aria-hidden and owns its stacking context.
|
|
42
|
+
* Unsupported backdrop-filter leaves transparent layers and readable content.
|
|
43
|
+
*/
|
|
44
|
+
export declare function createEdgeProgressiveBlurStyles(options?: EdgeProgressiveBlurOptions): ProgressiveBlurStyles;
|
|
32
45
|
export declare const DEFAULT_PROGRESSIVE_BLUR_LAYER_COUNT = 16;
|
|
33
46
|
export declare const DEFAULT_PROGRESSIVE_BLUR_WIDTH = "calc((var(--size-12, 3rem) + var(--size-14, 3.5rem)) / 3)";
|
|
34
47
|
export declare const createProgressiveBlurContainerStyle: (options?: ProgressiveBlurOptions) => string;
|