@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.
Files changed (270) hide show
  1. package/AGENTS.md +21 -0
  2. package/LICENSE +133 -89
  3. package/README.md +32 -11
  4. package/component-catalog.json +506 -106
  5. package/dist/client/blocks/Sidebar.js +21 -7
  6. package/dist/client/blocks/SidebarItem.js +2 -2
  7. package/dist/client/blocks/SidebarSection.js +2 -2
  8. package/dist/client/blocks/index.js +2 -0
  9. package/dist/client/compat.d.ts +1 -1
  10. package/dist/client/compat.js +3 -1
  11. package/dist/client/components/BlurText.js +2 -2
  12. package/dist/client/components/DataTable.js +2 -2
  13. package/dist/client/components/FlowText.js +2 -2
  14. package/dist/client/components/Frame.d.ts +9 -0
  15. package/dist/client/components/Frame.js +82 -24
  16. package/dist/client/components/GradientMotion.d.ts +1 -1
  17. package/dist/client/components/GradientMotion.js +2 -2
  18. package/dist/client/components/NumberFlow.js +4 -4
  19. package/dist/client/components/NumericText.js +2 -2
  20. package/dist/client/components/ScrambleText.js +2 -2
  21. package/dist/client/components/SidePanel.js +3 -3
  22. package/dist/client/components/SlotText.js +2 -2
  23. package/dist/client/components/TableCell.js +1 -1
  24. package/dist/client/components/Text.js +36 -20
  25. package/dist/client/components/Toaster.js +1 -1
  26. package/dist/client/components/Tooltip.js +200 -195
  27. package/dist/client/context.js +2 -0
  28. package/dist/client/dev.js +2 -0
  29. package/dist/client/i18n/messages.d.ts +1 -1
  30. package/dist/client/i18n/messages.js +3 -1
  31. package/dist/client/index.d.ts +0 -1
  32. package/dist/client/index.js +5 -5
  33. package/dist/client/internal/code-block/prettier-svelte.d.ts +2 -0
  34. package/dist/client/internal/component-icon/index.js +2 -0
  35. package/dist/client/internal/snow-ui-logo/Wordmark.js +1 -1
  36. package/dist/client/internal/snow-ui-logo/emoji-metrics.js +2 -0
  37. package/dist/client/keys.js +2 -0
  38. package/dist/client/lib/adaptive-contrast-renderer.js +2 -0
  39. package/dist/client/lib/chart/appearance-timeline.js +2 -0
  40. package/dist/client/lib/chart/arc-path.js +2 -0
  41. package/dist/client/lib/chart/colors.js +2 -0
  42. package/dist/client/lib/chart/size.js +2 -0
  43. package/dist/client/lib/clipboard.js +2 -0
  44. package/dist/client/lib/color.js +2 -0
  45. package/dist/client/lib/date-format.js +2 -0
  46. package/dist/client/lib/edge-fade.js +3 -1
  47. package/dist/client/lib/number-format.js +2 -0
  48. package/dist/client/lib/overflow-actions-motion.js +2 -0
  49. package/dist/client/lib/overlay-trigger-timing.js +2 -0
  50. package/dist/client/lib/resizable.d.ts +1 -1
  51. package/dist/client/lib/responsive-exit.js +2 -0
  52. package/dist/client/lib/search-filter.js +2 -0
  53. package/dist/client/lib/side-panel.js +2 -0
  54. package/dist/client/lib/split-pane.js +2 -0
  55. package/dist/client/lib/table-column-motion.js +2 -0
  56. package/dist/client/lib/table-responsive.js +2 -0
  57. package/dist/client/lib/table-selection-fade.js +2 -0
  58. package/dist/client/lib/table-truncation.js +2 -0
  59. package/dist/client/lib/text-motion/animation.js +2 -0
  60. package/dist/client/lib/text-motion/character.js +2 -0
  61. package/dist/client/lib/text-motion/color.js +2 -0
  62. package/dist/client/lib/text-motion/layout.js +2 -0
  63. package/dist/client/lib/text-motion/preference.js +2 -0
  64. package/dist/client/lib/text-motion/sequence.js +2 -0
  65. package/dist/client/lib/text-motion/typography.js +2 -0
  66. package/dist/client/lib/tooltip-delay.js +2 -0
  67. package/dist/client/lib/tooltip-motion-dismiss.js +2 -0
  68. package/dist/client/lib/tooltip-pointer-speed.js +2 -0
  69. package/dist/client/lib/truncate.js +2 -0
  70. package/dist/client/logic/frame-field-control.js +2 -0
  71. package/dist/client/logic/frame-motion-defaults.js +2 -0
  72. package/dist/client/logic/frame-motion.d.ts +15 -23
  73. package/dist/client/logic/frame-motion.js +196 -30
  74. package/dist/client/logic/frame-prop-filter.js +2 -0
  75. package/dist/client/logic/frame-state.d.ts +2 -14
  76. package/dist/client/logic/frame-state.js +60 -9
  77. package/dist/client/logic/geometry-cache.js +2 -0
  78. package/dist/client/logic/layout-flip.js +2 -0
  79. package/dist/client/logic/morph.js +2 -0
  80. package/dist/client/logic/motion-engine.js +2 -0
  81. package/dist/client/logic/motion-orchestration.js +2 -0
  82. package/dist/client/logic/motion-types.js +2 -0
  83. package/dist/client/logic/wc-adapter.js +2 -0
  84. package/dist/client/motion/bridge.js +2 -0
  85. package/dist/client/motion/content-crossfade.js +2 -0
  86. package/dist/client/motion/expand.js +2 -0
  87. package/dist/client/motion/fade-in.js +2 -0
  88. package/dist/client/motion/fade-out.js +2 -0
  89. package/dist/client/motion/morph.js +2 -0
  90. package/dist/client/motion/move.js +2 -0
  91. package/dist/client/motion/number.d.ts +3 -3
  92. package/dist/client/motion/number.js +5 -3
  93. package/dist/client/motion/replace.js +2 -0
  94. package/dist/client/motion/rotate.css +2 -0
  95. package/dist/client/motion/rotate.js +2 -0
  96. package/dist/client/motion/scale-in.js +2 -0
  97. package/dist/client/motion/tokens.js +2 -0
  98. package/dist/client/motion/while-2xl.js +2 -0
  99. package/dist/client/motion/while-active.js +2 -0
  100. package/dist/client/motion/while-appear.js +2 -0
  101. package/dist/client/motion/while-click.js +2 -0
  102. package/dist/client/motion/while-collapsed.js +2 -0
  103. package/dist/client/motion/while-disabled.js +2 -0
  104. package/dist/client/motion/while-disappear.js +2 -0
  105. package/dist/client/motion/while-drag.js +2 -0
  106. package/dist/client/motion/while-editing.js +2 -0
  107. package/dist/client/motion/while-expanded.js +2 -0
  108. package/dist/client/motion/while-focus.js +2 -0
  109. package/dist/client/motion/while-hover.js +2 -0
  110. package/dist/client/motion/while-idle.js +2 -0
  111. package/dist/client/motion/while-key.js +2 -0
  112. package/dist/client/motion/while-lg.js +2 -0
  113. package/dist/client/motion/while-load.js +2 -0
  114. package/dist/client/motion/while-md.js +2 -0
  115. package/dist/client/motion/while-reload.js +2 -0
  116. package/dist/client/motion/while-scroll.js +2 -0
  117. package/dist/client/motion/while-sm.js +2 -0
  118. package/dist/client/motion/while-uploading.js +2 -0
  119. package/dist/client/motion/while-validating.js +2 -0
  120. package/dist/client/motion/while-xl.js +2 -0
  121. package/dist/client/motion/while-xs.js +2 -0
  122. package/dist/client/styles/auto-layout.css +3 -1
  123. package/dist/client/styles/backdrop.css +2 -0
  124. package/dist/client/styles/components.css +20 -18
  125. package/dist/client/styles/index.css +2 -0
  126. package/dist/client/styles/layout.css +9 -3
  127. package/dist/client/styles/scale.css +2 -0
  128. package/dist/client/styles/scrollbar.css +3 -1
  129. package/dist/client/styles/tokens.css +2 -0
  130. package/dist/client/vite-env.d.ts +2 -0
  131. package/dist/server/blocks/Sidebar.js +24 -18
  132. package/dist/server/blocks/SidebarItem.js +2 -2
  133. package/dist/server/blocks/SidebarSection.js +2 -2
  134. package/dist/server/blocks/index.js +2 -0
  135. package/dist/server/compat.d.ts +1 -1
  136. package/dist/server/compat.js +3 -1
  137. package/dist/server/components/BlurText.js +2 -2
  138. package/dist/server/components/DataTable.js +2 -2
  139. package/dist/server/components/FlowText.js +2 -2
  140. package/dist/server/components/Frame.d.ts +9 -0
  141. package/dist/server/components/Frame.js +52 -24
  142. package/dist/server/components/GradientMotion.d.ts +1 -1
  143. package/dist/server/components/GradientMotion.js +2 -2
  144. package/dist/server/components/NumberFlow.js +4 -4
  145. package/dist/server/components/NumericText.js +2 -2
  146. package/dist/server/components/ScrambleText.js +2 -2
  147. package/dist/server/components/SidePanel.js +3 -3
  148. package/dist/server/components/SlotText.js +2 -2
  149. package/dist/server/components/TableCell.js +1 -1
  150. package/dist/server/components/Text.js +15 -11
  151. package/dist/server/components/Toaster.js +1 -1
  152. package/dist/server/components/Tooltip.js +10 -10
  153. package/dist/server/context.js +2 -0
  154. package/dist/server/dev.js +2 -0
  155. package/dist/server/i18n/messages.d.ts +1 -1
  156. package/dist/server/i18n/messages.js +3 -1
  157. package/dist/server/index.d.ts +0 -1
  158. package/dist/server/index.js +5 -5
  159. package/dist/server/internal/code-block/prettier-svelte.d.ts +2 -0
  160. package/dist/server/internal/component-icon/index.js +2 -0
  161. package/dist/server/internal/snow-ui-logo/Wordmark.js +1 -1
  162. package/dist/server/internal/snow-ui-logo/emoji-metrics.js +2 -0
  163. package/dist/server/keys.js +2 -0
  164. package/dist/server/lib/adaptive-contrast-renderer.js +2 -0
  165. package/dist/server/lib/chart/appearance-timeline.js +2 -0
  166. package/dist/server/lib/chart/arc-path.js +2 -0
  167. package/dist/server/lib/chart/colors.js +2 -0
  168. package/dist/server/lib/chart/size.js +2 -0
  169. package/dist/server/lib/clipboard.js +2 -0
  170. package/dist/server/lib/color.js +2 -0
  171. package/dist/server/lib/date-format.js +2 -0
  172. package/dist/server/lib/edge-fade.js +3 -1
  173. package/dist/server/lib/number-format.js +2 -0
  174. package/dist/server/lib/overflow-actions-motion.js +2 -0
  175. package/dist/server/lib/overlay-trigger-timing.js +2 -0
  176. package/dist/server/lib/resizable.d.ts +1 -1
  177. package/dist/server/lib/responsive-exit.js +2 -0
  178. package/dist/server/lib/search-filter.js +2 -0
  179. package/dist/server/lib/side-panel.js +2 -0
  180. package/dist/server/lib/split-pane.js +2 -0
  181. package/dist/server/lib/table-column-motion.js +2 -0
  182. package/dist/server/lib/table-responsive.js +2 -0
  183. package/dist/server/lib/table-selection-fade.js +2 -0
  184. package/dist/server/lib/table-truncation.js +2 -0
  185. package/dist/server/lib/text-motion/animation.js +2 -0
  186. package/dist/server/lib/text-motion/character.js +2 -0
  187. package/dist/server/lib/text-motion/color.js +2 -0
  188. package/dist/server/lib/text-motion/layout.js +2 -0
  189. package/dist/server/lib/text-motion/preference.js +2 -0
  190. package/dist/server/lib/text-motion/sequence.js +2 -0
  191. package/dist/server/lib/text-motion/typography.js +2 -0
  192. package/dist/server/lib/tooltip-delay.js +2 -0
  193. package/dist/server/lib/tooltip-motion-dismiss.js +2 -0
  194. package/dist/server/lib/tooltip-pointer-speed.js +2 -0
  195. package/dist/server/lib/truncate.js +2 -0
  196. package/dist/server/logic/frame-field-control.js +2 -0
  197. package/dist/server/logic/frame-motion-defaults.js +2 -0
  198. package/dist/server/logic/frame-motion.d.ts +15 -23
  199. package/dist/server/logic/frame-motion.js +75 -29
  200. package/dist/server/logic/frame-prop-filter.js +2 -0
  201. package/dist/server/logic/frame-state.d.ts +2 -14
  202. package/dist/server/logic/frame-state.js +60 -9
  203. package/dist/server/logic/geometry-cache.js +2 -0
  204. package/dist/server/logic/layout-flip.js +2 -0
  205. package/dist/server/logic/morph.js +2 -0
  206. package/dist/server/logic/motion-engine.js +2 -0
  207. package/dist/server/logic/motion-orchestration.js +2 -0
  208. package/dist/server/logic/motion-types.js +2 -0
  209. package/dist/server/logic/wc-adapter.js +2 -0
  210. package/dist/server/motion/bridge.js +2 -0
  211. package/dist/server/motion/content-crossfade.js +2 -0
  212. package/dist/server/motion/expand.js +2 -0
  213. package/dist/server/motion/fade-in.js +2 -0
  214. package/dist/server/motion/fade-out.js +2 -0
  215. package/dist/server/motion/morph.js +2 -0
  216. package/dist/server/motion/move.js +2 -0
  217. package/dist/server/motion/number.d.ts +3 -3
  218. package/dist/server/motion/number.js +5 -3
  219. package/dist/server/motion/replace.js +2 -0
  220. package/dist/server/motion/rotate.css +2 -0
  221. package/dist/server/motion/rotate.js +2 -0
  222. package/dist/server/motion/scale-in.js +2 -0
  223. package/dist/server/motion/tokens.js +2 -0
  224. package/dist/server/motion/while-2xl.js +2 -0
  225. package/dist/server/motion/while-active.js +2 -0
  226. package/dist/server/motion/while-appear.js +2 -0
  227. package/dist/server/motion/while-click.js +2 -0
  228. package/dist/server/motion/while-collapsed.js +2 -0
  229. package/dist/server/motion/while-disabled.js +2 -0
  230. package/dist/server/motion/while-disappear.js +2 -0
  231. package/dist/server/motion/while-drag.js +2 -0
  232. package/dist/server/motion/while-editing.js +2 -0
  233. package/dist/server/motion/while-expanded.js +2 -0
  234. package/dist/server/motion/while-focus.js +2 -0
  235. package/dist/server/motion/while-hover.js +2 -0
  236. package/dist/server/motion/while-idle.js +2 -0
  237. package/dist/server/motion/while-key.js +2 -0
  238. package/dist/server/motion/while-lg.js +2 -0
  239. package/dist/server/motion/while-load.js +2 -0
  240. package/dist/server/motion/while-md.js +2 -0
  241. package/dist/server/motion/while-reload.js +2 -0
  242. package/dist/server/motion/while-scroll.js +2 -0
  243. package/dist/server/motion/while-sm.js +2 -0
  244. package/dist/server/motion/while-uploading.js +2 -0
  245. package/dist/server/motion/while-validating.js +2 -0
  246. package/dist/server/motion/while-xl.js +2 -0
  247. package/dist/server/motion/while-xs.js +2 -0
  248. package/dist/server/styles/auto-layout.css +3 -1
  249. package/dist/server/styles/backdrop.css +2 -0
  250. package/dist/server/styles/components.css +20 -18
  251. package/dist/server/styles/index.css +2 -0
  252. package/dist/server/styles/layout.css +9 -3
  253. package/dist/server/styles/scale.css +2 -0
  254. package/dist/server/styles/scrollbar.css +3 -1
  255. package/dist/server/styles/tokens.css +2 -0
  256. package/dist/server/vite-env.d.ts +2 -0
  257. package/llms.txt +5 -0
  258. package/package.json +13 -6
  259. package/dist/client/components/FramePro.d.ts +0 -23
  260. package/dist/client/components/FramePro.js +0 -412
  261. package/dist/client/logic/frame-pro-motion.d.ts +0 -26
  262. package/dist/client/logic/frame-pro-motion.js +0 -310
  263. package/dist/client/logic/frame-pro-state.d.ts +0 -39
  264. package/dist/client/logic/frame-pro-state.js +0 -538
  265. package/dist/server/components/FramePro.d.ts +0 -23
  266. package/dist/server/components/FramePro.js +0 -301
  267. package/dist/server/logic/frame-pro-motion.d.ts +0 -26
  268. package/dist/server/logic/frame-pro-motion.js +0 -176
  269. package/dist/server/logic/frame-pro-state.d.ts +0 -39
  270. package/dist/server/logic/frame-pro-state.js +0 -445
@@ -1,310 +0,0 @@
1
- /* frame-pro-motion.svelte.js generated by Svelte v5.56.4 */
2
- import * as $ from 'svelte/internal/client';
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
- $.user_effect(() => {
24
- const id = this.#getId();
25
- const element = this.#getElement();
26
-
27
- // 独立 FLIP 进场:layoutId/itemId 存在时尝试从模块注册表读取起点
28
- const flipId = this.#props.itemId ?? this.#props.layoutId;
29
-
30
- if (flipId && element) {
31
- beginFlipEnter(flipId, element);
32
- }
33
-
34
- if (!this.#motion || !this.shouldRegister || !element || !id) return;
35
-
36
- return this.#motion.register({
37
- id,
38
- element,
39
- timeline: this.#props.timeline,
40
- scroll: this.#props.scroll,
41
- layoutId: this.#props.itemId ?? this.#props.layoutId,
42
- scope: this.#props.scope
43
- });
44
- });
45
-
46
- // === 状态变化 -> 动效通知 (合并优化) ===
47
- // 使用单一 effect 替代多个独立 effect,减少响应式订阅开销
48
- // 缓存上一次的触发器状态,用于差量更新
49
- let prevTriggerStates = {};
50
-
51
- $.user_effect(() => {
52
- // 收集所有触发器状态
53
- const currentStates = {
54
- whileHover: this.#state.hovered,
55
- whileClick: this.#state.pressed,
56
- whileFocus: this.#state.focused,
57
- whileDrag: this.#state.isDragging,
58
- whileScroll: this.#state.isScrolling,
59
- whileKey: this.#state.isKeyActive,
60
- whileLoad: this.#state.currentState === "StartLoad" || this.#state.currentState === "Load" || !!this.#props.loading,
61
- whileReload: this.#state.currentState === "Reload" || !!this.#props.whileReload,
62
- whileActive: this.#state.currentState === "Active" || !!this.#props.whileActive,
63
- whileDisabled: this.#state.currentState === "Disabled" || !!this.#props.whileDisabled,
64
- whileValidating: this.#state.currentState === "Validating" || !!this.#props.whileValidating,
65
- whileUploading: this.#state.currentState === "Uploading" || !!this.#props.whileUploading,
66
- whileEditing: this.#state.currentState === "Editing" || !!this.#props.whileEditing,
67
- whileCollapsed: !!this.#props.collapsed,
68
- whileExpanded: !!this.#props.expanded,
69
- whileIdle: !this.#state.isAnyTriggerActive
70
- };
71
-
72
- // 仅通知发生变化的触发器
73
- for (const [event, active] of Object.entries(currentStates)) {
74
- if (prevTriggerStates[event] !== active) {
75
- this.#notify(event, { active });
76
- }
77
- }
78
-
79
- prevTriggerStates = currentStates;
80
- });
81
-
82
- // 生命周期通知 (单独保留,因为需要 cleanup)
83
- $.user_effect(() => {
84
- this.#notify("whileAppear", { active: true });
85
-
86
- // === 编排触发逻辑 ===
87
- // 根据 orchestrateTrigger 决定何时触发编排
88
- const trigger = this.#props.orchestrateTrigger ?? "appear";
89
-
90
- if (this.#props.orchestrate && trigger === "appear") {
91
- const id = this.#getId();
92
-
93
- if (id && this.#motion) {
94
- // 使用微任务或下一帧确保子组件已挂载并注册
95
- requestAnimationFrame(() => {
96
- this.#motion?.Play(id);
97
- });
98
- }
99
- }
100
-
101
- return () => this.#notify("whileDisappear", { active: true });
102
- });
103
-
104
- // === orchestrateTrigger: hover ===
105
- $.user_effect(() => {
106
- const trigger = this.#props.orchestrateTrigger;
107
-
108
- if (this.#props.orchestrate && trigger === "hover" && this.#state.hovered) {
109
- const id = this.#getId();
110
-
111
- if (id && this.#motion) {
112
- this.#motion.Play(id);
113
- }
114
- }
115
- });
116
-
117
- // === orchestrateTrigger: click ===
118
- $.user_effect(() => {
119
- const trigger = this.#props.orchestrateTrigger;
120
-
121
- if (this.#props.orchestrate && trigger === "click" && this.#state.pressed) {
122
- const id = this.#getId();
123
-
124
- if (id && this.#motion) {
125
- this.#motion.Play(id);
126
- }
127
- }
128
- });
129
-
130
- // === orchestrateTrigger: scroll ===
131
- $.user_effect(() => {
132
- const trigger = this.#props.orchestrateTrigger;
133
-
134
- if (this.#props.orchestrate && trigger === "scroll" && this.#state.isScrolling) {
135
- const id = this.#getId();
136
-
137
- if (id && this.#motion) {
138
- this.#motion.Play(id);
139
- }
140
- }
141
- });
142
-
143
- // 响应式断点通知
144
- let prevBreakpoint;
145
-
146
- $.user_effect(() => {
147
- if (!this.#responsive) return;
148
-
149
- const breakpoint = this.#responsive.breakpoint;
150
-
151
- if (!breakpoint || breakpoint === prevBreakpoint) return;
152
-
153
- const eventMap = {
154
- xs: "whileXs",
155
- sm: "whileSm",
156
- md: "whileMd",
157
- lg: "whileLg",
158
- xl: "whileXl",
159
- "2xl": "while2xl"
160
- };
161
-
162
- const eventName = eventMap[breakpoint];
163
-
164
- if (eventName) this.#notify(eventName, { active: true });
165
-
166
- prevBreakpoint = breakpoint;
167
- });
168
-
169
- // Setup whileScroll trigger
170
- $.user_effect(() => {
171
- if (this.#props.whileScroll) {
172
- this.#setupWhileScroll();
173
- }
174
- });
175
- }
176
-
177
- get shouldRegister() {
178
- const id = this.#getId();
179
-
180
- return !!id || hasMotionConfig(this.#props);
181
- }
182
-
183
- get controller() {
184
- return {
185
- play: (options) => {
186
- const id = this.#getId();
187
-
188
- if (id && this.#motion) this.#motion.Play(id, options);
189
- },
190
-
191
- captureLayout: (layoutId) => {
192
- const id = layoutId ?? this.#props.itemId ?? this.#props.layoutId ?? this.#getId();
193
- const element = this.#getElement();
194
-
195
- if (id && element && this.#motion) {
196
- this.#motion.captureLayout(id, element);
197
- }
198
- },
199
-
200
- playLayoutTo: (target, options) => {
201
- const id = options?.layoutId ?? this.#props.itemId ?? this.#props.layoutId ?? this.#getId();
202
- const element = this.#getElement();
203
-
204
- if (id && element && this.#motion) {
205
- this.#motion.playLayoutTo(id, element, target, options);
206
- } else {
207
- options?.onComplete?.();
208
- }
209
- },
210
-
211
- /** 捕获当前 Frame 位置写入模块级 FLIP 注册表,无需 initMotion 上下文。 */
212
- captureFlip: (layoutId) => {
213
- const id = layoutId ?? this.#props.itemId ?? this.#props.layoutId ?? this.#getId();
214
- const element = this.#getElement();
215
-
216
- if (id && element) captureFlipRect(id, element);
217
- },
218
-
219
- /** 将当前 Frame 以 FLIP 方式过渡到目标位置,无需 initMotion 上下文。 */
220
- playFlipTo: (target, options) => {
221
- const element = this.#getElement();
222
-
223
- if (element && target) {
224
- applyFlipExit(element, target, options);
225
- } else {
226
- options?.onComplete?.();
227
- }
228
- },
229
-
230
- reset: () => {
231
- const id = this.#getId();
232
-
233
- if (id && this.#motion) this.#motion.Reset(id);
234
- },
235
-
236
- pause: () => {
237
- // TODO
238
- }
239
- };
240
- }
241
-
242
- #notify(event, detail) {
243
- const id = this.#getId();
244
-
245
- if (!this.#motion || !this.shouldRegister || !id) return;
246
-
247
- this.#motion.notify(id, event, detail);
248
- }
249
-
250
- #setupWhileScroll() {
251
- const element = this.#getElement();
252
-
253
- if (!element) return;
254
-
255
- // 解析 offset 配置 (如 ["start center", "end center"])
256
- const scrollConfig = this.#props.scroll;
257
-
258
- const offset = scrollConfig?.offset ?? ["start center", "end center"];
259
-
260
- // 解析偏移量
261
- const parseOffset = (str) => {
262
- const parts = str.split(" ");
263
-
264
- return {
265
- element: parts[0] || "start", // start, center, end
266
- viewport: parts[1] || "center" // start, center, end
267
- };
268
- };
269
-
270
- const startOffset = parseOffset(offset[0]);
271
-
272
- const handleScroll = () => {
273
- const rect = element.getBoundingClientRect();
274
- const viewportHeight = window.innerHeight;
275
-
276
- // 计算元素位置
277
- const getElementPosition = (pos) => {
278
- if (pos === "start") return rect.top;
279
- if (pos === "end") return rect.bottom;
280
-
281
- return rect.top + rect.height / 2; // center
282
- };
283
-
284
- // 计算视口位置
285
- const getViewportPosition = (pos) => {
286
- if (pos === "start") return 0;
287
- if (pos === "end") return viewportHeight;
288
-
289
- return viewportHeight / 2; // center
290
- };
291
-
292
- const elementPos = getElementPosition(startOffset.element);
293
- const viewportTrigger = getViewportPosition(startOffset.viewport);
294
-
295
- // 当元素位置到达视口触发点时激活
296
- const isActive = elementPos <= viewportTrigger;
297
-
298
- if (this.#state.isScrolling !== isActive) {
299
- this.#state.isScrolling = isActive;
300
- }
301
- };
302
-
303
- window.addEventListener("scroll", handleScroll);
304
- handleScroll(); // Initial check
305
-
306
- return () => {
307
- window.removeEventListener("scroll", handleScroll);
308
- };
309
- }
310
- }
@@ -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
- }