@snowui-design-system/components 0.1.0 → 0.2.0-alpha.3
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/README.md +1 -2
- package/package.json +6 -2
- package/src/components/Accordion.md +218 -0
- package/src/components/Accordion.svelte +301 -0
- package/src/components/Accordion.test.ts +126 -0
- package/src/components/AccordionItem.md +114 -0
- package/src/components/AccordionItem.svelte +389 -0
- package/src/components/AccordionItem.test.ts +52 -0
- package/src/components/Avatar.md +54 -36
- package/src/components/Avatar.svelte +73 -126
- package/src/components/AvatarGroup.md +17 -14
- package/src/components/AvatarGroup.svelte +12 -50
- package/src/components/AvatarGroup.test.ts +69 -68
- package/src/components/Badge.md +53 -8
- package/src/components/Badge.svelte +303 -79
- package/src/components/Badge.test.ts +47 -0
- package/src/components/Breadcrumb.md +164 -0
- package/src/components/Breadcrumb.svelte +330 -0
- package/src/components/Breadcrumb.test.ts +154 -0
- package/src/components/Button.md +243 -57
- package/src/components/Button.svelte +278 -177
- package/src/components/Button.test.ts +175 -86
- package/src/components/ButtonGroup.md +140 -0
- package/src/components/ButtonGroup.svelte +491 -0
- package/src/components/ButtonGroup.test.ts +58 -0
- package/src/components/Card.md +186 -0
- package/src/components/Card.svelte +408 -0
- package/src/components/Card.test.ts +193 -0
- package/src/components/Checkbox.md +14 -10
- package/src/components/Checkbox.svelte +39 -99
- package/src/components/Chip.md +185 -0
- package/src/components/Chip.svelte +241 -0
- package/src/components/Chip.test.ts +117 -0
- package/src/components/CodeBlock.md +29 -16
- package/src/components/CodeBlock.svelte +132 -352
- package/src/components/CodeBlock.test.ts +15 -1
- package/src/components/CopyButton.md +41 -0
- package/src/components/CopyButton.svelte +164 -0
- package/src/components/CopyButton.test.ts +26 -0
- package/src/components/Dialog.md +95 -0
- package/src/components/Dialog.svelte +416 -0
- package/src/components/Dialog.test.ts +145 -0
- package/src/components/ExpandButton.md +41 -0
- package/src/components/ExpandButton.svelte +103 -0
- package/src/components/ExpandButton.test.ts +18 -0
- package/src/components/Form.md +4 -3
- package/src/components/Form.test.ts +72 -73
- package/src/components/Frame.md +243 -0
- package/src/components/Frame.svelte +208 -87
- package/src/components/Frame.test.ts +121 -0
- package/src/components/Icon.md +34 -6
- package/src/components/Icon.svelte +46 -95
- package/src/components/Image.md +24 -13
- package/src/components/Image.svelte +42 -128
- package/src/components/ImageGroup.md +6 -7
- package/src/components/ImageGroup.svelte +1 -28
- package/src/components/Indicator.md +92 -0
- package/src/components/Indicator.svelte +490 -0
- package/src/components/Indicator.test.ts +57 -0
- package/src/components/Input.md +81 -28
- package/src/components/Input.svelte +291 -178
- package/src/components/Input.test.ts +85 -48
- package/src/components/Kbd.md +0 -3
- package/src/components/Kbd.svelte +0 -1
- package/src/components/Link.md +192 -0
- package/src/components/Link.svelte +464 -0
- package/src/components/Link.test.ts +110 -0
- package/src/components/Listbox.md +52 -10
- package/src/components/Listbox.svelte +204 -50
- package/src/components/Listbox.test.ts +76 -33
- package/src/components/LocaleProvider.md +52 -0
- package/src/components/LocaleProvider.svelte +30 -0
- package/src/components/LocaleProvider.test.ts +32 -0
- package/src/components/MenuItem.md +23 -9
- package/src/components/MenuItem.svelte +57 -47
- package/src/components/MenuItem.test.ts +72 -65
- package/src/components/Pagination.md +504 -0
- package/src/components/Pagination.svelte +958 -0
- package/src/components/Pagination.test.ts +316 -0
- package/src/components/Popover.md +245 -42
- package/src/components/Popover.svelte +558 -127
- package/src/components/Popover.test.ts +361 -44
- package/src/components/Progress.md +91 -0
- package/src/components/Progress.svelte +374 -0
- package/src/components/Progress.test.ts +56 -0
- package/src/components/Radio.md +4 -6
- package/src/components/Radio.svelte +25 -117
- package/src/components/ScrollArea.md +116 -0
- package/src/components/ScrollArea.svelte +180 -0
- package/src/components/ScrollArea.test.ts +84 -0
- package/src/components/SearchInput.md +135 -0
- package/src/components/SearchInput.svelte +153 -0
- package/src/components/SearchInput.test.ts +61 -0
- package/src/components/Select.md +39 -8
- package/src/components/Select.svelte +196 -45
- package/src/components/Select.test.ts +79 -41
- package/src/components/SelectButton.md +50 -0
- package/src/components/SelectButton.svelte +186 -0
- package/src/components/SelectButton.test.ts +142 -0
- package/src/components/Separator.md +89 -0
- package/src/components/Separator.svelte +143 -0
- package/src/components/Separator.test.ts +35 -0
- package/src/components/Skeleton.md +2 -5
- package/src/components/Skeleton.svelte +202 -7
- package/src/components/Skeleton.test.ts +10 -10
- package/src/components/Slider.md +101 -0
- package/src/components/Slider.svelte +566 -0
- package/src/components/Slider.test.ts +51 -0
- package/src/components/Spinner.md +3 -4
- package/src/components/Spinner.svelte +11 -23
- package/src/components/{Toggle.md → Switch.md} +20 -21
- package/src/components/Switch.svelte +314 -0
- package/src/components/Switch.test.ts +57 -0
- package/src/components/Table.md +249 -0
- package/src/components/Table.svelte +139 -0
- package/src/components/Table.test.ts +64 -0
- package/src/components/TableBody.md +63 -0
- package/src/components/TableBody.svelte +78 -0
- package/src/components/TableBody.test.ts +13 -0
- package/src/components/TableCell.md +89 -0
- package/src/components/TableCell.svelte +368 -0
- package/src/components/TableCell.test.ts +51 -0
- package/src/components/TableHead.md +129 -0
- package/src/components/TableHead.svelte +281 -0
- package/src/components/TableHead.test.ts +44 -0
- package/src/components/TableHeader.md +26 -0
- package/src/components/TableHeader.svelte +10 -0
- package/src/components/TableHeader.test.ts +3 -0
- package/src/components/TableRow.md +36 -0
- package/src/components/TableRow.svelte +64 -0
- package/src/components/TableRow.test.ts +2 -0
- package/src/components/TableToolbar.svelte +260 -0
- package/src/components/Tag.md +270 -0
- package/src/components/Tag.svelte +462 -0
- package/src/components/Tag.test.ts +91 -0
- package/src/components/Text.md +87 -25
- package/src/components/Text.svelte +467 -93
- package/src/components/Text.test.ts +21 -36
- package/src/components/Textarea.md +22 -7
- package/src/components/Textarea.svelte +76 -155
- package/src/components/Textarea.test.ts +12 -5
- package/src/components/Tooltip.md +101 -12
- package/src/components/Tooltip.svelte +581 -108
- package/src/components/Tooltip.test.ts +63 -1
- package/src/context.ts +93 -5
- package/src/dev.ts +6 -10
- package/src/i18n/locale.svelte.ts +60 -0
- package/src/i18n/messages.ts +45 -0
- package/src/index.ts +177 -2
- package/src/keys.ts +7 -0
- package/src/lib/clipboard.ts +10 -0
- package/src/lib/color.md +36 -0
- package/src/lib/color.ts +57 -0
- package/src/lib/date-format.md +37 -0
- package/src/lib/date-format.ts +130 -0
- package/src/lib/edge-fade.md +101 -0
- package/src/lib/edge-fade.ts +55 -0
- package/src/lib/floating-position.md +20 -0
- package/src/lib/floating-position.ts +107 -0
- package/src/lib/number-format.md +40 -0
- package/src/lib/number-format.ts +132 -0
- package/src/lib/overlay-scrollbar.md +36 -0
- package/src/lib/overlay-scrollbar.svelte.ts +221 -0
- package/src/lib/overlay-trigger-timing.md +15 -0
- package/src/lib/overlay-trigger-timing.ts +8 -0
- package/src/lib/progressive-blur.md +95 -0
- package/src/lib/progressive-blur.ts +266 -0
- package/src/lib/resizable.md +41 -0
- package/src/lib/resizable.ts +211 -0
- package/src/lib/table-context.svelte.ts +129 -0
- package/src/lib/table-row-context.svelte.ts +16 -0
- package/src/lib/tooltip-behavior.ts +39 -0
- package/src/lib/tooltip-delay.md +33 -0
- package/src/lib/tooltip-delay.ts +49 -0
- package/src/lib/tooltip-overlay.md +30 -0
- package/src/lib/tooltip-overlay.ts +64 -0
- package/src/lib/truncate.md +7 -2
- package/src/lib/truncate.ts +105 -10
- package/src/logic/README.md +17 -7
- package/src/logic/component-parts.md +32 -0
- package/src/logic/component-parts.svelte.ts +130 -0
- package/src/logic/dialog.md +30 -0
- package/src/logic/dialog.svelte.ts +88 -0
- package/src/logic/frame-actions.md +28 -0
- package/src/logic/frame-actions.svelte.ts +49 -0
- package/src/logic/frame-class-state.md +21 -0
- package/src/logic/frame-class-state.svelte.ts +163 -0
- package/src/logic/frame-dom-runtime.svelte.ts +51 -0
- package/src/logic/frame-inline-style.md +56 -0
- package/src/logic/frame-inline-style.svelte.ts +623 -0
- package/src/logic/frame-motion-defaults.md +90 -9
- package/src/logic/frame-motion-defaults.ts +55 -49
- package/src/logic/frame-motion.svelte.ts +173 -0
- package/src/logic/frame-perception.md +83 -0
- package/src/logic/frame-perception.svelte.ts +273 -0
- package/src/logic/frame-prop-filter.ts +7 -1
- package/src/logic/frame-scale-observer.md +153 -0
- package/src/logic/frame-scale-observer.svelte.ts +98 -0
- package/src/logic/frame-scale-resolver.md +25 -0
- package/src/logic/frame-scale-resolver.svelte.ts +56 -0
- package/src/logic/frame-state-value.md +74 -0
- package/src/logic/frame-state-value.ts +30 -0
- package/src/logic/frame-state.svelte.ts +426 -0
- package/src/logic/frame-truncation.md +17 -3
- package/src/logic/frame-truncation.svelte.ts +23 -43
- package/src/logic/frame-types.md +2 -1
- package/src/logic/frame-types.ts +41 -7
- package/src/logic/frame-utils.md +4 -0
- package/src/logic/frame-utils.ts +54 -26
- package/src/logic/image-preview.md +9 -2
- package/src/logic/image-preview.ts +33 -7
- package/src/logic/morph.md +19 -0
- package/src/logic/morph.ts +7 -0
- package/src/logic/motion-config.ts +49 -3
- package/src/logic/motion-engine.md +43 -0
- package/src/logic/motion-engine.ts +272 -0
- package/src/logic/overlay-presence.svelte.ts +71 -0
- package/src/logic/popover.md +89 -0
- package/src/logic/popover.svelte.ts +236 -0
- package/src/logic/resource-size.md +21 -0
- package/src/logic/resource-size.ts +53 -0
- package/src/logic/text-collapse.md +2 -1
- package/src/logic/text-collapse.svelte.ts +1 -1
- package/src/logic/wc-adapter.ts +1 -1
- package/src/motion/README.md +97 -37
- package/src/motion/{defaults/bridge.md → bridge.md} +24 -4
- package/src/motion/{defaults/bridge.ts → bridge.ts} +16 -5
- package/src/motion/{defaults/content-crossfade.ts → content-crossfade.ts} +1 -1
- package/src/motion/{defaults/expand.md → expand.md} +2 -2
- package/src/motion/{defaults/expand.ts → expand.ts} +4 -3
- package/src/motion/fade-in.md +40 -0
- package/src/motion/fade-in.ts +14 -0
- package/src/motion/{defaults/fade-out.md → fade-out.md} +2 -2
- package/src/motion/fade-out.ts +14 -0
- package/src/motion/{defaults/morph.md → morph.md} +1 -1
- package/src/motion/{defaults/morph.ts → morph.ts} +3 -3
- package/src/motion/move.md +179 -0
- package/src/motion/move.ts +74 -0
- package/src/motion/number.md +50 -0
- package/src/motion/number.ts +30 -0
- package/src/motion/presets/README.md +50 -0
- package/src/motion/presets/dialog.md +20 -0
- package/src/motion/presets/dialog.ts +47 -0
- package/src/motion/presets/effects.md +32 -0
- package/src/motion/presets/effects.ts +111 -0
- package/src/motion/presets/generic.md +27 -0
- package/src/motion/presets/generic.ts +32 -0
- package/src/motion/presets/overlay.md +21 -0
- package/src/motion/presets/overlay.ts +18 -0
- package/src/motion/presets/replacement.md +19 -0
- package/src/motion/presets/replacement.ts +6 -0
- package/src/motion/presets/resize.md +23 -0
- package/src/motion/presets/resize.ts +16 -0
- package/src/motion/presets/tab.md +21 -0
- package/src/motion/presets/tab.ts +19 -0
- package/src/motion/presets/tooltip.md +20 -0
- package/src/motion/presets/tooltip.ts +37 -0
- package/src/motion/presets/utils.md +15 -0
- package/src/motion/presets/utils.ts +11 -0
- package/src/motion/primitives.md +22 -0
- package/src/motion/primitives.ts +46 -0
- package/src/motion/{defaults/replace.md → replace.md} +2 -2
- package/src/motion/{defaults/replace.ts → replace.ts} +4 -4
- package/src/motion/{defaults/rotate.md → rotate.md} +4 -4
- package/src/motion/{defaults/rotate.ts → rotate.ts} +4 -3
- package/src/motion/scale-in.md +40 -0
- package/src/motion/scale-in.ts +19 -0
- package/src/motion/spring.md +19 -0
- package/src/motion/spring.ts +96 -0
- package/src/motion/tokens.md +45 -0
- package/src/motion/tokens.ts +80 -0
- package/src/motion/{defaults/while-2xl.ts → while-2xl.ts} +1 -1
- package/src/motion/{defaults/while-active.ts → while-active.ts} +1 -1
- package/src/motion/while-appear.ts +10 -0
- package/src/motion/{defaults/while-click.ts → while-click.ts} +1 -1
- package/src/motion/{defaults/while-collapsed.ts → while-collapsed.ts} +1 -1
- package/src/motion/{defaults/while-disabled.ts → while-disabled.ts} +3 -2
- package/src/motion/while-disappear.ts +10 -0
- package/src/motion/{defaults/while-drag.ts → while-drag.ts} +1 -1
- package/src/motion/{defaults/while-editing.ts → while-editing.ts} +1 -1
- package/src/motion/{defaults/while-expanded.ts → while-expanded.ts} +1 -1
- package/src/motion/{defaults/while-focus.ts → while-focus.ts} +1 -1
- package/src/motion/{defaults/while-hover.ts → while-hover.ts} +1 -1
- package/src/motion/{defaults/while-idle.ts → while-idle.ts} +1 -1
- package/src/motion/{defaults/while-key.ts → while-key.ts} +1 -1
- package/src/motion/{defaults/while-lg.ts → while-lg.ts} +1 -1
- package/src/motion/{defaults/while-load.ts → while-load.ts} +3 -2
- package/src/motion/{defaults/while-md.ts → while-md.ts} +1 -1
- package/src/motion/{defaults/while-reload.ts → while-reload.ts} +1 -1
- package/src/motion/{defaults/while-scroll.ts → while-scroll.ts} +1 -1
- package/src/motion/{defaults/while-sm.ts → while-sm.ts} +1 -1
- package/src/motion/{defaults/while-uploading.ts → while-uploading.ts} +1 -1
- package/src/motion/{defaults/while-validating.ts → while-validating.ts} +1 -1
- package/src/motion/{defaults/while-xl.ts → while-xl.ts} +1 -1
- package/src/motion/{defaults/while-xs.ts → while-xs.ts} +1 -1
- package/src/styles/auto-layout.css +92 -10
- package/src/styles/layout.css +370 -30
- package/src/styles/scrollbar.css +72 -7
- package/src/App.svelte +0 -103
- package/src/components/QuickAction.md +0 -146
- package/src/components/QuickAction.svelte +0 -161
- package/src/components/QuickAction.test.ts +0 -299
- package/src/components/Test.md +0 -72
- package/src/components/Test.svelte +0 -106
- package/src/components/Test.test.ts +0 -27
- package/src/components/Toggle.svelte +0 -384
- package/src/components/Toggle.test.ts +0 -57
- package/src/logic/frame-profile.md +0 -156
- package/src/logic/frame-profile.ts +0 -130
- package/src/motion/NumberFlow.md +0 -16
- package/src/motion/defaults/fade-out.ts +0 -14
- package/src/motion/defaults/move.md +0 -81
- package/src/motion/defaults/move.ts +0 -31
- package/src/motion/defaults/number.md +0 -41
- package/src/motion/defaults/number.ts +0 -17
- package/src/motion/defaults/while-appear.ts +0 -12
- package/src/motion/defaults/while-disappear.ts +0 -12
- package/src//344/273/243/347/240/201.txt +0 -61
- /package/src/motion/{defaults/rotate.css → rotate.css} +0 -0
|
@@ -1,27 +1,42 @@
|
|
|
1
1
|
<!--
|
|
2
|
-
Frame OSS
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
Frame OSS v1.0.0
|
|
3
|
+
职责:自包含 Frame 容器(作用半径 = 1 个 Frame)。
|
|
4
|
+
能力:状态机、JS 动效执行、自身 FLIP、Scale Observer、Perception、Skeleton、stateContent Grid Stacking。
|
|
5
|
+
边界:不含跨组件协调(§7.7 编排模式 / §8 联动控制 / §10 样式编排),那些能力在 FramePro。
|
|
6
|
+
关键字定义:./Frame.md(本目录,OSS 版规范);全量关键字 API 见仓库根 ../../../Frame.md。
|
|
7
|
+
|
|
8
|
+
v1.0.0 (2026-05-06): OSS / PRO 切割线重构。OSS Frame 接入完整状态机、动效执行、FLIP、Scale Observer、Perception、stateContent。
|
|
9
|
+
详见 /Frame-Refactor-Plan.md。
|
|
10
|
+
v0.1.0 (起点): OSS 仅做 props 归一化、CSS class 拼装、bridge 变量、skeleton 渲染。
|
|
7
11
|
-->
|
|
8
12
|
|
|
9
13
|
<script module lang="ts">
|
|
10
14
|
export * from "../logic/frame-types";
|
|
11
|
-
import { resolveProfileProps } from "../logic/frame-profile";
|
|
12
15
|
</script>
|
|
13
16
|
|
|
14
17
|
<script lang="ts">
|
|
15
|
-
import "../motion/
|
|
16
|
-
import { setContext } from "svelte";
|
|
18
|
+
import "../motion/rotate.css";
|
|
19
|
+
import { setContext, getContext } from "svelte";
|
|
17
20
|
import { SIZE_CONTEXT_KEY, SKELETON_CONTEXT_KEY } from "../keys";
|
|
18
21
|
import type { FrameProps } from "../logic/frame-types";
|
|
19
22
|
import { Identity } from "../logic/frame-identity.svelte";
|
|
23
|
+
import { FrameState } from "../logic/frame-state.svelte";
|
|
20
24
|
import { FrameLayout } from "../logic/frame-layout.svelte";
|
|
21
25
|
import { FrameResponsive } from "../logic/frame-responsive.svelte";
|
|
26
|
+
import { FrameMotion } from "../logic/frame-motion.svelte";
|
|
27
|
+
import { FramePerception } from "../logic/frame-perception.svelte";
|
|
28
|
+
import { frameScaleObserver } from "../logic/frame-scale-observer.svelte";
|
|
29
|
+
import { resolveScaleObserverOptions } from "../logic/frame-scale-resolver.svelte";
|
|
30
|
+
import {
|
|
31
|
+
buildFrameActions,
|
|
32
|
+
mountFrameActions,
|
|
33
|
+
} from "../logic/frame-actions.svelte";
|
|
34
|
+
import { FRAME_MOTION_DEFAULTS } from "../logic/frame-motion-defaults";
|
|
35
|
+
import { createFrameInlineStyleRuntime } from "../logic/frame-inline-style.svelte";
|
|
22
36
|
import { createFrameDomRuntime } from "../logic/frame-dom-runtime.svelte";
|
|
23
37
|
import { createFrameSkeletonRuntime } from "../logic/frame-skeleton-runtime.svelte";
|
|
24
|
-
import {
|
|
38
|
+
import { createFrameClassStateRuntime } from "../logic/frame-class-state.svelte";
|
|
39
|
+
import { provideComponentParts } from "../logic/component-parts.svelte";
|
|
25
40
|
import Skeleton, { getSkeletonComponentKey } from "./Skeleton.svelte";
|
|
26
41
|
|
|
27
42
|
interface Props extends FrameProps {
|
|
@@ -30,96 +45,120 @@
|
|
|
30
45
|
|
|
31
46
|
let { element = $bindable(), ...rawProps }: Props = $props();
|
|
32
47
|
|
|
33
|
-
// === 0.
|
|
34
|
-
const frameProps = $derived(
|
|
48
|
+
// === 0. Props ===
|
|
49
|
+
const frameProps = $derived(rawProps);
|
|
50
|
+
provideComponentParts(() => frameProps.componentParts);
|
|
35
51
|
|
|
36
52
|
// === 0.1 能力开关 ===
|
|
37
53
|
const enableResponsive = $derived(frameProps.enableResponsive ?? true);
|
|
38
54
|
const enableContext = $derived(frameProps.enableContext ?? true);
|
|
55
|
+
const enableScaleObserver = $derived(frameProps.enableScaleObserver ?? false);
|
|
39
56
|
|
|
40
|
-
// === 1. 身份 ===
|
|
57
|
+
// === 1. 身份 (Identity) ===
|
|
41
58
|
// svelte-ignore state_referenced_locally
|
|
42
59
|
const identity = new Identity(frameProps);
|
|
43
60
|
|
|
44
|
-
// === 2. 响应式 ===
|
|
61
|
+
// === 2. 响应式 (Responsive) ===
|
|
62
|
+
// OSS 不支持 orchestrate*,所以 needsResponsive 仅依赖 frameProps.responsive
|
|
45
63
|
const needsResponsive = $derived(
|
|
46
64
|
enableResponsive && frameProps.responsive !== undefined,
|
|
47
65
|
);
|
|
48
66
|
// svelte-ignore state_referenced_locally
|
|
49
67
|
const responsive = needsResponsive ? new FrameResponsive() : null;
|
|
50
68
|
|
|
51
|
-
// === 3. 布局 ===
|
|
69
|
+
// === 3. 布局 (Layout) ===
|
|
52
70
|
// svelte-ignore state_referenced_locally
|
|
53
71
|
const layout = new FrameLayout(frameProps, responsive);
|
|
54
72
|
|
|
55
|
-
// === 4.
|
|
73
|
+
// === 4. 状态 (State) ===
|
|
74
|
+
// OSS 不接受 motion 参数(PRO 用它做 §8 联动控制;OSS 不支持联动)
|
|
56
75
|
const parentSkeletonContext = getContext<
|
|
57
76
|
{ loading: boolean; skeleton?: boolean } | undefined
|
|
58
77
|
>(SKELETON_CONTEXT_KEY);
|
|
78
|
+
// svelte-ignore state_referenced_locally
|
|
79
|
+
const frameState = new FrameState(frameProps);
|
|
80
|
+
|
|
81
|
+
// === 5. 动效 (Motion) ===
|
|
82
|
+
// OSS FrameMotion 仅承担:自身 FLIP 进场(layoutId/itemId)+ whileScroll 监听
|
|
83
|
+
// 状态驱动的视觉动效由 frame-inline-style 注入 CSS bridge 变量,由浏览器 transition 完成
|
|
84
|
+
// svelte-ignore state_referenced_locally
|
|
85
|
+
const motion = new FrameMotion(
|
|
86
|
+
frameProps,
|
|
87
|
+
frameState,
|
|
88
|
+
() => identity.id,
|
|
89
|
+
() => element,
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
// === 6. 加载 / Skeleton 状态 ===
|
|
59
93
|
const inheritedLoading = $derived(parentSkeletonContext?.loading ?? false);
|
|
60
94
|
const inheritedSkeleton = $derived(parentSkeletonContext?.skeleton ?? true);
|
|
61
|
-
const
|
|
62
|
-
const
|
|
95
|
+
const explicitLoading = $derived(frameProps.loading === true);
|
|
96
|
+
const explicitSkeleton = $derived(frameProps.skeleton);
|
|
97
|
+
const stateLoading = $derived(
|
|
98
|
+
frameState.currentState === "StartLoad" ||
|
|
99
|
+
frameState.currentState === "Load",
|
|
100
|
+
);
|
|
101
|
+
const effectiveLoading = $derived(
|
|
102
|
+
inheritedLoading || explicitLoading || stateLoading,
|
|
103
|
+
);
|
|
104
|
+
const effectiveSkeleton = $derived(explicitSkeleton ?? inheritedSkeleton);
|
|
63
105
|
|
|
64
|
-
// ===
|
|
106
|
+
// === 7. 感知 (Perception) ===
|
|
107
|
+
// svelte-ignore state_referenced_locally
|
|
65
108
|
if (enableContext) {
|
|
109
|
+
new FramePerception(
|
|
110
|
+
frameProps,
|
|
111
|
+
frameState,
|
|
112
|
+
layout,
|
|
113
|
+
responsive,
|
|
114
|
+
() => effectiveLoading,
|
|
115
|
+
() => effectiveSkeleton,
|
|
116
|
+
);
|
|
66
117
|
// svelte-ignore state_referenced_locally
|
|
67
118
|
if (frameProps.size !== undefined) {
|
|
68
119
|
setContext(SIZE_CONTEXT_KEY, {
|
|
69
|
-
get size() {
|
|
120
|
+
get size() {
|
|
121
|
+
return frameProps.size as number;
|
|
122
|
+
},
|
|
70
123
|
});
|
|
71
124
|
}
|
|
72
125
|
}
|
|
73
126
|
|
|
74
|
-
// ===
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
return [
|
|
83
|
-
"snowui-frame",
|
|
84
|
-
frameProps.class,
|
|
85
|
-
toRoleClass(frameProps.as),
|
|
86
|
-
layout.direction ? `snowui-direction-${layout.direction}` : "",
|
|
87
|
-
frameProps.morph ? "snowui-morph-container" : "",
|
|
88
|
-
effectiveLoading ? "snowui-loading" : "",
|
|
89
|
-
(frameProps.disabled || frameProps.whileDisabled) ? "snowui-disabled" : "",
|
|
90
|
-
frameProps.collapsed ? "snowui-collapsed" : "",
|
|
91
|
-
frameProps.expanded ? "snowui-expanded" : "",
|
|
92
|
-
].filter(Boolean).join(" ");
|
|
93
|
-
});
|
|
127
|
+
// === 8. Scale Observer ===
|
|
128
|
+
// OSS 版:不向 orchestrator 上报 width/height/size(无 orchestrator)
|
|
129
|
+
const scaleObserverOptions = $derived(resolveScaleObserverOptions(frameProps));
|
|
130
|
+
const hasScaleApplyConfig = $derived(
|
|
131
|
+
frameProps.sizeRatio !== undefined ||
|
|
132
|
+
frameProps.iconSizeRatio !== undefined ||
|
|
133
|
+
frameProps.avatarSizeRatio !== undefined,
|
|
134
|
+
);
|
|
94
135
|
|
|
95
|
-
// ===
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
handleInput: noop, handleChange: noop, handleSubmit: noop,
|
|
107
|
-
handleScroll: noop, handleDragStart: noop, handleDrag: noop, handleDragEnd: noop,
|
|
108
|
-
};
|
|
136
|
+
// === 9. 多指令 (FrameActions) ===
|
|
137
|
+
function multiuse(node: HTMLElement, actions: any[] | undefined) {
|
|
138
|
+
const allActions = buildFrameActions({
|
|
139
|
+
userActions: actions,
|
|
140
|
+
scaleAction: enableScaleObserver
|
|
141
|
+
? [frameScaleObserver, scaleObserverOptions]
|
|
142
|
+
: null,
|
|
143
|
+
responsiveAction: responsive?.resizeObserver ?? null,
|
|
144
|
+
});
|
|
145
|
+
return mountFrameActions(node, allActions);
|
|
146
|
+
}
|
|
109
147
|
|
|
110
|
-
|
|
148
|
+
// === 10. State-driven class/style/content ===
|
|
149
|
+
const classStateRuntime = createFrameClassStateRuntime({
|
|
111
150
|
getFrameProps: () => frameProps,
|
|
112
|
-
frameState
|
|
151
|
+
frameState,
|
|
152
|
+
layout,
|
|
153
|
+
responsive,
|
|
113
154
|
getEffectiveLoading: () => effectiveLoading,
|
|
114
|
-
|
|
155
|
+
getElement: () => element,
|
|
115
156
|
});
|
|
116
|
-
const
|
|
117
|
-
const
|
|
118
|
-
const
|
|
119
|
-
const nativeHandlers = $derived(domRuntime.nativeHandlers);
|
|
120
|
-
const runtimeDataAttrs = $derived(domRuntime.dataAttrs);
|
|
157
|
+
const resolvedStateStyle = $derived(classStateRuntime.resolvedStateStyle);
|
|
158
|
+
const computedClass = $derived(classStateRuntime.computedClass);
|
|
159
|
+
const childrenRenderContext = $derived(classStateRuntime.childrenRenderContext);
|
|
121
160
|
|
|
122
|
-
// ===
|
|
161
|
+
// === 11. Skeleton ===
|
|
123
162
|
const skeletonComponentKey = $derived(getSkeletonComponentKey(computedClass));
|
|
124
163
|
let skeletonProbe = $state<HTMLElement>();
|
|
125
164
|
const skeletonRuntime = createFrameSkeletonRuntime({
|
|
@@ -131,31 +170,45 @@
|
|
|
131
170
|
});
|
|
132
171
|
const shouldRenderSkeleton = $derived(skeletonRuntime.shouldRenderSkeleton);
|
|
133
172
|
const needsSkeletonProbe = $derived(skeletonRuntime.needsSkeletonProbe);
|
|
134
|
-
const shouldRenderProbedChildSkeletons = $derived(
|
|
135
|
-
|
|
173
|
+
const shouldRenderProbedChildSkeletons = $derived(
|
|
174
|
+
skeletonRuntime.shouldRenderProbedChildSkeletons,
|
|
175
|
+
);
|
|
176
|
+
const shouldRenderDirectSkeleton = $derived(
|
|
177
|
+
skeletonRuntime.shouldRenderDirectSkeleton,
|
|
178
|
+
);
|
|
136
179
|
const probedSkeletonChildren = $derived(skeletonRuntime.probedSkeletonChildren);
|
|
137
180
|
|
|
138
|
-
// ===
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
181
|
+
// === 12. Inline Style(含 while* bridge 变量)===
|
|
182
|
+
// OSS:getOrchestratedStyle 始终返回空字符串(OSS 无 §10 样式编排)
|
|
183
|
+
const inlineStyleRuntime = createFrameInlineStyleRuntime({
|
|
184
|
+
getFrameProps: () => frameProps,
|
|
185
|
+
frameState,
|
|
186
|
+
motion,
|
|
187
|
+
getIdentityId: () => identity.id,
|
|
188
|
+
getEffectiveLoading: () => effectiveLoading,
|
|
189
|
+
getShouldRenderSkeleton: () => shouldRenderSkeleton,
|
|
190
|
+
getResolvedStateStyle: () => resolvedStateStyle,
|
|
191
|
+
getOrchestratedStyle: () => "",
|
|
192
|
+
});
|
|
193
|
+
const computedStyle = $derived(inlineStyleRuntime.computedStyle);
|
|
142
194
|
|
|
143
|
-
//
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
loading: effectiveLoading,
|
|
150
|
-
active: !!frameProps.whileActive,
|
|
151
|
-
disabled: !!frameProps.disabled || !!frameProps.whileDisabled,
|
|
152
|
-
currentState: "Idle" as const,
|
|
153
|
-
interactionState: "Idle" as const,
|
|
154
|
-
stateVars: {},
|
|
155
|
-
stateClass: "",
|
|
156
|
-
stateStyle: "",
|
|
157
|
-
motionDefaults: undefined,
|
|
195
|
+
// === 13. DOM runtime ===
|
|
196
|
+
const domRuntime = createFrameDomRuntime({
|
|
197
|
+
getFrameProps: () => frameProps,
|
|
198
|
+
frameState,
|
|
199
|
+
getEffectiveLoading: () => effectiveLoading,
|
|
200
|
+
getHasScaleApplyConfig: () => hasScaleApplyConfig,
|
|
158
201
|
});
|
|
202
|
+
const resolvedTag = $derived(domRuntime.resolvedTag);
|
|
203
|
+
const domPropsWithAccessibility = $derived(domRuntime.domProps);
|
|
204
|
+
const captureHandlers = $derived(domRuntime.captureHandlers);
|
|
205
|
+
const nativeHandlers = $derived(domRuntime.nativeHandlers);
|
|
206
|
+
const runtimeDataAttrs = $derived(domRuntime.dataAttrs);
|
|
207
|
+
|
|
208
|
+
// === 14. Controller(OSS 仅暴露 FLIP 自身转场方法)===
|
|
209
|
+
export function getController() {
|
|
210
|
+
return motion.controller;
|
|
211
|
+
}
|
|
159
212
|
</script>
|
|
160
213
|
|
|
161
214
|
<svelte:element
|
|
@@ -163,6 +216,7 @@
|
|
|
163
216
|
{...domPropsWithAccessibility}
|
|
164
217
|
id={identity.id}
|
|
165
218
|
data-snowui-frame={true}
|
|
219
|
+
use:multiuse={frameProps.use || []}
|
|
166
220
|
class={computedClass}
|
|
167
221
|
bind:this={element}
|
|
168
222
|
onclickcapture={captureHandlers.onclickcapture}
|
|
@@ -203,10 +257,43 @@
|
|
|
203
257
|
{/if}
|
|
204
258
|
{#if shouldRenderProbedChildSkeletons}
|
|
205
259
|
{#each probedSkeletonChildren as child}
|
|
206
|
-
<Skeleton
|
|
260
|
+
<Skeleton
|
|
261
|
+
componentClass={child.componentClass}
|
|
262
|
+
renderHints={child.renderHints}
|
|
263
|
+
/>
|
|
207
264
|
{/each}
|
|
208
265
|
{:else if shouldRenderDirectSkeleton}
|
|
209
|
-
<Skeleton
|
|
266
|
+
<Skeleton
|
|
267
|
+
componentClass={computedClass}
|
|
268
|
+
renderHints={frameProps.renderHints}
|
|
269
|
+
/>
|
|
270
|
+
{:else if frameProps.stateContent}
|
|
271
|
+
<!-- stateContent: Grid Stacking 确保切换时尺寸不跳动且互相堆叠 -->
|
|
272
|
+
<div
|
|
273
|
+
style="display: grid; align-items: inherit; justify-content: inherit; gap: inherit; width: 100%; height: 100%;"
|
|
274
|
+
>
|
|
275
|
+
{#each Object.entries(frameProps.stateContent) as [contentState, snippet]}
|
|
276
|
+
<div
|
|
277
|
+
style="grid-area: 1 / 1; display: flex; flex-direction: inherit; align-items: inherit; justify-content: inherit; gap: inherit; opacity:{frameState.currentState ===
|
|
278
|
+
contentState
|
|
279
|
+
? 1
|
|
280
|
+
: 0};transform:scale({frameState.currentState ===
|
|
281
|
+
contentState
|
|
282
|
+
? 1
|
|
283
|
+
: 0.01});transition:all {frameState.currentState ===
|
|
284
|
+
contentState
|
|
285
|
+
? `${FRAME_MOTION_DEFAULTS.contentCrossfadeIn.duration}ms ${FRAME_MOTION_DEFAULTS.contentCrossfadeIn.easing} ${FRAME_MOTION_DEFAULTS.contentCrossfadeIn.delay}ms`
|
|
286
|
+
: `${FRAME_MOTION_DEFAULTS.contentCrossfadeOut.duration}ms ${FRAME_MOTION_DEFAULTS.contentCrossfadeOut.easing}`};pointer-events:{frameState.currentState ===
|
|
287
|
+
contentState
|
|
288
|
+
? 'auto'
|
|
289
|
+
: 'none'};"
|
|
290
|
+
>
|
|
291
|
+
{#if snippet}
|
|
292
|
+
{@render snippet()}
|
|
293
|
+
{/if}
|
|
294
|
+
</div>
|
|
295
|
+
{/each}
|
|
296
|
+
</div>
|
|
210
297
|
{:else if frameProps.children}
|
|
211
298
|
{@render frameProps.children(childrenRenderContext)}
|
|
212
299
|
{/if}
|
|
@@ -214,7 +301,41 @@
|
|
|
214
301
|
|
|
215
302
|
<style>
|
|
216
303
|
@keyframes -global-snowui-frame-transform-motion {
|
|
217
|
-
from {
|
|
218
|
-
|
|
304
|
+
from {
|
|
305
|
+
transform: var(--snowui-frame-transform-from, none);
|
|
306
|
+
opacity: var(--snowui-frame-opacity-from, var(--snowui-frame-opacity-static, 1));
|
|
307
|
+
filter: var(--snowui-frame-blur-from);
|
|
308
|
+
}
|
|
309
|
+
to {
|
|
310
|
+
transform: var(--snowui-frame-transform-to, none);
|
|
311
|
+
opacity: var(--snowui-frame-opacity-to, var(--snowui-frame-opacity-static, 1));
|
|
312
|
+
filter: var(--snowui-frame-blur-to);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
@keyframes -global-snowui-frame-appear-transform-motion {
|
|
317
|
+
from {
|
|
318
|
+
transform: var(--snowui-frame-transform-from, none);
|
|
319
|
+
opacity: var(--snowui-frame-opacity-from, var(--snowui-frame-opacity-static, 1));
|
|
320
|
+
filter: var(--snowui-frame-blur-from);
|
|
321
|
+
}
|
|
322
|
+
to {
|
|
323
|
+
transform: var(--snowui-frame-transform-to, none);
|
|
324
|
+
opacity: var(--snowui-frame-opacity-to, var(--snowui-frame-opacity-static, 1));
|
|
325
|
+
filter: var(--snowui-frame-blur-to);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
@keyframes -global-snowui-frame-disappear-transform-motion {
|
|
330
|
+
from {
|
|
331
|
+
transform: var(--snowui-frame-transform-from, none);
|
|
332
|
+
opacity: var(--snowui-frame-opacity-from, var(--snowui-frame-opacity-static, 1));
|
|
333
|
+
filter: var(--snowui-frame-blur-from);
|
|
334
|
+
}
|
|
335
|
+
to {
|
|
336
|
+
transform: var(--snowui-frame-transform-to, none);
|
|
337
|
+
opacity: var(--snowui-frame-opacity-to, var(--snowui-frame-opacity-static, 1));
|
|
338
|
+
filter: var(--snowui-frame-blur-to);
|
|
339
|
+
}
|
|
219
340
|
}
|
|
220
341
|
</style>
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Frame.test.ts
|
|
3
|
+
* v1.0.0
|
|
4
|
+
* 变更记录 (2026-05-20): 改为显式 class 示例。
|
|
5
|
+
* 变更记录 (2026-05-09): 补充 OSS Frame 基础示例,覆盖状态内容与 Skeleton 协议。
|
|
6
|
+
*/
|
|
7
|
+
export const examples = [
|
|
8
|
+
{
|
|
9
|
+
name: "F1: 显式类与布局",
|
|
10
|
+
code: `F1
|
|
11
|
+
<Frame class="flex flex-col gap-8 p-16 rounded-12 bg-background-2">
|
|
12
|
+
<Text class="text-14">普通 Frame</Text>
|
|
13
|
+
<Frame class="p-12 rounded-8 bg-background-1 cursor-pointer">
|
|
14
|
+
Interactive Frame
|
|
15
|
+
</Frame>
|
|
16
|
+
</Frame>`,
|
|
17
|
+
expected: {
|
|
18
|
+
render: "Frame composition with explicit classes",
|
|
19
|
+
layout: "Vertical container with nested interactive frame",
|
|
20
|
+
interaction: "Pointer cursor comes from explicit class",
|
|
21
|
+
responsive: "None",
|
|
22
|
+
},
|
|
23
|
+
logic: ["class", "children"],
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: "F2: 状态内容",
|
|
27
|
+
code: `F2
|
|
28
|
+
{#snippet idleContent()}
|
|
29
|
+
Idle
|
|
30
|
+
{/snippet}
|
|
31
|
+
{#snippet activeContent()}
|
|
32
|
+
Active
|
|
33
|
+
{/snippet}
|
|
34
|
+
|
|
35
|
+
<Frame
|
|
36
|
+
class="p-16 rounded-12 bg-background-2 cursor-pointer"
|
|
37
|
+
Click={{ Idle: "Active", Active: "Idle" }}
|
|
38
|
+
stateContent={{ Idle: idleContent, Active: activeContent }}
|
|
39
|
+
>
|
|
40
|
+
Idle
|
|
41
|
+
</Frame>`,
|
|
42
|
+
expected: {
|
|
43
|
+
render: "Frame switches rendered content by state",
|
|
44
|
+
layout: "Single surface frame",
|
|
45
|
+
interaction: "Click toggles Idle and Active",
|
|
46
|
+
responsive: "None",
|
|
47
|
+
},
|
|
48
|
+
logic: ["Click", "stateContent"],
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: "F3: Skeleton 协议",
|
|
52
|
+
code: `F3
|
|
53
|
+
<Frame loading skeleton class="w-64">
|
|
54
|
+
Loading content
|
|
55
|
+
</Frame>`,
|
|
56
|
+
expected: {
|
|
57
|
+
render: "Skeleton placeholder is rendered while loading",
|
|
58
|
+
layout: "Single frame skeleton",
|
|
59
|
+
interaction: "None",
|
|
60
|
+
responsive: "None",
|
|
61
|
+
},
|
|
62
|
+
logic: ["loading", "skeleton"],
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: "F4: 内容宽度策略",
|
|
66
|
+
code: `F4
|
|
67
|
+
<Frame column class="gap-8">
|
|
68
|
+
<Frame row contentHug class="gap-8 p-8 bg-background-2 rounded-8">
|
|
69
|
+
<Text>Hug</Text>
|
|
70
|
+
<Text>Content</Text>
|
|
71
|
+
</Frame>
|
|
72
|
+
<Frame row contentFill style="width: 18rem;" class="gap-8 p-8 bg-background-2 rounded-8">
|
|
73
|
+
<Text>Fill</Text>
|
|
74
|
+
<Text>Content</Text>
|
|
75
|
+
</Frame>
|
|
76
|
+
</Frame>`,
|
|
77
|
+
expected: {
|
|
78
|
+
render: "Frame 支持 contentHug 与 contentFill。",
|
|
79
|
+
layout: "contentHug 普通子项按内容收缩,contentFill 普通子项填满可用宽度。",
|
|
80
|
+
interaction: "None",
|
|
81
|
+
responsive: "固定宽度 Frame 内 contentFill 子项随容器分配宽度。",
|
|
82
|
+
},
|
|
83
|
+
logic: ["contentFill", "contentHug", "layout"],
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: "F5: 单一 opacity 动效通道",
|
|
87
|
+
code: `F5
|
|
88
|
+
<Frame
|
|
89
|
+
Appear={["Idle", "auto"]}
|
|
90
|
+
whileAppear={{ opacity: [0, 1] }}
|
|
91
|
+
class="p-16 rounded-12 bg-background-2"
|
|
92
|
+
>
|
|
93
|
+
只渐显,不继承默认 scale
|
|
94
|
+
</Frame>`,
|
|
95
|
+
expected: {
|
|
96
|
+
render: "Frame 从透明到不透明出现,尺寸始终保持不变。",
|
|
97
|
+
layout: "单一 surface frame。",
|
|
98
|
+
interaction: "显式 whileAppear 对象只执行 opacity,并继承默认进入时序。",
|
|
99
|
+
responsive: "None",
|
|
100
|
+
},
|
|
101
|
+
logic: ["whileAppear", "opacity", "motionChannels"],
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
name: "F6: 单一 scale 动效通道",
|
|
105
|
+
code: `F6
|
|
106
|
+
<Frame
|
|
107
|
+
Appear={["Idle", "auto"]}
|
|
108
|
+
whileAppear={{ scale: [0.95, 1] }}
|
|
109
|
+
class="p-16 rounded-12 bg-background-2"
|
|
110
|
+
>
|
|
111
|
+
只缩放,不继承默认 opacity
|
|
112
|
+
</Frame>`,
|
|
113
|
+
expected: {
|
|
114
|
+
render: "Frame 从 0.95 缩放到 1,透明度始终保持不变。",
|
|
115
|
+
layout: "单一 surface frame。",
|
|
116
|
+
interaction: "显式 whileAppear 对象只执行 scale,并继承默认进入时序。",
|
|
117
|
+
responsive: "None",
|
|
118
|
+
},
|
|
119
|
+
logic: ["whileAppear", "scale", "motionChannels"],
|
|
120
|
+
},
|
|
121
|
+
] as const;
|
package/src/components/Icon.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# Icon.svelte 文档
|
|
2
2
|
|
|
3
3
|
> **版本**: v2.3.2
|
|
4
|
+
> **变更记录 (2026-05-18)**: 新增 `stateIcon`,支持读取父 Frame `currentState` 后声明式切换图标。
|
|
4
5
|
> **变更记录 (2026-04-28)**: 标注主布局模型为内禀原子布局,明确 `as` 仅作为外部/宿主角色,不改变 Icon 内部尺寸原语语义。
|
|
5
6
|
> **变更记录 (2026-03-31)**: 新增 `icon` 资源组件透传能力:支持 `<Icon icon={Warning} />` 直接渲染 `resource-svelte` 图标,避免回退为默认占位块。
|
|
6
7
|
> **变更记录 (2026-03-10)**: 新增 Image / ImageViewer 宿主角色接入,支持 `as="icon" / "badge" / "prev" / "next" / "close"`。
|
|
@@ -8,7 +9,6 @@
|
|
|
8
9
|
> **职责**: 图标组件,用于显示 SVG 图标。
|
|
9
10
|
|
|
10
11
|
**继承**: 复用 Frame.svelte 的所有通用能力 (交互、动效、响应式)。
|
|
11
|
-
**默认 Profile**: `Container`。
|
|
12
12
|
**默认能力开关**: `enableResponsive=false`, `enableContext=false`。
|
|
13
13
|
|
|
14
14
|
## 布局模型
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
主布局模型:内禀原子布局。
|
|
17
17
|
|
|
18
18
|
- Icon 的根节点是由 `size`、`background` padding 与图标资源共同决定的内禀盒,作为其他布局子项时表现为 Hug。
|
|
19
|
-
- `as="leading" / "trailing" / "icon" / "badge" / "prev" / "next" / "close"` 只声明 Icon
|
|
19
|
+
- `as="leading" / "trailing" / "icon" / "badge" / "prev" / "next" / "close"` 只声明 Icon 在外部宿主中的角色;进入 Image / ImageViewer 宿主时会由宿主上下文翻译为对应 `pin-*` 方位。
|
|
20
20
|
- 背景、空占位、badge overlay 与图片资源渲染都是 Icon 私有结构,不对外承诺通用槽位。
|
|
21
21
|
- 外部需要图标加文字排列时,应由 Button、MenuItem、Frame 等宿主组件负责 gap / padding / alignment。
|
|
22
22
|
|
|
@@ -25,6 +25,8 @@
|
|
|
25
25
|
| 属性 | 类型 | 默认值 | 描述 |
|
|
26
26
|
| :--- | :--- | :--- | :--- |
|
|
27
27
|
| src | string | undefined | 图标图片 URL |
|
|
28
|
+
| icon | Component | undefined | 直接渲染 resource-svelte 图标组件。 |
|
|
29
|
+
| stateIcon | `Partial<Record<CoreState, Component \| null>>` | undefined | 根据最近父级 Frame 的 `currentState` 解析图标。未命中当前状态时回退 `Idle`,再回退 `icon` / `src` / children;状态值为 `null` 时隐藏 Icon。 |
|
|
28
30
|
| size | 12\|16\|20\|24\|28\|32\|40\|48\|80 | 16 | 图标尺寸。未显式设置时,自动继承父级 `Frame` 提供尺寸上下文。 |
|
|
29
31
|
| background | boolean | false | 是否显示背景 |
|
|
30
32
|
| weight | string | undefined | 图标字重(font-weight) |
|
|
@@ -37,6 +39,18 @@
|
|
|
37
39
|
| :--- | :--- | :--- | :--- |
|
|
38
40
|
| size | `12 \| 16 \| 20 \| 24 \| 28 \| 32 \| 40 \| 48 \| 80` | `16` | 图标尺寸。支持从上下文自动继承。 |
|
|
39
41
|
| background | `boolean` | `false` | 是否显示背景 |
|
|
42
|
+
| stateIcon | `Partial<Record<CoreState, Component \| null>>` | - | 父状态驱动图标。消费最近父 Frame Context 的 `currentState`,只改变 Icon 自身展示,不修改父状态;值为 `null` 时隐藏。 |
|
|
43
|
+
|
|
44
|
+
### `stateIcon` 解析规则
|
|
45
|
+
|
|
46
|
+
1. `Icon` 读取最近父级 Frame Context 的 `currentState`。
|
|
47
|
+
2. 当前状态命中 `stateIcon[currentState]` 时使用该图标。
|
|
48
|
+
3. 未命中当前状态时回退 `stateIcon.Idle`。
|
|
49
|
+
4. 仍未解析出图标时回退现有 `icon` / `src` / children 渲染规则。
|
|
50
|
+
5. 状态值为 `null` 时隐藏 Icon,用于 `Idle` 无图标、`Pending` 显示 Spinner 这类稳定结构状态流。
|
|
51
|
+
6. `stateIcon` 只影响 Icon 自身展示,不修改父 Frame 状态。
|
|
52
|
+
|
|
53
|
+
> `Load` 是 Frame loading / skeleton 协议状态名。若只是按钮任务处理中并需要展示真实 Spinner,优先使用 `Pending`。
|
|
40
54
|
|
|
41
55
|
## 使用示例
|
|
42
56
|
|
|
@@ -60,6 +74,21 @@
|
|
|
60
74
|
<Bell />
|
|
61
75
|
</Icon>
|
|
62
76
|
|
|
77
|
+
<!-- 父 Frame / Button 状态驱动图标 -->
|
|
78
|
+
<Button Click="Active" Active={["Idle", "auto"]} whileActive={{ duration: 2000 }}>
|
|
79
|
+
<Icon stateIcon={{ Idle: Paperclip, Active: Check }} />
|
|
80
|
+
<Text stateText={{ Idle: "复制", Active: "已复制" }} />
|
|
81
|
+
</Button>
|
|
82
|
+
|
|
83
|
+
<!-- 状态流:Idle 无图标,Pending 显示 Spinner,Active 显示 Check -->
|
|
84
|
+
<Button
|
|
85
|
+
Click={{ Idle: "Pending", Active: "Idle" }}
|
|
86
|
+
Pending={["Active", "auto"]}
|
|
87
|
+
>
|
|
88
|
+
<Icon stateIcon={{ Idle: null, Pending: Spinner, Active: Check }} />
|
|
89
|
+
<Text stateText={{ Idle: "Ready", Pending: "Loading...", Active: "Completed" }} />
|
|
90
|
+
</Button>
|
|
91
|
+
|
|
63
92
|
<!-- 作为 Badge 附加在头像上 -->
|
|
64
93
|
<Avatar size={40}>
|
|
65
94
|
<Icon as="badge" background class="bg-blue text-white">
|
|
@@ -75,7 +104,6 @@ Icon 为子组件 (如 Badge 或 另一个 Icon) 提供自适应定位上下文
|
|
|
75
104
|
- `badgeSize`: 默认点状态尺寸 (`0.25em`)。
|
|
76
105
|
- `size/weight`: Icon 容器默认透传;子图标显式传入时覆盖(不推荐)。
|
|
77
106
|
|
|
78
|
-
<!-- @UserDefined -->
|
|
79
107
|
## 样式规范 (Style Spec)
|
|
80
108
|
|
|
81
109
|
### 1. 默认样式 (Defaults)
|
|
@@ -130,7 +158,6 @@ Icon 为子组件 (如 Badge 或 另一个 Icon) 提供自适应定位上下文
|
|
|
130
158
|
- **圆角**: 统一继承当前尺寸应有的 `var(--radius-1)` 渲染(随外框大小自动缩放,若无特例默认 4px)。
|
|
131
159
|
一旦传入了图标元素,此占位会被自动消除。
|
|
132
160
|
|
|
133
|
-
<!-- /@UserDefined -->
|
|
134
161
|
|
|
135
162
|
---
|
|
136
163
|
|
|
@@ -170,6 +197,8 @@ Icon 为子组件 (如 Badge 或 另一个 Icon) 提供自适应定位上下文
|
|
|
170
197
|
|
|
171
198
|
## 更新日志 (Changelog)
|
|
172
199
|
|
|
200
|
+
- **Icon-Docs.2026-05-25** 源码顶部历史变更记录已归档;后续新增变更统一写入本文档 Changelog,源码顶部只保留职责、当前关键架构与文档路径。
|
|
201
|
+
|
|
173
202
|
### v2.3.2 (2026-03-31)
|
|
174
203
|
|
|
175
204
|
#### 新功能
|
|
@@ -178,7 +207,7 @@ Icon 为子组件 (如 Badge 或 另一个 Icon) 提供自适应定位上下文
|
|
|
178
207
|
### v2.3.1 (2026-03-10)
|
|
179
208
|
|
|
180
209
|
#### 新功能
|
|
181
|
-
- **IC-Role.3** Icon 新增 `Image` 宿主组合支持:`as="icon"` 居中覆盖,`as="badge"`
|
|
210
|
+
- **IC-Role.3** Icon 新增 `Image` 宿主组合支持:`as="icon"` 通过 `pin-center` 居中覆盖,`as="badge"` 通过 `pin-top-right` / `pin-bottom-right` 显示角标。
|
|
182
211
|
- **IC-Role.4** Icon 新增 `ImageViewer` 宿主组合支持:`as="prev"` / `as="next"` / `as="close"` 可直接接入预览控制定位协议。
|
|
183
212
|
|
|
184
213
|
### v2.3.0 (2026-03-02)
|
|
@@ -276,4 +305,3 @@ Icon 为子组件 (如 Badge 或 另一个 Icon) 提供自适应定位上下文
|
|
|
276
305
|
|
|
277
306
|
#### 破坏性变更
|
|
278
307
|
- **IC-Break.1** 移除 `name` Props,`<img>` 使用空 `alt`
|
|
279
|
-
<!-- /@UserDefined -->
|