@snowui-design-system/components 0.3.0-alpha.2 → 0.3.0-alpha.4

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 (88) hide show
  1. package/THIRD_PARTY_NOTICES.md +14 -0
  2. package/dist/client/blocks/Sidebar.js +56 -41
  3. package/dist/client/blocks/SidebarSection.js +3 -1
  4. package/dist/client/components/BarChart.js +1 -1
  5. package/dist/client/components/Breadcrumb.js +17 -11
  6. package/dist/client/components/CircularChart.js +2 -2
  7. package/dist/client/components/CodeBlock.js +278 -225
  8. package/dist/client/components/CopyButton.js +5 -2
  9. package/dist/client/components/ExpandButton.js +10 -3
  10. package/dist/client/components/Frame.js +15 -9
  11. package/dist/client/components/GaugeChart.js +2 -2
  12. package/dist/client/components/ImageViewer.js +51 -27
  13. package/dist/client/components/Indicator.js +5 -3
  14. package/dist/client/components/Input.js +27 -17
  15. package/dist/client/components/LineChart.js +1 -1
  16. package/dist/client/components/Link.d.ts +1 -1
  17. package/dist/client/components/Link.js +43 -22
  18. package/dist/client/components/Listbox.js +26 -15
  19. package/dist/client/components/OverflowAction.d.ts +2 -0
  20. package/dist/client/components/OverflowAction.js +146 -65
  21. package/dist/client/components/OverflowActions.d.ts +2 -0
  22. package/dist/client/components/OverflowActions.js +67 -16
  23. package/dist/client/components/Pagination.js +71 -48
  24. package/dist/client/components/Select.js +29 -18
  25. package/dist/client/components/SidePanel.js +76 -50
  26. package/dist/client/components/Tab.js +30 -31
  27. package/dist/client/components/TableBody.js +10 -4
  28. package/dist/client/components/TableCell.js +57 -32
  29. package/dist/client/components/TableHead.js +69 -38
  30. package/dist/client/components/TableToolbar.js +112 -79
  31. package/dist/client/components/Text.js +99 -59
  32. package/dist/client/components/Textarea.js +7 -1
  33. package/dist/client/components/Toast.js +8 -1
  34. package/dist/client/i18n/messages.d.ts +1 -1
  35. package/dist/client/i18n/messages.js +114 -0
  36. package/dist/client/index.d.ts +1 -1
  37. package/dist/client/index.js +1 -1
  38. package/dist/client/lib/number-format.js +6 -0
  39. package/dist/client/lib/progressive-blur.d.ts +13 -0
  40. package/dist/client/lib/progressive-blur.js +54 -0
  41. package/dist/client/logic/ComponentPartsBoundary.d.ts +7 -0
  42. package/dist/client/logic/ComponentPartsBoundary.js +15 -0
  43. package/dist/client/logic/overflow-actions.d.ts +3 -2
  44. package/dist/client/styles/layout.css +12 -2
  45. package/dist/server/blocks/Sidebar.js +19 -5
  46. package/dist/server/blocks/SidebarSection.js +3 -1
  47. package/dist/server/components/BarChart.js +1 -1
  48. package/dist/server/components/Breadcrumb.js +9 -2
  49. package/dist/server/components/CircularChart.js +2 -2
  50. package/dist/server/components/CodeBlock.js +25 -13
  51. package/dist/server/components/CopyButton.js +6 -2
  52. package/dist/server/components/ExpandButton.js +7 -3
  53. package/dist/server/components/Frame.js +10 -3
  54. package/dist/server/components/GaugeChart.js +2 -2
  55. package/dist/server/components/ImageViewer.js +6 -3
  56. package/dist/server/components/Indicator.js +5 -3
  57. package/dist/server/components/Input.js +14 -17
  58. package/dist/server/components/LineChart.js +1 -1
  59. package/dist/server/components/Link.d.ts +1 -1
  60. package/dist/server/components/Link.js +20 -3
  61. package/dist/server/components/Listbox.js +17 -4
  62. package/dist/server/components/OverflowAction.d.ts +2 -0
  63. package/dist/server/components/OverflowAction.js +70 -26
  64. package/dist/server/components/OverflowActions.d.ts +2 -0
  65. package/dist/server/components/OverflowActions.js +49 -14
  66. package/dist/server/components/Pagination.js +21 -10
  67. package/dist/server/components/Select.js +23 -11
  68. package/dist/server/components/SidePanel.js +28 -8
  69. package/dist/server/components/Tab.js +61 -52
  70. package/dist/server/components/TableBody.js +9 -2
  71. package/dist/server/components/TableCell.js +28 -7
  72. package/dist/server/components/TableHead.js +31 -7
  73. package/dist/server/components/TableToolbar.js +57 -30
  74. package/dist/server/components/Text.js +46 -10
  75. package/dist/server/components/Textarea.js +4 -1
  76. package/dist/server/components/Toast.js +4 -1
  77. package/dist/server/i18n/messages.d.ts +1 -1
  78. package/dist/server/i18n/messages.js +114 -0
  79. package/dist/server/index.d.ts +1 -1
  80. package/dist/server/index.js +1 -1
  81. package/dist/server/lib/number-format.js +6 -0
  82. package/dist/server/lib/progressive-blur.d.ts +13 -0
  83. package/dist/server/lib/progressive-blur.js +54 -0
  84. package/dist/server/logic/ComponentPartsBoundary.d.ts +7 -0
  85. package/dist/server/logic/ComponentPartsBoundary.js +12 -0
  86. package/dist/server/logic/overflow-actions.d.ts +3 -2
  87. package/dist/server/styles/layout.css +12 -2
  88. package/package.json +4 -3
@@ -18,6 +18,7 @@ import {
18
18
 
19
19
  import { getMotionTotalDurationMs } from "../motion/presets/utils.js";
20
20
  import { mergeComponentPartProps, useComponentPart } from "../logic/component-parts.js";
21
+ import ComponentPartsBoundary from "../logic/ComponentPartsBoundary.js";
21
22
  import { ContinuousHoverController } from "../logic/continuous-hover.js";
22
23
  import { CONTINUOUS_HOVER_MOTION_STYLE } from "../motion/presets/continuous-hover.js";
23
24
 
@@ -660,16 +661,21 @@ export default function Listbox($$anchor, $$props) {
660
661
 
661
662
  {
662
663
  var consequent_1 = ($$anchor) => {
663
- var fragment_4 = $.comment();
664
- var node_6 = $.first_child(fragment_4);
665
-
666
- $.snippet(node_6, () => $.get(children));
667
- $.append($$anchor, fragment_4);
664
+ ComponentPartsBoundary($$anchor, {
665
+ children: ($$anchor, $$slotProps) => {
666
+ var fragment_5 = $.comment();
667
+ var node_6 = $.first_child(fragment_5);
668
+
669
+ $.snippet(node_6, () => $.get(children));
670
+ $.append($$anchor, fragment_5);
671
+ },
672
+ $$slots: { default: true }
673
+ });
668
674
  };
669
675
 
670
676
  var alternate = ($$anchor) => {
671
- var fragment_5 = $.comment();
672
- var node_7 = $.first_child(fragment_5);
677
+ var fragment_6 = $.comment();
678
+ var node_7 = $.first_child(fragment_6);
673
679
 
674
680
  $.each(node_7, 17, () => $.get(items), (item) => item.value, ($$anchor, item) => {
675
681
  MenuItem($$anchor, {
@@ -694,7 +700,7 @@ export default function Listbox($$anchor, $$props) {
694
700
  });
695
701
  });
696
702
 
697
- $.append($$anchor, fragment_5);
703
+ $.append($$anchor, fragment_6);
698
704
  };
699
705
 
700
706
  $.if(node_5, ($$render) => {
@@ -788,16 +794,21 @@ export default function Listbox($$anchor, $$props) {
788
794
 
789
795
  {
790
796
  var consequent_4 = ($$anchor) => {
791
- var fragment_10 = $.comment();
792
- var node_11 = $.first_child(fragment_10);
797
+ ComponentPartsBoundary($$anchor, {
798
+ children: ($$anchor, $$slotProps) => {
799
+ var fragment_12 = $.comment();
800
+ var node_11 = $.first_child(fragment_12);
793
801
 
794
- $.snippet(node_11, () => $.get(children));
795
- $.append($$anchor, fragment_10);
802
+ $.snippet(node_11, () => $.get(children));
803
+ $.append($$anchor, fragment_12);
804
+ },
805
+ $$slots: { default: true }
806
+ });
796
807
  };
797
808
 
798
809
  var alternate_1 = ($$anchor) => {
799
- var fragment_11 = $.comment();
800
- var node_12 = $.first_child(fragment_11);
810
+ var fragment_13 = $.comment();
811
+ var node_12 = $.first_child(fragment_13);
801
812
 
802
813
  $.each(node_12, 17, () => $.get(items), (item) => item.value, ($$anchor, item) => {
803
814
  MenuItem($$anchor, {
@@ -822,7 +833,7 @@ export default function Listbox($$anchor, $$props) {
822
833
  });
823
834
  });
824
835
 
825
- $.append($$anchor, fragment_11);
836
+ $.append($$anchor, fragment_13);
826
837
  };
827
838
 
828
839
  $.if(node_10, ($$render) => {
@@ -10,8 +10,10 @@ interface Props extends Omit<ButtonProps, ControlledButtonKeys> {
10
10
  icon?: OverflowActionIcon;
11
11
  disabled?: boolean;
12
12
  href?: string;
13
+ iconOnly?: boolean;
13
14
  onclick?: (event?: MouseEvent) => void;
14
15
  children?: Snippet;
16
+ control?: Snippet<[(event?: MouseEvent) => void, boolean]>;
15
17
  parts?: ComponentPartsOf<{
16
18
  Button: typeof Button;
17
19
  }>;
@@ -16,19 +16,22 @@ var rest_excludes = new Set([
16
16
  'icon',
17
17
  'disabled',
18
18
  'href',
19
+ 'iconOnly',
19
20
  'onclick',
20
21
  'children',
22
+ 'control',
21
23
  'parts',
22
24
  'as'
23
25
  ]);
24
26
 
25
27
  var root = $.from_html(`<!> `, 1);
26
28
  var root_1 = $.from_html(`<span><!></span>`);
27
- var root_2 = $.from_html(`<span class="snowui-overflow-action-visual"><!></span> <span class="snowui-overflow-action-measure" aria-hidden="true" inert=""><span><!></span> <!></span>`, 1);
29
+ var root_2 = $.from_html(`<span class="snowui-overflow-action-measure" aria-hidden="true" inert=""><span><!></span> <!></span>`);
30
+ var root_3 = $.from_html(`<span class="snowui-overflow-action-visual"><!></span> <!>`, 1);
28
31
 
29
32
  const $$css = {
30
33
  hash: 'svelte-tc9pz8',
31
- code: ':where(.snowui-overflow-action-visual) {display:inline-flex;opacity:var(--snowui-responsive-exit-opacity, 1);}\n @media (prefers-reduced-motion: reduce) {:where(.snowui-overflow-action-visual) {opacity:1;}\n }:where(.snowui-overflow-action) {position:relative;display:inline-flex;flex:0 0 auto;min-width:0;font-size:inherit;line-height:inherit;}:where(.snowui-overflow-action[data-overflow-mode="hidden"]) {position:absolute;visibility:hidden;pointer-events:none;}:where(.snowui-overflow-action-measure) {position:absolute;inset:0 auto auto 0;display:inline-flex;visibility:hidden;pointer-events:none;contain:layout style;white-space:nowrap;}'
34
+ code: ':where(.snowui-overflow-action-visual) {display:inline-flex;opacity:var(--snowui-responsive-exit-opacity, 1);}\n @media (prefers-reduced-motion: reduce) {:where(.snowui-overflow-action-visual) {opacity:1;}\n }:where(.snowui-overflow-action) {position:relative;display:inline-flex;flex:0 0 auto;min-width:0;font-size:inherit;line-height:inherit;}:where(.snowui-overflow-action-measure) {position:absolute;inset:0 auto auto 0;display:inline-flex;visibility:hidden;pointer-events:none;contain:layout style;white-space:nowrap;}:where(.snowui-overflow-action[data-overflow-mode="hidden"]) {display:none;}'
32
35
  };
33
36
 
34
37
  export default function OverflowAction($$anchor, $$props) {
@@ -81,20 +84,24 @@ export default function OverflowAction($$anchor, $$props) {
81
84
  $.append($$anchor, fragment_4);
82
85
  };
83
86
 
87
+ var consequent_3 = ($$anchor) => {
88
+ renderIcon($$anchor);
89
+ };
90
+
84
91
  var alternate = ($$anchor) => {
85
- var fragment_5 = root();
86
- var node_4 = $.first_child(fragment_5);
92
+ var fragment_6 = root();
93
+ var node_4 = $.first_child(fragment_6);
87
94
 
88
95
  renderIcon(node_4);
89
96
 
90
97
  var text = $.sibling(node_4);
91
98
 
92
99
  $.template_effect(() => $.set_text(text, ` ${$$props.label ?? ''}`));
93
- $.append($$anchor, fragment_5);
100
+ $.append($$anchor, fragment_6);
94
101
  };
95
102
 
96
103
  $.if(node_2, ($$render) => {
97
- if (children()) $$render(consequent_2); else $$render(alternate, -1);
104
+ if (children()) $$render(consequent_2); else if (iconOnly()) $$render(consequent_3, 1); else $$render(alternate, -1);
98
105
  });
99
106
  }
100
107
 
@@ -104,8 +111,10 @@ export default function OverflowAction($$anchor, $$props) {
104
111
  let icon = $.prop($$props, 'icon', 3, undefined),
105
112
  disabled = $.prop($$props, 'disabled', 3, false),
106
113
  href = $.prop($$props, 'href', 3, undefined),
114
+ iconOnly = $.prop($$props, 'iconOnly', 3, false),
107
115
  onclick = $.prop($$props, 'onclick', 3, undefined),
108
116
  children = $.prop($$props, 'children', 3, undefined),
117
+ control = $.prop($$props, 'control', 3, undefined),
109
118
  parts = $.prop($$props, 'parts', 3, undefined),
110
119
  as = $.prop($$props, 'as', 3, undefined),
111
120
  rest = $.rest_props($$props, rest_excludes);
@@ -113,6 +122,7 @@ export default function OverflowAction($$anchor, $$props) {
113
122
  const owner = getOverflowActionsContext();
114
123
  const resolvedButtonProps = $.derived(() => mergeComponentPartProps(mergeComponentPartProps(owner?.buttonProps, parts()?.Button ?? {}), rest));
115
124
  let rootElement = $.state(undefined);
125
+ let visualElement = $.state(undefined);
116
126
  let fullMeasureElement = $.state(undefined);
117
127
  let compactMeasureElement = $.state(undefined);
118
128
  const mode = $.derived(() => owner?.getMode($$props.id) ?? "full");
@@ -154,12 +164,35 @@ export default function OverflowAction($$anchor, $$props) {
154
164
  return href();
155
165
  },
156
166
 
167
+ get target() {
168
+ return $$props.target;
169
+ },
170
+
171
+ get rel() {
172
+ return $$props.rel;
173
+ },
174
+
157
175
  execute(event) {
158
176
  onclick()?.(event);
159
177
  },
160
178
  getElement: () => $.get(rootElement),
161
- getFullMeasureElement: () => $.get(fullMeasureElement),
162
- getCompactMeasureElement: () => $.get(compactMeasureElement)
179
+ getWidth(mode) {
180
+ const hidden = $.get(rootElement)?.dataset.overflowMode === "hidden";
181
+
182
+ if (hidden && $.get(rootElement)) $.get(rootElement).style.display = "inline-flex";
183
+
184
+ try {
185
+ const element = control()
186
+ ? $.get(visualElement)
187
+ : mode === "compact"
188
+ ? $.get(compactMeasureElement)
189
+ : $.get(fullMeasureElement);
190
+
191
+ return element?.getBoundingClientRect().width ?? 0;
192
+ } finally {
193
+ if (hidden && $.get(rootElement)) $.get(rootElement).style.removeProperty("display");
194
+ }
195
+ }
163
196
  });
164
197
  });
165
198
 
@@ -169,6 +202,8 @@ export default function OverflowAction($$anchor, $$props) {
169
202
  icon();
170
203
  disabled();
171
204
  href();
205
+ iconOnly();
206
+ control();
172
207
  $.get(resolvedButtonProps);
173
208
  owner?.requestLayout();
174
209
  });
@@ -205,12 +240,21 @@ export default function OverflowAction($$anchor, $$props) {
205
240
  },
206
241
 
207
242
  children: ($$anchor, $$slotProps) => {
208
- var fragment_7 = root_2();
209
- var span = $.first_child(fragment_7);
243
+ var fragment_8 = root_3();
244
+ var span = $.first_child(fragment_8);
245
+ let styles;
210
246
  var node_5 = $.child(span);
211
247
 
212
248
  {
213
- var consequent_3 = ($$anchor) => {
249
+ var consequent_4 = ($$anchor) => {
250
+ var fragment_9 = $.comment();
251
+ var node_6 = $.first_child(fragment_9);
252
+
253
+ $.snippet(node_6, control, () => execute, () => $.get(resolvedDisabled));
254
+ $.append($$anchor, fragment_9);
255
+ };
256
+
257
+ var consequent_5 = ($$anchor) => {
214
258
  Button($$anchor, $.spread_props(() => $.get(resolvedButtonProps), {
215
259
  iconOnly: true,
216
260
  get 'aria-label'() {
@@ -237,76 +281,113 @@ export default function OverflowAction($$anchor, $$props) {
237
281
  };
238
282
 
239
283
  var alternate_1 = ($$anchor) => {
240
- Button($$anchor, $.spread_props(() => $.get(resolvedButtonProps), {
241
- get disabled() {
242
- return $.get(resolvedDisabled);
243
- },
244
-
245
- get href() {
246
- return href();
247
- },
248
- onclick: execute,
249
- children: ($$anchor, $$slotProps) => {
250
- renderFull($$anchor);
251
- },
252
- $$slots: { default: true }
253
- }));
284
+ {
285
+ let $0 = $.derived(() => iconOnly() ? $$props.label : undefined);
286
+
287
+ Button($$anchor, $.spread_props(() => $.get(resolvedButtonProps), {
288
+ get iconOnly() {
289
+ return iconOnly();
290
+ },
291
+
292
+ get 'aria-label'() {
293
+ return $.get($0);
294
+ },
295
+
296
+ get disabled() {
297
+ return $.get(resolvedDisabled);
298
+ },
299
+
300
+ get href() {
301
+ return href();
302
+ },
303
+ onclick: execute,
304
+ children: ($$anchor, $$slotProps) => {
305
+ renderFull($$anchor);
306
+ },
307
+ $$slots: { default: true }
308
+ }));
309
+ }
254
310
  };
255
311
 
256
312
  $.if(node_5, ($$render) => {
257
- if ($.get(mode) === "compact") $$render(consequent_3); else $$render(alternate_1, -1);
313
+ if (control()) $$render(consequent_4); else if ($.get(mode) === "compact") $$render(consequent_5, 1); else $$render(alternate_1, -1);
258
314
  });
259
315
  }
260
316
 
261
317
  $.reset(span);
318
+ $.bind_this(span, ($$value) => $.set(visualElement, $$value), () => $.get(visualElement));
262
319
 
263
- var span_1 = $.sibling(span, 2);
264
- var span_2 = $.child(span_1);
265
- var node_6 = $.child(span_2);
266
-
267
- Button(node_6, $.spread_props(() => $.get(resolvedButtonProps), {
268
- tabindex: -1,
269
- children: ($$anchor, $$slotProps) => {
270
- renderFull($$anchor);
271
- },
272
- $$slots: { default: true }
273
- }));
274
-
275
- $.reset(span_2);
276
- $.bind_this(span_2, ($$value) => $.set(fullMeasureElement, $$value), () => $.get(fullMeasureElement));
277
-
278
- var node_7 = $.sibling(span_2, 2);
320
+ var node_7 = $.sibling(span, 2);
279
321
 
280
322
  {
281
- var consequent_4 = ($$anchor) => {
282
- var span_3 = root_1();
283
- var node_8 = $.child(span_3);
284
-
285
- Button(node_8, $.spread_props(() => $.get(resolvedButtonProps), {
286
- iconOnly: true,
287
- tabindex: -1,
288
- get 'aria-label'() {
289
- return $$props.label;
290
- },
291
-
292
- children: ($$anchor, $$slotProps) => {
293
- renderIcon($$anchor);
294
- },
295
- $$slots: { default: true }
296
- }));
297
-
298
- $.reset(span_3);
299
- $.bind_this(span_3, ($$value) => $.set(compactMeasureElement, $$value), () => $.get(compactMeasureElement));
300
- $.append($$anchor, span_3);
323
+ var consequent_7 = ($$anchor) => {
324
+ var span_1 = root_2();
325
+ var span_2 = $.child(span_1);
326
+ var node_8 = $.child(span_2);
327
+
328
+ {
329
+ let $0 = $.derived(() => iconOnly() ? $$props.label : undefined);
330
+
331
+ Button(node_8, $.spread_props(() => $.get(resolvedButtonProps), {
332
+ get iconOnly() {
333
+ return iconOnly();
334
+ },
335
+
336
+ get 'aria-label'() {
337
+ return $.get($0);
338
+ },
339
+ tabindex: -1,
340
+ children: ($$anchor, $$slotProps) => {
341
+ renderFull($$anchor);
342
+ },
343
+ $$slots: { default: true }
344
+ }));
345
+ }
346
+
347
+ $.reset(span_2);
348
+ $.bind_this(span_2, ($$value) => $.set(fullMeasureElement, $$value), () => $.get(fullMeasureElement));
349
+
350
+ var node_9 = $.sibling(span_2, 2);
351
+
352
+ {
353
+ var consequent_6 = ($$anchor) => {
354
+ var span_3 = root_1();
355
+ var node_10 = $.child(span_3);
356
+
357
+ Button(node_10, $.spread_props(() => $.get(resolvedButtonProps), {
358
+ iconOnly: true,
359
+ tabindex: -1,
360
+ get 'aria-label'() {
361
+ return $$props.label;
362
+ },
363
+
364
+ children: ($$anchor, $$slotProps) => {
365
+ renderIcon($$anchor);
366
+ },
367
+ $$slots: { default: true }
368
+ }));
369
+
370
+ $.reset(span_3);
371
+ $.bind_this(span_3, ($$value) => $.set(compactMeasureElement, $$value), () => $.get(compactMeasureElement));
372
+ $.append($$anchor, span_3);
373
+ };
374
+
375
+ $.if(node_9, ($$render) => {
376
+ if (icon()) $$render(consequent_6);
377
+ });
378
+ }
379
+
380
+ $.reset(span_1);
381
+ $.append($$anchor, span_1);
301
382
  };
302
383
 
303
384
  $.if(node_7, ($$render) => {
304
- if (icon()) $$render(consequent_4);
385
+ if (!control()) $$render(consequent_7);
305
386
  });
306
387
  }
307
388
 
308
- $.reset(span_1);
309
- $.append($$anchor, fragment_7);
389
+ $.template_effect(() => styles = $.set_style(span, '', styles, { visibility: $.get(mode) === "hidden" ? "hidden" : undefined }));
390
+ $.append($$anchor, fragment_8);
310
391
  },
311
392
  $$slots: { default: true }
312
393
  }
@@ -17,6 +17,8 @@ export interface OverflowActionsActionItem {
17
17
  icon?: OverflowActionIcon;
18
18
  disabled?: boolean;
19
19
  href?: string;
20
+ target?: string;
21
+ rel?: string;
20
22
  onAction?: () => void;
21
23
  }
22
24
  export interface OverflowActionsSeparatorItem {
@@ -14,6 +14,7 @@ import { createResponsiveExit } from "../lib/responsive-exit.js";
14
14
  import { resizeManager } from "../logic/observer.js";
15
15
  import { OVERFLOW_ACTIONS_CONTEXT_KEY } from "../logic/overflow-actions.js";
16
16
  import { mergeComponentPartProps } from "../logic/component-parts.js";
17
+ import { useLocale } from "../i18n/locale.js";
17
18
 
18
19
  const renderMenuIcon = ($$anchor, icon = $.noop) => {
19
20
  var fragment = $.comment();
@@ -84,7 +85,7 @@ export default function OverflowActions($$anchor, $$props) {
84
85
  overflow = $.prop($$props, 'overflow', 3, "all"),
85
86
  overflowFrom = $.prop($$props, 'overflowFrom', 3, "end"),
86
87
  availableWidth = $.prop($$props, 'availableWidth', 3, undefined),
87
- moreLabel = $.prop($$props, 'moreLabel', 3, "更多操作"),
88
+ moreLabel = $.prop($$props, 'moreLabel', 3, undefined),
88
89
  align = $.prop($$props, 'align', 3, "end"),
89
90
  disabled = $.prop($$props, 'disabled', 3, false),
90
91
  buttonProps = $.prop($$props, 'buttonProps', 3, undefined),
@@ -94,10 +95,13 @@ export default function OverflowActions($$anchor, $$props) {
94
95
  userClass = $.prop($$props, 'class', 3, ""),
95
96
  rest = $.rest_props($$props, rest_excludes);
96
97
 
98
+ const locale = useLocale();
99
+ const resolvedMoreLabel = $.derived(() => moreLabel() ?? locale.t("overflowActions.more"));
97
100
  let rootElement = $.state(undefined);
98
101
  let moreMeasureElement = $.state(undefined);
99
102
  let fadeMeasureElement;
100
103
  const separatorWidths = new Map();
104
+ const actionWidths = new Map();
101
105
  let modes = $.state($.proxy({}));
102
106
  let menuEntries = $.state($.proxy([]));
103
107
  let hasOverflow = $.state(false);
@@ -164,11 +168,23 @@ export default function OverflowActions($$anchor, $$props) {
164
168
  onAction()?.({ id, item, source, originalEvent });
165
169
 
166
170
  if (source === "menu" && action.href && typeof window !== "undefined") {
167
- window.location.assign(action.href);
171
+ if (action.target && action.target !== "_self") {
172
+ window.open(action.href, action.target, action.rel?.includes("noreferrer") ? "noopener,noreferrer" : "noopener");
173
+ } else {
174
+ window.location.assign(action.href);
175
+ }
168
176
  }
169
177
  }
170
178
 
171
179
  function requestLayout() {
180
+ // 内容或 Props 改变时才重新测量;连续拖动只复用固有宽度。
181
+ actionWidths.clear();
182
+
183
+ separatorWidths.clear();
184
+ scheduleLayout();
185
+ }
186
+
187
+ function scheduleLayout() {
172
188
  if (!isMounted || layoutFrame) return;
173
189
 
174
190
  layoutFrame = requestAnimationFrame(() => {
@@ -245,11 +261,7 @@ export default function OverflowActions($$anchor, $$props) {
245
261
  return separatorWidths.get(entry.element) ?? 0;
246
262
  }
247
263
 
248
- const element = mode === "compact"
249
- ? entry.action.getCompactMeasureElement()
250
- : entry.action.getFullMeasureElement();
251
-
252
- return element?.getBoundingClientRect().width ?? 0;
264
+ return actionWidths.get(entry.action.id)?.[mode] ?? 0;
253
265
  }
254
266
 
255
267
  function totalWidth(entries, mode, includeMore, gap) {
@@ -270,16 +282,26 @@ export default function OverflowActions($$anchor, $$props) {
270
282
  const actions = entries.filter((entry) => entry.type === "action").map((entry) => entry.action);
271
283
  const allIds = new Set(actions.map((action) => action.id));
272
284
  const normalizedAll = normalizeEntries(entries, allIds);
273
- const width = Math.max(0, availableWidth() ?? $.get(rootElement).getBoundingClientRect().width);
274
285
  const computed = getComputedStyle($.get(rootElement));
286
+
287
+ // 与 Table 一样读取小数布局宽度;clientWidth 的整数取整会在临界点往返跳变。
288
+ const width = Math.max(0, availableWidth() ?? (Number.parseFloat(computed.width) || $.get(rootElement).clientWidth));
289
+
275
290
  const gap = Number.parseFloat(computed.columnGap || computed.gap) || 0;
276
291
  const canCompact = compact() === "auto" && actions.length > 0 && actions.every((action) => !!action.icon);
277
292
 
278
- // 隐藏的 Separator 仍参与未来布局预算;同帧恢复测量后还原,不改变绘制状态。
279
- separatorWidths.clear();
293
+ // 隐藏项只在内容变化后测量一次,避免拖动时反复切换 display 触发布局反馈。
294
+ for (const action of actions) {
295
+ if (!actionWidths.has(action.id)) {
296
+ actionWidths.set(action.id, {
297
+ full: action.getWidth("full"),
298
+ compact: action.getWidth("compact")
299
+ });
300
+ }
301
+ }
280
302
 
281
303
  for (const entry of entries) {
282
- if (entry.type !== "separator") continue;
304
+ if (entry.type !== "separator" || separatorWidths.has(entry.element)) continue;
283
305
 
284
306
  const hidden = entry.element.hidden;
285
307
 
@@ -397,16 +419,27 @@ export default function OverflowActions($$anchor, $$props) {
397
419
  requestLayout();
398
420
  }
399
421
 
422
+ function handleViewportResize() {
423
+ // 窗口缩放时在下一次绘制前同步求解,观察器随后交付同一宽度也不会重新测量。
424
+ updateLayout();
425
+ }
426
+
400
427
  onMount(() => {
401
428
  isMounted = true;
402
429
 
403
430
  if ($.get(rootElement)) movement = createOverflowActionsMotion($.get(rootElement));
404
431
 
432
+ window.addEventListener('resize', handleViewportResize);
433
+ document.fonts?.addEventListener('loadingdone', requestLayout);
405
434
  requestLayout();
406
435
  });
407
436
 
408
437
  onDestroy(() => {
409
438
  isMounted = false;
439
+
440
+ if (typeof window !== 'undefined') window.removeEventListener('resize', handleViewportResize);
441
+ if (typeof document !== 'undefined') document.fonts?.removeEventListener('loadingdone', requestLayout);
442
+
410
443
  movement?.destroy();
411
444
  exit.destroy();
412
445
 
@@ -419,12 +452,15 @@ export default function OverflowActions($$anchor, $$props) {
419
452
  if (availableWidth() !== undefined || !node) return;
420
453
 
421
454
  return resizeManager.watch(node, () => {
422
- void flushLayout();
455
+ // 观察器已在动画帧交付,直接求解,避免额外一帧的旧位置与新位置叠画。
456
+ if (layoutFrame) cancelAnimationFrame(layoutFrame);
457
+
458
+ layoutFrame = 0;
459
+ updateLayout();
423
460
  });
424
461
  });
425
462
 
426
463
  $.user_effect(() => {
427
- availableWidth();
428
464
  compact();
429
465
  overflow();
430
466
  overflowFrom();
@@ -435,6 +471,13 @@ export default function OverflowActions($$anchor, $$props) {
435
471
  requestLayout();
436
472
  });
437
473
 
474
+ $.user_effect(() => {
475
+ availableWidth();
476
+
477
+ // 外部列宽也可能逐帧变化;只更新预算,不使固有宽度缓存失效。
478
+ if (isMounted) void flushLayout();
479
+ });
480
+
438
481
  {
439
482
  let $0 = $.derived(() => `snowui-overflow-actions${userClass() ? ` ${userClass()}` : ""}`);
440
483
  let $1 = $.derived(() => $.get(hasOverflow) || undefined);
@@ -517,6 +560,14 @@ export default function OverflowActions($$anchor, $$props) {
517
560
  return $.get(item).href;
518
561
  },
519
562
 
563
+ get target() {
564
+ return $.get(item).target;
565
+ },
566
+
567
+ get rel() {
568
+ return $.get(item).rel;
569
+ },
570
+
520
571
  get onclick() {
521
572
  return $.get(item).onAction;
522
573
  }
@@ -558,11 +609,11 @@ export default function OverflowActions($$anchor, $$props) {
558
609
  showIndicator: false,
559
610
  selectionMode: 'action',
560
611
  get ariaLabel() {
561
- return moreLabel();
612
+ return $.get(resolvedMoreLabel);
562
613
  },
563
614
 
564
615
  get title() {
565
- return moreLabel();
616
+ return $.get(resolvedMoreLabel);
566
617
  },
567
618
 
568
619
  get disabled() {
@@ -669,7 +720,7 @@ export default function OverflowActions($$anchor, $$props) {
669
720
  showIndicator: false,
670
721
  selectionMode: 'action',
671
722
  get ariaLabel() {
672
- return moreLabel();
723
+ return $.get(resolvedMoreLabel);
673
724
  },
674
725
  tabindex: -1,
675
726
  get parts() {