@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
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
} from "../motion/presets/effects.js";
|
|
13
13
|
|
|
14
14
|
import { mergeComponentPartProps, useComponentPart } from "../logic/component-parts.js";
|
|
15
|
+
import ComponentPartsBoundary from "../logic/ComponentPartsBoundary.js";
|
|
15
16
|
|
|
16
17
|
import {
|
|
17
18
|
getImage,
|
|
@@ -21,10 +22,12 @@ import {
|
|
|
21
22
|
getButtonGroup,
|
|
22
23
|
getButtonCollection,
|
|
23
24
|
getButtonSize,
|
|
25
|
+
getButtonTooltip,
|
|
24
26
|
getBreadcrumb
|
|
25
27
|
} from "../context.js";
|
|
26
28
|
|
|
27
29
|
import Spinner from "./Spinner.js";
|
|
30
|
+
import { resolveTooltipProp } from "../logic/tooltip-prop.js";
|
|
28
31
|
|
|
29
32
|
const $$css = {
|
|
30
33
|
hash: 'svelte-1klcfz0',
|
|
@@ -36,6 +39,8 @@ export default function Button($$renderer, $$props) {
|
|
|
36
39
|
|
|
37
40
|
$$renderer.component(($$renderer) => {
|
|
38
41
|
// Shared capability: Frame.singleLine; contract: docs/standards/LayoutProtocol.md §4.6.
|
|
42
|
+
let TooltipComponent = void 0;
|
|
43
|
+
|
|
39
44
|
/** 有 padding 的纯图标按钮,控制对称 padding 与图标大小;不根据 children 自动推断。 */
|
|
40
45
|
/** 无外壳按钮,以图标操作为主,也支持文字;无需叠加 iconOnly。 */
|
|
41
46
|
/** bare 模式的视觉强调级别;normal 默认始终 100%,muted 为 40% 并在 hover 时提升到 100%。 */
|
|
@@ -49,6 +54,8 @@ export default function Button($$renderer, $$props) {
|
|
|
49
54
|
* `aria-pressed` 也由 Frame 自动输出。
|
|
50
55
|
* 消费方可继续传 `Click` / `whileClick` 覆盖默认行为。
|
|
51
56
|
*/
|
|
57
|
+
/** Hover/focus tooltip toggle or config; disabled by default. When true, reuses the button's aria-label. */
|
|
58
|
+
/** Configure the built-in Tooltip rendered when `tooltip` is enabled. */
|
|
52
59
|
// 跨独立仓库源码检查时,Svelte 的 Snippet nominal symbol 可能来自不同物理安装。
|
|
53
60
|
// 此处只归一化传给 Frame 的类型身份,不改变 snippet 本身或运行时调用。
|
|
54
61
|
function normalizeFrameSnippet(snippet) {
|
|
@@ -56,6 +63,7 @@ export default function Button($$renderer, $$props) {
|
|
|
56
63
|
}
|
|
57
64
|
|
|
58
65
|
const inheritedButtonPart = useComponentPart("Button");
|
|
66
|
+
const inheritedTooltipPart = useComponentPart("Tooltip");
|
|
59
67
|
let { $$slots, $$events, ...explicitProps } = $$props;
|
|
60
68
|
|
|
61
69
|
let $$d = $.derived((// Pass everything else to Frame
|
|
@@ -77,6 +85,8 @@ export default function Button($$renderer, $$props) {
|
|
|
77
85
|
holdRepeat = $.derived(() => $.fallback($$d().holdRepeat, false)),
|
|
78
86
|
holdRepeatDelay = $.derived(() => $.fallback($$d().holdRepeatDelay, 260)),
|
|
79
87
|
holdRepeatInterval = $.derived(() => $.fallback($$d().holdRepeatInterval, 80)),
|
|
88
|
+
tooltip = $.derived(() => $.fallback($$d().tooltip, undefined)),
|
|
89
|
+
parts = $.derived(() => $.fallback($$d().parts, undefined)),
|
|
80
90
|
userOnClick = $.derived(() => $$d().onclick),
|
|
81
91
|
userOnPointerDown = $.derived(() => $$d().onpointerdown),
|
|
82
92
|
userOnPointerUp = $.derived(() => $$d().onpointerup),
|
|
@@ -107,6 +117,8 @@ export default function Button($$renderer, $$props) {
|
|
|
107
117
|
'holdRepeat',
|
|
108
118
|
'holdRepeatDelay',
|
|
109
119
|
'holdRepeatInterval',
|
|
120
|
+
'tooltip',
|
|
121
|
+
'parts',
|
|
110
122
|
'onclick',
|
|
111
123
|
'onpointerdown',
|
|
112
124
|
'onpointerup',
|
|
@@ -194,8 +206,8 @@ export default function Button($$renderer, $$props) {
|
|
|
194
206
|
let hasWarnedMissingIconOnlyName = false;
|
|
195
207
|
let backgroundWidthFactor = 1;
|
|
196
208
|
|
|
197
|
-
//
|
|
198
|
-
//
|
|
209
|
+
// Compute width factor lazily on first pointer/focus/click interaction instead of forcing
|
|
210
|
+
// synchronous getComputedStyle + ResizeObserver on every Button during initial page mount.
|
|
199
211
|
// 传递给 Frame Context 的尺寸(供 Icon/Avatar 等子组件继承)
|
|
200
212
|
const contextPixelSize = $.derived(() => {
|
|
201
213
|
if (bare() || iconOnly()) {
|
|
@@ -610,6 +622,15 @@ export default function Button($$renderer, $$props) {
|
|
|
610
622
|
clearHoldSuppressResetTimer();
|
|
611
623
|
}
|
|
612
624
|
|
|
625
|
+
const buttonTooltipCtx = getButtonTooltip();
|
|
626
|
+
const effectiveTooltipProp = $.derived(() => tooltip() ?? buttonTooltipCtx?.tooltip);
|
|
627
|
+
|
|
628
|
+
const resolvedTooltip = $.derived(() => resolveTooltipProp(effectiveTooltipProp(), typeof rest()["aria-label"] === "string"
|
|
629
|
+
? rest()["aria-label"]
|
|
630
|
+
: typeof rest().ariaLabel === "string" ? rest().ariaLabel : undefined));
|
|
631
|
+
|
|
632
|
+
const mergedTooltipConfig = $.derived(() => mergeComponentPartProps(mergeComponentPartProps(mergeComponentPartProps(buttonTooltipCtx?.tooltipPart, inheritedTooltipPart.current ?? {}), parts()?.Tooltip ?? {}), resolvedTooltip().config));
|
|
633
|
+
|
|
613
634
|
onDestroy(() => {
|
|
614
635
|
clearHoldTimers();
|
|
615
636
|
clearHoldSuppressResetTimer();
|
|
@@ -636,8 +657,13 @@ export default function Button($$renderer, $$props) {
|
|
|
636
657
|
},
|
|
637
658
|
|
|
638
659
|
children: ($$renderer) => {
|
|
639
|
-
|
|
640
|
-
|
|
660
|
+
ComponentPartsBoundary($$renderer, {
|
|
661
|
+
children: ($$renderer) => {
|
|
662
|
+
children()?.($$renderer);
|
|
663
|
+
$$renderer.push(`<!---->`);
|
|
664
|
+
},
|
|
665
|
+
$$slots: { default: true }
|
|
666
|
+
});
|
|
641
667
|
},
|
|
642
668
|
$$slots: { default: true }
|
|
643
669
|
});
|
|
@@ -653,6 +679,45 @@ export default function Button($$renderer, $$props) {
|
|
|
653
679
|
$$renderer.push('<!--[-1-->');
|
|
654
680
|
}
|
|
655
681
|
|
|
682
|
+
$$renderer.push(`<!--]--> `);
|
|
683
|
+
|
|
684
|
+
if (resolvedTooltip().enabled && TooltipComponent) {
|
|
685
|
+
$$renderer.push('<!--[0-->');
|
|
686
|
+
|
|
687
|
+
if (TooltipComponent) {
|
|
688
|
+
$$renderer.push('<!--[-->');
|
|
689
|
+
|
|
690
|
+
TooltipComponent($$renderer, $.spread_props([
|
|
691
|
+
{ as: 'tooltip' },
|
|
692
|
+
mergedTooltipConfig(),
|
|
693
|
+
{
|
|
694
|
+
children: ($$renderer) => {
|
|
695
|
+
if (typeof resolvedTooltip().content === "string") {
|
|
696
|
+
$$renderer.push('<!--[0-->');
|
|
697
|
+
$$renderer.push(`${$.escape(resolvedTooltip().content)}`);
|
|
698
|
+
} else if (typeof resolvedTooltip().content === "function") {
|
|
699
|
+
$$renderer.push('<!--[1-->');
|
|
700
|
+
resolvedTooltip().content($$renderer);
|
|
701
|
+
$$renderer.push(`<!---->`);
|
|
702
|
+
} else {
|
|
703
|
+
$$renderer.push('<!--[-1-->');
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
$$renderer.push(`<!--]-->`);
|
|
707
|
+
},
|
|
708
|
+
$$slots: { default: true }
|
|
709
|
+
}
|
|
710
|
+
]));
|
|
711
|
+
|
|
712
|
+
$$renderer.push('<!--]-->');
|
|
713
|
+
} else {
|
|
714
|
+
$$renderer.push('<!--[!-->');
|
|
715
|
+
$$renderer.push('<!--]-->');
|
|
716
|
+
}
|
|
717
|
+
} else {
|
|
718
|
+
$$renderer.push('<!--[-1-->');
|
|
719
|
+
}
|
|
720
|
+
|
|
656
721
|
$$renderer.push(`<!--]-->`);
|
|
657
722
|
}
|
|
658
723
|
|
|
@@ -715,7 +780,8 @@ export default function Button($$renderer, $$props) {
|
|
|
715
780
|
onpointerleave: handlePointerLeave,
|
|
716
781
|
onpointercancel: handlePointerCancel,
|
|
717
782
|
onanimationend: handleAnimationEnd,
|
|
718
|
-
renderHints: buttonRenderHints()
|
|
783
|
+
renderHints: buttonRenderHints(),
|
|
784
|
+
componentParts: parts()
|
|
719
785
|
},
|
|
720
786
|
toggleDefaults(),
|
|
721
787
|
clickProps(),
|
|
@@ -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,9 +1,12 @@
|
|
|
1
1
|
import * as $ from 'svelte/internal/server';
|
|
2
|
-
import { onMount } from "svelte";
|
|
2
|
+
import { onMount, setContext } from "svelte";
|
|
3
3
|
import { ComponentIcon } from "../internal/component-icon/index.js";
|
|
4
4
|
import Frame from "./Frame.js";
|
|
5
5
|
import Button from "./Button.js";
|
|
6
6
|
import { mergeComponentPartProps } from "../logic/component-parts.js";
|
|
7
|
+
import ComponentPartsBoundary from "../logic/ComponentPartsBoundary.js";
|
|
8
|
+
import { getButtonTooltip } from "../context.js";
|
|
9
|
+
import { BUTTON_TOOLTIP_CONTEXT_KEY } from "../keys.js";
|
|
7
10
|
import { getOverflowActionsContext } from "../logic/overflow-actions.js";
|
|
8
11
|
|
|
9
12
|
const $$css = {
|
|
@@ -15,6 +18,7 @@ export default function OverflowAction($$renderer, $$props) {
|
|
|
15
18
|
$$renderer.global.css.add($$css);
|
|
16
19
|
|
|
17
20
|
$$renderer.component(($$renderer) => {
|
|
21
|
+
/** Tooltip toggle or config for the built-in Button and descendant Button controls; defaults to inherited or off. */
|
|
18
22
|
let {
|
|
19
23
|
id,
|
|
20
24
|
label,
|
|
@@ -22,6 +26,7 @@ export default function OverflowAction($$renderer, $$props) {
|
|
|
22
26
|
disabled = false,
|
|
23
27
|
href = undefined,
|
|
24
28
|
iconOnly = false,
|
|
29
|
+
tooltip = undefined,
|
|
25
30
|
onclick = undefined,
|
|
26
31
|
children = undefined,
|
|
27
32
|
control = undefined,
|
|
@@ -33,7 +38,36 @@ export default function OverflowAction($$renderer, $$props) {
|
|
|
33
38
|
} = $$props;
|
|
34
39
|
|
|
35
40
|
const owner = getOverflowActionsContext();
|
|
41
|
+
const parentButtonTooltip = getButtonTooltip();
|
|
36
42
|
const resolvedButtonProps = $.derived(() => mergeComponentPartProps(mergeComponentPartProps(owner?.buttonProps, parts?.Button ?? {}), rest));
|
|
43
|
+
const effectiveTooltip = $.derived(() => tooltip ?? parts?.Button?.tooltip ?? owner?.tooltip ?? owner?.buttonProps?.tooltip ?? parentButtonTooltip?.tooltip);
|
|
44
|
+
|
|
45
|
+
const resolvedFullButtonTooltip = $.derived(() => iconOnly
|
|
46
|
+
? effectiveTooltip()
|
|
47
|
+
: typeof effectiveTooltip() === "boolean" ? false : effectiveTooltip());
|
|
48
|
+
|
|
49
|
+
const resolvedTooltipPart = $.derived(() => mergeComponentPartProps(mergeComponentPartProps(parentButtonTooltip?.tooltipPart, owner?.tooltipPart ?? {}), parts?.Tooltip ?? {}));
|
|
50
|
+
|
|
51
|
+
const resolvedBuiltInParts = $.derived(() => parts?.Button || Object.keys(resolvedTooltipPart()).length > 0
|
|
52
|
+
? {
|
|
53
|
+
...parts?.Button ? { Button: parts.Button } : {},
|
|
54
|
+
...Object.keys(resolvedTooltipPart()).length > 0 ? { Tooltip: resolvedTooltipPart() } : {}
|
|
55
|
+
}
|
|
56
|
+
: undefined);
|
|
57
|
+
|
|
58
|
+
// Universal SnowUI Context propagation: descendant Button hosts (including ColorSchemeButton,
|
|
59
|
+
// StyleButton, CopyButton, ExpandButton, SelectButton, or custom wrappers inside `control`)
|
|
60
|
+
// inherit tooltip defaults while explicit child props keep highest priority.
|
|
61
|
+
setContext(BUTTON_TOOLTIP_CONTEXT_KEY, {
|
|
62
|
+
get tooltip() {
|
|
63
|
+
return effectiveTooltip();
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
get tooltipPart() {
|
|
67
|
+
return Object.keys(resolvedTooltipPart()).length > 0 ? resolvedTooltipPart() : undefined;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
|
|
37
71
|
let rootElement = undefined;
|
|
38
72
|
let visualElement = undefined;
|
|
39
73
|
let fullMeasureElement = undefined;
|
|
@@ -157,7 +191,8 @@ export default function OverflowAction($$renderer, $$props) {
|
|
|
157
191
|
enableResponsive: false,
|
|
158
192
|
enableContext: false,
|
|
159
193
|
enableScaleObserver: false,
|
|
160
|
-
enableDefaultMotion: false
|
|
194
|
+
enableDefaultMotion: false,
|
|
195
|
+
componentParts: resolvedBuiltInParts()
|
|
161
196
|
},
|
|
162
197
|
frameRestProps(),
|
|
163
198
|
{
|
|
@@ -175,8 +210,14 @@ export default function OverflowAction($$renderer, $$props) {
|
|
|
175
210
|
|
|
176
211
|
if (control) {
|
|
177
212
|
$$renderer.push('<!--[0-->');
|
|
178
|
-
|
|
179
|
-
$$renderer
|
|
213
|
+
|
|
214
|
+
ComponentPartsBoundary($$renderer, {
|
|
215
|
+
children: ($$renderer) => {
|
|
216
|
+
control($$renderer, execute, resolvedDisabled());
|
|
217
|
+
$$renderer.push(`<!---->`);
|
|
218
|
+
},
|
|
219
|
+
$$slots: { default: true }
|
|
220
|
+
});
|
|
180
221
|
} else if (mode() === "compact") {
|
|
181
222
|
$$renderer.push('<!--[1-->');
|
|
182
223
|
|
|
@@ -185,7 +226,7 @@ export default function OverflowAction($$renderer, $$props) {
|
|
|
185
226
|
{
|
|
186
227
|
iconOnly: true,
|
|
187
228
|
'aria-label': label,
|
|
188
|
-
|
|
229
|
+
tooltip: effectiveTooltip(),
|
|
189
230
|
disabled: resolvedDisabled(),
|
|
190
231
|
href,
|
|
191
232
|
onclick: execute,
|
|
@@ -203,6 +244,7 @@ export default function OverflowAction($$renderer, $$props) {
|
|
|
203
244
|
{
|
|
204
245
|
iconOnly,
|
|
205
246
|
'aria-label': iconOnly ? label : undefined,
|
|
247
|
+
tooltip: resolvedFullButtonTooltip(),
|
|
206
248
|
disabled: resolvedDisabled(),
|
|
207
249
|
href,
|
|
208
250
|
onclick: execute,
|
|
@@ -225,6 +267,7 @@ export default function OverflowAction($$renderer, $$props) {
|
|
|
225
267
|
{
|
|
226
268
|
iconOnly,
|
|
227
269
|
'aria-label': iconOnly ? label : undefined,
|
|
270
|
+
tooltip: false,
|
|
228
271
|
tabindex: -1,
|
|
229
272
|
children: ($$renderer) => {
|
|
230
273
|
renderFull($$renderer);
|
|
@@ -243,6 +286,7 @@ export default function OverflowAction($$renderer, $$props) {
|
|
|
243
286
|
resolvedButtonProps(),
|
|
244
287
|
{
|
|
245
288
|
iconOnly: true,
|
|
289
|
+
tooltip: false,
|
|
246
290
|
tabindex: -1,
|
|
247
291
|
'aria-label': label,
|
|
248
292
|
children: ($$renderer) => {
|
|
@@ -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;
|
|
@@ -44,6 +44,7 @@ export default function OverflowActions($$renderer, $$props) {
|
|
|
44
44
|
$$renderer.global.css.add($$css);
|
|
45
45
|
|
|
46
46
|
$$renderer.component(($$renderer) => {
|
|
47
|
+
/** Default tooltip toggle for child OverflowAction items and the overflow More button; disabled by default. */
|
|
47
48
|
let {
|
|
48
49
|
items = [],
|
|
49
50
|
compact = "auto",
|
|
@@ -54,6 +55,7 @@ export default function OverflowActions($$renderer, $$props) {
|
|
|
54
55
|
moreLabel = undefined,
|
|
55
56
|
align = "end",
|
|
56
57
|
disabled = false,
|
|
58
|
+
tooltip = undefined,
|
|
57
59
|
buttonProps = undefined,
|
|
58
60
|
children = undefined,
|
|
59
61
|
parts = undefined,
|
|
@@ -131,11 +133,21 @@ export default function OverflowActions($$renderer, $$props) {
|
|
|
131
133
|
return disabled;
|
|
132
134
|
},
|
|
133
135
|
|
|
136
|
+
get tooltip() {
|
|
137
|
+
return tooltip;
|
|
138
|
+
},
|
|
139
|
+
|
|
134
140
|
get buttonProps() {
|
|
135
141
|
return resolvedButtonProps();
|
|
142
|
+
},
|
|
143
|
+
|
|
144
|
+
get tooltipPart() {
|
|
145
|
+
return parts?.Tooltip;
|
|
136
146
|
}
|
|
137
147
|
};
|
|
138
148
|
|
|
149
|
+
const resolvedGroupTooltip = $.derived(() => tooltip ?? (typeof buttonProps?.tooltip === "boolean" ? buttonProps.tooltip : Boolean(buttonProps?.tooltip)));
|
|
150
|
+
|
|
139
151
|
setContext(OVERFLOW_ACTIONS_CONTEXT_KEY, context);
|
|
140
152
|
|
|
141
153
|
function runAction(id, source, originalEvent) {
|
|
@@ -489,6 +501,7 @@ export default function OverflowActions($$renderer, $$props) {
|
|
|
489
501
|
href: item.href,
|
|
490
502
|
target: item.target,
|
|
491
503
|
rel: item.rel,
|
|
504
|
+
tooltip: item.tooltip,
|
|
492
505
|
onclick: item.onAction
|
|
493
506
|
}
|
|
494
507
|
]));
|
|
@@ -518,10 +531,14 @@ export default function OverflowActions($$renderer, $$props) {
|
|
|
518
531
|
showIndicator: false,
|
|
519
532
|
selectionMode: 'action',
|
|
520
533
|
ariaLabel: resolvedMoreLabel(),
|
|
521
|
-
|
|
534
|
+
tooltip: resolvedGroupTooltip() ? resolvedMoreLabel() : false,
|
|
522
535
|
disabled,
|
|
523
536
|
onAction: handleMenuAction,
|
|
524
|
-
parts: {
|
|
537
|
+
parts: {
|
|
538
|
+
Listbox: parts?.Listbox,
|
|
539
|
+
MenuItem: parts?.MenuItem,
|
|
540
|
+
Tooltip: parts?.Tooltip
|
|
541
|
+
},
|
|
525
542
|
label,
|
|
526
543
|
children: ($$renderer) => {
|
|
527
544
|
Listbox($$renderer, {
|
|
@@ -586,6 +603,7 @@ export default function OverflowActions($$renderer, $$props) {
|
|
|
586
603
|
showIndicator: false,
|
|
587
604
|
selectionMode: 'action',
|
|
588
605
|
ariaLabel: resolvedMoreLabel(),
|
|
606
|
+
tooltip: false,
|
|
589
607
|
tabindex: -1,
|
|
590
608
|
parts: { Listbox: parts?.Listbox, MenuItem: parts?.MenuItem },
|
|
591
609
|
label,
|
|
@@ -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
|
}
|
|
@@ -2,7 +2,6 @@ import * as $ from 'svelte/internal/server';
|
|
|
2
2
|
import { getContext, setContext } from "svelte";
|
|
3
3
|
import Frame from "./Frame.js";
|
|
4
4
|
import Button from "./Button.js";
|
|
5
|
-
import Tooltip from "./Tooltip.js";
|
|
6
5
|
import { ComponentIcon } from "../internal/component-icon/index.js";
|
|
7
6
|
import ComponentPartsBoundary from "../logic/ComponentPartsBoundary.js";
|
|
8
7
|
import { fitTextToElement } from "../lib/truncate.js";
|
|
@@ -29,6 +28,7 @@ export default function Text($$renderer, $$props) {
|
|
|
29
28
|
$$renderer.global.css.add($$css);
|
|
30
29
|
|
|
31
30
|
$$renderer.component(($$renderer) => {
|
|
31
|
+
let TooltipComponent = void 0;
|
|
32
32
|
const localeContext = useLocale();
|
|
33
33
|
|
|
34
34
|
const isTooltipConfigObject = (value) => {
|
|
@@ -576,29 +576,38 @@ export default function Text($$renderer, $$props) {
|
|
|
576
576
|
|
|
577
577
|
$$renderer.push(`<!--]--> `);
|
|
578
578
|
|
|
579
|
-
if (needTooltip()) {
|
|
579
|
+
if (needTooltip() && TooltipComponent) {
|
|
580
580
|
$$renderer.push('<!--[0-->');
|
|
581
581
|
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
582
|
+
if (TooltipComponent) {
|
|
583
|
+
$$renderer.push('<!--[-->');
|
|
584
|
+
|
|
585
|
+
TooltipComponent($$renderer, $.spread_props([
|
|
586
|
+
tooltipConfig(),
|
|
587
|
+
{
|
|
588
|
+
children: ($$renderer) => {
|
|
589
|
+
if (typeof tooltipContent() === "string") {
|
|
590
|
+
$$renderer.push('<!--[0-->');
|
|
591
|
+
$$renderer.push(`${$.escape(tooltipContent())}`);
|
|
592
|
+
} else if (typeof tooltipContent() === "function") {
|
|
593
|
+
$$renderer.push('<!--[1-->');
|
|
594
|
+
tooltipContent()($$renderer);
|
|
595
|
+
$$renderer.push(`<!---->`);
|
|
596
|
+
} else {
|
|
597
|
+
$$renderer.push('<!--[-1-->');
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
$$renderer.push(`<!--]-->`);
|
|
601
|
+
},
|
|
602
|
+
$$slots: { default: true }
|
|
603
|
+
}
|
|
604
|
+
]));
|
|
605
|
+
|
|
606
|
+
$$renderer.push('<!--]-->');
|
|
607
|
+
} else {
|
|
608
|
+
$$renderer.push('<!--[!-->');
|
|
609
|
+
$$renderer.push('<!--]-->');
|
|
610
|
+
}
|
|
602
611
|
} else {
|
|
603
612
|
$$renderer.push('<!--[-1-->');
|
|
604
613
|
}
|
package/dist/server/context.d.ts
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
import { type Component } from "svelte";
|
|
14
14
|
import type { PreviewMode } from "./logic/image-preview";
|
|
15
15
|
import type { NumberFormatOptions } from "./lib/number-format";
|
|
16
|
+
import type { TooltipProp } from "./logic/tooltip-prop";
|
|
16
17
|
export * from "./keys";
|
|
17
18
|
import { LISTBOX_HEADER_PORTAL_KEY } from "./keys";
|
|
18
19
|
export type InteractionState = "idle" | "loading" | "active" | "disabled" | "hovered" | "pressed" | "focused";
|
|
@@ -160,6 +161,13 @@ export interface ButtonSizeContext {
|
|
|
160
161
|
readonly scaleOnHover?: boolean;
|
|
161
162
|
}
|
|
162
163
|
export declare function getButtonSize(): ButtonSizeContext | undefined;
|
|
164
|
+
export interface ButtonTooltipContext {
|
|
165
|
+
/** Default tooltip toggle or config inherited by descendant Button hosts unless overridden explicitly. */
|
|
166
|
+
readonly tooltip?: TooltipProp;
|
|
167
|
+
/** Default Tooltip part props inherited by descendant Button built-in Tooltips unless overridden explicitly. */
|
|
168
|
+
readonly tooltipPart?: Record<string, any>;
|
|
169
|
+
}
|
|
170
|
+
export declare function getButtonTooltip(): ButtonTooltipContext | undefined;
|
|
163
171
|
export type BreadcrumbVariant = "gray" | "filled" | "outline" | "borderless";
|
|
164
172
|
export interface BreadcrumbContext {
|
|
165
173
|
present: true;
|
package/dist/server/context.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import { getContext } from "svelte";
|
|
14
14
|
export * from "./keys.js";
|
|
15
|
-
import { INTERACTION_CONTEXT_KEY, MORPH_CONTEXT_KEY, SKELETON_CONTEXT_KEY, LAYOUT_CONTEXT_KEY, SCROLL_CONTEXT_KEY, TEXT_CONTEXT_KEY, ICON_CONTEXT_KEY, AVATAR_CONTEXT_KEY, IMAGE_CONTEXT_KEY, IMAGE_GROUP_CONTEXT_KEY, IMAGE_VIEWER_CONTEXT_KEY, MOTION_ORCHESTRATOR_CONTEXT_KEY, TRUNCATION_CONTEXT_KEY, SIZE_CONTEXT_KEY, FIELD_CONTEXT_KEY, BUTTON_GROUP_CONTEXT_KEY, BUTTON_COLLECTION_CONTEXT_KEY, BUTTON_SIZE_CONTEXT_KEY, BREADCRUMB_CONTEXT_KEY, ACCORDION_CONTEXT_KEY, LISTBOX_OWNER_CONTEXT_KEY, LISTBOX_HEADER_PORTAL_KEY, NUMBER_FORMAT_CONTEXT_KEY, } from "./keys.js";
|
|
15
|
+
import { INTERACTION_CONTEXT_KEY, MORPH_CONTEXT_KEY, SKELETON_CONTEXT_KEY, LAYOUT_CONTEXT_KEY, SCROLL_CONTEXT_KEY, TEXT_CONTEXT_KEY, ICON_CONTEXT_KEY, AVATAR_CONTEXT_KEY, IMAGE_CONTEXT_KEY, IMAGE_GROUP_CONTEXT_KEY, IMAGE_VIEWER_CONTEXT_KEY, MOTION_ORCHESTRATOR_CONTEXT_KEY, TRUNCATION_CONTEXT_KEY, SIZE_CONTEXT_KEY, FIELD_CONTEXT_KEY, BUTTON_GROUP_CONTEXT_KEY, BUTTON_COLLECTION_CONTEXT_KEY, BUTTON_SIZE_CONTEXT_KEY, BUTTON_TOOLTIP_CONTEXT_KEY, BREADCRUMB_CONTEXT_KEY, ACCORDION_CONTEXT_KEY, LISTBOX_OWNER_CONTEXT_KEY, LISTBOX_HEADER_PORTAL_KEY, NUMBER_FORMAT_CONTEXT_KEY, } from "./keys.js";
|
|
16
16
|
// --- Helper Functions ---
|
|
17
17
|
// 封装 getContext 调用,提供更语义化的 API
|
|
18
18
|
export function getInteraction() {
|
|
@@ -84,6 +84,9 @@ export function getButtonCollection() {
|
|
|
84
84
|
export function getButtonSize() {
|
|
85
85
|
return getContext(BUTTON_SIZE_CONTEXT_KEY);
|
|
86
86
|
}
|
|
87
|
+
export function getButtonTooltip() {
|
|
88
|
+
return getContext(BUTTON_TOOLTIP_CONTEXT_KEY);
|
|
89
|
+
}
|
|
87
90
|
export function getBreadcrumb() {
|
|
88
91
|
return getContext(BREADCRUMB_CONTEXT_KEY);
|
|
89
92
|
}
|
package/dist/server/index.d.ts
CHANGED
|
@@ -54,6 +54,7 @@ export { default as IconProvider } from "./components/IconProvider.js";
|
|
|
54
54
|
export { createComponentIconResolver, type ComponentIconComponent, type ComponentIconMap, type ComponentIconRenderProps, type ComponentIconRequest, type ComponentIconResolver, type ComponentIconWeight, } from "./logic/component-icon";
|
|
55
55
|
export { default as Text } from './components/Text.js';
|
|
56
56
|
export { default as Tooltip } from "./components/Tooltip.js";
|
|
57
|
+
export type { TooltipProp } from "./logic/tooltip-prop";
|
|
57
58
|
export { default as Badge } from "./components/Badge.js";
|
|
58
59
|
export { default as Chip } from "./components/Chip.js";
|
|
59
60
|
export { default as Link } from "./components/Link.js";
|
package/dist/server/keys.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export declare const FIELD_CONTEXT_KEY: unique symbol;
|
|
|
21
21
|
export declare const BUTTON_GROUP_CONTEXT_KEY: unique symbol;
|
|
22
22
|
export declare const BUTTON_COLLECTION_CONTEXT_KEY: unique symbol;
|
|
23
23
|
export declare const BUTTON_SIZE_CONTEXT_KEY: unique symbol;
|
|
24
|
+
export declare const BUTTON_TOOLTIP_CONTEXT_KEY: unique symbol;
|
|
24
25
|
export declare const BREADCRUMB_CONTEXT_KEY: unique symbol;
|
|
25
26
|
export declare const ACCORDION_CONTEXT_KEY: unique symbol;
|
|
26
27
|
export declare const LISTBOX_OWNER_CONTEXT_KEY: unique symbol;
|
package/dist/server/keys.js
CHANGED
|
@@ -22,6 +22,7 @@ export const FIELD_CONTEXT_KEY = Symbol("FIELD_CONTEXT");
|
|
|
22
22
|
export const BUTTON_GROUP_CONTEXT_KEY = Symbol("BUTTON_GROUP_CONTEXT");
|
|
23
23
|
export const BUTTON_COLLECTION_CONTEXT_KEY = Symbol("BUTTON_COLLECTION_CONTEXT");
|
|
24
24
|
export const BUTTON_SIZE_CONTEXT_KEY = Symbol("BUTTON_SIZE_CONTEXT");
|
|
25
|
+
export const BUTTON_TOOLTIP_CONTEXT_KEY = Symbol("BUTTON_TOOLTIP_CONTEXT");
|
|
25
26
|
export const BREADCRUMB_CONTEXT_KEY = Symbol("BREADCRUMB_CONTEXT");
|
|
26
27
|
export const ACCORDION_CONTEXT_KEY = Symbol("ACCORDION_CONTEXT");
|
|
27
28
|
export const LISTBOX_OWNER_CONTEXT_KEY = Symbol("LISTBOX_OWNER_CONTEXT");
|
|
@@ -30,29 +30,29 @@ export declare function createFrameDomRuntime(options: FrameDomRuntimeOptions):
|
|
|
30
30
|
};
|
|
31
31
|
readonly nativeHandlers: {
|
|
32
32
|
onclick: (e: any) => void;
|
|
33
|
-
ondblclick: (e: any) => void;
|
|
34
|
-
oncontextmenu: (e: any) => void;
|
|
33
|
+
ondblclick: ((e: any) => void) | undefined;
|
|
34
|
+
oncontextmenu: ((e: any) => void) | undefined;
|
|
35
35
|
onmouseenter: (e: any) => void;
|
|
36
36
|
onmouseleave: (e: any) => void;
|
|
37
|
-
onmousemove: (e: any) => void;
|
|
37
|
+
onmousemove: ((e: any) => void) | undefined;
|
|
38
38
|
onmousedown: (e: any) => void;
|
|
39
39
|
onmouseup: (e: any) => void;
|
|
40
|
-
ontouchstart: (e: any) => void;
|
|
41
|
-
ontouchend: (e: any) => void;
|
|
42
|
-
ontouchmove: (e: any) => void;
|
|
43
|
-
ontouchcancel: (e: any) => void;
|
|
40
|
+
ontouchstart: ((e: any) => void) | undefined;
|
|
41
|
+
ontouchend: ((e: any) => void) | undefined;
|
|
42
|
+
ontouchmove: ((e: any) => void) | undefined;
|
|
43
|
+
ontouchcancel: ((e: any) => void) | undefined;
|
|
44
44
|
onfocus: (e: any) => void;
|
|
45
45
|
onblur: (e: any) => void;
|
|
46
46
|
onkeydown: (e: any) => void;
|
|
47
47
|
onkeyup: (e: any) => void;
|
|
48
|
-
onkeypress: (e: any) => void;
|
|
49
|
-
oninput: (e: any) => void;
|
|
50
|
-
onchange: (e: any) => void;
|
|
51
|
-
onsubmit: (e: any) => void;
|
|
52
|
-
onscroll: (e: any) => void;
|
|
53
|
-
ondragstart: (e: DragEvent) => void;
|
|
54
|
-
ondrag: (
|
|
55
|
-
ondragend: (_e: DragEvent) => void;
|
|
48
|
+
onkeypress: ((e: any) => void) | undefined;
|
|
49
|
+
oninput: ((e: any) => void) | undefined;
|
|
50
|
+
onchange: ((e: any) => void) | undefined;
|
|
51
|
+
onsubmit: ((e: any) => void) | undefined;
|
|
52
|
+
onscroll: ((e: any) => void) | undefined;
|
|
53
|
+
ondragstart: ((e: DragEvent) => void) | undefined;
|
|
54
|
+
ondrag: ((e: any) => void) | undefined;
|
|
55
|
+
ondragend: ((_e: DragEvent) => void) | undefined;
|
|
56
56
|
};
|
|
57
57
|
readonly dataAttrs: {
|
|
58
58
|
"data-orchestrate-mode": "sequential" | "random" | "parallel" | undefined;
|