@snowui-design-system/components 0.3.0-alpha.0 → 0.3.0-alpha.1
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 +13 -6
- package/component-catalog.json +2 -23
- package/dist/client/blocks/Sidebar.js +2 -2
- package/dist/client/blocks/SidebarItem.js +2 -2
- package/dist/client/blocks/SidebarSection.js +2 -2
- package/dist/client/compat.d.ts +1 -1
- package/dist/client/compat.js +1 -1
- package/dist/client/components/BlurText.js +2 -2
- package/dist/client/components/DataTable.js +2 -2
- package/dist/client/components/FlowText.js +2 -2
- package/dist/client/components/Frame.d.ts +9 -0
- package/dist/client/components/Frame.js +82 -24
- package/dist/client/components/GradientMotion.d.ts +1 -1
- package/dist/client/components/GradientMotion.js +2 -2
- package/dist/client/components/NumberFlow.js +4 -4
- package/dist/client/components/NumericText.js +2 -2
- package/dist/client/components/ScrambleText.js +2 -2
- package/dist/client/components/SidePanel.js +3 -3
- package/dist/client/components/SlotText.js +2 -2
- package/dist/client/components/TableCell.js +1 -1
- package/dist/client/components/Toaster.js +1 -1
- package/dist/client/index.d.ts +0 -1
- package/dist/client/index.js +3 -5
- package/dist/client/internal/snow-ui-logo/Wordmark.js +1 -1
- package/dist/client/lib/edge-fade.js +1 -1
- package/dist/client/lib/resizable.d.ts +1 -1
- package/dist/client/logic/frame-motion.d.ts +15 -23
- package/dist/client/logic/frame-motion.js +196 -30
- package/dist/client/logic/frame-state.d.ts +2 -14
- package/dist/client/logic/frame-state.js +60 -9
- package/dist/client/motion/number.d.ts +3 -3
- package/dist/client/motion/number.js +3 -3
- package/dist/client/styles/components.css +14 -14
- package/dist/client/styles/layout.css +1 -1
- package/dist/server/blocks/Sidebar.js +2 -2
- package/dist/server/blocks/SidebarItem.js +2 -2
- package/dist/server/blocks/SidebarSection.js +2 -2
- package/dist/server/compat.d.ts +1 -1
- package/dist/server/compat.js +1 -1
- package/dist/server/components/BlurText.js +2 -2
- package/dist/server/components/DataTable.js +2 -2
- package/dist/server/components/FlowText.js +2 -2
- package/dist/server/components/Frame.d.ts +9 -0
- package/dist/server/components/Frame.js +52 -24
- package/dist/server/components/GradientMotion.d.ts +1 -1
- package/dist/server/components/GradientMotion.js +2 -2
- package/dist/server/components/NumberFlow.js +4 -4
- package/dist/server/components/NumericText.js +2 -2
- package/dist/server/components/ScrambleText.js +2 -2
- package/dist/server/components/SidePanel.js +3 -3
- package/dist/server/components/SlotText.js +2 -2
- package/dist/server/components/TableCell.js +1 -1
- package/dist/server/components/Toaster.js +1 -1
- package/dist/server/index.d.ts +0 -1
- package/dist/server/index.js +3 -5
- package/dist/server/internal/snow-ui-logo/Wordmark.js +1 -1
- package/dist/server/lib/edge-fade.js +1 -1
- package/dist/server/lib/resizable.d.ts +1 -1
- package/dist/server/logic/frame-motion.d.ts +15 -23
- package/dist/server/logic/frame-motion.js +75 -29
- package/dist/server/logic/frame-state.d.ts +2 -14
- package/dist/server/logic/frame-state.js +60 -9
- package/dist/server/motion/number.d.ts +3 -3
- package/dist/server/motion/number.js +3 -3
- package/dist/server/styles/components.css +14 -14
- package/dist/server/styles/layout.css +1 -1
- package/package.json +2 -2
- package/dist/client/components/FramePro.d.ts +0 -23
- package/dist/client/components/FramePro.js +0 -412
- package/dist/client/logic/frame-pro-motion.d.ts +0 -26
- package/dist/client/logic/frame-pro-motion.js +0 -310
- package/dist/client/logic/frame-pro-state.d.ts +0 -39
- package/dist/client/logic/frame-pro-state.js +0 -538
- package/dist/server/components/FramePro.d.ts +0 -23
- package/dist/server/components/FramePro.js +0 -301
- package/dist/server/logic/frame-pro-motion.d.ts +0 -26
- package/dist/server/logic/frame-pro-motion.js +0 -176
- package/dist/server/logic/frame-pro-state.d.ts +0 -39
- package/dist/server/logic/frame-pro-state.js +0 -445
|
@@ -1,301 +0,0 @@
|
|
|
1
|
-
import * as $ from 'svelte/internal/server';
|
|
2
|
-
import "../motion/rotate.css";
|
|
3
|
-
import { getContext, setContext } from "svelte";
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
MOTION_ORCHESTRATOR_CONTEXT_KEY,
|
|
7
|
-
SIZE_CONTEXT_KEY,
|
|
8
|
-
SKELETON_CONTEXT_KEY
|
|
9
|
-
} from "../keys.js";
|
|
10
|
-
|
|
11
|
-
import { Identity } from "../logic/frame-identity.js";
|
|
12
|
-
import { FrameState } from "../logic/frame-pro-state.js";
|
|
13
|
-
import { FrameLayout } from "../logic/frame-layout.js";
|
|
14
|
-
import { FrameResponsive } from "../logic/frame-responsive.js";
|
|
15
|
-
import { FrameMotion } from "../logic/frame-pro-motion.js";
|
|
16
|
-
import { FramePerception } from "../logic/frame-perception.js";
|
|
17
|
-
import { frameScaleObserver } from "../logic/frame-scale-observer.js";
|
|
18
|
-
import { resolveScaleObserverOptions } from "../logic/frame-scale-resolver.js";
|
|
19
|
-
import { buildFrameActions, mountFrameActions } from "../logic/frame-actions.js";
|
|
20
|
-
import { FRAME_MOTION_DEFAULTS } from "../logic/frame-motion-defaults.js";
|
|
21
|
-
import { createFrameInlineStyleRuntime } from "../logic/frame-inline-style.js";
|
|
22
|
-
import { createFrameDomRuntime } from "../logic/frame-dom-runtime.js";
|
|
23
|
-
import { createFrameSkeletonRuntime } from "../logic/frame-skeleton-runtime.js";
|
|
24
|
-
import { createFrameClassStateRuntime } from "../logic/frame-class-state.js";
|
|
25
|
-
import { provideComponentParts } from "../logic/component-parts.js";
|
|
26
|
-
import { initOrchestrator, getOrchestrator } from "../logic/frame-orchestrator.js";
|
|
27
|
-
import { Skeleton } from "../index.js";
|
|
28
|
-
|
|
29
|
-
export * from "../logic/frame-types.js";
|
|
30
|
-
|
|
31
|
-
const $$css = {
|
|
32
|
-
hash: 'svelte-m0vogk',
|
|
33
|
-
code: '\n @keyframes snowui-frame-transform-motion {\n from {\n transform: var(--snowui-frame-transform-from, none);\n opacity: var(--snowui-frame-opacity-from, var(--snowui-frame-opacity-static, 1));\n filter: var(--snowui-frame-blur-from);\n }\n to {\n transform: var(--snowui-frame-transform-to, none);\n opacity: var(--snowui-frame-opacity-to, var(--snowui-frame-opacity-static, 1));\n filter: var(--snowui-frame-blur-to);\n }\n }\n\n @keyframes snowui-frame-appear-transform-motion {\n from {\n transform: var(--snowui-frame-transform-from, none);\n opacity: var(--snowui-frame-opacity-from, var(--snowui-frame-opacity-static, 1));\n filter: var(--snowui-frame-blur-from);\n }\n to {\n transform: var(--snowui-frame-transform-to, none);\n opacity: var(--snowui-frame-opacity-to, var(--snowui-frame-opacity-static, 1));\n filter: var(--snowui-frame-blur-to);\n }\n }\n\n @keyframes snowui-frame-disappear-transform-motion {\n from {\n transform: var(--snowui-frame-transform-from, none);\n opacity: var(--snowui-frame-opacity-from, var(--snowui-frame-opacity-static, 1));\n filter: var(--snowui-frame-blur-from);\n }\n to {\n transform: var(--snowui-frame-transform-to, none);\n opacity: var(--snowui-frame-opacity-to, var(--snowui-frame-opacity-static, 1));\n filter: var(--snowui-frame-blur-to);\n }\n }'
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export default function FramePro($$renderer, $$props) {
|
|
37
|
-
$$renderer.global.css.add($$css);
|
|
38
|
-
|
|
39
|
-
$$renderer.component(($$renderer) => {
|
|
40
|
-
// 以下 5 个模块已迁入 OSS(v1.0.0 切割线变更,2026-05-06)
|
|
41
|
-
let { element = void 0, $$slots, $$events, ...rawProps } = $$props;
|
|
42
|
-
|
|
43
|
-
// === 0. Props ===
|
|
44
|
-
const frameProps = $.derived(() => rawProps);
|
|
45
|
-
|
|
46
|
-
provideComponentParts(() => frameProps().componentParts);
|
|
47
|
-
|
|
48
|
-
// === 0.1 能力开关推导 ===
|
|
49
|
-
// 默认全部开启,组件或用户可显式关闭
|
|
50
|
-
const enableResponsive = $.derived(() => frameProps().enableResponsive ?? true);
|
|
51
|
-
|
|
52
|
-
const enableContext = $.derived(() => frameProps().enableContext ?? true);
|
|
53
|
-
const enableScaleObserver = $.derived(() => frameProps().enableScaleObserver ?? false);
|
|
54
|
-
|
|
55
|
-
// === Orchestration Setup ===
|
|
56
|
-
// If 'styles' is provided, we act as a root orchestrator provider
|
|
57
|
-
function resolveInitialOrchestrator() {
|
|
58
|
-
if (rawProps.styles) {
|
|
59
|
-
return initOrchestrator();
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return getOrchestrator();
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const orchestrator = resolveInitialOrchestrator();
|
|
66
|
-
|
|
67
|
-
// Sync rules if this is the root
|
|
68
|
-
// === 1. 身份 (Identity) ===
|
|
69
|
-
// svelte-ignore state_referenced_locally
|
|
70
|
-
const identity = new Identity(frameProps());
|
|
71
|
-
|
|
72
|
-
// === 2. 响应式 (Responsive) ===
|
|
73
|
-
// 根据开关决定是否启用
|
|
74
|
-
const needsResponsive = $.derived(enableResponsive);
|
|
75
|
-
|
|
76
|
-
// svelte-ignore state_referenced_locally
|
|
77
|
-
const responsive = needsResponsive() ? new FrameResponsive() : null;
|
|
78
|
-
|
|
79
|
-
// === 3. 布局 (Layout) ===
|
|
80
|
-
// svelte-ignore state_referenced_locally
|
|
81
|
-
const layout = new FrameLayout(frameProps(), responsive);
|
|
82
|
-
|
|
83
|
-
// === 4. 状态 (State) ===
|
|
84
|
-
// 获取 motion 实例用于联动控制
|
|
85
|
-
const motionInstance = getContext(MOTION_ORCHESTRATOR_CONTEXT_KEY);
|
|
86
|
-
|
|
87
|
-
const parentSkeletonContext = getContext(SKELETON_CONTEXT_KEY);
|
|
88
|
-
|
|
89
|
-
// svelte-ignore state_referenced_locally
|
|
90
|
-
const frameState = new FrameState(frameProps(), motionInstance);
|
|
91
|
-
|
|
92
|
-
// === 5. 动效 (Motion) ===
|
|
93
|
-
// 动效能力始终可用(内置组件也需要)
|
|
94
|
-
// svelte-ignore state_referenced_locally
|
|
95
|
-
const motion = new FrameMotion(frameProps(), motionInstance, frameState, responsive, () => identity.id, () => element);
|
|
96
|
-
|
|
97
|
-
// === 6. 感知 (Perception) ===
|
|
98
|
-
// 根据开关决定是否提供 Context
|
|
99
|
-
// svelte-ignore state_referenced_locally
|
|
100
|
-
const inheritedLoading = $.derived(() => parentSkeletonContext?.loading ?? false);
|
|
101
|
-
|
|
102
|
-
const inheritedSkeleton = $.derived(() => parentSkeletonContext?.skeleton ?? true);
|
|
103
|
-
const explicitLoading = $.derived(() => frameProps().loading === true);
|
|
104
|
-
const explicitSkeleton = $.derived(() => frameProps().skeleton);
|
|
105
|
-
const stateLoading = $.derived(() => frameState.currentState === "StartLoad" || frameState.currentState === "Load");
|
|
106
|
-
const effectiveLoading = $.derived(() => inheritedLoading() || explicitLoading() || stateLoading());
|
|
107
|
-
const effectiveSkeleton = $.derived(() => explicitSkeleton() ?? inheritedSkeleton());
|
|
108
|
-
|
|
109
|
-
// svelte-ignore state_referenced_locally
|
|
110
|
-
if (enableContext()) {
|
|
111
|
-
// svelte-ignore state_referenced_locally
|
|
112
|
-
new FramePerception(frameProps(), frameState, layout, responsive, () => effectiveLoading(), () => effectiveSkeleton());
|
|
113
|
-
|
|
114
|
-
// 提供尺寸上下文给子组件(如资源组件选择正确分辨率)
|
|
115
|
-
// svelte-ignore state_referenced_locally
|
|
116
|
-
if (frameProps().size !== undefined) {
|
|
117
|
-
setContext(SIZE_CONTEXT_KEY, {
|
|
118
|
-
get size() {
|
|
119
|
-
return frameProps().size;
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// === Orchestration Registration & Monitoring ===
|
|
126
|
-
// Register self if ID is present
|
|
127
|
-
const scaleObserverOptions = $.derived(() => ({
|
|
128
|
-
...resolveScaleObserverOptions(frameProps()),
|
|
129
|
-
onResize: (width, height, size) => {
|
|
130
|
-
const id = identity.id;
|
|
131
|
-
|
|
132
|
-
if (id && orchestrator) {
|
|
133
|
-
orchestrator.updateState(id, { width, height, size });
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}));
|
|
137
|
-
|
|
138
|
-
const hasScaleApplyConfig = $.derived(() => frameProps().sizeRatio !== undefined || frameProps().iconSizeRatio !== undefined || frameProps().avatarSizeRatio !== undefined);
|
|
139
|
-
|
|
140
|
-
// === 辅助逻辑 ===
|
|
141
|
-
// 多指令支持
|
|
142
|
-
function multiuse(node, actions) {
|
|
143
|
-
const allActions = buildFrameActions({
|
|
144
|
-
userActions: actions,
|
|
145
|
-
scaleAction: enableScaleObserver() ? [frameScaleObserver, scaleObserverOptions()] : null,
|
|
146
|
-
responsiveAction: responsive?.resizeObserver ?? null
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
return mountFrameActions(node, allActions);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
const classStateRuntime = createFrameClassStateRuntime({
|
|
153
|
-
getFrameProps: () => frameProps(),
|
|
154
|
-
frameState,
|
|
155
|
-
layout,
|
|
156
|
-
responsive,
|
|
157
|
-
getEffectiveLoading: () => effectiveLoading(),
|
|
158
|
-
getElement: () => element
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
const resolvedStateStyle = $.derived(() => classStateRuntime.resolvedStateStyle);
|
|
162
|
-
const computedClass = $.derived(() => classStateRuntime.computedClass);
|
|
163
|
-
let skeletonProbe = void 0;
|
|
164
|
-
|
|
165
|
-
const skeletonRuntime = createFrameSkeletonRuntime({
|
|
166
|
-
getFrameProps: () => frameProps(),
|
|
167
|
-
getEffectiveLoading: () => effectiveLoading(),
|
|
168
|
-
getEffectiveSkeleton: () => effectiveSkeleton(),
|
|
169
|
-
// 兼容当前已安装的 OSS 类型;v1.1 runtime 不再读取 class key。
|
|
170
|
-
getSkeletonComponentKey: () => undefined,
|
|
171
|
-
getProbeHost: () => skeletonProbe
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
const shouldRenderSkeleton = $.derived(() => skeletonRuntime.shouldRenderSkeleton);
|
|
175
|
-
const needsSkeletonProbe = $.derived(() => skeletonRuntime.needsSkeletonProbe);
|
|
176
|
-
const shouldRenderProbedChildSkeletons = $.derived(() => skeletonRuntime.shouldRenderProbedChildSkeletons);
|
|
177
|
-
const shouldRenderDirectSkeleton = $.derived(() => skeletonRuntime.shouldRenderDirectSkeleton);
|
|
178
|
-
const probedSkeletonChildren = $.derived(() => skeletonRuntime.probedSkeletonChildren);
|
|
179
|
-
|
|
180
|
-
const inlineStyleRuntime = createFrameInlineStyleRuntime({
|
|
181
|
-
getFrameProps: () => frameProps(),
|
|
182
|
-
frameState,
|
|
183
|
-
motion,
|
|
184
|
-
getIdentityId: () => identity.id,
|
|
185
|
-
getEffectiveLoading: () => effectiveLoading(),
|
|
186
|
-
getShouldRenderSkeleton: () => shouldRenderSkeleton(),
|
|
187
|
-
getResolvedStateStyle: () => resolvedStateStyle(),
|
|
188
|
-
getOrchestratedStyle: () => identity.id && orchestrator ? orchestrator.getStyle(identity.id) : ""
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
const childrenRenderContext = $.derived(() => classStateRuntime.childrenRenderContext);
|
|
192
|
-
const computedStyle = $.derived(() => inlineStyleRuntime.computedStyle);
|
|
193
|
-
|
|
194
|
-
const domRuntime = createFrameDomRuntime({
|
|
195
|
-
getFrameProps: () => frameProps(),
|
|
196
|
-
frameState,
|
|
197
|
-
getEffectiveLoading: () => effectiveLoading(),
|
|
198
|
-
getHasScaleApplyConfig: () => hasScaleApplyConfig()
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
const resolvedTag = $.derived(() => domRuntime.resolvedTag);
|
|
202
|
-
const domPropsWithAccessibility = $.derived(() => domRuntime.domProps);
|
|
203
|
-
const captureHandlers = $.derived(() => domRuntime.captureHandlers);
|
|
204
|
-
const nativeHandlers = $.derived(() => domRuntime.nativeHandlers);
|
|
205
|
-
const runtimeDataAttrs = $.derived(() => domRuntime.dataAttrs);
|
|
206
|
-
|
|
207
|
-
function getController() {
|
|
208
|
-
return motion.controller;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
$.element(
|
|
212
|
-
$$renderer,
|
|
213
|
-
resolvedTag(),
|
|
214
|
-
() => {
|
|
215
|
-
$$renderer.push(`${$.attributes(
|
|
216
|
-
{
|
|
217
|
-
...domPropsWithAccessibility(),
|
|
218
|
-
id: identity.id,
|
|
219
|
-
'data-snowui-frame': true,
|
|
220
|
-
class: $.clsx(computedClass()),
|
|
221
|
-
style: computedStyle(),
|
|
222
|
-
...runtimeDataAttrs()
|
|
223
|
-
},
|
|
224
|
-
'svelte-m0vogk'
|
|
225
|
-
)}`);
|
|
226
|
-
},
|
|
227
|
-
() => {
|
|
228
|
-
if (needsSkeletonProbe() && frameProps().children) {
|
|
229
|
-
$$renderer.push('<!--[0-->');
|
|
230
|
-
$$renderer.push(`<div aria-hidden="true" style="display: none;">`);
|
|
231
|
-
frameProps().children($$renderer, childrenRenderContext());
|
|
232
|
-
$$renderer.push(`<!----></div>`);
|
|
233
|
-
} else {
|
|
234
|
-
$$renderer.push('<!--[-1-->');
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
$$renderer.push(`<!--]--> `);
|
|
238
|
-
|
|
239
|
-
if (shouldRenderProbedChildSkeletons()) {
|
|
240
|
-
$$renderer.push('<!--[0-->');
|
|
241
|
-
$$renderer.push(`<!--[-->`);
|
|
242
|
-
|
|
243
|
-
const each_array = $.ensure_array_like(probedSkeletonChildren());
|
|
244
|
-
|
|
245
|
-
for (let $$index = 0, $$length = each_array.length; $$index < $$length; $$index++) {
|
|
246
|
-
let child = each_array[$$index];
|
|
247
|
-
|
|
248
|
-
Skeleton($$renderer, {
|
|
249
|
-
componentClass: child.componentClass,
|
|
250
|
-
renderHints: child.renderHints
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
$$renderer.push(`<!--]-->`);
|
|
255
|
-
} else if (shouldRenderDirectSkeleton()) {
|
|
256
|
-
$$renderer.push('<!--[1-->');
|
|
257
|
-
|
|
258
|
-
Skeleton($$renderer, {
|
|
259
|
-
componentClass: computedClass(),
|
|
260
|
-
renderHints: frameProps().renderHints
|
|
261
|
-
});
|
|
262
|
-
} else if (frameProps().stateContent) {
|
|
263
|
-
$$renderer.push('<!--[2-->');
|
|
264
|
-
$$renderer.push(`<div style="display: grid; align-items: inherit; justify-content: inherit; gap: inherit; width: 100%; height: 100%;"><!--[-->`);
|
|
265
|
-
|
|
266
|
-
const each_array_1 = $.ensure_array_like(Object.entries(frameProps().stateContent));
|
|
267
|
-
|
|
268
|
-
for (let $$index_1 = 0, $$length = each_array_1.length; $$index_1 < $$length; $$index_1++) {
|
|
269
|
-
let [contentState, snippet] = each_array_1[$$index_1];
|
|
270
|
-
|
|
271
|
-
$$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
|
|
272
|
-
? `${FRAME_MOTION_DEFAULTS.contentCrossfadeIn.duration}ms ${FRAME_MOTION_DEFAULTS.contentCrossfadeIn.easing} ${FRAME_MOTION_DEFAULTS.contentCrossfadeIn.delay}ms`
|
|
273
|
-
: `${FRAME_MOTION_DEFAULTS.contentCrossfadeOut.duration}ms ${FRAME_MOTION_DEFAULTS.contentCrossfadeOut.easing}`};pointer-events:${frameState.currentState === contentState ? 'auto' : 'none'};`)}>`);
|
|
274
|
-
|
|
275
|
-
if (snippet) {
|
|
276
|
-
$$renderer.push('<!--[0-->');
|
|
277
|
-
snippet($$renderer);
|
|
278
|
-
$$renderer.push(`<!---->`);
|
|
279
|
-
} else {
|
|
280
|
-
$$renderer.push('<!--[-1-->');
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
$$renderer.push(`<!--]--></div>`);
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
$$renderer.push(`<!--]--></div>`);
|
|
287
|
-
} else if (frameProps().children) {
|
|
288
|
-
$$renderer.push('<!--[3-->');
|
|
289
|
-
frameProps().children($$renderer, childrenRenderContext());
|
|
290
|
-
$$renderer.push(`<!---->`);
|
|
291
|
-
} else {
|
|
292
|
-
$$renderer.push('<!--[-1-->');
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
$$renderer.push(`<!--]-->`);
|
|
296
|
-
}
|
|
297
|
-
);
|
|
298
|
-
|
|
299
|
-
$.bind_props($$props, { element, getController });
|
|
300
|
-
});
|
|
301
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { FrameProps } from "./frame-types";
|
|
2
|
-
import type { LayoutTransitionOptions } from "./motion-types";
|
|
3
|
-
import type { Motion } from "./motion.js";
|
|
4
|
-
import type { FrameState } from "./frame-pro-state.js";
|
|
5
|
-
import type { FrameResponsive } from "./frame-responsive.js";
|
|
6
|
-
import { type FlipTransitionOptions } from "./layout-flip";
|
|
7
|
-
export declare class FrameMotion {
|
|
8
|
-
#private;
|
|
9
|
-
constructor(props: FrameProps, motion: Motion | undefined, state: FrameState, responsive: FrameResponsive | null, getId: () => string | undefined, getElement: () => HTMLElement | undefined);
|
|
10
|
-
get shouldRegister(): boolean;
|
|
11
|
-
get controller(): {
|
|
12
|
-
play: (options?: {
|
|
13
|
-
reverse?: boolean;
|
|
14
|
-
}) => void;
|
|
15
|
-
captureLayout: (layoutId?: string) => void;
|
|
16
|
-
playLayoutTo: (target?: HTMLElement | DOMRect, options?: LayoutTransitionOptions & {
|
|
17
|
-
layoutId?: string;
|
|
18
|
-
}) => void;
|
|
19
|
-
/** 捕获当前 Frame 位置写入模块级 FLIP 注册表,无需 initMotion 上下文。 */
|
|
20
|
-
captureFlip: (layoutId?: string) => void;
|
|
21
|
-
/** 将当前 Frame 以 FLIP 方式过渡到目标位置,无需 initMotion 上下文。 */
|
|
22
|
-
playFlipTo: (target?: HTMLElement | DOMRect, options?: FlipTransitionOptions) => void;
|
|
23
|
-
reset: () => void;
|
|
24
|
-
pause: () => void;
|
|
25
|
-
};
|
|
26
|
-
}
|
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
/* frame-pro-motion.svelte.js generated by Svelte v5.56.4 */
|
|
2
|
-
import * as $ from 'svelte/internal/server';
|
|
3
|
-
import { hasMotionConfig } from "./frame-utils.js";
|
|
4
|
-
import { captureFlipRect, beginFlipEnter, applyFlipExit } from "./layout-flip.js";
|
|
5
|
-
|
|
6
|
-
export class FrameMotion {
|
|
7
|
-
#props;
|
|
8
|
-
#motion;
|
|
9
|
-
#state;
|
|
10
|
-
#responsive;
|
|
11
|
-
#getId;
|
|
12
|
-
#getElement;
|
|
13
|
-
|
|
14
|
-
constructor(props, motion, state, responsive, getId, getElement) {
|
|
15
|
-
this.#props = props;
|
|
16
|
-
this.#motion = motion;
|
|
17
|
-
this.#state = state;
|
|
18
|
-
this.#responsive = responsive;
|
|
19
|
-
this.#getId = getId;
|
|
20
|
-
this.#getElement = getElement;
|
|
21
|
-
|
|
22
|
-
// 注册到编排器,并触发独立 FLIP 进场(无需 Motion 上下文)
|
|
23
|
-
// 独立 FLIP 进场:layoutId/itemId 存在时尝试从模块注册表读取起点
|
|
24
|
-
// === 状态变化 -> 动效通知 (合并优化) ===
|
|
25
|
-
// 使用单一 effect 替代多个独立 effect,减少响应式订阅开销
|
|
26
|
-
// 缓存上一次的触发器状态,用于差量更新
|
|
27
|
-
let prevTriggerStates = {};
|
|
28
|
-
|
|
29
|
-
// 收集所有触发器状态
|
|
30
|
-
// 仅通知发生变化的触发器
|
|
31
|
-
// 生命周期通知 (单独保留,因为需要 cleanup)
|
|
32
|
-
// === 编排触发逻辑 ===
|
|
33
|
-
// 根据 orchestrateTrigger 决定何时触发编排
|
|
34
|
-
// 使用微任务或下一帧确保子组件已挂载并注册
|
|
35
|
-
// === orchestrateTrigger: hover ===
|
|
36
|
-
// === orchestrateTrigger: click ===
|
|
37
|
-
// === orchestrateTrigger: scroll ===
|
|
38
|
-
// 响应式断点通知
|
|
39
|
-
let prevBreakpoint;
|
|
40
|
-
// Setup whileScroll trigger
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
get shouldRegister() {
|
|
44
|
-
const id = this.#getId();
|
|
45
|
-
|
|
46
|
-
return !!id || hasMotionConfig(this.#props);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
get controller() {
|
|
50
|
-
return {
|
|
51
|
-
play: (options) => {
|
|
52
|
-
const id = this.#getId();
|
|
53
|
-
|
|
54
|
-
if (id && this.#motion) this.#motion.Play(id, options);
|
|
55
|
-
},
|
|
56
|
-
|
|
57
|
-
captureLayout: (layoutId) => {
|
|
58
|
-
const id = layoutId ?? this.#props.itemId ?? this.#props.layoutId ?? this.#getId();
|
|
59
|
-
const element = this.#getElement();
|
|
60
|
-
|
|
61
|
-
if (id && element && this.#motion) {
|
|
62
|
-
this.#motion.captureLayout(id, element);
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
|
|
66
|
-
playLayoutTo: (target, options) => {
|
|
67
|
-
const id = options?.layoutId ?? this.#props.itemId ?? this.#props.layoutId ?? this.#getId();
|
|
68
|
-
const element = this.#getElement();
|
|
69
|
-
|
|
70
|
-
if (id && element && this.#motion) {
|
|
71
|
-
this.#motion.playLayoutTo(id, element, target, options);
|
|
72
|
-
} else {
|
|
73
|
-
options?.onComplete?.();
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
/** 捕获当前 Frame 位置写入模块级 FLIP 注册表,无需 initMotion 上下文。 */
|
|
78
|
-
captureFlip: (layoutId) => {
|
|
79
|
-
const id = layoutId ?? this.#props.itemId ?? this.#props.layoutId ?? this.#getId();
|
|
80
|
-
const element = this.#getElement();
|
|
81
|
-
|
|
82
|
-
if (id && element) captureFlipRect(id, element);
|
|
83
|
-
},
|
|
84
|
-
|
|
85
|
-
/** 将当前 Frame 以 FLIP 方式过渡到目标位置,无需 initMotion 上下文。 */
|
|
86
|
-
playFlipTo: (target, options) => {
|
|
87
|
-
const element = this.#getElement();
|
|
88
|
-
|
|
89
|
-
if (element && target) {
|
|
90
|
-
applyFlipExit(element, target, options);
|
|
91
|
-
} else {
|
|
92
|
-
options?.onComplete?.();
|
|
93
|
-
}
|
|
94
|
-
},
|
|
95
|
-
|
|
96
|
-
reset: () => {
|
|
97
|
-
const id = this.#getId();
|
|
98
|
-
|
|
99
|
-
if (id && this.#motion) this.#motion.Reset(id);
|
|
100
|
-
},
|
|
101
|
-
|
|
102
|
-
pause: () => {
|
|
103
|
-
// TODO
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
#notify(event, detail) {
|
|
109
|
-
const id = this.#getId();
|
|
110
|
-
|
|
111
|
-
if (!this.#motion || !this.shouldRegister || !id) return;
|
|
112
|
-
|
|
113
|
-
this.#motion.notify(id, event, detail);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
#setupWhileScroll() {
|
|
117
|
-
const element = this.#getElement();
|
|
118
|
-
|
|
119
|
-
if (!element) return;
|
|
120
|
-
|
|
121
|
-
// 解析 offset 配置 (如 ["start center", "end center"])
|
|
122
|
-
const scrollConfig = this.#props.scroll;
|
|
123
|
-
|
|
124
|
-
const offset = scrollConfig?.offset ?? ["start center", "end center"];
|
|
125
|
-
|
|
126
|
-
// 解析偏移量
|
|
127
|
-
const parseOffset = (str) => {
|
|
128
|
-
const parts = str.split(" ");
|
|
129
|
-
|
|
130
|
-
return {
|
|
131
|
-
element: parts[0] || "start", // start, center, end
|
|
132
|
-
viewport: parts[1] || "center" // start, center, end
|
|
133
|
-
};
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
const startOffset = parseOffset(offset[0]);
|
|
137
|
-
|
|
138
|
-
const handleScroll = () => {
|
|
139
|
-
const rect = element.getBoundingClientRect();
|
|
140
|
-
const viewportHeight = window.innerHeight;
|
|
141
|
-
|
|
142
|
-
// 计算元素位置
|
|
143
|
-
const getElementPosition = (pos) => {
|
|
144
|
-
if (pos === "start") return rect.top;
|
|
145
|
-
if (pos === "end") return rect.bottom;
|
|
146
|
-
|
|
147
|
-
return rect.top + rect.height / 2; // center
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
// 计算视口位置
|
|
151
|
-
const getViewportPosition = (pos) => {
|
|
152
|
-
if (pos === "start") return 0;
|
|
153
|
-
if (pos === "end") return viewportHeight;
|
|
154
|
-
|
|
155
|
-
return viewportHeight / 2; // center
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
const elementPos = getElementPosition(startOffset.element);
|
|
159
|
-
const viewportTrigger = getViewportPosition(startOffset.viewport);
|
|
160
|
-
|
|
161
|
-
// 当元素位置到达视口触发点时激活
|
|
162
|
-
const isActive = elementPos <= viewportTrigger;
|
|
163
|
-
|
|
164
|
-
if (this.#state.isScrolling !== isActive) {
|
|
165
|
-
this.#state.isScrolling = isActive;
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
window.addEventListener("scroll", handleScroll);
|
|
170
|
-
handleScroll(); // Initial check
|
|
171
|
-
|
|
172
|
-
return () => {
|
|
173
|
-
window.removeEventListener("scroll", handleScroll);
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { FrameProps, CoreState } from "./frame-types";
|
|
2
|
-
import type { Motion } from "./motion.js";
|
|
3
|
-
export declare class FrameState {
|
|
4
|
-
#private;
|
|
5
|
-
hovered: boolean;
|
|
6
|
-
pressed: boolean;
|
|
7
|
-
focused: boolean;
|
|
8
|
-
isDragging: boolean;
|
|
9
|
-
isScrolling: boolean;
|
|
10
|
-
isKeyActive: boolean;
|
|
11
|
-
currentState: CoreState;
|
|
12
|
-
constructor(props: FrameProps, motion: Motion | undefined);
|
|
13
|
-
get interactionState(): (string & {}) | "StartLoad" | "Load" | "Reload" | "Appear" | "Disappear" | "Idle" | "Active" | "Disabled" | "Validating" | "Uploading" | "Editing" | "Click" | "Hover" | "Focus" | "Drag" | "Scroll";
|
|
14
|
-
get isAnyTriggerActive(): boolean | undefined;
|
|
15
|
-
handleClick: (e: MouseEvent) => void;
|
|
16
|
-
handleDblClick: (_e: MouseEvent) => void;
|
|
17
|
-
handleContextMenu: (_e: MouseEvent) => void;
|
|
18
|
-
handleMouseEnter: (e: MouseEvent) => void;
|
|
19
|
-
handleMouseLeave: () => void;
|
|
20
|
-
handleMouseDown: () => void;
|
|
21
|
-
handleMouseUp: (_e: MouseEvent) => void;
|
|
22
|
-
handleMouseMove: (_e: MouseEvent) => void;
|
|
23
|
-
handleTouchStart: (_e: TouchEvent) => void;
|
|
24
|
-
handleTouchEnd: (_e: TouchEvent) => void;
|
|
25
|
-
handleTouchMove: (_e: TouchEvent) => void;
|
|
26
|
-
handleTouchCancel: (_e: TouchEvent) => void;
|
|
27
|
-
handleFocus: (e: FocusEvent) => void;
|
|
28
|
-
handleBlur: () => void;
|
|
29
|
-
handleKeyDown: (e: KeyboardEvent) => void;
|
|
30
|
-
handleKeyUp: () => void;
|
|
31
|
-
handleKeyPress: (_e: KeyboardEvent) => void;
|
|
32
|
-
handleInput: (_e: Event) => void;
|
|
33
|
-
handleChange: (_e: Event) => void;
|
|
34
|
-
handleSubmit: (_e: Event) => void;
|
|
35
|
-
handleDragStart: (e: DragEvent) => void;
|
|
36
|
-
handleDrag: (_e: DragEvent) => void;
|
|
37
|
-
handleDragEnd: (_e: DragEvent) => void;
|
|
38
|
-
handleScroll: (_e: Event) => void;
|
|
39
|
-
}
|