@snowui-design-system/components 0.3.0-alpha.0 → 0.3.0-alpha.2
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/AGENTS.md +21 -0
- package/LICENSE +133 -89
- package/README.md +32 -11
- package/component-catalog.json +506 -106
- package/dist/client/blocks/Sidebar.js +21 -7
- package/dist/client/blocks/SidebarItem.js +2 -2
- package/dist/client/blocks/SidebarSection.js +2 -2
- package/dist/client/blocks/index.js +2 -0
- package/dist/client/compat.d.ts +1 -1
- package/dist/client/compat.js +3 -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/Text.js +36 -20
- package/dist/client/components/Toaster.js +1 -1
- package/dist/client/components/Tooltip.js +200 -195
- package/dist/client/context.js +2 -0
- package/dist/client/dev.js +2 -0
- package/dist/client/i18n/messages.d.ts +1 -1
- package/dist/client/i18n/messages.js +3 -1
- package/dist/client/index.d.ts +0 -1
- package/dist/client/index.js +5 -5
- package/dist/client/internal/code-block/prettier-svelte.d.ts +2 -0
- package/dist/client/internal/component-icon/index.js +2 -0
- package/dist/client/internal/snow-ui-logo/Wordmark.js +1 -1
- package/dist/client/internal/snow-ui-logo/emoji-metrics.js +2 -0
- package/dist/client/keys.js +2 -0
- package/dist/client/lib/adaptive-contrast-renderer.js +2 -0
- package/dist/client/lib/chart/appearance-timeline.js +2 -0
- package/dist/client/lib/chart/arc-path.js +2 -0
- package/dist/client/lib/chart/colors.js +2 -0
- package/dist/client/lib/chart/size.js +2 -0
- package/dist/client/lib/clipboard.js +2 -0
- package/dist/client/lib/color.js +2 -0
- package/dist/client/lib/date-format.js +2 -0
- package/dist/client/lib/edge-fade.js +3 -1
- package/dist/client/lib/number-format.js +2 -0
- package/dist/client/lib/overflow-actions-motion.js +2 -0
- package/dist/client/lib/overlay-trigger-timing.js +2 -0
- package/dist/client/lib/resizable.d.ts +1 -1
- package/dist/client/lib/responsive-exit.js +2 -0
- package/dist/client/lib/search-filter.js +2 -0
- package/dist/client/lib/side-panel.js +2 -0
- package/dist/client/lib/split-pane.js +2 -0
- package/dist/client/lib/table-column-motion.js +2 -0
- package/dist/client/lib/table-responsive.js +2 -0
- package/dist/client/lib/table-selection-fade.js +2 -0
- package/dist/client/lib/table-truncation.js +2 -0
- package/dist/client/lib/text-motion/animation.js +2 -0
- package/dist/client/lib/text-motion/character.js +2 -0
- package/dist/client/lib/text-motion/color.js +2 -0
- package/dist/client/lib/text-motion/layout.js +2 -0
- package/dist/client/lib/text-motion/preference.js +2 -0
- package/dist/client/lib/text-motion/sequence.js +2 -0
- package/dist/client/lib/text-motion/typography.js +2 -0
- package/dist/client/lib/tooltip-delay.js +2 -0
- package/dist/client/lib/tooltip-motion-dismiss.js +2 -0
- package/dist/client/lib/tooltip-pointer-speed.js +2 -0
- package/dist/client/lib/truncate.js +2 -0
- package/dist/client/logic/frame-field-control.js +2 -0
- package/dist/client/logic/frame-motion-defaults.js +2 -0
- package/dist/client/logic/frame-motion.d.ts +15 -23
- package/dist/client/logic/frame-motion.js +196 -30
- package/dist/client/logic/frame-prop-filter.js +2 -0
- package/dist/client/logic/frame-state.d.ts +2 -14
- package/dist/client/logic/frame-state.js +60 -9
- package/dist/client/logic/geometry-cache.js +2 -0
- package/dist/client/logic/layout-flip.js +2 -0
- package/dist/client/logic/morph.js +2 -0
- package/dist/client/logic/motion-engine.js +2 -0
- package/dist/client/logic/motion-orchestration.js +2 -0
- package/dist/client/logic/motion-types.js +2 -0
- package/dist/client/logic/wc-adapter.js +2 -0
- package/dist/client/motion/bridge.js +2 -0
- package/dist/client/motion/content-crossfade.js +2 -0
- package/dist/client/motion/expand.js +2 -0
- package/dist/client/motion/fade-in.js +2 -0
- package/dist/client/motion/fade-out.js +2 -0
- package/dist/client/motion/morph.js +2 -0
- package/dist/client/motion/move.js +2 -0
- package/dist/client/motion/number.d.ts +3 -3
- package/dist/client/motion/number.js +5 -3
- package/dist/client/motion/replace.js +2 -0
- package/dist/client/motion/rotate.css +2 -0
- package/dist/client/motion/rotate.js +2 -0
- package/dist/client/motion/scale-in.js +2 -0
- package/dist/client/motion/tokens.js +2 -0
- package/dist/client/motion/while-2xl.js +2 -0
- package/dist/client/motion/while-active.js +2 -0
- package/dist/client/motion/while-appear.js +2 -0
- package/dist/client/motion/while-click.js +2 -0
- package/dist/client/motion/while-collapsed.js +2 -0
- package/dist/client/motion/while-disabled.js +2 -0
- package/dist/client/motion/while-disappear.js +2 -0
- package/dist/client/motion/while-drag.js +2 -0
- package/dist/client/motion/while-editing.js +2 -0
- package/dist/client/motion/while-expanded.js +2 -0
- package/dist/client/motion/while-focus.js +2 -0
- package/dist/client/motion/while-hover.js +2 -0
- package/dist/client/motion/while-idle.js +2 -0
- package/dist/client/motion/while-key.js +2 -0
- package/dist/client/motion/while-lg.js +2 -0
- package/dist/client/motion/while-load.js +2 -0
- package/dist/client/motion/while-md.js +2 -0
- package/dist/client/motion/while-reload.js +2 -0
- package/dist/client/motion/while-scroll.js +2 -0
- package/dist/client/motion/while-sm.js +2 -0
- package/dist/client/motion/while-uploading.js +2 -0
- package/dist/client/motion/while-validating.js +2 -0
- package/dist/client/motion/while-xl.js +2 -0
- package/dist/client/motion/while-xs.js +2 -0
- package/dist/client/styles/auto-layout.css +3 -1
- package/dist/client/styles/backdrop.css +2 -0
- package/dist/client/styles/components.css +20 -18
- package/dist/client/styles/index.css +2 -0
- package/dist/client/styles/layout.css +9 -3
- package/dist/client/styles/scale.css +2 -0
- package/dist/client/styles/scrollbar.css +3 -1
- package/dist/client/styles/tokens.css +2 -0
- package/dist/client/vite-env.d.ts +2 -0
- package/dist/server/blocks/Sidebar.js +24 -18
- package/dist/server/blocks/SidebarItem.js +2 -2
- package/dist/server/blocks/SidebarSection.js +2 -2
- package/dist/server/blocks/index.js +2 -0
- package/dist/server/compat.d.ts +1 -1
- package/dist/server/compat.js +3 -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/Text.js +15 -11
- package/dist/server/components/Toaster.js +1 -1
- package/dist/server/components/Tooltip.js +10 -10
- package/dist/server/context.js +2 -0
- package/dist/server/dev.js +2 -0
- package/dist/server/i18n/messages.d.ts +1 -1
- package/dist/server/i18n/messages.js +3 -1
- package/dist/server/index.d.ts +0 -1
- package/dist/server/index.js +5 -5
- package/dist/server/internal/code-block/prettier-svelte.d.ts +2 -0
- package/dist/server/internal/component-icon/index.js +2 -0
- package/dist/server/internal/snow-ui-logo/Wordmark.js +1 -1
- package/dist/server/internal/snow-ui-logo/emoji-metrics.js +2 -0
- package/dist/server/keys.js +2 -0
- package/dist/server/lib/adaptive-contrast-renderer.js +2 -0
- package/dist/server/lib/chart/appearance-timeline.js +2 -0
- package/dist/server/lib/chart/arc-path.js +2 -0
- package/dist/server/lib/chart/colors.js +2 -0
- package/dist/server/lib/chart/size.js +2 -0
- package/dist/server/lib/clipboard.js +2 -0
- package/dist/server/lib/color.js +2 -0
- package/dist/server/lib/date-format.js +2 -0
- package/dist/server/lib/edge-fade.js +3 -1
- package/dist/server/lib/number-format.js +2 -0
- package/dist/server/lib/overflow-actions-motion.js +2 -0
- package/dist/server/lib/overlay-trigger-timing.js +2 -0
- package/dist/server/lib/resizable.d.ts +1 -1
- package/dist/server/lib/responsive-exit.js +2 -0
- package/dist/server/lib/search-filter.js +2 -0
- package/dist/server/lib/side-panel.js +2 -0
- package/dist/server/lib/split-pane.js +2 -0
- package/dist/server/lib/table-column-motion.js +2 -0
- package/dist/server/lib/table-responsive.js +2 -0
- package/dist/server/lib/table-selection-fade.js +2 -0
- package/dist/server/lib/table-truncation.js +2 -0
- package/dist/server/lib/text-motion/animation.js +2 -0
- package/dist/server/lib/text-motion/character.js +2 -0
- package/dist/server/lib/text-motion/color.js +2 -0
- package/dist/server/lib/text-motion/layout.js +2 -0
- package/dist/server/lib/text-motion/preference.js +2 -0
- package/dist/server/lib/text-motion/sequence.js +2 -0
- package/dist/server/lib/text-motion/typography.js +2 -0
- package/dist/server/lib/tooltip-delay.js +2 -0
- package/dist/server/lib/tooltip-motion-dismiss.js +2 -0
- package/dist/server/lib/tooltip-pointer-speed.js +2 -0
- package/dist/server/lib/truncate.js +2 -0
- package/dist/server/logic/frame-field-control.js +2 -0
- package/dist/server/logic/frame-motion-defaults.js +2 -0
- package/dist/server/logic/frame-motion.d.ts +15 -23
- package/dist/server/logic/frame-motion.js +75 -29
- package/dist/server/logic/frame-prop-filter.js +2 -0
- package/dist/server/logic/frame-state.d.ts +2 -14
- package/dist/server/logic/frame-state.js +60 -9
- package/dist/server/logic/geometry-cache.js +2 -0
- package/dist/server/logic/layout-flip.js +2 -0
- package/dist/server/logic/morph.js +2 -0
- package/dist/server/logic/motion-engine.js +2 -0
- package/dist/server/logic/motion-orchestration.js +2 -0
- package/dist/server/logic/motion-types.js +2 -0
- package/dist/server/logic/wc-adapter.js +2 -0
- package/dist/server/motion/bridge.js +2 -0
- package/dist/server/motion/content-crossfade.js +2 -0
- package/dist/server/motion/expand.js +2 -0
- package/dist/server/motion/fade-in.js +2 -0
- package/dist/server/motion/fade-out.js +2 -0
- package/dist/server/motion/morph.js +2 -0
- package/dist/server/motion/move.js +2 -0
- package/dist/server/motion/number.d.ts +3 -3
- package/dist/server/motion/number.js +5 -3
- package/dist/server/motion/replace.js +2 -0
- package/dist/server/motion/rotate.css +2 -0
- package/dist/server/motion/rotate.js +2 -0
- package/dist/server/motion/scale-in.js +2 -0
- package/dist/server/motion/tokens.js +2 -0
- package/dist/server/motion/while-2xl.js +2 -0
- package/dist/server/motion/while-active.js +2 -0
- package/dist/server/motion/while-appear.js +2 -0
- package/dist/server/motion/while-click.js +2 -0
- package/dist/server/motion/while-collapsed.js +2 -0
- package/dist/server/motion/while-disabled.js +2 -0
- package/dist/server/motion/while-disappear.js +2 -0
- package/dist/server/motion/while-drag.js +2 -0
- package/dist/server/motion/while-editing.js +2 -0
- package/dist/server/motion/while-expanded.js +2 -0
- package/dist/server/motion/while-focus.js +2 -0
- package/dist/server/motion/while-hover.js +2 -0
- package/dist/server/motion/while-idle.js +2 -0
- package/dist/server/motion/while-key.js +2 -0
- package/dist/server/motion/while-lg.js +2 -0
- package/dist/server/motion/while-load.js +2 -0
- package/dist/server/motion/while-md.js +2 -0
- package/dist/server/motion/while-reload.js +2 -0
- package/dist/server/motion/while-scroll.js +2 -0
- package/dist/server/motion/while-sm.js +2 -0
- package/dist/server/motion/while-uploading.js +2 -0
- package/dist/server/motion/while-validating.js +2 -0
- package/dist/server/motion/while-xl.js +2 -0
- package/dist/server/motion/while-xs.js +2 -0
- package/dist/server/styles/auto-layout.css +3 -1
- package/dist/server/styles/backdrop.css +2 -0
- package/dist/server/styles/components.css +20 -18
- package/dist/server/styles/index.css +2 -0
- package/dist/server/styles/layout.css +9 -3
- package/dist/server/styles/scale.css +2 -0
- package/dist/server/styles/scrollbar.css +3 -1
- package/dist/server/styles/tokens.css +2 -0
- package/dist/server/vite-env.d.ts +2 -0
- package/llms.txt +5 -0
- package/package.json +13 -6
- 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,538 +0,0 @@
|
|
|
1
|
-
/* frame-pro-state.svelte.js generated by Svelte v5.56.4 */
|
|
2
|
-
import * as $ from 'svelte/internal/client';
|
|
3
|
-
import { resolveFrameWhileMotionConfig } from "./frame-motion-defaults.js";
|
|
4
|
-
|
|
5
|
-
export class FrameState {
|
|
6
|
-
#props;
|
|
7
|
-
#motion;
|
|
8
|
-
|
|
9
|
-
#hovered = // === 交互状态 (Internal Interaction States) ===
|
|
10
|
-
$.state(false);
|
|
11
|
-
|
|
12
|
-
get hovered() {
|
|
13
|
-
return $.get(this.#hovered);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
set hovered(value) {
|
|
17
|
-
$.set(this.#hovered, value, true);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
#pressed = $.state(false);
|
|
21
|
-
|
|
22
|
-
get pressed() {
|
|
23
|
-
return $.get(this.#pressed);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
set pressed(value) {
|
|
27
|
-
$.set(this.#pressed, value, true);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
#focused = $.state(false);
|
|
31
|
-
|
|
32
|
-
get focused() {
|
|
33
|
-
return $.get(this.#focused);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
set focused(value) {
|
|
37
|
-
$.set(this.#focused, value, true);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
#isDragging = $.state(false);
|
|
41
|
-
|
|
42
|
-
get isDragging() {
|
|
43
|
-
return $.get(this.#isDragging);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
set isDragging(value) {
|
|
47
|
-
$.set(this.#isDragging, value, true);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
#isScrolling = $.state(false);
|
|
51
|
-
|
|
52
|
-
get isScrolling() {
|
|
53
|
-
return $.get(this.#isScrolling);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
set isScrolling(value) {
|
|
57
|
-
$.set(this.#isScrolling, value, true);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
#isKeyActive = $.state(false);
|
|
61
|
-
|
|
62
|
-
get isKeyActive() {
|
|
63
|
-
return $.get(this.#isKeyActive);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
set isKeyActive(value) {
|
|
67
|
-
$.set(this.#isKeyActive, value, true);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
#currentState = $.state("Idle");
|
|
71
|
-
|
|
72
|
-
get currentState() {
|
|
73
|
-
return $.get(this.#currentState);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
set currentState(value) {
|
|
77
|
-
$.set(this.#currentState, value, true);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
constructor(props, motion) {
|
|
81
|
-
this.#props = props;
|
|
82
|
-
this.#motion = motion;
|
|
83
|
-
|
|
84
|
-
$.user_effect(() => {
|
|
85
|
-
const controlledState = this.#props.currentState;
|
|
86
|
-
|
|
87
|
-
if (controlledState && this.currentState !== controlledState) {
|
|
88
|
-
this.currentState = controlledState;
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
// 状态变化时处理链式转变
|
|
93
|
-
$.user_effect(() => {
|
|
94
|
-
const transitionConfig = this.#getTransitionConfig(this.currentState);
|
|
95
|
-
const { nextState, auto, run } = this.#parseTransition(transitionConfig);
|
|
96
|
-
|
|
97
|
-
// 执行回调
|
|
98
|
-
if (run) {
|
|
99
|
-
run();
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// Reload 状态时调用 onReload 回调
|
|
103
|
-
if (this.currentState === "Reload" && this.#props.onReload) {
|
|
104
|
-
this.#props.onReload();
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
if (nextState && auto) {
|
|
108
|
-
const duration = this.#getDuration(this.currentState);
|
|
109
|
-
|
|
110
|
-
const timer = setTimeout(
|
|
111
|
-
() => {
|
|
112
|
-
this.currentState = nextState;
|
|
113
|
-
},
|
|
114
|
-
duration
|
|
115
|
-
);
|
|
116
|
-
|
|
117
|
-
return () => clearTimeout(timer);
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// === 综合状态 (Derived Interaction State) ===
|
|
123
|
-
get interactionState() {
|
|
124
|
-
// 优先使用声明式状态机状态
|
|
125
|
-
if (this.currentState !== "Idle") return this.currentState;
|
|
126
|
-
|
|
127
|
-
// 回退到传统状态判断
|
|
128
|
-
if (this.#props.whileDisabled) return "Disabled";
|
|
129
|
-
|
|
130
|
-
if (this.#props.loading) return "Load";
|
|
131
|
-
if (this.pressed) return "Click";
|
|
132
|
-
if (this.hovered) return "Hover";
|
|
133
|
-
if (this.focused) return "Focus";
|
|
134
|
-
if (this.isDragging) return "Drag";
|
|
135
|
-
if (this.isScrolling) return "Scroll";
|
|
136
|
-
|
|
137
|
-
return "Idle";
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// 是否有任何触发器激活 (用于 whileIdle)
|
|
141
|
-
get isAnyTriggerActive() {
|
|
142
|
-
return this.hovered || this.pressed || this.focused || this.isDragging || this.isScrolling || !!this.#props.loading || !!this.#props.whileActive || !!this.#props.whileDisabled || this.#props.collapsed || this.#props.expanded;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// === Helpers ===
|
|
146
|
-
#parseTransition(config) {
|
|
147
|
-
if (!config) return { nextState: null, auto: false };
|
|
148
|
-
|
|
149
|
-
// 1. 数组形式: [State, 'auto']
|
|
150
|
-
if (Array.isArray(config)) {
|
|
151
|
-
return { nextState: config[0], auto: config[1] === "auto" };
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// 2. 函数形式: () => void
|
|
155
|
-
if (typeof config === "function") {
|
|
156
|
-
return { nextState: null, auto: false, run: config };
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
// 3. 对象形式: { next, auto, run }
|
|
160
|
-
if (typeof config === "object" && ("next" in config || "run" in config)) {
|
|
161
|
-
return { nextState: config.next, auto: !!config.auto, run: config.run };
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
// 4. 字符串形式: State
|
|
165
|
-
return { nextState: config, auto: false };
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
#getWhileConfig(state) {
|
|
169
|
-
// 标准状态优先走统一默认动效解析,保证 auto 时长与默认/覆写配置一致
|
|
170
|
-
const configMap = {
|
|
171
|
-
StartLoad: resolveFrameWhileMotionConfig(this.#props, "whileLoad"),
|
|
172
|
-
Load: resolveFrameWhileMotionConfig(this.#props, "whileLoad"),
|
|
173
|
-
Reload: resolveFrameWhileMotionConfig(this.#props, "whileReload"),
|
|
174
|
-
Appear: resolveFrameWhileMotionConfig(this.#props, "whileAppear"),
|
|
175
|
-
Disappear: resolveFrameWhileMotionConfig(this.#props, "whileDisappear"),
|
|
176
|
-
Idle: resolveFrameWhileMotionConfig(this.#props, "whileIdle"),
|
|
177
|
-
Active: resolveFrameWhileMotionConfig(this.#props, "whileActive"),
|
|
178
|
-
Disabled: resolveFrameWhileMotionConfig(this.#props, "whileDisabled"),
|
|
179
|
-
Validating: resolveFrameWhileMotionConfig(this.#props, "whileValidating"),
|
|
180
|
-
Uploading: resolveFrameWhileMotionConfig(this.#props, "whileUploading"),
|
|
181
|
-
Editing: resolveFrameWhileMotionConfig(this.#props, "whileEditing")
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
// 标准状态直接返回(可为 undefined)
|
|
185
|
-
if (state in configMap) return configMap[state];
|
|
186
|
-
|
|
187
|
-
// 尝试获取动态属性 (Custom States): while[State]
|
|
188
|
-
const dynamicKey = `while${state}`;
|
|
189
|
-
|
|
190
|
-
return this.#props[dynamicKey];
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
#getDuration(state) {
|
|
194
|
-
const config = this.#getWhileConfig(state);
|
|
195
|
-
|
|
196
|
-
if (config && typeof config === "object" && "duration" in config) {
|
|
197
|
-
return config.duration;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
return 300; // 默认 300ms
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
#getTransitionConfig(state) {
|
|
204
|
-
const transitionMap = {
|
|
205
|
-
StartLoad: this.#props.StartLoad,
|
|
206
|
-
Load: this.#props.Load,
|
|
207
|
-
Reload: this.#props.Reload,
|
|
208
|
-
Appear: this.#props.Appear,
|
|
209
|
-
Disappear: this.#props.Disappear,
|
|
210
|
-
Idle: this.#props.Idle,
|
|
211
|
-
Active: this.#props.Active,
|
|
212
|
-
Disabled: this.#props.Disabled
|
|
213
|
-
};
|
|
214
|
-
|
|
215
|
-
// 如果是标准状态且有配置,直接返回
|
|
216
|
-
if (transitionMap[state]) return transitionMap[state];
|
|
217
|
-
|
|
218
|
-
// 尝试获取动态属性 (Custom States): [State]
|
|
219
|
-
return this.#props[state];
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
// === Event Handlers ===
|
|
223
|
-
#handleModifiers(e, config) {
|
|
224
|
-
if (config && typeof config === 'object') {
|
|
225
|
-
if (config.stop) e.stopPropagation();
|
|
226
|
-
if (config.prevent) e.preventDefault();
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
#isStateMapTrigger(config) {
|
|
231
|
-
if (!config || typeof config !== "object" || Array.isArray(config)) {
|
|
232
|
-
return false;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
// 这些字段属于普通 Trigger/Linkage 配置,不视为“按状态映射”
|
|
236
|
-
const reservedKeys = [
|
|
237
|
-
"run",
|
|
238
|
-
"target",
|
|
239
|
-
"action",
|
|
240
|
-
"reverse",
|
|
241
|
-
"state",
|
|
242
|
-
"key",
|
|
243
|
-
"next",
|
|
244
|
-
"auto",
|
|
245
|
-
"stop",
|
|
246
|
-
"prevent"
|
|
247
|
-
];
|
|
248
|
-
|
|
249
|
-
if (reservedKeys.some((key) => key in config)) return false;
|
|
250
|
-
|
|
251
|
-
return Object.keys(config).length > 0;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
#resolveStateMapTrigger(config) {
|
|
255
|
-
return config[this.currentState] ?? config.Idle;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
#applyEventTrigger(config, e) {
|
|
259
|
-
if (!config) return;
|
|
260
|
-
|
|
261
|
-
this.#handleModifiers(e, config);
|
|
262
|
-
|
|
263
|
-
if (typeof config === "function") {
|
|
264
|
-
config(e);
|
|
265
|
-
|
|
266
|
-
return;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
if (typeof config === "string") {
|
|
270
|
-
this.currentState = config;
|
|
271
|
-
|
|
272
|
-
return;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
if (Array.isArray(config)) {
|
|
276
|
-
if (typeof config[0] === "string") {
|
|
277
|
-
this.currentState = config[0];
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
return;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
if (typeof config === "object") {
|
|
284
|
-
if ("run" in config && typeof config.run === "function") {
|
|
285
|
-
config.run(e);
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
if ("state" in config && typeof config.state === "string") {
|
|
289
|
-
this.currentState = config.state;
|
|
290
|
-
} else if ("next" in config && typeof config.next === "string") {
|
|
291
|
-
this.currentState = config.next;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
if ("target" in config) {
|
|
295
|
-
this.#handleLinkageControl(config);
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
// --- Mouse Events ---
|
|
301
|
-
handleClick = (e) => {
|
|
302
|
-
const { Click } = this.#props;
|
|
303
|
-
|
|
304
|
-
if (!Click) return;
|
|
305
|
-
|
|
306
|
-
// 支持按当前状态分发点击触发器:
|
|
307
|
-
// Click={{ Idle: "Load", Active: "Idle" }}
|
|
308
|
-
if (this.#isStateMapTrigger(Click)) {
|
|
309
|
-
const mapped = this.#resolveStateMapTrigger(Click);
|
|
310
|
-
|
|
311
|
-
this.#applyEventTrigger(mapped, e);
|
|
312
|
-
|
|
313
|
-
return;
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
// 兼容旧行为:非映射模式仅在 Idle 状态响应 Click
|
|
317
|
-
if (this.currentState !== "Idle") return;
|
|
318
|
-
|
|
319
|
-
this.#applyEventTrigger(Click, e);
|
|
320
|
-
};
|
|
321
|
-
|
|
322
|
-
handleDblClick = (_e) => {
|
|
323
|
-
// Reserved for future DblClick prop
|
|
324
|
-
};
|
|
325
|
-
|
|
326
|
-
handleContextMenu = (_e) => {
|
|
327
|
-
// Reserved for future ContextMenu prop
|
|
328
|
-
};
|
|
329
|
-
|
|
330
|
-
handleMouseEnter = (e) => {
|
|
331
|
-
this.hovered = true;
|
|
332
|
-
|
|
333
|
-
const { Hover } = this.#props;
|
|
334
|
-
|
|
335
|
-
if (Hover) {
|
|
336
|
-
this.#handleModifiers(e, Hover);
|
|
337
|
-
|
|
338
|
-
if (typeof Hover === "function") {
|
|
339
|
-
Hover(e);
|
|
340
|
-
} else if (typeof Hover === "string") {
|
|
341
|
-
this.currentState = Hover;
|
|
342
|
-
} else if (typeof Hover === "object") {
|
|
343
|
-
if ("run" in Hover && typeof Hover.run === "function") {
|
|
344
|
-
Hover.run(e);
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
if ("target" in Hover) {
|
|
348
|
-
this.#handleLinkageControl(Hover);
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
};
|
|
353
|
-
|
|
354
|
-
handleMouseLeave = () => {
|
|
355
|
-
this.hovered = false;
|
|
356
|
-
this.pressed = false;
|
|
357
|
-
};
|
|
358
|
-
|
|
359
|
-
handleMouseDown = () => {
|
|
360
|
-
this.pressed = true;
|
|
361
|
-
};
|
|
362
|
-
|
|
363
|
-
handleMouseUp = (_e) => {
|
|
364
|
-
this.pressed = false;
|
|
365
|
-
|
|
366
|
-
// Click logic moved to handleClick
|
|
367
|
-
};
|
|
368
|
-
|
|
369
|
-
handleMouseMove = (_e) => {
|
|
370
|
-
// Reserved
|
|
371
|
-
};
|
|
372
|
-
|
|
373
|
-
// --- Touch Events ---
|
|
374
|
-
handleTouchStart = (_e) => {
|
|
375
|
-
this.pressed = true;
|
|
376
|
-
};
|
|
377
|
-
|
|
378
|
-
handleTouchEnd = (_e) => {
|
|
379
|
-
this.pressed = false;
|
|
380
|
-
};
|
|
381
|
-
|
|
382
|
-
handleTouchMove = (_e) => {
|
|
383
|
-
// Reserved
|
|
384
|
-
};
|
|
385
|
-
|
|
386
|
-
handleTouchCancel = (_e) => {
|
|
387
|
-
this.pressed = false;
|
|
388
|
-
};
|
|
389
|
-
|
|
390
|
-
// --- Focus Events ---
|
|
391
|
-
handleFocus = (e) => {
|
|
392
|
-
this.focused = true;
|
|
393
|
-
|
|
394
|
-
const { Focus } = this.#props;
|
|
395
|
-
|
|
396
|
-
if (Focus) {
|
|
397
|
-
this.#handleModifiers(e, Focus);
|
|
398
|
-
|
|
399
|
-
if (typeof Focus === "function") {
|
|
400
|
-
Focus(e);
|
|
401
|
-
} else if (typeof Focus === "string") {
|
|
402
|
-
this.currentState = Focus;
|
|
403
|
-
} else if (typeof Focus === "object") {
|
|
404
|
-
if ("run" in Focus && typeof Focus.run === "function") {
|
|
405
|
-
Focus.run(e);
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
if ("target" in Focus) {
|
|
409
|
-
this.#handleLinkageControl(Focus);
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
};
|
|
414
|
-
|
|
415
|
-
handleBlur = () => {
|
|
416
|
-
this.focused = false;
|
|
417
|
-
};
|
|
418
|
-
|
|
419
|
-
// --- Keyboard Events ---
|
|
420
|
-
handleKeyDown = (e) => {
|
|
421
|
-
this.isKeyActive = true;
|
|
422
|
-
|
|
423
|
-
const { Key } = this.#props;
|
|
424
|
-
|
|
425
|
-
if (Key && e.key === Key.key) {
|
|
426
|
-
this.#handleModifiers(e, Key);
|
|
427
|
-
|
|
428
|
-
if ("run" in Key && typeof Key.run === "function") {
|
|
429
|
-
Key.run(e);
|
|
430
|
-
} else if ("state" in Key) {
|
|
431
|
-
this.currentState = Key.state;
|
|
432
|
-
} else if ("target" in Key) {
|
|
433
|
-
this.#handleLinkageControl(Key);
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
};
|
|
437
|
-
|
|
438
|
-
handleKeyUp = () => {
|
|
439
|
-
this.isKeyActive = false;
|
|
440
|
-
};
|
|
441
|
-
|
|
442
|
-
handleKeyPress = (_e) => {
|
|
443
|
-
// Reserved
|
|
444
|
-
};
|
|
445
|
-
|
|
446
|
-
// --- Form Events ---
|
|
447
|
-
handleInput = (_e) => {
|
|
448
|
-
// Reserved
|
|
449
|
-
};
|
|
450
|
-
|
|
451
|
-
handleChange = (_e) => {
|
|
452
|
-
// Reserved
|
|
453
|
-
};
|
|
454
|
-
|
|
455
|
-
handleSubmit = (_e) => {
|
|
456
|
-
// Reserved
|
|
457
|
-
};
|
|
458
|
-
|
|
459
|
-
// --- Drag Events ---
|
|
460
|
-
handleDragStart = (e) => {
|
|
461
|
-
this.isDragging = true;
|
|
462
|
-
|
|
463
|
-
const { Drag } = this.#props;
|
|
464
|
-
|
|
465
|
-
if (Drag) {
|
|
466
|
-
this.#handleModifiers(e, Drag);
|
|
467
|
-
|
|
468
|
-
if (typeof Drag === "function") {
|
|
469
|
-
Drag(e);
|
|
470
|
-
} else if (typeof Drag === "string") {
|
|
471
|
-
this.currentState = Drag;
|
|
472
|
-
} else if (typeof Drag === "object") {
|
|
473
|
-
if ("run" in Drag && typeof Drag.run === "function") {
|
|
474
|
-
Drag.run(e);
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
if ("target" in Drag) {
|
|
478
|
-
this.#handleLinkageControl(Drag);
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
};
|
|
483
|
-
|
|
484
|
-
handleDrag = (_e) => {
|
|
485
|
-
// Reserved for future Drag move handling
|
|
486
|
-
};
|
|
487
|
-
|
|
488
|
-
handleDragEnd = (_e) => {
|
|
489
|
-
this.isDragging = false;
|
|
490
|
-
};
|
|
491
|
-
|
|
492
|
-
// --- UI Events ---
|
|
493
|
-
handleScroll = (_e) => {
|
|
494
|
-
// Reserved
|
|
495
|
-
};
|
|
496
|
-
|
|
497
|
-
#handleLinkageControl(config) {
|
|
498
|
-
if (config.target) {
|
|
499
|
-
// 1. Resolve Target Controller
|
|
500
|
-
let controller;
|
|
501
|
-
|
|
502
|
-
if (typeof config.target === 'string') {
|
|
503
|
-
// String ID -> Use internal motion instance
|
|
504
|
-
// No controller object for string IDs, handled in step 2 directly via this.#motion
|
|
505
|
-
} else if (typeof config.target === 'object') {
|
|
506
|
-
// Object Ref -> Try to get controller
|
|
507
|
-
// Case A: Svelte 5 bind:this instance with exported getController
|
|
508
|
-
if ('getController' in config.target && typeof config.target.getController === 'function') {
|
|
509
|
-
controller = config.target.getController();
|
|
510
|
-
} else // Case B: Maybe it IS the controller?
|
|
511
|
-
{
|
|
512
|
-
controller = config.target;
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
// 2. Execute Action
|
|
517
|
-
if (typeof config.target === 'string' && this.#motion) {
|
|
518
|
-
// Legacy String ID Logic
|
|
519
|
-
if (config.action === "play") {
|
|
520
|
-
this.#motion.Play(config.target, { reverse: config.reverse });
|
|
521
|
-
} else if (config.action === "reset") {
|
|
522
|
-
this.#motion.Reset(config.target);
|
|
523
|
-
} else if (config.action === "pause") {
|
|
524
|
-
this.#motion.pause(config.target);
|
|
525
|
-
}
|
|
526
|
-
} else if (controller) {
|
|
527
|
-
// Object Controller Logic
|
|
528
|
-
if (config.action === "play" && controller.play) {
|
|
529
|
-
controller.play({ reverse: config.reverse });
|
|
530
|
-
} else if (config.action === "reset" && controller.reset) {
|
|
531
|
-
controller.reset();
|
|
532
|
-
} else if (config.action === "pause" && controller.pause) {
|
|
533
|
-
controller.pause();
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export * from "../logic/frame-types";
|
|
2
|
-
import "../motion/rotate.css";
|
|
3
|
-
import type { FrameProps } from "../logic/frame-types";
|
|
4
|
-
interface Props extends FrameProps {
|
|
5
|
-
[key: string]: any;
|
|
6
|
-
}
|
|
7
|
-
declare const FramePro: import("svelte").Component<Props, {
|
|
8
|
-
getController: () => {
|
|
9
|
-
play: (options?: {
|
|
10
|
-
reverse?: boolean;
|
|
11
|
-
} | undefined) => void;
|
|
12
|
-
captureLayout: (layoutId?: string) => void;
|
|
13
|
-
playLayoutTo: (target?: HTMLElement | DOMRect, options?: (import("../logic/motion-types").LayoutTransitionOptions & {
|
|
14
|
-
layoutId?: string;
|
|
15
|
-
}) | undefined) => void;
|
|
16
|
-
captureFlip: (layoutId?: string) => void;
|
|
17
|
-
playFlipTo: (target?: HTMLElement | DOMRect, options?: import("../logic/layout-flip").FlipTransitionOptions) => void;
|
|
18
|
-
reset: () => void;
|
|
19
|
-
pause: () => void;
|
|
20
|
-
};
|
|
21
|
-
}, "element">;
|
|
22
|
-
type FramePro = ReturnType<typeof FramePro>;
|
|
23
|
-
export default FramePro;
|