@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
|
@@ -1,3 +1,57 @@
|
|
|
1
|
+
/** Four layers match the established 80px Site edge treatment. */
|
|
2
|
+
const EDGE_BLUR_LAYERS = [
|
|
3
|
+
{ blur: "2px", solid: "20%", fade: "100%" },
|
|
4
|
+
{ blur: "6px", solid: "16%", fade: "72%" },
|
|
5
|
+
{ blur: "12px", solid: "10%", fade: "48%" },
|
|
6
|
+
{ blur: "24px", solid: "4%", fade: "28%" },
|
|
7
|
+
];
|
|
8
|
+
/**
|
|
9
|
+
* Decorative full-edge blur. The host supplies aria-hidden and owns its stacking context.
|
|
10
|
+
* Unsupported backdrop-filter leaves transparent layers and readable content.
|
|
11
|
+
*/
|
|
12
|
+
export function createEdgeProgressiveBlurStyles(options = {}) {
|
|
13
|
+
const direction = options.direction ?? "top-to-bottom";
|
|
14
|
+
const vertical = direction === "top-to-bottom" || direction === "bottom-to-top";
|
|
15
|
+
const edge = {
|
|
16
|
+
"top-to-bottom": "top: 0; left: 0; right: 0",
|
|
17
|
+
"bottom-to-top": "bottom: 0; left: 0; right: 0",
|
|
18
|
+
"left-to-right": "left: 0; top: 0; bottom: 0",
|
|
19
|
+
"right-to-left": "right: 0; top: 0; bottom: 0",
|
|
20
|
+
}[direction];
|
|
21
|
+
const gradient = {
|
|
22
|
+
"top-to-bottom": "to bottom",
|
|
23
|
+
"bottom-to-top": "to top",
|
|
24
|
+
"left-to-right": "to right",
|
|
25
|
+
"right-to-left": "to left",
|
|
26
|
+
}[direction];
|
|
27
|
+
const extent = options.extent ?? "80px";
|
|
28
|
+
const size = vertical ? `height: ${extent}` : `width: ${extent}`;
|
|
29
|
+
return {
|
|
30
|
+
containerStyle: [
|
|
31
|
+
`position: ${options.position ?? "absolute"}`,
|
|
32
|
+
edge,
|
|
33
|
+
size,
|
|
34
|
+
options.zIndex === undefined ? "" : `z-index: ${options.zIndex}`,
|
|
35
|
+
"pointer-events: none",
|
|
36
|
+
].filter(Boolean).join("; "),
|
|
37
|
+
layers: EDGE_BLUR_LAYERS.map((layer, index) => {
|
|
38
|
+
const mask = `linear-gradient(${gradient}, #000 0%, #000 ${layer.solid}, transparent ${layer.fade})`;
|
|
39
|
+
return {
|
|
40
|
+
index,
|
|
41
|
+
style: [
|
|
42
|
+
"position: absolute",
|
|
43
|
+
"inset: 0",
|
|
44
|
+
"pointer-events: none",
|
|
45
|
+
"background-image: linear-gradient(transparent, transparent)",
|
|
46
|
+
`-webkit-backdrop-filter: blur(${layer.blur})`,
|
|
47
|
+
`backdrop-filter: blur(${layer.blur})`,
|
|
48
|
+
`-webkit-mask-image: ${mask}`,
|
|
49
|
+
`mask-image: ${mask}`,
|
|
50
|
+
].join("; "),
|
|
51
|
+
};
|
|
52
|
+
}),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
1
55
|
export const DEFAULT_PROGRESSIVE_BLUR_LAYER_COUNT = 16;
|
|
2
56
|
export const DEFAULT_PROGRESSIVE_BLUR_WIDTH = "calc((var(--size-12, 3rem) + var(--size-14, 3.5rem)) / 3)";
|
|
3
57
|
const DEFAULT_OPTIONS = {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
type $$ComponentProps = {
|
|
3
|
+
children?: Snippet;
|
|
4
|
+
};
|
|
5
|
+
declare const ComponentPartsBoundary: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
6
|
+
type ComponentPartsBoundary = ReturnType<typeof ComponentPartsBoundary>;
|
|
7
|
+
export default ComponentPartsBoundary;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import 'svelte/internal/disclose-version';
|
|
2
|
+
import * as $ from 'svelte/internal/client';
|
|
3
|
+
import { provideComponentParts } from "./component-parts.js";
|
|
4
|
+
|
|
5
|
+
export default function ComponentPartsBoundary($$anchor, $$props) {
|
|
6
|
+
$.push($$props, true);
|
|
7
|
+
provideComponentParts(() => undefined);
|
|
8
|
+
|
|
9
|
+
var fragment = $.comment();
|
|
10
|
+
var node = $.first_child(fragment);
|
|
11
|
+
|
|
12
|
+
$.snippet(node, () => $$props.children ?? $.noop);
|
|
13
|
+
$.append($$anchor, fragment);
|
|
14
|
+
$.pop();
|
|
15
|
+
}
|
|
@@ -7,10 +7,11 @@ export interface OverflowActionRegistration {
|
|
|
7
7
|
icon?: OverflowActionIcon;
|
|
8
8
|
disabled: boolean;
|
|
9
9
|
href?: string;
|
|
10
|
+
target?: string;
|
|
11
|
+
rel?: string;
|
|
10
12
|
execute: (event?: MouseEvent) => void;
|
|
11
13
|
getElement: () => HTMLElement | undefined;
|
|
12
|
-
|
|
13
|
-
getCompactMeasureElement: () => HTMLElement | undefined;
|
|
14
|
+
getWidth: (mode: "full" | "compact") => number;
|
|
14
15
|
}
|
|
15
16
|
export interface OverflowActionsContext {
|
|
16
17
|
register: (action: OverflowActionRegistration) => () => void;
|
|
@@ -103,6 +103,16 @@
|
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
+
@media (prefers-reduced-motion: reduce) {
|
|
107
|
+
:where([data-snowui-frame]) {
|
|
108
|
+
animation: none !important;
|
|
109
|
+
transition: none !important;
|
|
110
|
+
}
|
|
111
|
+
:where(.snowui-frame-state-content-layer) {
|
|
112
|
+
transition: none !important;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
106
116
|
/* === Hoverable 工具类 (hover 叠加反馈 + 交互态手形指针) ===
|
|
107
117
|
语义:hoverable 表示该元素响应 hover、属于可交互元素。
|
|
108
118
|
消费方(Avatar / Image / Button 等)只需条件加 .snowui-hoverable,
|
|
@@ -130,13 +140,13 @@
|
|
|
130
140
|
transition: var(--snowui-frame-shared-transition);
|
|
131
141
|
}
|
|
132
142
|
|
|
133
|
-
:where(.snowui-hoverable:hover:not(.snowui-disabled):not([data-disabled="true"]):not(:disabled)) {
|
|
143
|
+
:where(.snowui-hoverable:hover:not(.snowui-disabled):not([data-disabled="true"]):not([aria-disabled="true"]):not(:disabled)) {
|
|
134
144
|
/* 仅更新 overlay 透明度变量;background-image 引用它自动更新,无需重新声明 background-image */
|
|
135
145
|
--snowui-hover-overlay-opacity: var(--snowui-hover-opacity, var(--snowui-frame-hover-opacity, 4%));
|
|
136
146
|
}
|
|
137
147
|
|
|
138
148
|
/* Dark Mode 补偿 */
|
|
139
|
-
:where([theme="dark"] .snowui-hoverable:hover:not(.snowui-disabled):not([data-disabled="true"]):not(:disabled)) {
|
|
149
|
+
:where([theme="dark"] .snowui-hoverable:hover:not(.snowui-disabled):not([data-disabled="true"]):not([aria-disabled="true"]):not(:disabled)) {
|
|
140
150
|
--snowui-frame-hover-opacity: 10%;
|
|
141
151
|
}
|
|
142
152
|
}
|
|
@@ -18,6 +18,7 @@ import Frame from "../components/Frame.js";
|
|
|
18
18
|
import SidebarSection from "./SidebarSection.js";
|
|
19
19
|
import SidebarItem from "./SidebarItem.js";
|
|
20
20
|
import { SIDEBAR_CONTEXT_KEY } from "./sidebar-context.js";
|
|
21
|
+
import { useLocale } from "../i18n/locale.js";
|
|
21
22
|
|
|
22
23
|
const $$css = {
|
|
23
24
|
hash: 'svelte-1ndms6a',
|
|
@@ -67,6 +68,8 @@ export default function Sidebar($$renderer, $$props) {
|
|
|
67
68
|
...rest
|
|
68
69
|
} = $$props;
|
|
69
70
|
|
|
71
|
+
const localeContext = useLocale();
|
|
72
|
+
|
|
70
73
|
// 可绑定 Prop 负责输入/回传,本地 state 保持连续交互时的显示状态。
|
|
71
74
|
let isCollapsed = untrack(() => collapsed ?? defaultCollapsed);
|
|
72
75
|
|
|
@@ -358,18 +361,29 @@ export default function Sidebar($$renderer, $$props) {
|
|
|
358
361
|
|
|
359
362
|
collapsedSections = restoredCollapsedSections;
|
|
360
363
|
|
|
361
|
-
|
|
362
|
-
|
|
364
|
+
const targetItemId = activeItemId ?? restored.activeItemId;
|
|
365
|
+
const targetItem = targetItemId ? findItem(targetItemId) : undefined;
|
|
366
|
+
|
|
367
|
+
const targetSectionId = targetItemId
|
|
368
|
+
? targetItem
|
|
369
|
+
? findItemSectionId(targetItemId)
|
|
370
|
+
: targetItemId === restored.activeItemId ? restored.activeItemSectionId : undefined
|
|
371
|
+
: undefined;
|
|
372
|
+
|
|
373
|
+
if (targetSectionId && collapsedSections[targetSectionId] === true) {
|
|
374
|
+
collapsedSections = { ...collapsedSections, [targetSectionId]: false };
|
|
363
375
|
}
|
|
364
376
|
|
|
365
377
|
await tick();
|
|
366
378
|
|
|
367
|
-
if (restored.activeItemId && findItem(restored.activeItemId)) {
|
|
379
|
+
if (!activeItemId && restored.activeItemId && findItem(restored.activeItemId)) {
|
|
368
380
|
internalActiveItemId = restored.activeItemId;
|
|
369
|
-
activeItemSectionId = findItemSectionId(restored.activeItemId)
|
|
381
|
+
activeItemSectionId = findItemSectionId(restored.activeItemId);
|
|
370
382
|
onActiveItemChange?.(restored.activeItemId);
|
|
371
383
|
await tick();
|
|
372
384
|
expandActiveItemSection(restored.activeItemId);
|
|
385
|
+
} else if (activeItemId) {
|
|
386
|
+
activeItemSectionId = findItem(activeItemId) ? findItemSectionId(activeItemId) : targetSectionId;
|
|
373
387
|
} else {
|
|
374
388
|
collapsedSections = restoredCollapsedSections;
|
|
375
389
|
}
|
|
@@ -588,7 +602,7 @@ export default function Sidebar($$renderer, $$props) {
|
|
|
588
602
|
minSize: minWidth,
|
|
589
603
|
maxSize: maxWidth,
|
|
590
604
|
applySize: false,
|
|
591
|
-
ariaLabel:
|
|
605
|
+
ariaLabel: localeContext.t("sidebar.resize"),
|
|
592
606
|
onResizeStart: startWidthResize,
|
|
593
607
|
onSizeChange: handleWidthChange,
|
|
594
608
|
onResizeEnd: (next) => void finishWidthResize(next)
|
|
@@ -46,7 +46,9 @@ export default function SidebarSection($$renderer, $$props) {
|
|
|
46
46
|
const next = !isCollapsed();
|
|
47
47
|
|
|
48
48
|
internalCollapsed = next;
|
|
49
|
-
|
|
49
|
+
|
|
50
|
+
if (collapsed !== undefined) collapsed = next;
|
|
51
|
+
|
|
50
52
|
sidebar?.setSectionCollapsed(id, next);
|
|
51
53
|
onCollapsedChange?.(next);
|
|
52
54
|
}
|
|
@@ -3,6 +3,7 @@ import { setContext } from "svelte";
|
|
|
3
3
|
import Frame from "./Frame.js";
|
|
4
4
|
import Button from "./Button.js";
|
|
5
5
|
import Text from "./Text.js";
|
|
6
|
+
import ComponentPartsBoundary from "../logic/ComponentPartsBoundary.js";
|
|
6
7
|
import { BREADCRUMB_CONTEXT_KEY, BUTTON_COLLECTION_CONTEXT_KEY } from "../context.js";
|
|
7
8
|
|
|
8
9
|
const $$css = {
|
|
@@ -247,8 +248,14 @@ export default function Breadcrumb($$renderer, $$props) {
|
|
|
247
248
|
children: ($$renderer) => {
|
|
248
249
|
if (children) {
|
|
249
250
|
$$renderer.push('<!--[0-->');
|
|
250
|
-
|
|
251
|
-
$$renderer
|
|
251
|
+
|
|
252
|
+
ComponentPartsBoundary($$renderer, {
|
|
253
|
+
children: ($$renderer) => {
|
|
254
|
+
children($$renderer);
|
|
255
|
+
$$renderer.push(`<!---->`);
|
|
256
|
+
},
|
|
257
|
+
$$slots: { default: true }
|
|
258
|
+
});
|
|
252
259
|
} else {
|
|
253
260
|
$$renderer.push('<!--[-1-->');
|
|
254
261
|
$$renderer.push(`<!--[-->`);
|
|
@@ -830,7 +830,7 @@ export default function CircularChart($$renderer, $$props) {
|
|
|
830
830
|
skeleton: false,
|
|
831
831
|
class: ["snowui-circular-chart", userClass].filter(Boolean).join(" "),
|
|
832
832
|
style: rootStyle(),
|
|
833
|
-
role: '
|
|
833
|
+
role: 'group',
|
|
834
834
|
'aria-label': '圆形图表',
|
|
835
835
|
get element() {
|
|
836
836
|
return rootElement;
|
|
@@ -842,7 +842,7 @@ export default function CircularChart($$renderer, $$props) {
|
|
|
842
842
|
},
|
|
843
843
|
|
|
844
844
|
children: ($$renderer) => {
|
|
845
|
-
$$renderer.push(`<div class="snowui-circular-chart-body"><svg class="snowui-circular-chart-svg"${$.attr('viewBox', `0 0 ${numericSize()} ${numericSize()}`)}
|
|
845
|
+
$$renderer.push(`<div class="snowui-circular-chart-body"><svg class="snowui-circular-chart-svg"${$.attr('viewBox', `0 0 ${numericSize()} ${numericSize()}`)} role="presentation"><defs><!--[-->`);
|
|
846
846
|
|
|
847
847
|
const each_array = $.ensure_array_like(segmentPaints());
|
|
848
848
|
|
|
@@ -3,8 +3,10 @@ import { formatCodeBlock } from "../internal/code-block/format.js";
|
|
|
3
3
|
import Frame from "./Frame.js";
|
|
4
4
|
import Indicator from "./Indicator.js";
|
|
5
5
|
import CopyButton from "./CopyButton.js";
|
|
6
|
+
import { useLocale } from "../i18n/locale.js";
|
|
6
7
|
import { resizeManager } from "../logic/observer.js";
|
|
7
8
|
import { useOverlayScrollbar } from "../lib/overlay-scrollbar.js";
|
|
9
|
+
import ComponentPartsBoundary from "../logic/ComponentPartsBoundary.js";
|
|
8
10
|
import { captureFlipRect, beginFlipEnter, applyFlipExit } from "../logic/layout-flip.js";
|
|
9
11
|
import ExpandButton from "./ExpandButton.js";
|
|
10
12
|
import { ComponentIcon } from "../internal/component-icon/index.js";
|
|
@@ -13,7 +15,7 @@ let codeBlockInstanceSeed = 0;
|
|
|
13
15
|
|
|
14
16
|
const $$css = {
|
|
15
17
|
hash: 'svelte-ipr7k2',
|
|
16
|
-
code: '\n /* ─── Level 2:组件基类(降权 0,0,0) ─── */:where(.snowui-code-block) {--snowui-code-block-bg: var(--background-2, #f9f9fa);--snowui-code-block-fg: var(--black-100, #000000ff);--snowui-code-block-muted-fg: var(--black-40, #00000066);--snowui-code-block-gutter-fg: var(--black-20, #00000033);--snowui-code-block-btn-fg: var(--black-100, #000000ff);--snowui-code-block-keyword-fg: #ff32c6;--snowui-code-block-function-fg: #ffac60;--snowui-code-block-property-fg: #1ac69c;--snowui-code-block-string-fg: #3fa4ff;--snowui-code-block-variable-fg: #c478ff;--snowui-code-block-radius: var(--radius-4);--snowui-code-block-padding-x: var(--padding-5);--snowui-code-block-padding-y: var(--padding-5);--snowui-code-block-gap: var(--gap-2);--snowui-code-block-code-gap: var(--gap-3);--snowui-code-block-footer-height: var(--padding-3);--snowui-code-block-font-size: var(--text-12);--snowui-code-block-line-height: var(--leading-12);--snowui-code-block-font-family: inherit;--snowui-code-block-visible-lines: 5;--snowui-code-block-content-height: calc(\n var(--snowui-code-block-visible-lines) * 1lh\n );background-color:var(\n --snowui-code-block-bg-override,\n var(--snowui-code-block-bg)\n );color:var(\n --snowui-code-block-fg-override,\n var(--snowui-code-block-fg)\n );border-radius:var(\n --snowui-code-block-radius-override,\n var(--snowui-code-block-radius)\n );padding:var(\n --snowui-code-block-padding-override,\n var(\n --snowui-code-block-padding-y-override,\n var(--snowui-code-block-padding-y)\n )\n var(\n --snowui-code-block-padding-x-override,\n var(--snowui-code-block-padding-x)\n )\n );font-size:var(--snowui-code-block-font-size);line-height:var(--snowui-code-block-line-height);font-family:var(--snowui-code-block-font-family);overflow:hidden;position:relative;width:100%;}:where(.snowui-code-block[data-variant="default"]) {display:flex;flex-direction:column;gap:var(--gap-2);}\n\n /* singleLine:沿用 Input 的 Leading / Content / Trailing 三槽结构。 */:where(.snowui-code-block[data-variant="singleLine"]) {--snowui-code-block-padding-x: var(--padding-4);--snowui-code-block-padding-y: var(--padding-3);gap:var(\n --snowui-code-block-gap-override,\n var(--snowui-code-block-gap)\n );box-sizing:border-box;height:auto;}:where(.snowui-code-block-single-line-content) {grid-row:1;min-width:0;overflow-x:auto;overflow-y:hidden;white-space:nowrap;scrollbar-width:none;}:where(.snowui-code-block-single-line-content::-webkit-scrollbar) {display:none;}\n :where(\n .snowui-code-block[data-variant="singleLine"]\n > [data-as="leading"],\n .snowui-code-block[data-variant="singleLine"]\n > [data-as="trailing"]\n )\n {display:inline-flex;align-items:center;justify-content:center;min-width:0;white-space:nowrap;line-height:inherit;}:where(.snowui-code-block-fullscreen) {--snowui-code-block-bg: var(--background-2, #f9f9fa);--snowui-code-block-fg: var(--black-100, #000000ff);--snowui-code-block-muted-fg: var(--black-40, #00000066);--snowui-code-block-gutter-fg: var(--black-20, #00000033);--snowui-code-block-btn-fg: var(--black-100, #000000ff);--snowui-code-block-radius: var(--radius-4);--snowui-code-block-padding-x: var(--padding-5);--snowui-code-block-padding-y: var(--padding-5);--snowui-code-block-gap: var(--gap-2);--snowui-code-block-code-gap: var(--gap-3);--snowui-code-block-footer-height: var(--padding-3);--snowui-code-block-font-size: var(--text-12);--snowui-code-block-line-height: var(--leading-12);--snowui-code-block-font-family: inherit;--snowui-code-block-content-height: 5lh;}\n\n /* ─── 工具栏 ─── */:where(.snowui-code-block-toolbar) {display:flex;align-items:center;justify-content:space-between;gap:var(--gap-2);z-index:3;}:where(.snowui-code-block-lang) {color:var(--snowui-code-block-muted-fg);user-select:none;}:where(.snowui-code-block-actions) {display:flex;align-items:center;gap:var(\n --snowui-code-block-gap-override,\n var(--snowui-code-block-gap)\n );}\n\n /* ─── 图标按钮:统一使用 CopyButton / ExpandButton 的 bare 默认尺寸 ─── */:where(button).snowui-code-block-btn {--snowui-field-focus-ring-width: 0;color:var(--snowui-code-block-btn-fg);transition:color var(--snowui-frame-color-motion-duration, 0.15s)\n var(--snowui-frame-color-motion-easing, ease-out);}\n :where(button).snowui-code-block-btn:focus,\n :where(button).snowui-code-block-btn:focus-visible\n {outline:none;box-shadow:none;}:where(button).snowui-code-block-btn:hover:not(:disabled) {background-image:none;box-shadow:none;}\n\n /* ─── 代码主体区域 ─── */:where(.snowui-code-block-scroll-shell) {position:relative;height:var(\n --snowui-code-block-content-height-override,\n var(--snowui-code-block-content-height)\n );min-height:0;overflow:clip;background:transparent;}:where(.snowui-code-block[data-resized="true"] .snowui-code-block-scroll-shell) {flex:1 1 0;height:auto;}\n\n /* 上下滚动渐隐:接入「内容渐隐层」通用能力的 CSS 静态形态(.snowui-scroll-mask,见 lib/edge-fade.md)。 */:where(.snowui-code-block-body) {--snowui-code-block-scroll-mask-size: var(\n --snowui-code-block-scroll-mask-size-override,\n 32px\n );display:flex;align-items:flex-start;gap:var(\n --snowui-code-block-code-gap-override,\n var(--snowui-code-block-code-gap)\n );flex:1 1 0;height:100%;overflow-x:auto;min-height:0;background:transparent;}\n\n /* ─── 行号槽 ─── */:where(.snowui-code-block-gutter) {display:block;flex-shrink:0;width:max-content;color:var(--snowui-code-block-gutter-fg);background:transparent;text-align:right;user-select:none;font:inherit;}:where(.snowui-code-block-line-number) {display:block;line-height:inherit;}:where(.snowui-code-block-pre-wrap) {flex:1 1 0;min-width:0;overflow:visible;background:transparent;}:where(.snowui-code-block-pre) {box-sizing:border-box;margin:0;tab-size:4;white-space:pre;overflow:visible;background:transparent;font:inherit;}:where(.snowui-code-block-code) {box-sizing:border-box;display:block;color:inherit;background:transparent;border-radius:0;font:inherit;margin:0;padding:0;}\n :where(\n .snowui-code-block[data-variant="singleLine"]\n .snowui-code-block-pre\n )\n {white-space:nowrap;}\n :where(\n .snowui-code-block[data-variant="singleLine"]\n .snowui-code-block-code\n )\n {display:inline;}:where(.snowui-code-block-line) {display:block;line-height:inherit;}:where(.snowui-code-block-token-comment) {color:var(--black-40, #00000066);}:where(.snowui-code-block-token-keyword) {color:#ff32c6;}:where(.snowui-code-block-token-function) {color:#ffac60;}:where(.snowui-code-block-token-property) {color:#1ac69c;}:where(.snowui-code-block-token-string) {color:#3fa4ff;}:where(.snowui-code-block-token-variable) {color:#c478ff;}\n\n /* ─── 全屏覆盖层 ─── */:where(.snowui-code-block-fullscreen) {position:fixed;inset:0;z-index:9999;display:flex;flex-direction:column;font-size:var(--snowui-code-block-font-size);line-height:var(--snowui-code-block-line-height);font-family:var(--snowui-code-block-font-family);background-color:var(\n --snowui-code-block-bg-override,\n var(--snowui-code-block-bg)\n );color:var(\n --snowui-code-block-fg-override,\n var(--snowui-code-block-fg)\n );border-radius:0;padding:var(\n --snowui-code-block-padding-override,\n var(\n --snowui-code-block-padding-y-override,\n var(--snowui-code-block-padding-y)\n )\n var(\n --snowui-code-block-padding-x-override,\n var(--snowui-code-block-padding-x)\n )\n );}\n\n /* 全屏工具栏与普通态保持一致:距上/右 8px。 */:where(.snowui-code-block-toolbar-fullscreen) {padding:0;}:where(.snowui-code-block-body-fullscreen) {padding-bottom:max(var(--padding-0), env(safe-area-inset-bottom));}:where(.snowui-code-block-scroll-shell-fullscreen) {flex:1 1 0;height:auto;}\n\n /* 组件只声明轨道定位;视觉样式由 scrollbar.css 的 .snowui-overlay-scrollbar 承接。 */\n /* 滚动条提升到根容器(position:relative),绕开 scroll-shell 的 overflow:clip 裁切。 */\n /* top/bottom 对齐 scroll-shell 上下边缘(即容器 padding-y 处),right: 4px 贴近右边缘。 */:where(.snowui-code-block-scrollbar[data-axis="vertical"]) {top:var(\n --snowui-code-block-padding-y-override,\n var(--snowui-code-block-padding-y)\n );right:4px;bottom:var(--snowui-code-block-footer-height);z-index:2;}:where(.snowui-code-block-accessories) {position:absolute;width:0;height:0;overflow:hidden;pointer-events:none;opacity:0;}\n\n /* ─── 内置 SVG 图标基础样式 ─── */:where(.snowui-code-block-icon-builtin),\n :where(.snowui-code-block-icon-custom) {display:block;flex-shrink:0;color:inherit;}:where(.snowui-code-block-icon-custom > *) {display:block;}:where(.snowui-code-block-trailing-custom) {display:inline-flex;align-items:center;justify-content:center;color:inherit;}:where(.snowui-code-block-trailing-custom > *) {display:inline-flex;}'
|
|
18
|
+
code: '\n /* ─── Level 2:组件基类(降权 0,0,0) ─── */:where(.snowui-code-block) {--snowui-code-block-bg: var(--background-2, #f9f9fa);--snowui-code-block-fg: var(--black-100, #000000ff);--snowui-code-block-muted-fg: var(--black-40, #00000066);--snowui-code-block-gutter-fg: var(--black-20, #00000033);--snowui-code-block-btn-fg: var(--black-100, #000000ff);--snowui-code-block-keyword-fg: #ff32c6;--snowui-code-block-function-fg: #ffac60;--snowui-code-block-property-fg: #1ac69c;--snowui-code-block-string-fg: #3fa4ff;--snowui-code-block-variable-fg: #c478ff;--snowui-code-block-radius: var(--radius-4);--snowui-code-block-padding-x: var(--padding-5);--snowui-code-block-padding-y: var(--padding-5);--snowui-code-block-gap: var(--gap-2);--snowui-code-block-code-gap: var(--gap-3);--snowui-code-block-footer-height: var(--padding-3);--snowui-code-block-font-size: var(--text-12);--snowui-code-block-line-height: var(--leading-12);--snowui-code-block-font-family: inherit;--snowui-code-block-visible-lines: 5;--snowui-code-block-content-height: calc(\n var(--snowui-code-block-visible-lines) * 1lh\n );background-color:var(\n --snowui-code-block-bg-override,\n var(--snowui-code-block-bg)\n );color:var(\n --snowui-code-block-fg-override,\n var(--snowui-code-block-fg)\n );border-radius:var(\n --snowui-code-block-radius-override,\n var(--snowui-code-block-radius)\n );padding:var(\n --snowui-code-block-padding-override,\n var(\n --snowui-code-block-padding-y-override,\n var(--snowui-code-block-padding-y)\n )\n var(\n --snowui-code-block-padding-x-override,\n var(--snowui-code-block-padding-x)\n )\n );font-size:var(--snowui-code-block-font-size);line-height:var(--snowui-code-block-line-height);font-family:var(--snowui-code-block-font-family);overflow:hidden;position:relative;width:100%;}:where(.snowui-code-block[data-variant="default"]) {display:flex;flex-direction:column;gap:var(--gap-2);}\n\n /* singleLine:沿用 Input 的 Leading / Content / Trailing 三槽结构。 */:where(.snowui-code-block[data-variant="singleLine"]) {--snowui-code-block-padding-x: var(--padding-4);--snowui-code-block-padding-y: var(--padding-3);gap:var(\n --snowui-code-block-gap-override,\n var(--snowui-code-block-gap)\n );box-sizing:border-box;height:auto;}:where(.snowui-code-block-single-line-content) {grid-row:1;min-width:0;overflow-x:auto;overflow-y:hidden;white-space:nowrap;scrollbar-width:none;}:where(.snowui-code-block-single-line-content::-webkit-scrollbar) {display:none;}\n :where(\n .snowui-code-block[data-variant="singleLine"]\n > [data-as="leading"],\n .snowui-code-block[data-variant="singleLine"]\n > [data-as="trailing"]\n )\n {display:inline-flex;align-items:center;justify-content:center;min-width:0;white-space:nowrap;line-height:inherit;}:where(.snowui-code-block-fullscreen) {--snowui-code-block-bg: var(--background-2, #f9f9fa);--snowui-code-block-fg: var(--black-100, #000000ff);--snowui-code-block-muted-fg: var(--black-40, #00000066);--snowui-code-block-gutter-fg: var(--black-20, #00000033);--snowui-code-block-btn-fg: var(--black-100, #000000ff);--snowui-code-block-radius: var(--radius-4);--snowui-code-block-padding-x: var(--padding-5);--snowui-code-block-padding-y: var(--padding-5);--snowui-code-block-gap: var(--gap-2);--snowui-code-block-code-gap: var(--gap-3);--snowui-code-block-footer-height: var(--padding-3);--snowui-code-block-font-size: var(--text-12);--snowui-code-block-line-height: var(--leading-12);--snowui-code-block-font-family: inherit;--snowui-code-block-content-height: 5lh;}\n\n /* ─── 工具栏 ─── */:where(.snowui-code-block-toolbar) {display:flex;align-items:center;justify-content:space-between;gap:var(--gap-2);max-width:calc(100% - var(--size-3));z-index:3;}:where(.snowui-code-block-lang) {color:var(--snowui-code-block-muted-fg);min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;user-select:none;}:where(.snowui-code-block-actions) {display:flex;align-items:center;flex-shrink:0;gap:var(\n --snowui-code-block-gap-override,\n var(--snowui-code-block-gap)\n );}\n\n /* 默认态与全屏态各按钮独立拥有背景与命中区;singleLine 保留行内 trailing。 */:where(.snowui-code-block-toolbar button).snowui-code-block-btn {--snowui-field-focus-ring-width: 0;--snowui-button-padding-override: var(--padding-1) var(--padding-2);--snowui-button-radius-override: var(--radius-2);--snowui-button-background-override: var(--black-20, #00000033);color:var(--snowui-code-block-btn-fg);backdrop-filter:blur(20px);-webkit-backdrop-filter:blur(20px);transition:color var(--snowui-frame-color-motion-duration, 0.15s)\n var(--snowui-frame-color-motion-easing, ease-out);}\n :where(.snowui-code-block-toolbar button).snowui-code-block-btn:focus-visible\n {outline:2px solid var(--brand, #33d1ffff);outline-offset:1px;}:where(.snowui-code-block-toolbar button).snowui-code-block-btn:hover:not(:disabled) {background-image:none;}\n\n /* ─── 代码主体区域 ─── */:where(.snowui-code-block-scroll-shell) {position:relative;height:var(\n --snowui-code-block-content-height-override,\n var(--snowui-code-block-content-height)\n );min-height:0;overflow:clip;background:transparent;}:where(.snowui-code-block[data-resized="true"] .snowui-code-block-scroll-shell) {flex:1 1 0;height:auto;}\n\n /* 上下滚动渐隐:接入「内容渐隐层」通用能力的 CSS 静态形态(.snowui-scroll-mask,见 lib/edge-fade.md)。 */:where(.snowui-code-block-body) {--snowui-code-block-scroll-mask-size: var(\n --snowui-code-block-scroll-mask-size-override,\n 32px\n );display:flex;align-items:flex-start;gap:var(\n --snowui-code-block-code-gap-override,\n var(--snowui-code-block-code-gap)\n );flex:1 1 0;height:100%;overflow-x:auto;min-height:0;background:transparent;}\n\n /* ─── 行号槽 ─── */:where(.snowui-code-block-gutter) {display:block;flex-shrink:0;width:max-content;color:var(--snowui-code-block-gutter-fg);background:transparent;text-align:right;user-select:none;font:inherit;}:where(.snowui-code-block-line-number) {display:block;line-height:inherit;}:where(.snowui-code-block-pre-wrap) {flex:1 1 0;min-width:0;overflow:visible;background:transparent;}:where(.snowui-code-block-pre) {box-sizing:border-box;margin:0;tab-size:4;white-space:pre;overflow:visible;background:transparent;font:inherit;}:where(.snowui-code-block-code) {box-sizing:border-box;display:block;color:inherit;background:transparent;border-radius:0;font:inherit;margin:0;padding:0;}\n :where(\n .snowui-code-block[data-variant="singleLine"]\n .snowui-code-block-pre\n )\n {white-space:nowrap;}\n :where(\n .snowui-code-block[data-variant="singleLine"]\n .snowui-code-block-code\n )\n {display:inline;}:where(.snowui-code-block-line) {display:block;line-height:inherit;}:where(.snowui-code-block-token-comment) {color:var(--black-40, #00000066);}:where(.snowui-code-block-token-keyword) {color:#ff32c6;}:where(.snowui-code-block-token-function) {color:#ffac60;}:where(.snowui-code-block-token-property) {color:#1ac69c;}:where(.snowui-code-block-token-string) {color:#3fa4ff;}:where(.snowui-code-block-token-variable) {color:#c478ff;}\n\n /* ─── 全屏覆盖层 ─── */:where(.snowui-code-block-fullscreen) {position:fixed;inset:0;z-index:9999;display:flex;flex-direction:column;font-size:var(--snowui-code-block-font-size);line-height:var(--snowui-code-block-line-height);font-family:var(--snowui-code-block-font-family);background-color:var(\n --snowui-code-block-bg-override,\n var(--snowui-code-block-bg)\n );color:var(\n --snowui-code-block-fg-override,\n var(--snowui-code-block-fg)\n );border-radius:0;padding:var(\n --snowui-code-block-padding-override,\n var(\n --snowui-code-block-padding-y-override,\n var(--snowui-code-block-padding-y)\n )\n var(\n --snowui-code-block-padding-x-override,\n var(--snowui-code-block-padding-x)\n )\n );}:where(.snowui-code-block[data-top-actions="true"]),\n :where(.snowui-code-block-fullscreen) {padding-top:calc(\n var(--snowui-code-block-padding-y-override, var(--snowui-code-block-padding-y))\n + var(--padding-4)\n );}\n\n /* 全屏工具栏与普通态保持一致:距上/右 8px。 */:where(.snowui-code-block-toolbar-fullscreen) {padding:0;}:where(.snowui-code-block-body-fullscreen) {padding-bottom:max(var(--padding-0), env(safe-area-inset-bottom));}:where(.snowui-code-block-scroll-shell-fullscreen) {flex:1 1 0;height:auto;}\n\n /* 组件只声明轨道定位;视觉样式由 scrollbar.css 的 .snowui-overlay-scrollbar 承接。 */\n /* 滚动条提升到根容器(position:relative),绕开 scroll-shell 的 overflow:clip 裁切。 */\n /* top/bottom 对齐 scroll-shell 上下边缘(即容器 padding-y 处),right: 4px 贴近右边缘。 */:where(.snowui-code-block-scrollbar[data-axis="vertical"]) {top:var(\n --snowui-code-block-padding-y-override,\n var(--snowui-code-block-padding-y)\n );right:4px;bottom:var(--snowui-code-block-footer-height);z-index:2;}:where(.snowui-code-block[data-top-actions="true"] .snowui-code-block-scrollbar[data-axis="vertical"]),\n :where(.snowui-code-block-fullscreen .snowui-code-block-scrollbar[data-axis="vertical"]) {top:calc(var(--padding-2) + var(--size-6) + var(--padding-1));}:where(.snowui-code-block-accessories) {position:absolute;width:0;height:0;overflow:hidden;pointer-events:none;opacity:0;}\n\n /* ─── 内置 SVG 图标基础样式 ─── */:where(.snowui-code-block-icon-builtin),\n :where(.snowui-code-block-icon-custom) {display:block;flex-shrink:0;color:inherit;}:where(.snowui-code-block-icon-custom > *) {display:block;}:where(.snowui-code-block-trailing-custom) {display:inline-flex;align-items:center;justify-content:center;color:inherit;}:where(.snowui-code-block-trailing-custom > *) {display:inline-flex;}'
|
|
17
19
|
};
|
|
18
20
|
|
|
19
21
|
export default function CodeBlock($$renderer, $$props) {
|
|
@@ -127,6 +129,7 @@ export default function CodeBlock($$renderer, $$props) {
|
|
|
127
129
|
/* ─── 内部状态 ─── */
|
|
128
130
|
const fullscreenMotionId = `code-block-fullscreen-${++codeBlockInstanceSeed}`;
|
|
129
131
|
|
|
132
|
+
const localeContext = useLocale();
|
|
130
133
|
let isFullscreen = false;
|
|
131
134
|
let isExitingFullscreen = false;
|
|
132
135
|
|
|
@@ -485,6 +488,7 @@ export default function CodeBlock($$renderer, $$props) {
|
|
|
485
488
|
className
|
|
486
489
|
].filter(Boolean).join(" "),
|
|
487
490
|
'data-variant': variant,
|
|
491
|
+
'data-top-actions': !isSingleLine() && (showLanguage && language || showCopyButton || showExpandButton || hasCustomTrailing) ? "true" : undefined,
|
|
488
492
|
'data-resized': !isSingleLine() && resizeHeight !== undefined ? "true" : undefined,
|
|
489
493
|
style: rootStyle(),
|
|
490
494
|
renderHints: {
|
|
@@ -542,7 +546,7 @@ export default function CodeBlock($$renderer, $$props) {
|
|
|
542
546
|
icon: hasCustomCopyIcon ? normalizeActionSnippet(copyIconSnippet) : undefined,
|
|
543
547
|
successIcon: hasCustomCopiedIcon ? normalizeActionSnippet(copiedIconSnippet) : undefined,
|
|
544
548
|
class: 'snowui-code-block-btn snowui-hoverable',
|
|
545
|
-
ariaLabel:
|
|
549
|
+
ariaLabel: localeContext.t("codeBlock.copyCode")
|
|
546
550
|
});
|
|
547
551
|
|
|
548
552
|
$$renderer.push(`<!----></div>`);
|
|
@@ -553,7 +557,7 @@ export default function CodeBlock($$renderer, $$props) {
|
|
|
553
557
|
$$renderer.push(`<!--]-->`);
|
|
554
558
|
} else {
|
|
555
559
|
$$renderer.push('<!--[-1-->');
|
|
556
|
-
$$renderer.push(`<div class="snowui-code-block-toolbar snowui-code-block-default-pin-top-right" data-as="pin-top-right" style="--pin-offset: var(--padding-
|
|
560
|
+
$$renderer.push(`<div class="snowui-code-block-toolbar snowui-code-block-default-pin-top-right" data-as="pin-top-right" style="--pin-offset-y: var(--padding-2); --pin-offset-x: var(--padding-1);">`);
|
|
557
561
|
|
|
558
562
|
if (showLanguage && language) {
|
|
559
563
|
$$renderer.push('<!--[0-->');
|
|
@@ -582,7 +586,7 @@ export default function CodeBlock($$renderer, $$props) {
|
|
|
582
586
|
icon: hasCustomCopyIcon ? normalizeActionSnippet(copyIconSnippet) : undefined,
|
|
583
587
|
successIcon: hasCustomCopiedIcon ? normalizeActionSnippet(copiedIconSnippet) : undefined,
|
|
584
588
|
class: 'snowui-code-block-btn snowui-hoverable',
|
|
585
|
-
ariaLabel:
|
|
589
|
+
ariaLabel: localeContext.t("codeBlock.copyCode")
|
|
586
590
|
});
|
|
587
591
|
} else {
|
|
588
592
|
$$renderer.push('<!--[-1-->');
|
|
@@ -598,8 +602,8 @@ export default function CodeBlock($$renderer, $$props) {
|
|
|
598
602
|
bare: true,
|
|
599
603
|
emphasis: parts?.ExpandButton?.emphasis ?? "muted",
|
|
600
604
|
class: 'snowui-code-block-btn',
|
|
601
|
-
ariaLabel:
|
|
602
|
-
collapseAriaLabel:
|
|
605
|
+
ariaLabel: localeContext.t("codeBlock.fullscreen"),
|
|
606
|
+
collapseAriaLabel: localeContext.t("codeBlock.exitFullscreen"),
|
|
603
607
|
onclick: toggleFullscreen,
|
|
604
608
|
icon: hasCustomExpandIcon ? normalizeActionSnippet(expandIconSnippet) : undefined,
|
|
605
609
|
collapseIcon: hasCustomCollapseIcon
|
|
@@ -660,7 +664,7 @@ export default function CodeBlock($$renderer, $$props) {
|
|
|
660
664
|
appearance: 'corner',
|
|
661
665
|
applySize: false,
|
|
662
666
|
minSize: 60,
|
|
663
|
-
ariaLabel:
|
|
667
|
+
ariaLabel: localeContext.t("codeBlock.resize"),
|
|
664
668
|
onSizeChange: handleResizeSize
|
|
665
669
|
});
|
|
666
670
|
|
|
@@ -672,7 +676,15 @@ export default function CodeBlock($$renderer, $$props) {
|
|
|
672
676
|
if (children) {
|
|
673
677
|
$$renderer.push('<!--[0-->');
|
|
674
678
|
$$renderer.push(`<div class="snowui-code-block-accessories" aria-hidden="true">`);
|
|
675
|
-
|
|
679
|
+
|
|
680
|
+
ComponentPartsBoundary($$renderer, {
|
|
681
|
+
children: ($$renderer) => {
|
|
682
|
+
children($$renderer);
|
|
683
|
+
$$renderer.push(`<!---->`);
|
|
684
|
+
},
|
|
685
|
+
$$slots: { default: true }
|
|
686
|
+
});
|
|
687
|
+
|
|
676
688
|
$$renderer.push(`<!----></div>`);
|
|
677
689
|
} else {
|
|
678
690
|
$$renderer.push('<!--[-1-->');
|
|
@@ -694,7 +706,7 @@ export default function CodeBlock($$renderer, $$props) {
|
|
|
694
706
|
tag: 'div',
|
|
695
707
|
role: 'dialog',
|
|
696
708
|
'aria-modal': 'true',
|
|
697
|
-
'aria-label':
|
|
709
|
+
'aria-label': localeContext.t("codeBlock.fullscreenDialog"),
|
|
698
710
|
enableResponsive: false,
|
|
699
711
|
enableContext: false,
|
|
700
712
|
enableScaleObserver: false,
|
|
@@ -711,7 +723,7 @@ export default function CodeBlock($$renderer, $$props) {
|
|
|
711
723
|
},
|
|
712
724
|
|
|
713
725
|
children: ($$renderer) => {
|
|
714
|
-
$$renderer.push(`<div class="snowui-code-block-toolbar snowui-code-block-toolbar-fullscreen" data-as="pin-top-right" style="--pin-offset: var(--padding-
|
|
726
|
+
$$renderer.push(`<div class="snowui-code-block-toolbar snowui-code-block-toolbar-fullscreen" data-as="pin-top-right" style="--pin-offset-y: var(--padding-2); --pin-offset-x: var(--padding-1);">`);
|
|
715
727
|
|
|
716
728
|
if (showLanguage && language) {
|
|
717
729
|
$$renderer.push('<!--[0-->');
|
|
@@ -737,7 +749,7 @@ export default function CodeBlock($$renderer, $$props) {
|
|
|
737
749
|
icon: hasCustomCopyIcon ? normalizeActionSnippet(copyIconSnippet) : undefined,
|
|
738
750
|
successIcon: hasCustomCopiedIcon ? normalizeActionSnippet(copiedIconSnippet) : undefined,
|
|
739
751
|
class: 'snowui-code-block-btn snowui-hoverable',
|
|
740
|
-
ariaLabel:
|
|
752
|
+
ariaLabel: localeContext.t("codeBlock.copyCode")
|
|
741
753
|
});
|
|
742
754
|
} else {
|
|
743
755
|
$$renderer.push('<!--[-1-->');
|
|
@@ -753,8 +765,8 @@ export default function CodeBlock($$renderer, $$props) {
|
|
|
753
765
|
bare: true,
|
|
754
766
|
emphasis: parts?.ExpandButton?.emphasis ?? "muted",
|
|
755
767
|
class: 'snowui-code-block-btn',
|
|
756
|
-
ariaLabel:
|
|
757
|
-
collapseAriaLabel:
|
|
768
|
+
ariaLabel: localeContext.t("codeBlock.fullscreen"),
|
|
769
|
+
collapseAriaLabel: localeContext.t("codeBlock.exitFullscreen"),
|
|
758
770
|
onclick: exitFullscreen,
|
|
759
771
|
collapseIcon: hasCustomCollapseIcon
|
|
760
772
|
? normalizeActionSnippet(collapseIconSnippet)
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
|
|
12
12
|
import Frame from "./Frame.js";
|
|
13
13
|
import { writeClipboardText } from "../lib/clipboard.js";
|
|
14
|
+
import { useLocale } from "../i18n/locale.js";
|
|
14
15
|
import { mergeComponentPartProps, useComponentPart } from "../logic/component-parts.js";
|
|
15
16
|
|
|
16
17
|
const $$css = {
|
|
@@ -25,6 +26,7 @@ export default function CopyButton($$renderer, $$props) {
|
|
|
25
26
|
// SnowUI 许可入口:首次阅读源码请先读 ../../LICENSE;访问文件不代表获得修改或移植权,官方维护授权及同任务去重见该文件。
|
|
26
27
|
const inheritedCopyButtonPart = useComponentPart("CopyButton");
|
|
27
28
|
|
|
29
|
+
const localeContext = useLocale();
|
|
28
30
|
let { $$slots, $$events, ...explicitProps } = $$props;
|
|
29
31
|
|
|
30
32
|
let $$d = $.derived(() => mergeComponentPartProps(inheritedCopyButtonPart.current, explicitProps)),
|
|
@@ -138,7 +140,9 @@ export default function CopyButton($$renderer, $$props) {
|
|
|
138
140
|
disabled: disabled(),
|
|
139
141
|
'data-copy-button': true,
|
|
140
142
|
'data-copy-status': status,
|
|
141
|
-
'aria-label': ariaLabel() ?? (showText()
|
|
143
|
+
'aria-label': ariaLabel() ?? (showText()
|
|
144
|
+
? undefined
|
|
145
|
+
: localeContext.t(status === "success" ? "copyButton.copied" : "copyButton.copy")),
|
|
142
146
|
'aria-live': 'polite',
|
|
143
147
|
'aria-busy': status === "pending" ? "true" : undefined,
|
|
144
148
|
whileClick: status === "idle" ? userWhileClick() : false,
|
|
@@ -183,7 +187,7 @@ export default function CopyButton($$renderer, $$props) {
|
|
|
183
187
|
$$renderer.push(`<!---->`);
|
|
184
188
|
} else {
|
|
185
189
|
$$renderer.push('<!--[-1-->');
|
|
186
|
-
$$renderer.push(
|
|
190
|
+
$$renderer.push(`${$.escape(localeContext.t("copyButton.copy"))}`);
|
|
187
191
|
}
|
|
188
192
|
|
|
189
193
|
$$renderer.push(`<!--]-->`);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as $ from 'svelte/internal/server';
|
|
2
2
|
import { ComponentIcon } from "../internal/component-icon/index.js";
|
|
3
3
|
import Button from "./Button.js";
|
|
4
|
+
import { useLocale } from "../i18n/locale.js";
|
|
4
5
|
|
|
5
6
|
import {
|
|
6
7
|
CONTROL_BUTTON_REPLACEMENT_MOTION,
|
|
@@ -16,12 +17,13 @@ export default function ExpandButton($$renderer, $$props) {
|
|
|
16
17
|
// SnowUI 许可入口:首次阅读源码请先读 ../../LICENSE;访问文件不代表获得修改或移植权,官方维护授权及同任务去重见该文件。
|
|
17
18
|
const inheritedExpandButtonPart = useComponentPart("ExpandButton");
|
|
18
19
|
|
|
20
|
+
const localeContext = useLocale();
|
|
19
21
|
let { expanded = void 0, $$slots, $$events, ...explicitProps } = $$props;
|
|
20
22
|
|
|
21
23
|
let $$d = $.derived(() => mergeComponentPartProps(inheritedExpandButtonPart.current, explicitProps)),
|
|
22
24
|
defaultExpanded = $.derived(() => $.fallback($$d().defaultExpanded, false)),
|
|
23
|
-
ariaLabel = $.derived(() => $.fallback($$d().ariaLabel,
|
|
24
|
-
collapseAriaLabel = $.derived(() => $.fallback($$d().collapseAriaLabel,
|
|
25
|
+
ariaLabel = $.derived(() => $.fallback($$d().ariaLabel, undefined)),
|
|
26
|
+
collapseAriaLabel = $.derived(() => $.fallback($$d().collapseAriaLabel, undefined)),
|
|
25
27
|
icon = $.derived(() => $$d().icon),
|
|
26
28
|
collapseIcon = $.derived(() => $$d().collapseIcon),
|
|
27
29
|
children = $.derived(() => $$d().children),
|
|
@@ -69,7 +71,9 @@ export default function ExpandButton($$renderer, $$props) {
|
|
|
69
71
|
iconOnly: !rest().bare && !children(),
|
|
70
72
|
disabled: disabled(),
|
|
71
73
|
'aria-expanded': resolvedExpanded(),
|
|
72
|
-
'aria-label': resolvedExpanded()
|
|
74
|
+
'aria-label': resolvedExpanded()
|
|
75
|
+
? collapseAriaLabel() ?? localeContext.t("expandButton.collapse")
|
|
76
|
+
: ariaLabel() ?? localeContext.t("expandButton.expand"),
|
|
73
77
|
'data-expanded': resolvedExpanded() ? "true" : "false",
|
|
74
78
|
onclick: handleClick,
|
|
75
79
|
children: ($$renderer) => {
|
|
@@ -23,6 +23,7 @@ import { createFrameDomRuntime } from "../logic/frame-dom-runtime.js";
|
|
|
23
23
|
import { createFrameSkeletonRuntime } from "../logic/frame-skeleton-runtime.js";
|
|
24
24
|
import { createFrameClassStateRuntime } from "../logic/frame-class-state.js";
|
|
25
25
|
import { provideComponentParts } from "../logic/component-parts.js";
|
|
26
|
+
import ComponentPartsBoundary from "../logic/ComponentPartsBoundary.js";
|
|
26
27
|
import { initOrchestrator, getOrchestrator } from "../logic/frame-orchestrator.js";
|
|
27
28
|
import Skeleton from "./Skeleton.js";
|
|
28
29
|
|
|
@@ -265,14 +266,20 @@ export default function Frame($$renderer, $$props) {
|
|
|
265
266
|
for (let $$index_1 = 0, $$length = each_array_1.length; $$index_1 < $$length; $$index_1++) {
|
|
266
267
|
let [contentState, snippet] = each_array_1[$$index_1];
|
|
267
268
|
|
|
268
|
-
$$renderer.push(`<div${$.attr_style(`grid-area: 1 / 1; display: flex; flex-direction: inherit; align-items: inherit; justify-content: inherit; gap: inherit; opacity:${$.stringify(frameState.currentState === contentState ? 1 : 0)};transform:scale(${$.stringify(frameState.currentState === contentState ? 1 : 0.01)});transition:all ${frameState.currentState === contentState
|
|
269
|
+
$$renderer.push(`<div class="snowui-frame-state-content-layer"${$.attr_style(`grid-area: 1 / 1; display: flex; flex-direction: inherit; align-items: inherit; justify-content: inherit; gap: inherit; opacity:${$.stringify(frameState.currentState === contentState ? 1 : 0)};transform:scale(${$.stringify(frameState.currentState === contentState ? 1 : 0.01)});transition:all ${frameState.currentState === contentState
|
|
269
270
|
? `${FRAME_MOTION_DEFAULTS.contentCrossfadeIn.duration}ms ${FRAME_MOTION_DEFAULTS.contentCrossfadeIn.easing} ${FRAME_MOTION_DEFAULTS.contentCrossfadeIn.delay}ms`
|
|
270
271
|
: `${FRAME_MOTION_DEFAULTS.contentCrossfadeOut.duration}ms ${FRAME_MOTION_DEFAULTS.contentCrossfadeOut.easing}`};pointer-events:${frameState.currentState === contentState ? 'auto' : 'none'};`)}>`);
|
|
271
272
|
|
|
272
273
|
if (snippet) {
|
|
273
274
|
$$renderer.push('<!--[0-->');
|
|
274
|
-
|
|
275
|
-
$$renderer
|
|
275
|
+
|
|
276
|
+
ComponentPartsBoundary($$renderer, {
|
|
277
|
+
children: ($$renderer) => {
|
|
278
|
+
snippet($$renderer);
|
|
279
|
+
$$renderer.push(`<!---->`);
|
|
280
|
+
},
|
|
281
|
+
$$slots: { default: true }
|
|
282
|
+
});
|
|
276
283
|
} else {
|
|
277
284
|
$$renderer.push('<!--[-1-->');
|
|
278
285
|
}
|
|
@@ -824,7 +824,7 @@ export default function GaugeChart($$renderer, $$props) {
|
|
|
824
824
|
skeleton: false,
|
|
825
825
|
class: ["snowui-gauge-chart", userClass].filter(Boolean).join(" "),
|
|
826
826
|
style: rootStyle(),
|
|
827
|
-
role: '
|
|
827
|
+
role: 'group',
|
|
828
828
|
'aria-label': '仪表图',
|
|
829
829
|
get element() {
|
|
830
830
|
return rootElement;
|
|
@@ -836,7 +836,7 @@ export default function GaugeChart($$renderer, $$props) {
|
|
|
836
836
|
},
|
|
837
837
|
|
|
838
838
|
children: ($$renderer) => {
|
|
839
|
-
$$renderer.push(`<div class="snowui-gauge-chart-body"><svg class="snowui-gauge-chart-svg"${$.attr('viewBox', `0 0 ${numericWidth()} ${numericHeight()}`)}
|
|
839
|
+
$$renderer.push(`<div class="snowui-gauge-chart-body"><svg class="snowui-gauge-chart-svg"${$.attr('viewBox', `0 0 ${numericWidth()} ${numericHeight()}`)} role="presentation"><defs><!--[-->`);
|
|
840
840
|
|
|
841
841
|
const each_array = $.ensure_array_like(segmentPaints());
|
|
842
842
|
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
|
|
16
16
|
import { ComponentIcon } from "../internal/component-icon/index.js";
|
|
17
17
|
import { DIALOG_BACKDROP_MOTION_STYLE } from "../motion/presets/dialog.js";
|
|
18
|
+
import { useLocale } from "../i18n/locale.js";
|
|
18
19
|
|
|
19
20
|
const $$css = {
|
|
20
21
|
hash: 'svelte-1n4vb3j',
|
|
@@ -26,6 +27,8 @@ export default function ImageViewer($$renderer, $$props) {
|
|
|
26
27
|
|
|
27
28
|
$$renderer.component(($$renderer) => {
|
|
28
29
|
// SnowUI 许可入口:首次阅读源码请先读 ../../LICENSE;访问文件不代表获得修改或移植权,官方维护授权及同任务去重见该文件。
|
|
30
|
+
const localeContext = useLocale();
|
|
31
|
+
|
|
29
32
|
let {
|
|
30
33
|
open = undefined,
|
|
31
34
|
items = undefined,
|
|
@@ -312,7 +315,7 @@ export default function ImageViewer($$renderer, $$props) {
|
|
|
312
315
|
{
|
|
313
316
|
as: 'prev',
|
|
314
317
|
iconOnly: true,
|
|
315
|
-
'aria-label':
|
|
318
|
+
'aria-label': localeContext.t("imageViewer.previous"),
|
|
316
319
|
children: ($$renderer) => {
|
|
317
320
|
ComponentIcon($$renderer, { name: 'arrow-line-left', 'aria-hidden': 'true' });
|
|
318
321
|
},
|
|
@@ -327,7 +330,7 @@ export default function ImageViewer($$renderer, $$props) {
|
|
|
327
330
|
{
|
|
328
331
|
as: 'next',
|
|
329
332
|
iconOnly: true,
|
|
330
|
-
'aria-label':
|
|
333
|
+
'aria-label': localeContext.t("imageViewer.next"),
|
|
331
334
|
children: ($$renderer) => {
|
|
332
335
|
ComponentIcon($$renderer, { name: 'arrow-line-right', 'aria-hidden': 'true' });
|
|
333
336
|
},
|
|
@@ -345,7 +348,7 @@ export default function ImageViewer($$renderer, $$props) {
|
|
|
345
348
|
{
|
|
346
349
|
as: 'close',
|
|
347
350
|
iconOnly: true,
|
|
348
|
-
'aria-label':
|
|
351
|
+
'aria-label': localeContext.t("imageViewer.close"),
|
|
349
352
|
children: ($$renderer) => {
|
|
350
353
|
ComponentIcon($$renderer, { name: 'close', 'aria-hidden': 'true' });
|
|
351
354
|
},
|
|
@@ -3,6 +3,7 @@ import ComponentIcon from "../internal/component-icon/ComponentIcon.js";
|
|
|
3
3
|
import Frame from "./Frame.js";
|
|
4
4
|
import { resizable } from "../lib/resizable.js";
|
|
5
5
|
import { untrack } from "svelte";
|
|
6
|
+
import { useLocale } from "../i18n/locale.js";
|
|
6
7
|
import { mergeComponentPartProps, useComponentPart } from "../logic/component-parts.js";
|
|
7
8
|
|
|
8
9
|
let indicatorSeed = 0;
|
|
@@ -17,6 +18,7 @@ export default function Indicator($$renderer, $$props) {
|
|
|
17
18
|
|
|
18
19
|
$$renderer.component(($$renderer) => {
|
|
19
20
|
const inheritedIndicatorPart = useComponentPart("Indicator");
|
|
21
|
+
const localeContext = useLocale();
|
|
20
22
|
let { $$slots, $$events, ...explicitProps } = $$props;
|
|
21
23
|
|
|
22
24
|
let $$d = $.derived(() => mergeComponentPartProps(inheritedIndicatorPart.current, explicitProps)),
|
|
@@ -109,9 +111,9 @@ export default function Indicator($$renderer, $$props) {
|
|
|
109
111
|
const resolvedRevealTarget = $.derived(() => revealTarget() ?? resolvedTarget());
|
|
110
112
|
const isVisible = $.derived(() => hostHovered || focused || dragging);
|
|
111
113
|
|
|
112
|
-
const resolvedAriaLabel = $.derived(() => ariaLabel() ?? (resolvedAxis() === "width"
|
|
113
|
-
? "
|
|
114
|
-
: resolvedAxis() === "height" ? "
|
|
114
|
+
const resolvedAriaLabel = $.derived(() => ariaLabel() ?? localeContext.t(resolvedAxis() === "width"
|
|
115
|
+
? "indicator.resizeWidth"
|
|
116
|
+
: resolvedAxis() === "height" ? "indicator.resizeHeight" : "indicator.resizeBoth"));
|
|
115
117
|
|
|
116
118
|
const rootClass = $.derived(() => [
|
|
117
119
|
"snowui-indicator",
|