@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,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;