@snowui-design-system/components 1.1.0 → 1.2.0
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.
- package/dist/client/components/Button.d.ts +9 -0
- package/dist/client/components/Button.js +105 -18
- package/dist/client/components/OverflowAction.d.ts +6 -1
- package/dist/client/components/OverflowAction.js +61 -9
- package/dist/client/components/OverflowActions.d.ts +6 -0
- package/dist/client/components/OverflowActions.js +30 -4
- package/dist/client/components/Select.d.ts +2 -0
- package/dist/client/components/SelectButton.d.ts +2 -0
- package/dist/client/components/Text.d.ts +2 -2
- package/dist/client/components/Text.js +46 -31
- package/dist/client/context.d.ts +8 -0
- package/dist/client/context.js +4 -1
- package/dist/client/index.d.ts +1 -0
- package/dist/client/keys.d.ts +1 -0
- package/dist/client/keys.js +1 -0
- package/dist/client/logic/frame-dom-runtime.d.ts +15 -15
- package/dist/client/logic/frame-dom-runtime.js +70 -30
- package/dist/client/logic/frame-responsive.js +72 -13
- package/dist/client/logic/overflow-actions.d.ts +2 -0
- package/dist/client/logic/tooltip-prop.d.ts +13 -0
- package/dist/client/logic/tooltip-prop.js +29 -0
- package/dist/server/components/Button.d.ts +9 -0
- package/dist/server/components/Button.js +71 -5
- package/dist/server/components/OverflowAction.d.ts +6 -1
- package/dist/server/components/OverflowAction.js +49 -5
- package/dist/server/components/OverflowActions.d.ts +6 -0
- package/dist/server/components/OverflowActions.js +20 -2
- package/dist/server/components/Select.d.ts +2 -0
- package/dist/server/components/SelectButton.d.ts +2 -0
- package/dist/server/components/Text.d.ts +2 -2
- package/dist/server/components/Text.js +31 -22
- package/dist/server/context.d.ts +8 -0
- package/dist/server/context.js +4 -1
- package/dist/server/index.d.ts +1 -0
- package/dist/server/keys.d.ts +1 -0
- package/dist/server/keys.js +1 -0
- package/dist/server/logic/frame-dom-runtime.d.ts +15 -15
- package/dist/server/logic/frame-dom-runtime.js +70 -30
- package/dist/server/logic/frame-responsive.js +72 -13
- package/dist/server/logic/overflow-actions.d.ts +2 -0
- package/dist/server/logic/tooltip-prop.d.ts +13 -0
- package/dist/server/logic/tooltip-prop.js +29 -0
- package/package.json +1 -1
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { type Snippet } from "svelte";
|
|
2
2
|
import { type FrameProps } from "./Frame.js";
|
|
3
|
+
import { type ComponentPartsOf } from "../logic/component-parts.js";
|
|
4
|
+
import type TooltipType from "./Tooltip.js";
|
|
5
|
+
import { type TooltipProp } from "../logic/tooltip-prop";
|
|
3
6
|
interface Props extends Omit<FrameProps, "size"> {
|
|
4
7
|
variant?: "gray" | "filled" | "outline" | "borderless";
|
|
5
8
|
size?: "sm" | "md" | "lg";
|
|
@@ -27,6 +30,12 @@ interface Props extends Omit<FrameProps, "size"> {
|
|
|
27
30
|
holdRepeat?: boolean;
|
|
28
31
|
holdRepeatDelay?: number;
|
|
29
32
|
holdRepeatInterval?: number;
|
|
33
|
+
/** Hover/focus tooltip toggle or config; disabled by default. When true, reuses the button's aria-label. */
|
|
34
|
+
tooltip?: TooltipProp;
|
|
35
|
+
/** Configure the built-in Tooltip rendered when `tooltip` is enabled. */
|
|
36
|
+
parts?: ComponentPartsOf<{
|
|
37
|
+
Tooltip: typeof TooltipType;
|
|
38
|
+
}>;
|
|
30
39
|
children?: Snippet;
|
|
31
40
|
[key: string]: any;
|
|
32
41
|
}
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
} from "../motion/presets/effects.js";
|
|
14
14
|
|
|
15
15
|
import { mergeComponentPartProps, useComponentPart } from "../logic/component-parts.js";
|
|
16
|
+
import ComponentPartsBoundary from "../logic/ComponentPartsBoundary.js";
|
|
16
17
|
|
|
17
18
|
import {
|
|
18
19
|
getImage,
|
|
@@ -22,14 +23,16 @@ import {
|
|
|
22
23
|
getButtonGroup,
|
|
23
24
|
getButtonCollection,
|
|
24
25
|
getButtonSize,
|
|
26
|
+
getButtonTooltip,
|
|
25
27
|
getBreadcrumb
|
|
26
28
|
} from "../context.js";
|
|
27
29
|
|
|
28
30
|
import Spinner from "./Spinner.js";
|
|
31
|
+
import { resolveTooltipProp } from "../logic/tooltip-prop.js";
|
|
29
32
|
|
|
30
33
|
var rest_excludes = new Set(['$$slots', '$$events', '$$legacy']);
|
|
31
34
|
var root = $.from_html(`<span class="snowui-button-spinner svelte-1klcfz0" aria-hidden="true"><!></span>`);
|
|
32
|
-
var root_1 = $.from_html(`<!> <!>`, 1);
|
|
35
|
+
var root_1 = $.from_html(`<!> <!> <!>`, 1);
|
|
33
36
|
|
|
34
37
|
const $$css = {
|
|
35
38
|
hash: 'svelte-1klcfz0',
|
|
@@ -54,6 +57,8 @@ export default function Button($$anchor, $$props) {
|
|
|
54
57
|
* `aria-pressed` 也由 Frame 自动输出。
|
|
55
58
|
* 消费方可继续传 `Click` / `whileClick` 覆盖默认行为。
|
|
56
59
|
*/
|
|
60
|
+
/** Hover/focus tooltip toggle or config; disabled by default. When true, reuses the button's aria-label. */
|
|
61
|
+
/** Configure the built-in Tooltip rendered when `tooltip` is enabled. */
|
|
57
62
|
// 跨独立仓库源码检查时,Svelte 的 Snippet nominal symbol 可能来自不同物理安装。
|
|
58
63
|
// 此处只归一化传给 Frame 的类型身份,不改变 snippet 本身或运行时调用。
|
|
59
64
|
// Pass everything else to Frame
|
|
@@ -62,8 +67,8 @@ export default function Button($$anchor, $$props) {
|
|
|
62
67
|
// 上下文感知
|
|
63
68
|
// 只在点击动画期间订阅;也覆盖 CSS 动画尚未开始就被取消的情况。
|
|
64
69
|
// 计算最终尺寸:优先使用 prop size,其次映射上下文尺寸
|
|
65
|
-
//
|
|
66
|
-
//
|
|
70
|
+
// Compute width factor lazily on first pointer/focus/click interaction instead of forcing
|
|
71
|
+
// synchronous getComputedStyle + ResizeObserver on every Button during initial page mount.
|
|
67
72
|
// 传递给 Frame Context 的尺寸(供 Icon/Avatar 等子组件继承)
|
|
68
73
|
// 资源图标直接放在 Button 内时,注入默认尺寸上下文(与 <Icon> 包裹一致)
|
|
69
74
|
// 上下文感知 (用于 as="more" 逻辑)
|
|
@@ -106,11 +111,16 @@ export default function Button($$anchor, $$props) {
|
|
|
106
111
|
},
|
|
107
112
|
|
|
108
113
|
children: ($$anchor, $$slotProps) => {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
+
ComponentPartsBoundary($$anchor, {
|
|
115
|
+
children: ($$anchor, $$slotProps) => {
|
|
116
|
+
var fragment_2 = $.comment();
|
|
117
|
+
var node_2 = $.first_child(fragment_2);
|
|
118
|
+
|
|
119
|
+
$.snippet(node_2, () => $.get(children) ?? $.noop);
|
|
120
|
+
$.append($$anchor, fragment_2);
|
|
121
|
+
},
|
|
122
|
+
$$slots: { default: true }
|
|
123
|
+
});
|
|
114
124
|
},
|
|
115
125
|
$$slots: { default: true }
|
|
116
126
|
});
|
|
@@ -133,14 +143,65 @@ export default function Button($$anchor, $$props) {
|
|
|
133
143
|
});
|
|
134
144
|
}
|
|
135
145
|
|
|
146
|
+
var node_5 = $.sibling(node_3, 2);
|
|
147
|
+
|
|
148
|
+
{
|
|
149
|
+
var consequent_3 = ($$anchor) => {
|
|
150
|
+
var fragment_3 = $.comment();
|
|
151
|
+
var node_6 = $.first_child(fragment_3);
|
|
152
|
+
|
|
153
|
+
$.component(node_6, () => $.get(TooltipComponent), ($$anchor, TooltipComponent_1) => {
|
|
154
|
+
TooltipComponent_1($$anchor, $.spread_props({ as: 'tooltip' }, () => $.get(mergedTooltipConfig), {
|
|
155
|
+
children: ($$anchor, $$slotProps) => {
|
|
156
|
+
var fragment_4 = $.comment();
|
|
157
|
+
var node_7 = $.first_child(fragment_4);
|
|
158
|
+
|
|
159
|
+
{
|
|
160
|
+
var consequent_1 = ($$anchor) => {
|
|
161
|
+
var text = $.text();
|
|
162
|
+
|
|
163
|
+
$.template_effect(() => $.set_text(text, $.get(resolvedTooltip).content));
|
|
164
|
+
$.append($$anchor, text);
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
var consequent_2 = ($$anchor) => {
|
|
168
|
+
var fragment_6 = $.comment();
|
|
169
|
+
var node_8 = $.first_child(fragment_6);
|
|
170
|
+
|
|
171
|
+
$.snippet(node_8, () => $.get(resolvedTooltip).content);
|
|
172
|
+
$.append($$anchor, fragment_6);
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
$.if(node_7, ($$render) => {
|
|
176
|
+
if (typeof $.get(resolvedTooltip).content === "string") $$render(consequent_1); else if (typeof $.get(resolvedTooltip).content === "function") $$render(consequent_2, 1);
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
$.append($$anchor, fragment_4);
|
|
181
|
+
},
|
|
182
|
+
$$slots: { default: true }
|
|
183
|
+
}));
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
$.append($$anchor, fragment_3);
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
$.if(node_5, ($$render) => {
|
|
190
|
+
if ($.get(resolvedTooltip).enabled && $.get(TooltipComponent)) $$render(consequent_3);
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
|
|
136
194
|
$.append($$anchor, fragment);
|
|
137
195
|
};
|
|
138
196
|
|
|
197
|
+
let TooltipComponent = $.state(void 0);
|
|
198
|
+
|
|
139
199
|
function normalizeFrameSnippet(snippet) {
|
|
140
200
|
return snippet;
|
|
141
201
|
}
|
|
142
202
|
|
|
143
203
|
const inheritedButtonPart = useComponentPart("Button");
|
|
204
|
+
const inheritedTooltipPart = useComponentPart("Tooltip");
|
|
144
205
|
let explicitProps = $.rest_props($$props, rest_excludes);
|
|
145
206
|
|
|
146
207
|
let $$d = $.derived((// Pass everything else to Frame
|
|
@@ -162,6 +223,8 @@ export default function Button($$anchor, $$props) {
|
|
|
162
223
|
holdRepeat = $.derived(() => $.fallback($.get($$d).holdRepeat, false)),
|
|
163
224
|
holdRepeatDelay = $.derived(() => $.fallback($.get($$d).holdRepeatDelay, 260)),
|
|
164
225
|
holdRepeatInterval = $.derived(() => $.fallback($.get($$d).holdRepeatInterval, 80)),
|
|
226
|
+
tooltip = $.derived(() => $.fallback($.get($$d).tooltip, undefined)),
|
|
227
|
+
parts = $.derived(() => $.fallback($.get($$d).parts, undefined)),
|
|
165
228
|
userOnClick = $.derived(() => $.get($$d).onclick),
|
|
166
229
|
userOnPointerDown = $.derived(() => $.get($$d).onpointerdown),
|
|
167
230
|
userOnPointerUp = $.derived(() => $.get($$d).onpointerup),
|
|
@@ -192,6 +255,8 @@ export default function Button($$anchor, $$props) {
|
|
|
192
255
|
'holdRepeat',
|
|
193
256
|
'holdRepeatDelay',
|
|
194
257
|
'holdRepeatInterval',
|
|
258
|
+
'tooltip',
|
|
259
|
+
'parts',
|
|
195
260
|
'onclick',
|
|
196
261
|
'onpointerdown',
|
|
197
262
|
'onpointerup',
|
|
@@ -310,8 +375,11 @@ export default function Button($$anchor, $$props) {
|
|
|
310
375
|
return;
|
|
311
376
|
}
|
|
312
377
|
|
|
378
|
+
let stopResize;
|
|
379
|
+
|
|
313
380
|
const refresh = () => {
|
|
314
|
-
//
|
|
381
|
+
// Compute width factor lazily on first pointer/focus/click interaction instead of forcing
|
|
382
|
+
// synchronous getComputedStyle + ResizeObserver on every Button during initial page mount.
|
|
315
383
|
const view = node.ownerDocument.defaultView;
|
|
316
384
|
|
|
317
385
|
if (!view) return;
|
|
@@ -324,20 +392,18 @@ export default function Button($$anchor, $$props) {
|
|
|
324
392
|
const rootFontSize = parseFloat(view.getComputedStyle(node.ownerDocument.documentElement).fontSize);
|
|
325
393
|
|
|
326
394
|
$.set(backgroundWidthFactor, getButtonBackgroundWidthFactor(hoverTo, backgroundWidth, rootFontSize), true);
|
|
327
|
-
};
|
|
328
|
-
|
|
329
|
-
refresh();
|
|
330
|
-
|
|
331
|
-
const stop = resizeManager.watch(node, refresh);
|
|
332
395
|
|
|
333
|
-
|
|
334
|
-
|
|
396
|
+
if (!stopResize) {
|
|
397
|
+
stopResize = resizeManager.watch(node, refresh);
|
|
398
|
+
}
|
|
399
|
+
};
|
|
335
400
|
|
|
336
|
-
node.addEventListener("
|
|
401
|
+
node.addEventListener("pointerenter", refresh, { passive: true });
|
|
402
|
+
node.addEventListener("focus", refresh, { passive: true });
|
|
337
403
|
node.addEventListener("click", refresh, true);
|
|
338
404
|
|
|
339
405
|
return () => {
|
|
340
|
-
|
|
406
|
+
stopResize?.();
|
|
341
407
|
node.removeEventListener("pointerenter", refresh);
|
|
342
408
|
node.removeEventListener("focus", refresh);
|
|
343
409
|
node.removeEventListener("click", refresh, true);
|
|
@@ -791,6 +857,23 @@ export default function Button($$anchor, $$props) {
|
|
|
791
857
|
clearHoldSuppressResetTimer();
|
|
792
858
|
}
|
|
793
859
|
|
|
860
|
+
const buttonTooltipCtx = getButtonTooltip();
|
|
861
|
+
const effectiveTooltipProp = $.derived(() => $.get(tooltip) ?? buttonTooltipCtx?.tooltip);
|
|
862
|
+
|
|
863
|
+
const resolvedTooltip = $.derived(() => resolveTooltipProp($.get(effectiveTooltipProp), typeof $.get(rest)["aria-label"] === "string"
|
|
864
|
+
? $.get(rest)["aria-label"]
|
|
865
|
+
: typeof $.get(rest).ariaLabel === "string" ? $.get(rest).ariaLabel : undefined));
|
|
866
|
+
|
|
867
|
+
const mergedTooltipConfig = $.derived(() => mergeComponentPartProps(mergeComponentPartProps(mergeComponentPartProps(buttonTooltipCtx?.tooltipPart, inheritedTooltipPart.current ?? {}), $.get(parts)?.Tooltip ?? {}), $.get(resolvedTooltip).config));
|
|
868
|
+
|
|
869
|
+
$.user_effect(() => {
|
|
870
|
+
if (!$.get(resolvedTooltip).enabled || $.get(TooltipComponent)) return;
|
|
871
|
+
|
|
872
|
+
void import("./Tooltip.js").then((mod) => {
|
|
873
|
+
$.set(TooltipComponent, mod.default, true);
|
|
874
|
+
});
|
|
875
|
+
});
|
|
876
|
+
|
|
794
877
|
onDestroy(() => {
|
|
795
878
|
clearHoldTimers();
|
|
796
879
|
clearHoldSuppressResetTimer();
|
|
@@ -933,6 +1016,10 @@ export default function Button($$anchor, $$props) {
|
|
|
933
1016
|
onanimationend: handleAnimationEnd,
|
|
934
1017
|
get renderHints() {
|
|
935
1018
|
return $.get(buttonRenderHints);
|
|
1019
|
+
},
|
|
1020
|
+
|
|
1021
|
+
get componentParts() {
|
|
1022
|
+
return $.get(parts);
|
|
936
1023
|
}
|
|
937
1024
|
},
|
|
938
1025
|
() => $.get(toggleDefaults),
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { type ComponentProps, type Snippet } from "svelte";
|
|
2
2
|
import Button from "./Button.js";
|
|
3
|
+
import type Tooltip from "./Tooltip.js";
|
|
4
|
+
import type { TooltipProp } from "../logic/tooltip-prop";
|
|
3
5
|
import { type ComponentPartsOf } from "../logic/component-parts.js";
|
|
4
6
|
import { type OverflowActionIcon } from "../logic/overflow-actions.js";
|
|
5
7
|
type ButtonProps = ComponentProps<typeof Button>;
|
|
6
|
-
type ControlledButtonKeys = "children" | "as" | "iconOnly" | "disabled" | "href" | "onclick" | "aria-label" | "title";
|
|
8
|
+
type ControlledButtonKeys = "children" | "as" | "iconOnly" | "disabled" | "href" | "onclick" | "aria-label" | "title" | "tooltip" | "parts";
|
|
7
9
|
interface Props extends Omit<ButtonProps, ControlledButtonKeys> {
|
|
8
10
|
id: string;
|
|
9
11
|
label: string;
|
|
@@ -11,11 +13,14 @@ interface Props extends Omit<ButtonProps, ControlledButtonKeys> {
|
|
|
11
13
|
disabled?: boolean;
|
|
12
14
|
href?: string;
|
|
13
15
|
iconOnly?: boolean;
|
|
16
|
+
/** Tooltip toggle or config for the built-in Button and descendant Button controls; defaults to inherited or off. */
|
|
17
|
+
tooltip?: TooltipProp;
|
|
14
18
|
onclick?: (event?: MouseEvent) => void;
|
|
15
19
|
children?: Snippet;
|
|
16
20
|
control?: Snippet<[(event?: MouseEvent) => void, boolean]>;
|
|
17
21
|
parts?: ComponentPartsOf<{
|
|
18
22
|
Button: typeof Button;
|
|
23
|
+
Tooltip: typeof Tooltip;
|
|
19
24
|
}>;
|
|
20
25
|
as?: string;
|
|
21
26
|
[key: string]: any;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import 'svelte/internal/disclose-version';
|
|
2
2
|
import * as $ from 'svelte/internal/client';
|
|
3
|
-
import { onMount } from "svelte";
|
|
3
|
+
import { onMount, setContext } from "svelte";
|
|
4
4
|
import { ComponentIcon } from "../internal/component-icon/index.js";
|
|
5
5
|
import Frame from "./Frame.js";
|
|
6
6
|
import Button from "./Button.js";
|
|
7
7
|
import { mergeComponentPartProps } from "../logic/component-parts.js";
|
|
8
|
+
import ComponentPartsBoundary from "../logic/ComponentPartsBoundary.js";
|
|
9
|
+
import { getButtonTooltip } from "../context.js";
|
|
10
|
+
import { BUTTON_TOOLTIP_CONTEXT_KEY } from "../keys.js";
|
|
8
11
|
import { getOverflowActionsContext } from "../logic/overflow-actions.js";
|
|
9
12
|
|
|
10
13
|
var rest_excludes = new Set([
|
|
@@ -17,6 +20,7 @@ var rest_excludes = new Set([
|
|
|
17
20
|
'disabled',
|
|
18
21
|
'href',
|
|
19
22
|
'iconOnly',
|
|
23
|
+
'tooltip',
|
|
20
24
|
'onclick',
|
|
21
25
|
'children',
|
|
22
26
|
'control',
|
|
@@ -38,7 +42,11 @@ export default function OverflowAction($$anchor, $$props) {
|
|
|
38
42
|
$.push($$props, true);
|
|
39
43
|
$.append_styles($$anchor, $$css);
|
|
40
44
|
|
|
41
|
-
const
|
|
45
|
+
const /** Tooltip toggle or config for the built-in Button and descendant Button controls; defaults to inherited or off. */
|
|
46
|
+
// Universal SnowUI Context propagation: descendant Button hosts (including ColorSchemeButton,
|
|
47
|
+
// StyleButton, CopyButton, ExpandButton, SelectButton, or custom wrappers inside `control`)
|
|
48
|
+
// inherit tooltip defaults while explicit child props keep highest priority.
|
|
49
|
+
// Button 仍接收完整兼容 Props;透明测量外壳只同步公开 data-* 标记,
|
|
42
50
|
// 避免把 onclick / motion 等交互能力重复绑定到两层宿主。
|
|
43
51
|
renderIcon = ($$anchor) => {
|
|
44
52
|
var fragment = $.comment();
|
|
@@ -111,6 +119,7 @@ export default function OverflowAction($$anchor, $$props) {
|
|
|
111
119
|
disabled = $.prop($$props, 'disabled', 3, false),
|
|
112
120
|
href = $.prop($$props, 'href', 3, undefined),
|
|
113
121
|
iconOnly = $.prop($$props, 'iconOnly', 3, false),
|
|
122
|
+
tooltip = $.prop($$props, 'tooltip', 3, undefined),
|
|
114
123
|
onclick = $.prop($$props, 'onclick', 3, undefined),
|
|
115
124
|
children = $.prop($$props, 'children', 3, undefined),
|
|
116
125
|
control = $.prop($$props, 'control', 3, undefined),
|
|
@@ -119,13 +128,42 @@ export default function OverflowAction($$anchor, $$props) {
|
|
|
119
128
|
rest = $.rest_props($$props, rest_excludes);
|
|
120
129
|
|
|
121
130
|
const owner = getOverflowActionsContext();
|
|
131
|
+
const parentButtonTooltip = getButtonTooltip();
|
|
122
132
|
const resolvedButtonProps = $.derived(() => mergeComponentPartProps(mergeComponentPartProps(owner?.buttonProps, parts()?.Button ?? {}), rest));
|
|
133
|
+
const effectiveTooltip = $.derived(() => tooltip() ?? parts()?.Button?.tooltip ?? owner?.tooltip ?? owner?.buttonProps?.tooltip ?? parentButtonTooltip?.tooltip);
|
|
134
|
+
|
|
135
|
+
const resolvedFullButtonTooltip = $.derived(() => iconOnly()
|
|
136
|
+
? $.get(effectiveTooltip)
|
|
137
|
+
: typeof $.get(effectiveTooltip) === "boolean" ? false : $.get(effectiveTooltip));
|
|
138
|
+
|
|
139
|
+
const resolvedTooltipPart = $.derived(() => mergeComponentPartProps(mergeComponentPartProps(parentButtonTooltip?.tooltipPart, owner?.tooltipPart ?? {}), parts()?.Tooltip ?? {}));
|
|
140
|
+
|
|
141
|
+
const resolvedBuiltInParts = $.derived(() => parts()?.Button || Object.keys($.get(resolvedTooltipPart)).length > 0
|
|
142
|
+
? {
|
|
143
|
+
...parts()?.Button ? { Button: parts().Button } : {},
|
|
144
|
+
...Object.keys($.get(resolvedTooltipPart)).length > 0 ? { Tooltip: $.get(resolvedTooltipPart) } : {}
|
|
145
|
+
}
|
|
146
|
+
: undefined);
|
|
147
|
+
|
|
148
|
+
setContext(BUTTON_TOOLTIP_CONTEXT_KEY, {
|
|
149
|
+
get tooltip() {
|
|
150
|
+
return $.get(effectiveTooltip);
|
|
151
|
+
},
|
|
152
|
+
|
|
153
|
+
get tooltipPart() {
|
|
154
|
+
return Object.keys($.get(resolvedTooltipPart)).length > 0 ? $.get(resolvedTooltipPart) : undefined;
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
|
|
123
158
|
let rootElement = $.state(undefined);
|
|
124
159
|
let visualElement = $.state(undefined);
|
|
125
160
|
let fullMeasureElement = $.state(undefined);
|
|
126
161
|
let compactMeasureElement = $.state(undefined);
|
|
127
162
|
const mode = $.derived(() => owner?.getMode($$props.id) ?? "full");
|
|
128
163
|
const resolvedDisabled = $.derived(() => disabled() || owner?.disabled === true);
|
|
164
|
+
|
|
165
|
+
// Button 仍接收完整兼容 Props;透明测量外壳只同步公开 data-* 标记,
|
|
166
|
+
// 避免把 onclick / motion 等交互能力重复绑定到两层宿主。
|
|
129
167
|
const frameRestProps = $.derived(() => Object.fromEntries(Object.entries(rest).filter(([key]) => key.startsWith("data-"))));
|
|
130
168
|
|
|
131
169
|
function execute(event) {
|
|
@@ -226,7 +264,10 @@ export default function OverflowAction($$anchor, $$props) {
|
|
|
226
264
|
enableResponsive: false,
|
|
227
265
|
enableContext: false,
|
|
228
266
|
enableScaleObserver: false,
|
|
229
|
-
enableDefaultMotion: false
|
|
267
|
+
enableDefaultMotion: false,
|
|
268
|
+
get componentParts() {
|
|
269
|
+
return $.get(resolvedBuiltInParts);
|
|
270
|
+
}
|
|
230
271
|
},
|
|
231
272
|
() => $.get(frameRestProps),
|
|
232
273
|
{
|
|
@@ -246,11 +287,16 @@ export default function OverflowAction($$anchor, $$props) {
|
|
|
246
287
|
|
|
247
288
|
{
|
|
248
289
|
var consequent_4 = ($$anchor) => {
|
|
249
|
-
|
|
250
|
-
|
|
290
|
+
ComponentPartsBoundary($$anchor, {
|
|
291
|
+
children: ($$anchor, $$slotProps) => {
|
|
292
|
+
var fragment_10 = $.comment();
|
|
293
|
+
var node_6 = $.first_child(fragment_10);
|
|
251
294
|
|
|
252
|
-
|
|
253
|
-
|
|
295
|
+
$.snippet(node_6, control, () => execute, () => $.get(resolvedDisabled));
|
|
296
|
+
$.append($$anchor, fragment_10);
|
|
297
|
+
},
|
|
298
|
+
$$slots: { default: true }
|
|
299
|
+
});
|
|
254
300
|
};
|
|
255
301
|
|
|
256
302
|
var consequent_5 = ($$anchor) => {
|
|
@@ -260,8 +306,8 @@ export default function OverflowAction($$anchor, $$props) {
|
|
|
260
306
|
return $$props.label;
|
|
261
307
|
},
|
|
262
308
|
|
|
263
|
-
get
|
|
264
|
-
return
|
|
309
|
+
get tooltip() {
|
|
310
|
+
return $.get(effectiveTooltip);
|
|
265
311
|
},
|
|
266
312
|
|
|
267
313
|
get disabled() {
|
|
@@ -292,6 +338,10 @@ export default function OverflowAction($$anchor, $$props) {
|
|
|
292
338
|
return $.get($0);
|
|
293
339
|
},
|
|
294
340
|
|
|
341
|
+
get tooltip() {
|
|
342
|
+
return $.get(resolvedFullButtonTooltip);
|
|
343
|
+
},
|
|
344
|
+
|
|
295
345
|
get disabled() {
|
|
296
346
|
return $.get(resolvedDisabled);
|
|
297
347
|
},
|
|
@@ -335,6 +385,7 @@ export default function OverflowAction($$anchor, $$props) {
|
|
|
335
385
|
get 'aria-label'() {
|
|
336
386
|
return $.get($0);
|
|
337
387
|
},
|
|
388
|
+
tooltip: false,
|
|
338
389
|
tabindex: -1,
|
|
339
390
|
children: ($$anchor, $$slotProps) => {
|
|
340
391
|
renderFull($$anchor);
|
|
@@ -355,6 +406,7 @@ export default function OverflowAction($$anchor, $$props) {
|
|
|
355
406
|
|
|
356
407
|
Button(node_10, $.spread_props(() => $.get(resolvedButtonProps), {
|
|
357
408
|
iconOnly: true,
|
|
409
|
+
tooltip: false,
|
|
358
410
|
tabindex: -1,
|
|
359
411
|
get 'aria-label'() {
|
|
360
412
|
return $$props.label;
|
|
@@ -6,6 +6,8 @@ import Listbox from "./Listbox.js";
|
|
|
6
6
|
import MenuItem from "./MenuItem.js";
|
|
7
7
|
import Separator from "./Separator.js";
|
|
8
8
|
import OverflowAction from "./OverflowAction.js";
|
|
9
|
+
import type Tooltip from "./Tooltip.js";
|
|
10
|
+
import type { TooltipProp } from "../logic/tooltip-prop";
|
|
9
11
|
import { type OverflowActionIcon } from "../logic/overflow-actions.js";
|
|
10
12
|
import { type ComponentPartsOf } from "../logic/component-parts.js";
|
|
11
13
|
type ButtonProps = ComponentProps<typeof Button>;
|
|
@@ -20,6 +22,7 @@ export interface OverflowActionsActionItem {
|
|
|
20
22
|
href?: string;
|
|
21
23
|
target?: string;
|
|
22
24
|
rel?: string;
|
|
25
|
+
tooltip?: TooltipProp;
|
|
23
26
|
onAction?: () => void;
|
|
24
27
|
buttonProps?: GlobalButtonProps;
|
|
25
28
|
parts?: ComponentProps<typeof OverflowAction>["parts"];
|
|
@@ -41,6 +44,7 @@ type Parts = ComponentPartsOf<{
|
|
|
41
44
|
Listbox: typeof Listbox;
|
|
42
45
|
MenuItem: typeof MenuItem;
|
|
43
46
|
Separator: typeof Separator;
|
|
47
|
+
Tooltip: typeof Tooltip;
|
|
44
48
|
}>;
|
|
45
49
|
interface Props extends Omit<FrameProps, "children"> {
|
|
46
50
|
items?: OverflowActionsItem[];
|
|
@@ -52,6 +56,8 @@ interface Props extends Omit<FrameProps, "children"> {
|
|
|
52
56
|
moreLabel?: string;
|
|
53
57
|
align?: "start" | "end";
|
|
54
58
|
disabled?: boolean;
|
|
59
|
+
/** Default tooltip toggle for child OverflowAction items and the overflow More button; disabled by default. */
|
|
60
|
+
tooltip?: boolean;
|
|
55
61
|
buttonProps?: GlobalButtonProps;
|
|
56
62
|
children?: Snippet;
|
|
57
63
|
parts?: Parts;
|
|
@@ -64,6 +64,7 @@ var rest_excludes = new Set([
|
|
|
64
64
|
'moreLabel',
|
|
65
65
|
'align',
|
|
66
66
|
'disabled',
|
|
67
|
+
'tooltip',
|
|
67
68
|
'buttonProps',
|
|
68
69
|
'children',
|
|
69
70
|
'parts',
|
|
@@ -85,6 +86,7 @@ export default function OverflowActions($$anchor, $$props) {
|
|
|
85
86
|
$.push($$props, true);
|
|
86
87
|
$.append_styles($$anchor, $$css);
|
|
87
88
|
|
|
89
|
+
/** Default tooltip toggle for child OverflowAction items and the overflow More button; disabled by default. */
|
|
88
90
|
let items = $.prop($$props, 'items', 19, () => []),
|
|
89
91
|
compact = $.prop($$props, 'compact', 3, "auto"),
|
|
90
92
|
overflow = $.prop($$props, 'overflow', 3, undefined),
|
|
@@ -94,6 +96,7 @@ export default function OverflowActions($$anchor, $$props) {
|
|
|
94
96
|
moreLabel = $.prop($$props, 'moreLabel', 3, undefined),
|
|
95
97
|
align = $.prop($$props, 'align', 3, "end"),
|
|
96
98
|
disabled = $.prop($$props, 'disabled', 3, false),
|
|
99
|
+
tooltip = $.prop($$props, 'tooltip', 3, undefined),
|
|
97
100
|
buttonProps = $.prop($$props, 'buttonProps', 3, undefined),
|
|
98
101
|
children = $.prop($$props, 'children', 3, undefined),
|
|
99
102
|
parts = $.prop($$props, 'parts', 3, undefined),
|
|
@@ -168,11 +171,23 @@ export default function OverflowActions($$anchor, $$props) {
|
|
|
168
171
|
return disabled();
|
|
169
172
|
},
|
|
170
173
|
|
|
174
|
+
get tooltip() {
|
|
175
|
+
return tooltip();
|
|
176
|
+
},
|
|
177
|
+
|
|
171
178
|
get buttonProps() {
|
|
172
179
|
return $.get(resolvedButtonProps);
|
|
180
|
+
},
|
|
181
|
+
|
|
182
|
+
get tooltipPart() {
|
|
183
|
+
return parts()?.Tooltip;
|
|
173
184
|
}
|
|
174
185
|
};
|
|
175
186
|
|
|
187
|
+
const resolvedGroupTooltip = $.derived(() => tooltip() ?? (typeof buttonProps()?.tooltip === "boolean"
|
|
188
|
+
? buttonProps().tooltip
|
|
189
|
+
: Boolean(buttonProps()?.tooltip)));
|
|
190
|
+
|
|
176
191
|
setContext(OVERFLOW_ACTIONS_CONTEXT_KEY, context);
|
|
177
192
|
|
|
178
193
|
function runAction(id, source, originalEvent) {
|
|
@@ -592,6 +607,10 @@ export default function OverflowActions($$anchor, $$props) {
|
|
|
592
607
|
return $.get(item).rel;
|
|
593
608
|
},
|
|
594
609
|
|
|
610
|
+
get tooltip() {
|
|
611
|
+
return $.get(item).tooltip;
|
|
612
|
+
},
|
|
613
|
+
|
|
595
614
|
get onclick() {
|
|
596
615
|
return $.get(item).onAction;
|
|
597
616
|
}
|
|
@@ -626,7 +645,13 @@ export default function OverflowActions($$anchor, $$props) {
|
|
|
626
645
|
ComponentIcon($$anchor, { name: 'three-dots', 'aria-hidden': 'true' });
|
|
627
646
|
};
|
|
628
647
|
|
|
629
|
-
let $0 = $.derived(() => (
|
|
648
|
+
let $0 = $.derived(() => $.get(resolvedGroupTooltip) ? $.get(resolvedMoreLabel) : false);
|
|
649
|
+
|
|
650
|
+
let $1 = $.derived(() => ({
|
|
651
|
+
Listbox: parts()?.Listbox,
|
|
652
|
+
MenuItem: parts()?.MenuItem,
|
|
653
|
+
Tooltip: parts()?.Tooltip
|
|
654
|
+
}));
|
|
630
655
|
|
|
631
656
|
SelectButton(node_8, $.spread_props(() => $.get(resolvedMoreButtonProps), {
|
|
632
657
|
iconOnly: true,
|
|
@@ -636,8 +661,8 @@ export default function OverflowActions($$anchor, $$props) {
|
|
|
636
661
|
return $.get(resolvedMoreLabel);
|
|
637
662
|
},
|
|
638
663
|
|
|
639
|
-
get
|
|
640
|
-
return $.get(
|
|
664
|
+
get tooltip() {
|
|
665
|
+
return $.get($0);
|
|
641
666
|
},
|
|
642
667
|
|
|
643
668
|
get disabled() {
|
|
@@ -645,7 +670,7 @@ export default function OverflowActions($$anchor, $$props) {
|
|
|
645
670
|
},
|
|
646
671
|
onAction: handleMenuAction,
|
|
647
672
|
get parts() {
|
|
648
|
-
return $.get($
|
|
673
|
+
return $.get($1);
|
|
649
674
|
},
|
|
650
675
|
label,
|
|
651
676
|
children: ($$anchor, $$slotProps) => {
|
|
@@ -746,6 +771,7 @@ export default function OverflowActions($$anchor, $$props) {
|
|
|
746
771
|
get ariaLabel() {
|
|
747
772
|
return $.get(resolvedMoreLabel);
|
|
748
773
|
},
|
|
774
|
+
tooltip: false,
|
|
749
775
|
tabindex: -1,
|
|
750
776
|
get parts() {
|
|
751
777
|
return $.get($0);
|
|
@@ -4,6 +4,7 @@ import Button from "./Button.js";
|
|
|
4
4
|
import Input from "./Input.js";
|
|
5
5
|
import Listbox, { type ListboxItem } from "./Listbox.js";
|
|
6
6
|
import MenuItem from "./MenuItem.js";
|
|
7
|
+
import type Tooltip from "./Tooltip.js";
|
|
7
8
|
import { type ComponentPartsOf } from "../logic/component-parts.js";
|
|
8
9
|
export type SelectValue = string | number | undefined;
|
|
9
10
|
export type SelectOption = ListboxItem;
|
|
@@ -19,6 +20,7 @@ type SelectParts = ComponentPartsOf<{
|
|
|
19
20
|
Listbox: typeof Listbox;
|
|
20
21
|
Input: typeof Input;
|
|
21
22
|
MenuItem: typeof MenuItem;
|
|
23
|
+
Tooltip: typeof Tooltip;
|
|
22
24
|
}> & {
|
|
23
25
|
Button?: Omit<ComponentProps<typeof Button>, "children" | "onclick" | "onkeydown" | "disabled">;
|
|
24
26
|
};
|
|
@@ -4,6 +4,7 @@ import { type SelectOption, type SelectValue } from "./Select.js";
|
|
|
4
4
|
import Input from "./Input.js";
|
|
5
5
|
import Listbox from "./Listbox.js";
|
|
6
6
|
import MenuItem from "./MenuItem.js";
|
|
7
|
+
import type Tooltip from "./Tooltip.js";
|
|
7
8
|
import type { ComponentPartsOf } from "../logic/component-parts.js";
|
|
8
9
|
export interface SelectButtonLabelContext {
|
|
9
10
|
value: SelectValue;
|
|
@@ -39,6 +40,7 @@ interface Props extends Omit<ButtonProps, ControlledButtonKeys> {
|
|
|
39
40
|
Listbox: typeof Listbox;
|
|
40
41
|
Input: typeof Input;
|
|
41
42
|
MenuItem: typeof MenuItem;
|
|
43
|
+
Tooltip: typeof Tooltip;
|
|
42
44
|
}>;
|
|
43
45
|
onchange?: (event: Event) => void;
|
|
44
46
|
onAction?: (value: string) => void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Snippet } from "svelte";
|
|
2
2
|
import { type FrameProps } from "./Frame.js";
|
|
3
3
|
import Button from "./Button.js";
|
|
4
|
-
import
|
|
4
|
+
import type TooltipType from "./Tooltip.js";
|
|
5
5
|
import type { ComponentPartsOf } from "../logic/component-parts.js";
|
|
6
6
|
import type { StateValueMap } from "../logic/frame-types";
|
|
7
7
|
type TooltipProp = boolean | string | Snippet | Record<string, any>;
|
|
@@ -18,7 +18,7 @@ interface Props extends FrameProps {
|
|
|
18
18
|
children?: Snippet<[any]>;
|
|
19
19
|
parts?: ComponentPartsOf<{
|
|
20
20
|
Button: typeof Button;
|
|
21
|
-
Tooltip: typeof
|
|
21
|
+
Tooltip: typeof TooltipType;
|
|
22
22
|
}>;
|
|
23
23
|
[key: string]: any;
|
|
24
24
|
}
|