@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.
Files changed (79) hide show
  1. package/README.md +13 -6
  2. package/component-catalog.json +2 -23
  3. package/dist/client/blocks/Sidebar.js +2 -2
  4. package/dist/client/blocks/SidebarItem.js +2 -2
  5. package/dist/client/blocks/SidebarSection.js +2 -2
  6. package/dist/client/compat.d.ts +1 -1
  7. package/dist/client/compat.js +1 -1
  8. package/dist/client/components/BlurText.js +2 -2
  9. package/dist/client/components/DataTable.js +2 -2
  10. package/dist/client/components/FlowText.js +2 -2
  11. package/dist/client/components/Frame.d.ts +9 -0
  12. package/dist/client/components/Frame.js +82 -24
  13. package/dist/client/components/GradientMotion.d.ts +1 -1
  14. package/dist/client/components/GradientMotion.js +2 -2
  15. package/dist/client/components/NumberFlow.js +4 -4
  16. package/dist/client/components/NumericText.js +2 -2
  17. package/dist/client/components/ScrambleText.js +2 -2
  18. package/dist/client/components/SidePanel.js +3 -3
  19. package/dist/client/components/SlotText.js +2 -2
  20. package/dist/client/components/TableCell.js +1 -1
  21. package/dist/client/components/Toaster.js +1 -1
  22. package/dist/client/index.d.ts +0 -1
  23. package/dist/client/index.js +3 -5
  24. package/dist/client/internal/snow-ui-logo/Wordmark.js +1 -1
  25. package/dist/client/lib/edge-fade.js +1 -1
  26. package/dist/client/lib/resizable.d.ts +1 -1
  27. package/dist/client/logic/frame-motion.d.ts +15 -23
  28. package/dist/client/logic/frame-motion.js +196 -30
  29. package/dist/client/logic/frame-state.d.ts +2 -14
  30. package/dist/client/logic/frame-state.js +60 -9
  31. package/dist/client/motion/number.d.ts +3 -3
  32. package/dist/client/motion/number.js +3 -3
  33. package/dist/client/styles/components.css +14 -14
  34. package/dist/client/styles/layout.css +1 -1
  35. package/dist/server/blocks/Sidebar.js +2 -2
  36. package/dist/server/blocks/SidebarItem.js +2 -2
  37. package/dist/server/blocks/SidebarSection.js +2 -2
  38. package/dist/server/compat.d.ts +1 -1
  39. package/dist/server/compat.js +1 -1
  40. package/dist/server/components/BlurText.js +2 -2
  41. package/dist/server/components/DataTable.js +2 -2
  42. package/dist/server/components/FlowText.js +2 -2
  43. package/dist/server/components/Frame.d.ts +9 -0
  44. package/dist/server/components/Frame.js +52 -24
  45. package/dist/server/components/GradientMotion.d.ts +1 -1
  46. package/dist/server/components/GradientMotion.js +2 -2
  47. package/dist/server/components/NumberFlow.js +4 -4
  48. package/dist/server/components/NumericText.js +2 -2
  49. package/dist/server/components/ScrambleText.js +2 -2
  50. package/dist/server/components/SidePanel.js +3 -3
  51. package/dist/server/components/SlotText.js +2 -2
  52. package/dist/server/components/TableCell.js +1 -1
  53. package/dist/server/components/Toaster.js +1 -1
  54. package/dist/server/index.d.ts +0 -1
  55. package/dist/server/index.js +3 -5
  56. package/dist/server/internal/snow-ui-logo/Wordmark.js +1 -1
  57. package/dist/server/lib/edge-fade.js +1 -1
  58. package/dist/server/lib/resizable.d.ts +1 -1
  59. package/dist/server/logic/frame-motion.d.ts +15 -23
  60. package/dist/server/logic/frame-motion.js +75 -29
  61. package/dist/server/logic/frame-state.d.ts +2 -14
  62. package/dist/server/logic/frame-state.js +60 -9
  63. package/dist/server/motion/number.d.ts +3 -3
  64. package/dist/server/motion/number.js +3 -3
  65. package/dist/server/styles/components.css +14 -14
  66. package/dist/server/styles/layout.css +1 -1
  67. package/package.json +2 -2
  68. package/dist/client/components/FramePro.d.ts +0 -23
  69. package/dist/client/components/FramePro.js +0 -412
  70. package/dist/client/logic/frame-pro-motion.d.ts +0 -26
  71. package/dist/client/logic/frame-pro-motion.js +0 -310
  72. package/dist/client/logic/frame-pro-state.d.ts +0 -39
  73. package/dist/client/logic/frame-pro-state.js +0 -538
  74. package/dist/server/components/FramePro.d.ts +0 -23
  75. package/dist/server/components/FramePro.js +0 -301
  76. package/dist/server/logic/frame-pro-motion.d.ts +0 -26
  77. package/dist/server/logic/frame-pro-motion.js +0 -176
  78. package/dist/server/logic/frame-pro-state.d.ts +0 -39
  79. package/dist/server/logic/frame-pro-state.js +0 -445
@@ -1,445 +0,0 @@
1
- /* frame-pro-state.svelte.js generated by Svelte v5.56.4 */
2
- import * as $ from 'svelte/internal/server';
3
- import { resolveFrameWhileMotionConfig } from "./frame-motion-defaults.js";
4
-
5
- export class FrameState {
6
- #props;
7
- #motion;
8
-
9
- // === 交互状态 (Internal Interaction States) ===
10
- hovered = false;
11
-
12
- pressed = false;
13
- focused = false;
14
- isDragging = false;
15
- isScrolling = false;
16
- isKeyActive = false;
17
-
18
- // === 核心状态 (Core State) ===
19
- currentState = "Idle";
20
-
21
- constructor(props, motion) {
22
- this.#props = props;
23
- this.#motion = motion;
24
- // 状态变化时处理链式转变
25
- // 执行回调
26
- // Reload 状态时调用 onReload 回调
27
- }
28
-
29
- // === 综合状态 (Derived Interaction State) ===
30
- get interactionState() {
31
- // 优先使用声明式状态机状态
32
- if (this.currentState !== "Idle") return this.currentState;
33
-
34
- // 回退到传统状态判断
35
- if (this.#props.whileDisabled) return "Disabled";
36
-
37
- if (this.#props.loading) return "Load";
38
- if (this.pressed) return "Click";
39
- if (this.hovered) return "Hover";
40
- if (this.focused) return "Focus";
41
- if (this.isDragging) return "Drag";
42
- if (this.isScrolling) return "Scroll";
43
-
44
- return "Idle";
45
- }
46
-
47
- // 是否有任何触发器激活 (用于 whileIdle)
48
- get isAnyTriggerActive() {
49
- 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;
50
- }
51
-
52
- // === Helpers ===
53
- #parseTransition(config) {
54
- if (!config) return { nextState: null, auto: false };
55
-
56
- // 1. 数组形式: [State, 'auto']
57
- if (Array.isArray(config)) {
58
- return { nextState: config[0], auto: config[1] === "auto" };
59
- }
60
-
61
- // 2. 函数形式: () => void
62
- if (typeof config === "function") {
63
- return { nextState: null, auto: false, run: config };
64
- }
65
-
66
- // 3. 对象形式: { next, auto, run }
67
- if (typeof config === "object" && ("next" in config || "run" in config)) {
68
- return { nextState: config.next, auto: !!config.auto, run: config.run };
69
- }
70
-
71
- // 4. 字符串形式: State
72
- return { nextState: config, auto: false };
73
- }
74
-
75
- #getWhileConfig(state) {
76
- // 标准状态优先走统一默认动效解析,保证 auto 时长与默认/覆写配置一致
77
- const configMap = {
78
- StartLoad: resolveFrameWhileMotionConfig(this.#props, "whileLoad"),
79
- Load: resolveFrameWhileMotionConfig(this.#props, "whileLoad"),
80
- Reload: resolveFrameWhileMotionConfig(this.#props, "whileReload"),
81
- Appear: resolveFrameWhileMotionConfig(this.#props, "whileAppear"),
82
- Disappear: resolveFrameWhileMotionConfig(this.#props, "whileDisappear"),
83
- Idle: resolveFrameWhileMotionConfig(this.#props, "whileIdle"),
84
- Active: resolveFrameWhileMotionConfig(this.#props, "whileActive"),
85
- Disabled: resolveFrameWhileMotionConfig(this.#props, "whileDisabled"),
86
- Validating: resolveFrameWhileMotionConfig(this.#props, "whileValidating"),
87
- Uploading: resolveFrameWhileMotionConfig(this.#props, "whileUploading"),
88
- Editing: resolveFrameWhileMotionConfig(this.#props, "whileEditing")
89
- };
90
-
91
- // 标准状态直接返回(可为 undefined)
92
- if (state in configMap) return configMap[state];
93
-
94
- // 尝试获取动态属性 (Custom States): while[State]
95
- const dynamicKey = `while${state}`;
96
-
97
- return this.#props[dynamicKey];
98
- }
99
-
100
- #getDuration(state) {
101
- const config = this.#getWhileConfig(state);
102
-
103
- if (config && typeof config === "object" && "duration" in config) {
104
- return config.duration;
105
- }
106
-
107
- return 300; // 默认 300ms
108
- }
109
-
110
- #getTransitionConfig(state) {
111
- const transitionMap = {
112
- StartLoad: this.#props.StartLoad,
113
- Load: this.#props.Load,
114
- Reload: this.#props.Reload,
115
- Appear: this.#props.Appear,
116
- Disappear: this.#props.Disappear,
117
- Idle: this.#props.Idle,
118
- Active: this.#props.Active,
119
- Disabled: this.#props.Disabled
120
- };
121
-
122
- // 如果是标准状态且有配置,直接返回
123
- if (transitionMap[state]) return transitionMap[state];
124
-
125
- // 尝试获取动态属性 (Custom States): [State]
126
- return this.#props[state];
127
- }
128
-
129
- // === Event Handlers ===
130
- #handleModifiers(e, config) {
131
- if (config && typeof config === 'object') {
132
- if (config.stop) e.stopPropagation();
133
- if (config.prevent) e.preventDefault();
134
- }
135
- }
136
-
137
- #isStateMapTrigger(config) {
138
- if (!config || typeof config !== "object" || Array.isArray(config)) {
139
- return false;
140
- }
141
-
142
- // 这些字段属于普通 Trigger/Linkage 配置,不视为“按状态映射”
143
- const reservedKeys = [
144
- "run",
145
- "target",
146
- "action",
147
- "reverse",
148
- "state",
149
- "key",
150
- "next",
151
- "auto",
152
- "stop",
153
- "prevent"
154
- ];
155
-
156
- if (reservedKeys.some((key) => key in config)) return false;
157
-
158
- return Object.keys(config).length > 0;
159
- }
160
-
161
- #resolveStateMapTrigger(config) {
162
- return config[this.currentState] ?? config.Idle;
163
- }
164
-
165
- #applyEventTrigger(config, e) {
166
- if (!config) return;
167
-
168
- this.#handleModifiers(e, config);
169
-
170
- if (typeof config === "function") {
171
- config(e);
172
-
173
- return;
174
- }
175
-
176
- if (typeof config === "string") {
177
- this.currentState = config;
178
-
179
- return;
180
- }
181
-
182
- if (Array.isArray(config)) {
183
- if (typeof config[0] === "string") {
184
- this.currentState = config[0];
185
- }
186
-
187
- return;
188
- }
189
-
190
- if (typeof config === "object") {
191
- if ("run" in config && typeof config.run === "function") {
192
- config.run(e);
193
- }
194
-
195
- if ("state" in config && typeof config.state === "string") {
196
- this.currentState = config.state;
197
- } else if ("next" in config && typeof config.next === "string") {
198
- this.currentState = config.next;
199
- }
200
-
201
- if ("target" in config) {
202
- this.#handleLinkageControl(config);
203
- }
204
- }
205
- }
206
-
207
- // --- Mouse Events ---
208
- handleClick = (e) => {
209
- const { Click } = this.#props;
210
-
211
- if (!Click) return;
212
-
213
- // 支持按当前状态分发点击触发器:
214
- // Click={{ Idle: "Load", Active: "Idle" }}
215
- if (this.#isStateMapTrigger(Click)) {
216
- const mapped = this.#resolveStateMapTrigger(Click);
217
-
218
- this.#applyEventTrigger(mapped, e);
219
-
220
- return;
221
- }
222
-
223
- // 兼容旧行为:非映射模式仅在 Idle 状态响应 Click
224
- if (this.currentState !== "Idle") return;
225
-
226
- this.#applyEventTrigger(Click, e);
227
- };
228
-
229
- handleDblClick = (_e) => {
230
- // Reserved for future DblClick prop
231
- };
232
-
233
- handleContextMenu = (_e) => {
234
- // Reserved for future ContextMenu prop
235
- };
236
-
237
- handleMouseEnter = (e) => {
238
- this.hovered = true;
239
-
240
- const { Hover } = this.#props;
241
-
242
- if (Hover) {
243
- this.#handleModifiers(e, Hover);
244
-
245
- if (typeof Hover === "function") {
246
- Hover(e);
247
- } else if (typeof Hover === "string") {
248
- this.currentState = Hover;
249
- } else if (typeof Hover === "object") {
250
- if ("run" in Hover && typeof Hover.run === "function") {
251
- Hover.run(e);
252
- }
253
-
254
- if ("target" in Hover) {
255
- this.#handleLinkageControl(Hover);
256
- }
257
- }
258
- }
259
- };
260
-
261
- handleMouseLeave = () => {
262
- this.hovered = false;
263
- this.pressed = false;
264
- };
265
-
266
- handleMouseDown = () => {
267
- this.pressed = true;
268
- };
269
-
270
- handleMouseUp = (_e) => {
271
- this.pressed = false;
272
-
273
- // Click logic moved to handleClick
274
- };
275
-
276
- handleMouseMove = (_e) => {
277
- // Reserved
278
- };
279
-
280
- // --- Touch Events ---
281
- handleTouchStart = (_e) => {
282
- this.pressed = true;
283
- };
284
-
285
- handleTouchEnd = (_e) => {
286
- this.pressed = false;
287
- };
288
-
289
- handleTouchMove = (_e) => {
290
- // Reserved
291
- };
292
-
293
- handleTouchCancel = (_e) => {
294
- this.pressed = false;
295
- };
296
-
297
- // --- Focus Events ---
298
- handleFocus = (e) => {
299
- this.focused = true;
300
-
301
- const { Focus } = this.#props;
302
-
303
- if (Focus) {
304
- this.#handleModifiers(e, Focus);
305
-
306
- if (typeof Focus === "function") {
307
- Focus(e);
308
- } else if (typeof Focus === "string") {
309
- this.currentState = Focus;
310
- } else if (typeof Focus === "object") {
311
- if ("run" in Focus && typeof Focus.run === "function") {
312
- Focus.run(e);
313
- }
314
-
315
- if ("target" in Focus) {
316
- this.#handleLinkageControl(Focus);
317
- }
318
- }
319
- }
320
- };
321
-
322
- handleBlur = () => {
323
- this.focused = false;
324
- };
325
-
326
- // --- Keyboard Events ---
327
- handleKeyDown = (e) => {
328
- this.isKeyActive = true;
329
-
330
- const { Key } = this.#props;
331
-
332
- if (Key && e.key === Key.key) {
333
- this.#handleModifiers(e, Key);
334
-
335
- if ("run" in Key && typeof Key.run === "function") {
336
- Key.run(e);
337
- } else if ("state" in Key) {
338
- this.currentState = Key.state;
339
- } else if ("target" in Key) {
340
- this.#handleLinkageControl(Key);
341
- }
342
- }
343
- };
344
-
345
- handleKeyUp = () => {
346
- this.isKeyActive = false;
347
- };
348
-
349
- handleKeyPress = (_e) => {
350
- // Reserved
351
- };
352
-
353
- // --- Form Events ---
354
- handleInput = (_e) => {
355
- // Reserved
356
- };
357
-
358
- handleChange = (_e) => {
359
- // Reserved
360
- };
361
-
362
- handleSubmit = (_e) => {
363
- // Reserved
364
- };
365
-
366
- // --- Drag Events ---
367
- handleDragStart = (e) => {
368
- this.isDragging = true;
369
-
370
- const { Drag } = this.#props;
371
-
372
- if (Drag) {
373
- this.#handleModifiers(e, Drag);
374
-
375
- if (typeof Drag === "function") {
376
- Drag(e);
377
- } else if (typeof Drag === "string") {
378
- this.currentState = Drag;
379
- } else if (typeof Drag === "object") {
380
- if ("run" in Drag && typeof Drag.run === "function") {
381
- Drag.run(e);
382
- }
383
-
384
- if ("target" in Drag) {
385
- this.#handleLinkageControl(Drag);
386
- }
387
- }
388
- }
389
- };
390
-
391
- handleDrag = (_e) => {
392
- // Reserved for future Drag move handling
393
- };
394
-
395
- handleDragEnd = (_e) => {
396
- this.isDragging = false;
397
- };
398
-
399
- // --- UI Events ---
400
- handleScroll = (_e) => {
401
- // Reserved
402
- };
403
-
404
- #handleLinkageControl(config) {
405
- if (config.target) {
406
- // 1. Resolve Target Controller
407
- let controller;
408
-
409
- if (typeof config.target === 'string') {
410
- // String ID -> Use internal motion instance
411
- // No controller object for string IDs, handled in step 2 directly via this.#motion
412
- } else if (typeof config.target === 'object') {
413
- // Object Ref -> Try to get controller
414
- // Case A: Svelte 5 bind:this instance with exported getController
415
- if ('getController' in config.target && typeof config.target.getController === 'function') {
416
- controller = config.target.getController();
417
- } else // Case B: Maybe it IS the controller?
418
- {
419
- controller = config.target;
420
- }
421
- }
422
-
423
- // 2. Execute Action
424
- if (typeof config.target === 'string' && this.#motion) {
425
- // Legacy String ID Logic
426
- if (config.action === "play") {
427
- this.#motion.Play(config.target, { reverse: config.reverse });
428
- } else if (config.action === "reset") {
429
- this.#motion.Reset(config.target);
430
- } else if (config.action === "pause") {
431
- this.#motion.pause(config.target);
432
- }
433
- } else if (controller) {
434
- // Object Controller Logic
435
- if (config.action === "play" && controller.play) {
436
- controller.play({ reverse: config.reverse });
437
- } else if (config.action === "reset" && controller.reset) {
438
- controller.reset();
439
- } else if (config.action === "pause" && controller.pause) {
440
- controller.pause();
441
- }
442
- }
443
- }
444
- }
445
- }