@snowui-design-system/components 0.2.0-alpha.7 → 0.2.0-alpha.9

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 (139) hide show
  1. package/README.md +27 -22
  2. package/component-catalog.json +1066 -0
  3. package/package.json +12 -4
  4. package/src/assets/gradient-avatar/blue.svg +1 -0
  5. package/src/assets/gradient-avatar/cyan.svg +1 -0
  6. package/src/assets/gradient-avatar/green.svg +1 -0
  7. package/src/assets/gradient-avatar/orange.svg +1 -0
  8. package/src/assets/gradient-avatar/purple.svg +1 -0
  9. package/src/assets/gradient-avatar/red.svg +1 -0
  10. package/src/components/Accordion.md +1 -1
  11. package/src/components/Accordion.svelte +5 -1
  12. package/src/components/Avatar.md +95 -58
  13. package/src/components/Avatar.svelte +286 -92
  14. package/src/components/Avatar.test.ts +24 -3
  15. package/src/components/Badge.md +31 -2
  16. package/src/components/Badge.svelte +38 -3
  17. package/src/components/Badge.test.ts +14 -1
  18. package/src/components/Button.md +42 -19
  19. package/src/components/Button.svelte +56 -50
  20. package/src/components/Button.test.ts +38 -27
  21. package/src/components/Card.test.ts +1 -1
  22. package/src/components/CodeBlock.md +50 -14
  23. package/src/components/CodeBlock.svelte +213 -34
  24. package/src/components/CodeBlock.test.ts +43 -2
  25. package/src/components/ColorSchemeButton.md +50 -0
  26. package/src/components/ColorSchemeButton.svelte +144 -0
  27. package/src/components/ColorSchemeButton.test.ts +39 -0
  28. package/src/components/CopyButton.md +5 -1
  29. package/src/components/CopyButton.svelte +6 -2
  30. package/src/components/Dialog.svelte +1 -0
  31. package/src/components/Dialog.test.ts +2 -2
  32. package/src/components/ExpandButton.md +5 -1
  33. package/src/components/ExpandButton.svelte +1 -0
  34. package/src/components/Form.test.ts +4 -4
  35. package/src/components/Gradient.md +278 -0
  36. package/src/components/Gradient.svelte +1283 -0
  37. package/src/components/Gradient.test.ts +77 -0
  38. package/src/components/Icon.svelte +3 -1
  39. package/src/components/Image.svelte +11 -8
  40. package/src/components/Image.test.ts +1 -1
  41. package/src/components/Indicator.md +18 -4
  42. package/src/components/Indicator.svelte +151 -11
  43. package/src/components/Indicator.test.ts +25 -0
  44. package/src/components/Input.md +15 -5
  45. package/src/components/Input.svelte +10 -1
  46. package/src/components/Input.test.ts +2 -2
  47. package/src/components/Listbox.md +5 -0
  48. package/src/components/Listbox.svelte +26 -0
  49. package/src/components/Listbox.test.ts +14 -0
  50. package/src/components/MenuItem.md +5 -0
  51. package/src/components/MenuItem.svelte +6 -0
  52. package/src/components/OverflowAction.md +41 -0
  53. package/src/components/OverflowAction.svelte +209 -0
  54. package/src/components/OverflowAction.test.ts +11 -0
  55. package/src/components/OverflowActions.md +95 -0
  56. package/src/components/OverflowActions.svelte +501 -0
  57. package/src/components/OverflowActions.test.ts +87 -0
  58. package/src/components/Pagination.md +2 -2
  59. package/src/components/Pagination.svelte +2 -2
  60. package/src/components/Pagination.test.ts +2 -2
  61. package/src/components/Popover.md +5 -0
  62. package/src/components/Popover.svelte +25 -0
  63. package/src/components/Popover.test.ts +14 -0
  64. package/src/components/ScrollArea.md +7 -3
  65. package/src/components/ScrollArea.test.ts +3 -2
  66. package/src/components/SearchInput.md +14 -1
  67. package/src/components/SearchInput.svelte +104 -2
  68. package/src/components/SearchInput.test.ts +16 -1
  69. package/src/components/SelectButton.md +1 -1
  70. package/src/components/SelectButton.svelte +8 -2
  71. package/src/components/Skeleton.md +13 -1
  72. package/src/components/Skeleton.svelte +30 -2
  73. package/src/components/Slider.md +68 -6
  74. package/src/components/Slider.svelte +329 -21
  75. package/src/components/Slider.test.ts +65 -0
  76. package/src/components/SnowUILogo.md +210 -0
  77. package/src/components/SnowUILogo.svelte +478 -0
  78. package/src/components/SnowUILogo.test.ts +62 -0
  79. package/src/components/StyleButton.md +58 -0
  80. package/src/components/StyleButton.svelte +144 -0
  81. package/src/components/StyleButton.test.ts +39 -0
  82. package/src/components/Table.md +23 -7
  83. package/src/components/Table.svelte +22 -1
  84. package/src/components/TableBody.md +12 -1
  85. package/src/components/TableBody.svelte +26 -2
  86. package/src/components/TableBody.test.ts +3 -0
  87. package/src/components/TableCell.md +9 -3
  88. package/src/components/TableCell.svelte +139 -78
  89. package/src/components/TableCell.test.ts +4 -4
  90. package/src/components/TableHead.md +9 -3
  91. package/src/components/TableHead.svelte +56 -43
  92. package/src/components/TableHead.test.ts +5 -5
  93. package/src/components/TableRow.md +15 -5
  94. package/src/components/TableRow.svelte +47 -10
  95. package/src/components/TableRow.test.ts +2 -2
  96. package/src/components/TableToolbar.svelte +20 -8
  97. package/src/components/Text.md +7 -1
  98. package/src/components/Text.svelte +17 -7
  99. package/src/components/Tooltip.md +37 -9
  100. package/src/components/Tooltip.svelte +145 -35
  101. package/src/components/Tooltip.test.ts +54 -4
  102. package/src/i18n/messages.ts +12 -0
  103. package/src/index.ts +24 -0
  104. package/src/internal/StyleButtonLogo.svelte +49 -0
  105. package/src/lib/color.md +2 -2
  106. package/src/lib/edge-fade.md +1 -0
  107. package/src/lib/overlay-scrollbar.md +6 -1
  108. package/src/lib/table-context.svelte.ts +36 -0
  109. package/src/lib/table-role-blur.ts +46 -0
  110. package/src/lib/table-truncation.md +14 -0
  111. package/src/lib/table-truncation.ts +83 -0
  112. package/src/lib/tooltip-delay.md +7 -1
  113. package/src/lib/tooltip-motion-dismiss.md +33 -0
  114. package/src/lib/tooltip-motion-dismiss.ts +160 -0
  115. package/src/lib/tooltip-overlay.md +21 -3
  116. package/src/lib/tooltip-overlay.ts +13 -2
  117. package/src/logic/README.md +4 -1
  118. package/src/logic/continuous-hover.svelte.md +22 -0
  119. package/src/logic/continuous-hover.svelte.ts +436 -0
  120. package/src/logic/frame-inline-style.svelte.ts +2 -2
  121. package/src/logic/frame-truncation.md +9 -3
  122. package/src/logic/frame-truncation.svelte.ts +6 -0
  123. package/src/logic/layout-flip.ts +182 -5
  124. package/src/logic/overflow-actions.svelte.ts +33 -0
  125. package/src/motion/presets/README.md +6 -2
  126. package/src/motion/presets/continuous-hover.md +11 -0
  127. package/src/motion/presets/continuous-hover.ts +18 -0
  128. package/src/motion/presets/tooltip.md +40 -2
  129. package/src/motion/presets/tooltip.ts +0 -2
  130. package/src/motion/tokens.md +9 -4
  131. package/src/motion/tokens.ts +4 -1
  132. package/src/styles/README.md +16 -2
  133. package/src/styles/auto-layout.css +10 -1
  134. package/src/styles/components.css +920 -0
  135. package/src/styles/index.css +3 -1
  136. package/src/styles/layout.css +44 -0
  137. package/src/styles/scrollbar.css +27 -7
  138. package/src/styles/themes.css +146 -0
  139. package/src/styles/tokens.css +33 -33
@@ -0,0 +1,501 @@
1
+ <!-- 响应式操作集合。文档:./OverflowActions.md -->
2
+ <script lang="ts">
3
+ import {
4
+ onDestroy,
5
+ onMount,
6
+ setContext,
7
+ tick,
8
+ type ComponentProps,
9
+ type Snippet,
10
+ } from "svelte";
11
+ import { Icon as ResourceIcon } from "@snowui-design-system/resource-svelte";
12
+ import Frame, { type FrameProps } from "./Frame.svelte";
13
+ import Button from "./Button.svelte";
14
+ import SelectButton from "./SelectButton.svelte";
15
+ import Listbox from "./Listbox.svelte";
16
+ import MenuItem from "./MenuItem.svelte";
17
+ import Separator from "./Separator.svelte";
18
+ import OverflowAction from "./OverflowAction.svelte";
19
+ import { resizeManager } from "../logic/observer.svelte";
20
+ import {
21
+ OVERFLOW_ACTIONS_CONTEXT_KEY,
22
+ type OverflowActionIcon,
23
+ type OverflowActionMode,
24
+ type OverflowActionRegistration,
25
+ type OverflowActionsContext,
26
+ } from "../logic/overflow-actions.svelte";
27
+ import {
28
+ mergeComponentPartProps,
29
+ type ComponentPartsOf,
30
+ } from "../logic/component-parts.svelte";
31
+
32
+ type ButtonProps = ComponentProps<typeof Button>;
33
+ type ControlledGlobalButtonKeys =
34
+ | "children"
35
+ | "as"
36
+ | "iconOnly"
37
+ | "disabled"
38
+ | "href"
39
+ | "onclick"
40
+ | "aria-label"
41
+ | "title";
42
+ type GlobalButtonProps = Omit<ButtonProps, ControlledGlobalButtonKeys>;
43
+
44
+ export interface OverflowActionsActionItem {
45
+ type?: "action";
46
+ id: string;
47
+ label: string;
48
+ icon?: OverflowActionIcon;
49
+ disabled?: boolean;
50
+ href?: string;
51
+ onAction?: () => void;
52
+ }
53
+
54
+ export interface OverflowActionsSeparatorItem {
55
+ type: "separator";
56
+ id: string;
57
+ }
58
+
59
+ export type OverflowActionsItem =
60
+ | OverflowActionsActionItem
61
+ | OverflowActionsSeparatorItem;
62
+
63
+ export interface OverflowActionsActionEvent {
64
+ id: string;
65
+ item?: OverflowActionsActionItem;
66
+ source: "button" | "menu";
67
+ originalEvent?: MouseEvent;
68
+ }
69
+
70
+ type Parts = ComponentPartsOf<{
71
+ Button: typeof Button;
72
+ SelectButton: typeof SelectButton;
73
+ Listbox: typeof Listbox;
74
+ MenuItem: typeof MenuItem;
75
+ Separator: typeof Separator;
76
+ }>;
77
+
78
+ interface Props extends Omit<FrameProps, "children"> {
79
+ items?: OverflowActionsItem[];
80
+ compact?: "auto" | "none";
81
+ overflow?: "all" | "progressive";
82
+ overflowFrom?: "start" | "end";
83
+ availableWidth?: number;
84
+ moreLabel?: string;
85
+ align?: "start" | "end";
86
+ disabled?: boolean;
87
+ buttonProps?: GlobalButtonProps;
88
+ children?: Snippet;
89
+ parts?: Parts;
90
+ onAction?: (event: OverflowActionsActionEvent) => void;
91
+ [key: string]: any;
92
+ }
93
+
94
+ let {
95
+ items = [],
96
+ compact = "auto",
97
+ overflow = "all",
98
+ overflowFrom = "end",
99
+ availableWidth = undefined,
100
+ moreLabel = "更多操作",
101
+ align = "end",
102
+ disabled = false,
103
+ buttonProps = undefined,
104
+ children = undefined,
105
+ parts = undefined,
106
+ onAction = undefined,
107
+ class: userClass = "",
108
+ ...rest
109
+ }: Props = $props();
110
+
111
+ let rootElement = $state<HTMLElement | undefined>(undefined);
112
+ let moreMeasureElement = $state<HTMLElement | undefined>(undefined);
113
+ let modes = $state<Record<string, OverflowActionMode>>({});
114
+ let menuEntries = $state<Extract<LayoutEntry, { type: "action" }>[]>([]);
115
+ let hasOverflow = $state(false);
116
+ let layoutFrame = 0;
117
+ let isMounted = false;
118
+ const registrations = new Map<string, OverflowActionRegistration>();
119
+
120
+ type LayoutEntry =
121
+ | { type: "action"; action: OverflowActionRegistration }
122
+ | { type: "separator"; element: HTMLElement; index: number };
123
+
124
+ const resolvedButtonProps = $derived(
125
+ mergeComponentPartProps(buttonProps, parts?.Button ?? {}),
126
+ );
127
+
128
+ const context: OverflowActionsContext = {
129
+ register(action) {
130
+ if (registrations.has(action.id) && import.meta.env.DEV) {
131
+ console.warn(
132
+ `[SnowUI OverflowActions] duplicate action id="${action.id}".`,
133
+ );
134
+ }
135
+ registrations.set(action.id, action);
136
+ requestLayout();
137
+ return () => {
138
+ if (registrations.get(action.id) === action) {
139
+ registrations.delete(action.id);
140
+ requestLayout();
141
+ }
142
+ };
143
+ },
144
+ getMode(id) {
145
+ return modes[id] ?? "full";
146
+ },
147
+ invoke(id, event) {
148
+ runAction(id, "button", event);
149
+ },
150
+ requestLayout,
151
+ get disabled() {
152
+ return disabled;
153
+ },
154
+ get buttonProps() {
155
+ return resolvedButtonProps;
156
+ },
157
+ };
158
+
159
+ setContext(OVERFLOW_ACTIONS_CONTEXT_KEY, context);
160
+ function runAction(
161
+ id: string,
162
+ source: "button" | "menu",
163
+ originalEvent?: MouseEvent,
164
+ ) {
165
+ const action = registrations.get(id);
166
+ if (!action || disabled || action.disabled) return;
167
+ action.execute(originalEvent);
168
+ const item = items.find(
169
+ (candidate): candidate is OverflowActionsActionItem =>
170
+ candidate.type !== "separator" && candidate.id === id,
171
+ );
172
+ onAction?.({ id, item, source, originalEvent });
173
+ if (source === "menu" && action.href && typeof window !== "undefined") {
174
+ window.location.assign(action.href);
175
+ }
176
+ }
177
+
178
+ function requestLayout() {
179
+ if (!isMounted || layoutFrame) return;
180
+ layoutFrame = requestAnimationFrame(async () => {
181
+ layoutFrame = 0;
182
+ await tick();
183
+ updateLayout();
184
+ });
185
+ }
186
+
187
+ function directEntries(): LayoutEntry[] {
188
+ if (!rootElement) return [];
189
+ const entries: LayoutEntry[] = [];
190
+ let separatorIndex = 0;
191
+ for (const node of Array.from(rootElement.children)) {
192
+ if (!(node instanceof HTMLElement)) continue;
193
+ const actionId = node.dataset.overflowActionId;
194
+ if (actionId) {
195
+ const action = registrations.get(actionId);
196
+ if (action) entries.push({ type: "action", action });
197
+ continue;
198
+ }
199
+ if (node.dataset.as === "separator") {
200
+ entries.push({
201
+ type: "separator",
202
+ element: node,
203
+ index: separatorIndex++,
204
+ });
205
+ }
206
+ }
207
+ return entries;
208
+ }
209
+
210
+ function normalizeEntries(
211
+ entries: LayoutEntry[],
212
+ actionIds: Set<string>,
213
+ ): LayoutEntry[] {
214
+ const kept: LayoutEntry[] = [];
215
+ let pendingSeparator: LayoutEntry | undefined;
216
+ for (const entry of entries) {
217
+ if (entry.type === "separator") {
218
+ if (kept.some(candidate => candidate.type === "action")) {
219
+ pendingSeparator = entry;
220
+ }
221
+ continue;
222
+ }
223
+ if (!actionIds.has(entry.action.id)) continue;
224
+ if (pendingSeparator) {
225
+ kept.push(pendingSeparator);
226
+ pendingSeparator = undefined;
227
+ }
228
+ kept.push(entry);
229
+ }
230
+ while (kept.at(-1)?.type === "separator") kept.pop();
231
+ return kept;
232
+ }
233
+
234
+ function entryWidth(entry: LayoutEntry, mode: "full" | "compact") {
235
+ if (entry.type === "separator") {
236
+ return entry.element.getBoundingClientRect().width;
237
+ }
238
+ const element = mode === "compact"
239
+ ? entry.action.getCompactMeasureElement()
240
+ : entry.action.getFullMeasureElement();
241
+ return element?.getBoundingClientRect().width ?? 0;
242
+ }
243
+
244
+ function totalWidth(
245
+ entries: LayoutEntry[],
246
+ mode: "full" | "compact",
247
+ includeMore: boolean,
248
+ gap: number,
249
+ ) {
250
+ const widths = entries.map(entry => entryWidth(entry, mode));
251
+ if (includeMore) {
252
+ widths.push(moreMeasureElement?.getBoundingClientRect().width ?? 0);
253
+ }
254
+ return widths.reduce((sum, width) => sum + width, 0) +
255
+ Math.max(0, widths.length - 1) * gap;
256
+ }
257
+
258
+ function updateLayout() {
259
+ if (!rootElement) return;
260
+ if (rootElement.querySelector('.snowui-select-button-trigger[aria-expanded="true"]')) return;
261
+
262
+ const entries = directEntries();
263
+ const actions = entries
264
+ .filter((entry): entry is Extract<LayoutEntry, { type: "action" }> =>
265
+ entry.type === "action",
266
+ )
267
+ .map(entry => entry.action);
268
+ const allIds = new Set(actions.map(action => action.id));
269
+ const normalizedAll = normalizeEntries(entries, allIds);
270
+ const width = Math.max(
271
+ 0,
272
+ availableWidth ?? rootElement.getBoundingClientRect().width,
273
+ );
274
+ const computed = getComputedStyle(rootElement);
275
+ const gap = Number.parseFloat(computed.columnGap || computed.gap) || 0;
276
+ const canCompact = compact === "auto" && actions.length > 0 &&
277
+ actions.every(action => !!action.icon);
278
+
279
+ let nextModes: Record<string, OverflowActionMode> = Object.fromEntries(
280
+ actions.map(action => [action.id, "full" as OverflowActionMode]),
281
+ );
282
+ let nextMenuEntries: LayoutEntry[] = [];
283
+ let visibleEntries = normalizedAll;
284
+
285
+ if (totalWidth(normalizedAll, "full", false, gap) <= width) {
286
+ // Full is the preferred stable state.
287
+ } else if (
288
+ canCompact &&
289
+ totalWidth(normalizedAll, "compact", false, gap) <= width
290
+ ) {
291
+ nextModes = Object.fromEntries(
292
+ actions.map(action => [action.id, "compact" as OverflowActionMode]),
293
+ );
294
+ } else if (overflow === "all") {
295
+ nextModes = Object.fromEntries(
296
+ actions.map(action => [action.id, "hidden" as OverflowActionMode]),
297
+ );
298
+ visibleEntries = [];
299
+ nextMenuEntries = normalizedAll;
300
+ } else {
301
+ const baseMode = canCompact ? "compact" : "full";
302
+ const visibleIds = new Set(allIds);
303
+ const candidates = overflowFrom === "start" ? actions : [...actions].reverse();
304
+ for (const candidate of candidates) {
305
+ const normalizedVisible = normalizeEntries(entries, visibleIds);
306
+ if (totalWidth(normalizedVisible, baseMode, true, gap) <= width) break;
307
+ visibleIds.delete(candidate.id);
308
+ }
309
+ visibleEntries = normalizeEntries(entries, visibleIds);
310
+ const hiddenIds = new Set(
311
+ actions.filter(action => !visibleIds.has(action.id)).map(action => action.id),
312
+ );
313
+ nextMenuEntries = normalizeEntries(entries, hiddenIds);
314
+ nextModes = Object.fromEntries(
315
+ actions.map(action => [
316
+ action.id,
317
+ visibleIds.has(action.id) ? baseMode : "hidden",
318
+ ]),
319
+ );
320
+ }
321
+
322
+ const visibleSeparators = new Set(
323
+ visibleEntries
324
+ .filter((entry): entry is Extract<LayoutEntry, { type: "separator" }> =>
325
+ entry.type === "separator",
326
+ )
327
+ .map(entry => entry.element),
328
+ );
329
+ for (const entry of entries) {
330
+ if (entry.type === "separator") {
331
+ entry.element.hidden = !visibleSeparators.has(entry.element);
332
+ }
333
+ }
334
+
335
+ modes = nextModes;
336
+ menuEntries = nextMenuEntries.filter(
337
+ (entry): entry is Extract<LayoutEntry, { type: "action" }> =>
338
+ entry.type === "action",
339
+ );
340
+ hasOverflow = menuEntries.length > 0;
341
+ }
342
+
343
+ function handleMenuAction(id: string) {
344
+ runAction(id, "menu");
345
+ requestLayout();
346
+ }
347
+
348
+ function handleInteractionEnd() {
349
+ requestLayout();
350
+ }
351
+
352
+ onMount(() => {
353
+ isMounted = true;
354
+ requestLayout();
355
+ });
356
+
357
+ onDestroy(() => {
358
+ isMounted = false;
359
+ if (layoutFrame) cancelAnimationFrame(layoutFrame);
360
+ });
361
+
362
+ $effect(() => {
363
+ const node = rootElement;
364
+ if (availableWidth !== undefined || !node) return;
365
+ return resizeManager.watch(node, requestLayout);
366
+ });
367
+
368
+ $effect(() => {
369
+ availableWidth;
370
+ compact;
371
+ overflow;
372
+ overflowFrom;
373
+ items;
374
+ buttonProps;
375
+ parts?.Button;
376
+ parts?.SelectButton;
377
+ requestLayout();
378
+ });
379
+ </script>
380
+
381
+ {#snippet renderMenuIcon(icon: OverflowActionIcon | undefined)}
382
+ {#if typeof icon === "string"}
383
+ <ResourceIcon name={icon} size={16} aria-hidden="true" />
384
+ {:else if icon}
385
+ {@render icon()}
386
+ {/if}
387
+ {/snippet}
388
+
389
+ <Frame
390
+ bind:element={rootElement}
391
+ tag="div"
392
+ row
393
+ class={`snowui-overflow-actions${userClass ? ` ${userClass}` : ""}`}
394
+ data-overflow={hasOverflow || undefined}
395
+ enableAutoLayout={false}
396
+ enableResponsive={false}
397
+ enableContext={true}
398
+ enableScaleObserver={false}
399
+ enableDefaultMotion={false}
400
+ onfocusin={handleInteractionEnd}
401
+ onkeyup={handleInteractionEnd}
402
+ {...rest}
403
+ >
404
+ {#if children}
405
+ {@render children()}
406
+ {:else}
407
+ {#each items as item (item.id)}
408
+ {#if item.type === "separator"}
409
+ <Separator {...parts?.Separator} as="separator" column />
410
+ {:else}
411
+ <OverflowAction
412
+ as="item"
413
+ id={item.id}
414
+ label={item.label}
415
+ icon={item.icon}
416
+ disabled={item.disabled}
417
+ href={item.href}
418
+ onclick={item.onAction}
419
+ />
420
+ {/if}
421
+ {/each}
422
+ {/if}
423
+
424
+ {#if hasOverflow}
425
+ <SelectButton
426
+ {...resolvedButtonProps}
427
+ {...parts?.SelectButton}
428
+ iconOnly
429
+ showIndicator={false}
430
+ selectionMode="action"
431
+ ariaLabel={moreLabel}
432
+ title={moreLabel}
433
+ disabled={disabled}
434
+ onAction={handleMenuAction}
435
+ parts={{ Listbox: parts?.Listbox, MenuItem: parts?.MenuItem }}
436
+ >
437
+ {#snippet label()}
438
+ <ResourceIcon name="three-dots" aria-hidden="true" />
439
+ {/snippet}
440
+ <Listbox search={false} showCheck={false} placementMode="bottom" {align}>
441
+ {#each menuEntries as entry}
442
+ <MenuItem
443
+ as="item"
444
+ value={entry.action.id}
445
+ disabled={disabled || entry.action.disabled}
446
+ >
447
+ {#if entry.action.icon}
448
+ <span data-as="leading">
449
+ {@render renderMenuIcon(entry.action.icon)}
450
+ </span>
451
+ {/if}
452
+ <span class="snowui-menu-item-label">
453
+ {entry.action.label}
454
+ </span>
455
+ </MenuItem>
456
+ {/each}
457
+ </Listbox>
458
+ </SelectButton>
459
+ {/if}
460
+
461
+ <span class="snowui-overflow-actions-more-measure" aria-hidden="true" inert>
462
+ <span bind:this={moreMeasureElement}>
463
+ <Button {...resolvedButtonProps} iconOnly tabindex={-1} aria-label={moreLabel}>
464
+ <ResourceIcon name="three-dots" aria-hidden="true" />
465
+ </Button>
466
+ </span>
467
+ </span>
468
+ </Frame>
469
+
470
+ <style>
471
+ :global(:where(.snowui-overflow-actions)) {
472
+ position: relative;
473
+ display: inline-flex;
474
+ align-items: center;
475
+ flex-wrap: nowrap;
476
+ gap: var(--snowui-overflow-actions-gap-override, var(--gap-2, 0.5rem));
477
+ width: 100%;
478
+ min-width: 0;
479
+ max-width: 100%;
480
+ white-space: nowrap;
481
+ font-size: inherit;
482
+ line-height: inherit;
483
+ }
484
+
485
+ :global(:where(.snowui-overflow-actions > [data-as="separator"])) {
486
+ height: var(--snowui-overflow-actions-separator-length, var(--size-3));
487
+ }
488
+
489
+ :global(:where(.snowui-overflow-actions > [data-as="separator"])[hidden]) {
490
+ display: none;
491
+ }
492
+
493
+ :global(:where(.snowui-overflow-actions-more-measure)) {
494
+ position: absolute;
495
+ inset: 0 auto auto 0;
496
+ display: inline-flex;
497
+ visibility: hidden;
498
+ pointer-events: none;
499
+ contain: layout style;
500
+ }
501
+ </style>
@@ -0,0 +1,87 @@
1
+ export const examples = [
2
+ {
3
+ name: "OA-01:默认数据与完整操作",
4
+ code: `OA-01
5
+ <OverflowActions
6
+ items={[
7
+ { id: "translate", label: "翻译", icon: "translate" },
8
+ { id: "theme", label: "切换主题", icon: "sun" },
9
+ { id: "github", label: "GitHub", icon: "github-logo" },
10
+ ]}
11
+ />`,
12
+ expected: { render: "宽度足够时三个 Icon + Text Button 完整显示。", layout: "操作按 8px gap 单行排列。", interaction: "每个按钮保持真实 Button 行为。", performance: "自测量模式复用全局 ResizeObserver。", responsive: "跟随真实容器宽度依次进入 compact 与 More 菜单。" },
13
+ logic: ["Items", "Full", "AutoWidth", "Responsive"],
14
+ },
15
+ {
16
+ name: "OA-02:统一收起文字",
17
+ code: `OA-02
18
+ <OverflowActions
19
+ availableWidth={96}
20
+ items={[
21
+ { id: "edit", label: "编辑", icon: "pencil-simple" },
22
+ { id: "copy", label: "复制", icon: "copy" },
23
+ { id: "delete", label: "删除", icon: "trash" },
24
+ ]}
25
+ />`,
26
+ expected: { render: "全部操作统一显示为 Icon-only。", layout: "不会混合 Icon + Text 与 Icon-only 两种密度。", interaction: "aria-label 与 title 沿用 label。", performance: "完整与紧凑宽度由隐藏测量副本一次读取。", responsive: "完整状态放不下时先统一 compact。" },
27
+ logic: ["Compact", "AccessibleName", "Measure"],
28
+ },
29
+ {
30
+ name: "OA-03:从左到右隐藏",
31
+ code: `OA-03
32
+ <OverflowActions
33
+ compact="none"
34
+ overflow="progressive"
35
+ overflowFrom="start"
36
+ items={[
37
+ { id: "edit", label: "编辑", icon: "pencil-simple" },
38
+ { id: "copy", label: "复制", icon: "copy" },
39
+ { id: "delete", label: "删除", icon: "trash" },
40
+ ]}
41
+ />`,
42
+ expected: { render: "初始完整显示三个 Icon + Text Button;宽度不足时按编辑、复制、删除的顺序从左向右转入 More。", layout: "compact=none 禁止先统一变成 Icon-only。", interaction: "More 菜单保持被隐藏操作的原顺序。", performance: "只复用既有测量结果。", responsive: "跟随效果区域实际宽度响应,overflowFrom=start 从左侧开始逐个隐藏。" },
43
+ logic: ["Progressive", "Start", "IconText", "NoCompact"],
44
+ },
45
+ {
46
+ name: "OA-04:从右到左隐藏",
47
+ code: `OA-04
48
+ <OverflowActions
49
+ compact="none"
50
+ overflow="progressive"
51
+ overflowFrom="end"
52
+ items={[
53
+ { id: "edit", label: "编辑", icon: "pencil-simple" },
54
+ { id: "copy", label: "复制", icon: "copy" },
55
+ { id: "delete", label: "删除", icon: "trash" },
56
+ ]}
57
+ />`,
58
+ expected: { render: "初始完整显示三个按钮;宽度不足时按删除、复制、编辑的顺序从右向左转入 More。", layout: "剩余操作保持原有视觉顺序。", interaction: "More 菜单按原始数据顺序显示被隐藏操作。", performance: "只复用既有测量结果。", responsive: "跟随效果区域实际宽度响应,overflowFrom=end 从右侧开始逐个隐藏。" },
59
+ logic: ["Progressive", "End", "NoCompact"],
60
+ },
61
+ {
62
+ name: "OA-05:分割线不进入菜单",
63
+ code: `OA-05
64
+ <OverflowActions overflow="all">
65
+ <OverflowAction as="item" id="copy" label="复制" icon="copy" />
66
+ <Separator as="separator" column />
67
+ <OverflowAction as="item" id="delete" label="删除" icon="trash" />
68
+ </OverflowActions>`,
69
+ expected: { render: "初始显示两个 Action 与 Separator;宽度不足时 Listbox 连续显示复制与删除,不显示 Separator。", layout: "Separator 只属于主操作区域。", interaction: "菜单项仍执行原 Action。", performance: "Separator 仍参与主区域宽度计算。", responsive: "跟随效果区域实际宽度响应,全部 Action 转入菜单时忽略分割线。" },
70
+ logic: ["All", "Separator", "Listbox"],
71
+ },
72
+ {
73
+ name: "OA-06:全局按钮样式与子项覆盖",
74
+ code: `OA-06
75
+ <OverflowActions
76
+ overflow="progressive"
77
+ overflowFrom="end"
78
+ buttonProps={{ variant: "outline", size: "md" }}
79
+ >
80
+ <OverflowAction as="item" id="edit" label="编辑" icon="pencil-simple" variant="filled" />
81
+ <OverflowAction as="item" id="copy" label="复制" icon="copy" />
82
+ <OverflowAction as="item" id="delete" label="删除" icon="trash" />
83
+ </OverflowActions>`,
84
+ expected: { render: "初始完整显示三个 Action;宽度不足时先统一隐藏文字,再按删除、复制、编辑的顺序从右向左逐个进入 More。组级 outline/md 应用于所有普通 Action 与 More,编辑显式 variant=filled 覆盖组级 outline。", layout: "完整、Icon-only 与 More 三阶段保持同一组级样式;More 默认与 Button 一样使用 gray,本例由 buttonProps 改为 outline。", interaction: "显式子项行为不变。", performance: "完整、紧凑与 More 测量使用同一 buttonProps。", responsive: "跟随效果区域实际宽度响应,先统一 compact,再由 overflowFrom=end 逐个隐藏。" },
85
+ logic: ["ButtonProps", "ExplicitOverride", "Compact", "Progressive", "More", "Measure"],
86
+ },
87
+ ] as const;
@@ -235,10 +235,10 @@ Pagination 只复制模板的外观属性并替换页码文本;点击和可用
235
235
  <Pagination page={1} total={22} style="width: 21.25rem;">
236
236
  <Button as="current" variant="gray" />
237
237
  <Button as="page" variant="outline" />
238
- <Button as="prev" variant="outline" bare>
238
+ <Button as="prev" variant="outline" bare iconOnly aria-label="上一页">
239
239
  <svg viewBox="0 0 32 32"><path fill="currentColor" fill-rule="evenodd" d="M20.68 7.293a.943.943 0 0 1 0 1.414l-7.18 6.586a.943.943 0 0 0 0 1.414l7.18 6.586a.943.943 0 0 1 0 1.414c-.425.39-1.116.39-1.541 0l-7.181-6.586c-1.277-1.171-1.277-3.07 0-4.242l7.18-6.586a1.16 1.16 0 0 1 1.543 0" clip-rule="evenodd" /></svg>
240
240
  </Button>
241
- <Button as="next" variant="outline" bare>
241
+ <Button as="next" variant="outline" bare iconOnly aria-label="下一页">
242
242
  <svg viewBox="0 0 32 32"><path fill="currentColor" fill-rule="evenodd" d="M11.32 24.707a.943.943 0 0 1 0-1.414l7.18-6.586a.943.943 0 0 0 0-1.414l-7.18-6.586a.943.943 0 0 1 0-1.414 1.16 1.16 0 0 1 1.541 0l7.181 6.586c1.277 1.171 1.277 3.07 0 4.242l-7.18 6.586c-.427.39-1.117.39-1.543 0" clip-rule="evenodd" /></svg>
243
243
  </Button>
244
244
  </Pagination>
@@ -669,10 +669,10 @@
669
669
  <Button as="pageSize" variant="borderless" />
670
670
  <Button as="current" variant="gray" />
671
671
  <Button as="page" variant="outline" />
672
- <Button as="prev" variant="outline">
672
+ <Button as="prev" variant="outline" iconOnly aria-label="上一页">
673
673
  <ResourceIcon name="arrow-line-left" size={16} aria-hidden="true" />
674
674
  </Button>
675
- <Button as="next" variant="outline">
675
+ <Button as="next" variant="outline" iconOnly aria-label="下一页">
676
676
  <ResourceIcon name="arrow-line-right" size={16} aria-hidden="true" />
677
677
  </Button>
678
678
  {/if}
@@ -140,10 +140,10 @@ export const examples = [
140
140
  <Pagination page={1} total={22} style="width: 21.25rem;">
141
141
  <Button as="current" variant="gray" />
142
142
  <Button as="page" variant="outline" />
143
- <Button as="prev" variant="outline" bare>
143
+ <Button as="prev" variant="outline" bare emphasis="muted">
144
144
  <svg viewBox="0 0 32 32"><path fill="currentColor" fill-rule="evenodd" d="M20.68 7.293a.943.943 0 0 1 0 1.414l-7.18 6.586a.943.943 0 0 0 0 1.414l7.18 6.586a.943.943 0 0 1 0 1.414c-.425.39-1.116.39-1.541 0l-7.181-6.586c-1.277-1.171-1.277-3.07 0-4.242l7.18-6.586a1.16 1.16 0 0 1 1.543 0" clip-rule="evenodd" /></svg>
145
145
  </Button>
146
- <Button as="next" variant="outline" bare>
146
+ <Button as="next" variant="outline" bare iconOnly emphasis="muted" aria-label="下一页">
147
147
  <svg viewBox="0 0 32 32"><path fill="currentColor" fill-rule="evenodd" d="M11.32 24.707a.943.943 0 0 1 0-1.414l7.18-6.586a.943.943 0 0 0 0-1.414l-7.18-6.586a.943.943 0 0 1 0-1.414 1.16 1.16 0 0 1 1.541 0l7.181 6.586c1.277 1.171 1.277 3.07 0 4.242l-7.18 6.586c-.427.39-1.117.39-1.543 0" clip-rule="evenodd" /></svg>
148
148
  </Button>
149
149
  </Pagination>`,
@@ -288,3 +288,8 @@ QuickAction 与 SearchPopup 源码组件已删除;SP-02 示例迁移到 PRO 中
288
288
 
289
289
  ### v1.1.1 (2026-02-03)
290
290
  - 初始版本
291
+ ## 连续 Hover
292
+
293
+ `continuousHover` 默认 `true`,作用于滚动内容区的直接 `MenuItem`。单一背景层在
294
+ 菜单项之间连续移动;`false` 恢复 MenuItem 原有逐项 hover。嵌套 Listbox 使用自己
295
+ 最近的连续 hover 容器,不由 Popover 越界接管。