@snowui-design-system/components 1.1.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/client/components/Avatar.d.ts +1 -1
  2. package/dist/client/components/Avatar.js +32 -16
  3. package/dist/client/components/Button.d.ts +9 -0
  4. package/dist/client/components/Button.js +133 -18
  5. package/dist/client/components/Gradient.d.ts +2 -3
  6. package/dist/client/components/Gradient.js +10 -36
  7. package/dist/client/components/OverflowAction.d.ts +6 -1
  8. package/dist/client/components/OverflowAction.js +67 -12
  9. package/dist/client/components/OverflowActions.d.ts +12 -6
  10. package/dist/client/components/OverflowActions.js +303 -125
  11. package/dist/client/components/Select.d.ts +2 -0
  12. package/dist/client/components/SelectButton.d.ts +2 -0
  13. package/dist/client/components/SidePanel.js +3 -1
  14. package/dist/client/components/Skeleton.d.ts +2 -22
  15. package/dist/client/components/Skeleton.js +63 -391
  16. package/dist/client/components/Text.d.ts +1 -1
  17. package/dist/client/components/Text.js +46 -31
  18. package/dist/client/context.d.ts +8 -0
  19. package/dist/client/context.js +4 -1
  20. package/dist/client/index.d.ts +1 -0
  21. package/dist/client/keys.d.ts +1 -0
  22. package/dist/client/keys.js +1 -0
  23. package/dist/client/logic/frame-dom-runtime.d.ts +15 -15
  24. package/dist/client/logic/frame-dom-runtime.js +70 -30
  25. package/dist/client/logic/frame-responsive.js +72 -13
  26. package/dist/client/logic/gradient-static.d.ts +6 -0
  27. package/dist/client/logic/gradient-static.js +38 -0
  28. package/dist/client/logic/overflow-actions.d.ts +2 -0
  29. package/dist/client/logic/skeleton-layouts.d.ts +25 -0
  30. package/dist/client/logic/skeleton-layouts.js +240 -0
  31. package/dist/client/logic/tooltip-prop.d.ts +13 -0
  32. package/dist/client/logic/tooltip-prop.js +29 -0
  33. package/dist/server/components/Avatar.d.ts +1 -1
  34. package/dist/server/components/Avatar.js +13 -8
  35. package/dist/server/components/Button.d.ts +9 -0
  36. package/dist/server/components/Button.js +82 -5
  37. package/dist/server/components/Gradient.d.ts +2 -3
  38. package/dist/server/components/Gradient.js +9 -36
  39. package/dist/server/components/OverflowAction.d.ts +6 -1
  40. package/dist/server/components/OverflowAction.js +55 -8
  41. package/dist/server/components/OverflowActions.d.ts +12 -6
  42. package/dist/server/components/OverflowActions.js +180 -65
  43. package/dist/server/components/Select.d.ts +2 -0
  44. package/dist/server/components/SelectButton.d.ts +2 -0
  45. package/dist/server/components/SidePanel.js +3 -1
  46. package/dist/server/components/Skeleton.d.ts +2 -22
  47. package/dist/server/components/Skeleton.js +35 -378
  48. package/dist/server/components/Text.d.ts +1 -1
  49. package/dist/server/components/Text.js +31 -22
  50. package/dist/server/context.d.ts +8 -0
  51. package/dist/server/context.js +4 -1
  52. package/dist/server/index.d.ts +1 -0
  53. package/dist/server/keys.d.ts +1 -0
  54. package/dist/server/keys.js +1 -0
  55. package/dist/server/logic/frame-dom-runtime.d.ts +15 -15
  56. package/dist/server/logic/frame-dom-runtime.js +70 -30
  57. package/dist/server/logic/frame-responsive.js +72 -13
  58. package/dist/server/logic/gradient-static.d.ts +6 -0
  59. package/dist/server/logic/gradient-static.js +38 -0
  60. package/dist/server/logic/overflow-actions.d.ts +2 -0
  61. package/dist/server/logic/skeleton-layouts.d.ts +25 -0
  62. package/dist/server/logic/skeleton-layouts.js +240 -0
  63. package/dist/server/logic/tooltip-prop.d.ts +13 -0
  64. package/dist/server/logic/tooltip-prop.js +29 -0
  65. package/package.json +1 -1
@@ -1,357 +1,8 @@
1
1
  import * as $ from 'svelte/internal/server';
2
2
  import { ResponsiveController } from "../logic/responsive.js";
3
+ import { EMPTY_SKELETON_LAYOUT, resolveSkeletonLayout, toCssLength } from "../logic/skeleton-layouts.js";
3
4
 
4
- const COMPONENT_CLASS_MAPPING = [
5
- [/\bsnowui-accordion-item\b/, "accordion-item"],
6
- [/\bsnowui-accordion\b/, "accordion"],
7
- [/\bsnowui-field\b/, "field"],
8
- [/\bsnowui-search-input\b/, "search-input"],
9
- [/\bsnowui-search-box\b/, "search-box"],
10
- [/\bsnowui-search-popup\b/, "search-popup"],
11
- [/\bsnowui-input\b/, "input"],
12
- [/\bsnowui-textarea\b/, "textarea"],
13
- [/\bsnowui-select\b/, "select"],
14
- [/\bsnowui-listbox\b/, "listbox"],
15
- [/\bsnowui-image-viewer\b/, "image-viewer"],
16
- [/\bsnowui-image-group\b/, "image-group"],
17
- [/\bsnowui-image\b/, "image"],
18
- [/\bsnowui-gradient\b/, "gradient"],
19
- [/\bsnowui-snow-ui-logo\b/, "snow-uilogo"],
20
- [/\bsnowui-avatar-group\b/, "avatar-group"],
21
- [/\bsnowui-avatar\b/, "avatar"],
22
- [/\bsnowui-flow-text\b/, "flow-text"],
23
- [/\bsnowui-circular-chart\b/, "circular-chart"],
24
- [/\bsnowui-gauge-chart\b/, "gauge-chart"],
25
- [/\bsnowui-chart-group\b/, "chart-group"],
26
- [/\bsnowui-line-chart\b/, "line-chart"],
27
- [/\bsnowui-bar-chart\b/, "bar-chart"],
28
- [/\bsnowui-button-group\b/, "button-group"],
29
- [/\bsnowui-breadcrumb\b/, "breadcrumb"],
30
- [/\bsnowui-card\b/, "card"],
31
- [/\bsnowui-scroll-area\b/, "scroll-area"],
32
- [/\bsnowui-pagination\b/, "pagination"],
33
- [/\bsnowui-progress\b/, "progress"],
34
- [/\bsnowui-separator\b/, "separator"],
35
- [/\bsnowui-button\b/, "button"],
36
- [/\bsnowui-text\b/, "text"],
37
- [/\bsnowui-badge\b/, "badge"],
38
- [/\bsnowui-chip\b/, "chip"],
39
- [/\bsnowui-link\b/, "link"],
40
- [/\bsnowui-tag\b/, "tag"],
41
- [/\bsnowui-copy-link\b/, "copy-link"],
42
- [/\bsnowui-code-block\b/, "code-block"],
43
- [/\bsnowui-kbd\b/, "kbd"],
44
- [/\bsnowui-switch\b/, "switch"],
45
- [/\bsnowui-spinner\b/, "spinner"],
46
- [/\bsnowui-radio\b/, "radio"],
47
- [/\bsnowui-icon\b/, "icon"],
48
- [/\bsnowui-checkbox\b/, "checkbox"],
49
- [/\bsnowui-tooltip\b/, "tooltip"],
50
- [/\bsnowui-popover\b/, "popover"],
51
- [/\bsnowui-dialog\b/, "dialog"],
52
- [/\bsnowui-menu-item\b/, "menu-item"],
53
- [/\bsnowui-quick-action\b/, "quick-action"],
54
- [/\bsnowui-toast\b/, "toast"],
55
- [/\bsnowui-segmented\b/, "segmented"],
56
- [/\bsnowui-tab\b/, "tab"],
57
- [/\bsnowui-frame\b/, "frame"],
58
- [/\bsnowui-test\b/, "test"]
59
- ];
60
-
61
- function toCssLength(value) {
62
- if (value === undefined || value === null || value === "") {
63
- return undefined;
64
- }
65
-
66
- if (typeof value === "number") {
67
- return `${value / 16}rem`;
68
- }
69
-
70
- return value;
71
- }
72
-
73
- function fit(length) {
74
- return length; // min(100%, length) 会导致在 flex/auto 容器中宽度收缩为 0。改在 CSS 中加 max-width兜底
75
- }
76
-
77
- function normalizeVariant(variant) {
78
- if (variant === "text") return "line";
79
- if (variant === "circular") return "circle";
80
- if (variant === "rectangular") return "rect";
81
-
82
- return variant ?? "rect";
83
- }
84
-
85
- export function getSkeletonComponentKey(componentClass) {
86
- if (!componentClass) return undefined;
87
-
88
- for (const [pattern, key] of COMPONENT_CLASS_MAPPING) {
89
- if (pattern.test(componentClass)) {
90
- return key;
91
- }
92
- }
93
-
94
- return undefined;
95
- }
96
-
97
- function createSingleLayout(key, shape, width, height, radius) {
98
- return { key, known: true, items: [{ shape, width, height, radius }] };
99
- }
100
-
101
- function createTextLayout(key, rows, width, height, radius) {
102
- const safeRows = Math.max(1, Math.floor(rows));
103
- const fullWidth = width ?? "100%";
104
-
105
- return {
106
- key,
107
- known: true,
108
- items: Array.from({ length: safeRows }, (_, index) => ({
109
- shape: "line",
110
- width: safeRows > 1 && index === safeRows - 1 ? "30%" : fullWidth,
111
- height,
112
- radius
113
- }))
114
- };
115
- }
116
-
117
- function applyRenderHints(layout, hints, explicit) {
118
- const variant = explicit?.variant ?? hints?.variant;
119
- const width = toCssLength(explicit?.width ?? hints?.width);
120
- const height = toCssLength(explicit?.height ?? hints?.height);
121
- const radius = toCssLength(hints?.radius);
122
- const rows = hints?.rows;
123
-
124
- if (!variant && !width && !height && !radius && rows === undefined) {
125
- return layout;
126
- }
127
-
128
- return {
129
- ...layout,
130
- items: rows !== undefined && rows > 1
131
- ? createTextLayout(layout.key, rows, width ?? layout.items[0]?.width, height ?? layout.items[0]?.height, radius ?? layout.items[0]?.radius).items
132
- : layout.items.map((item) => ({
133
- ...item,
134
- shape: variant ? normalizeVariant(variant) : item.shape,
135
- width: width ?? item.width,
136
- height: height ?? item.height,
137
- radius: radius ?? item.radius
138
- }))
139
- };
140
- }
141
-
142
- function createRegisteredLayout(options) {
143
- const variant = options.variant ?? options.renderHints.variant;
144
- const width = toCssLength(options.width ?? options.renderHints.width);
145
- const height = toCssLength(options.height ?? options.renderHints.height);
146
- const radius = toCssLength(options.renderHints.radius);
147
- const rows = options.renderHints.rows;
148
-
149
- if (rows !== undefined && rows > 1) {
150
- return createTextLayout("registered", rows, width ?? "100%", height ?? "1.25rem", radius);
151
- }
152
-
153
- return createSingleLayout("registered", normalizeVariant(variant), width ?? "6rem", height ?? "3rem", radius);
154
- }
155
-
156
- export function resolveSkeletonLayout(options = {}) {
157
- if (options.renderHints) {
158
- return createRegisteredLayout({
159
- renderHints: options.renderHints,
160
- variant: options.variant,
161
- width: options.width,
162
- height: options.height
163
- });
164
- }
165
-
166
- const componentKey = getSkeletonComponentKey(options.componentClass);
167
-
168
- if (!componentKey && (options.variant || options.width !== undefined || options.height !== undefined)) {
169
- return createSingleLayout("explicit", normalizeVariant(options.variant), toCssLength(options.width), toCssLength(options.height));
170
- }
171
-
172
- switch (componentKey) {
173
- case "accordion":
174
-
175
- case "accordion-item":
176
- return applyRenderHints(createTextLayout(componentKey, 3, fit("100%"), fit("var(--leading-14)")), options.renderHints, options);
177
-
178
- case "text":
179
- return applyRenderHints(createSingleLayout(componentKey, "line", fit("100%"), fit("1.25rem")), options.renderHints, options);
180
-
181
- case "card":
182
-
183
- case "scroll-area":
184
- return applyRenderHints(createSingleLayout(componentKey, "rect", fit("100%"), fit("6rem")), options.renderHints, options);
185
-
186
- case "flow-text":
187
- return applyRenderHints(createSingleLayout(componentKey, "line", fit("4rem"), fit("1rem")), options.renderHints, options);
188
-
189
- case "circular-chart":
190
- return applyRenderHints(createSingleLayout(componentKey, "circle", fit("15rem"), fit("15rem")), options.renderHints, options);
191
-
192
- case "gauge-chart":
193
- return applyRenderHints(createSingleLayout(componentKey, "rect", fit("20rem"), fit("10rem")), options.renderHints, options);
194
-
195
- case "line-chart":
196
-
197
- case "bar-chart":
198
-
199
- case "chart-group":
200
- return applyRenderHints(createSingleLayout(componentKey, "rect", fit("50rem"), fit("25rem")), options.renderHints, options);
201
-
202
- case "button":
203
-
204
- case "button-group":
205
-
206
- case "breadcrumb":
207
-
208
- case "pagination":
209
- return applyRenderHints(createSingleLayout(componentKey, "line", fit("5rem"), fit("1rem")), options.renderHints, options);
210
-
211
- case "separator":
212
- return applyRenderHints(createSingleLayout(componentKey, "line", fit("100%"), fit("var(--border-1)")), options.renderHints, options);
213
-
214
- case "progress":
215
- return applyRenderHints(createSingleLayout(componentKey, "line", fit("100%"), fit("calc(var(--size-4) / 4)")), options.renderHints, options);
216
-
217
- case "input":
218
-
219
- case "search-input":
220
-
221
- case "search-box":
222
- return applyRenderHints(createSingleLayout(componentKey, "line", fit("100%"), fit("1.25rem")), options.renderHints, options);
223
-
224
- case "search-popup":
225
- return applyRenderHints(createSingleLayout(componentKey, "rect", fit("37.5rem"), fit("48rem")), options.renderHints, options);
226
-
227
- case "field":
228
- return applyRenderHints(createSingleLayout(componentKey, "rect", fit("100%"), fit("1.25rem")), options.renderHints, options);
229
-
230
- case "textarea":
231
- return applyRenderHints(createSingleLayout(componentKey, "rect", fit("100%"), fit("calc((var(--leading-14) * 4) + var(--padding-3) + var(--padding-6))")), options.renderHints, options);
232
-
233
- case "select":
234
- return applyRenderHints(createSingleLayout(componentKey, "line", fit("100%"), fit("1.25rem")), options.renderHints, options);
235
-
236
- case "listbox":
237
- return applyRenderHints(createSingleLayout(componentKey, "rect", fit("10rem"), fit("8rem")), options.renderHints, options);
238
-
239
- case "badge":
240
- return applyRenderHints(createSingleLayout(componentKey, "line", fit("2.5rem"), fit("1rem")), options.renderHints, options);
241
-
242
- case "chip":
243
- return applyRenderHints(createSingleLayout(componentKey, "line", fit("3rem"), fit("1rem")), options.renderHints, options);
244
-
245
- case "link":
246
- return applyRenderHints(createSingleLayout(componentKey, "line", fit("4rem"), fit("1.25rem")), options.renderHints, options);
247
-
248
- case "tag":
249
- return applyRenderHints(createSingleLayout(componentKey, "line", fit("3rem"), fit("1.25rem")), options.renderHints, options);
250
-
251
- case "copy-link":
252
- return applyRenderHints(createSingleLayout(componentKey, "rect", fit("100%"), fit("2.75rem")), options.renderHints, options);
253
-
254
- case "code-block":
255
- return applyRenderHints(createSingleLayout(componentKey, "rect", fit("100%"), fit("12rem")), options.renderHints, options);
256
-
257
- case "kbd":
258
- return applyRenderHints(createSingleLayout(componentKey, "line", fit("3rem"), fit("1.25rem")), options.renderHints, options);
259
-
260
- case "switch":
261
- return applyRenderHints(createSingleLayout(componentKey, "line", fit("2.5rem"), fit("1.5rem")), options.renderHints, options);
262
-
263
- case "avatar":
264
- return applyRenderHints(createSingleLayout(componentKey, "circle", fit("2.5rem"), fit("2.5rem")), options.renderHints, options);
265
-
266
- case "spinner":
267
- return applyRenderHints(createSingleLayout(componentKey, "circle", fit("1.5rem"), fit("1.5rem")), options.renderHints, options);
268
-
269
- case "radio":
270
- return applyRenderHints(createSingleLayout(componentKey, "circle", fit("1.25rem"), fit("1.25rem")), options.renderHints, options);
271
-
272
- case "icon":
273
- return applyRenderHints(
274
- {
275
- key: componentKey,
276
- known: true,
277
- items: [
278
- {
279
- shape: "rect",
280
- width: fit("1.25rem"),
281
- height: fit("1.25rem"),
282
- radius: "50%"
283
- }
284
- ]
285
- },
286
- options.renderHints,
287
- options
288
- );
289
-
290
- case "checkbox":
291
- return applyRenderHints(createSingleLayout(componentKey, "rect", fit("1.25rem"), fit("1.25rem")), options.renderHints, options);
292
-
293
- case "tooltip":
294
- return applyRenderHints(createSingleLayout(componentKey, "rect", fit("4.5rem"), fit("2rem")), options.renderHints, options);
295
-
296
- case "toast":
297
- return applyRenderHints(createSingleLayout(componentKey, "rect", fit("12rem"), fit("2.25rem")), options.renderHints, options);
298
-
299
- case "tab":
300
-
301
- case "segmented":
302
- return applyRenderHints(createSingleLayout(componentKey, "rect", fit("12rem"), fit("1.5rem")), options.renderHints, options);
303
-
304
- case "popover":
305
- return applyRenderHints(createSingleLayout(componentKey, "rect", fit("7rem"), fit("5rem")), options.renderHints, options);
306
-
307
- case "dialog":
308
- return applyRenderHints(createSingleLayout(componentKey, "rect", fit("20rem"), fit("10rem")), options.renderHints, options);
309
-
310
- case "frame":
311
- return applyRenderHints(createSingleLayout(componentKey, "line", fit("100%"), fit("1.25rem")), options.renderHints, options);
312
-
313
- case "test":
314
- return applyRenderHints(createSingleLayout(componentKey, "rect", fit("5rem"), fit("2rem")), options.renderHints, options);
315
-
316
- case "anchor":
317
- return applyRenderHints(createSingleLayout(componentKey, "line", fit("4rem"), fit("1rem")), options.renderHints, options);
318
-
319
- case "avatar-group":
320
- return applyRenderHints(createSingleLayout(componentKey, "circle", fit("1rem"), fit("1rem")), options.renderHints, options);
321
-
322
- case "image":
323
- return applyRenderHints(createSingleLayout(componentKey, "rect", fit("2.5rem"), fit("2.5rem")), options.renderHints, options);
324
-
325
- case "gradient":
326
- return applyRenderHints(createSingleLayout(componentKey, "rect", fit("calc(var(--size-4) * 45 / 2)"), fit("calc(var(--size-4) * 45 / 2)")), options.renderHints, options);
327
-
328
- case "snow-uilogo":
329
- return applyRenderHints(createSingleLayout(componentKey, "rect", fit("calc(var(--size-4) * 105 / 16)"), fit("calc(var(--size-4) * 28 / 16)")), options.renderHints, options);
330
-
331
- case "image-group":
332
- return applyRenderHints(createSingleLayout(componentKey, "rect", fit("5rem"), fit("2.5rem")), options.renderHints, options);
333
-
334
- case "image-viewer":
335
- return applyRenderHints(createSingleLayout(componentKey, "rect", fit("7rem"), fit("5rem")), options.renderHints, options);
336
-
337
- case "quick-action":
338
- return applyRenderHints(createSingleLayout(componentKey, "rect", fit("10rem"), fit("6rem")), options.renderHints, options);
339
-
340
- case "menu-item":
341
- return applyRenderHints(createSingleLayout(componentKey, "line", fit("100%"), fit("2rem")), options.renderHints, options);
342
-
343
- default:
344
- return applyRenderHints(
345
- {
346
- key: "fallback",
347
- known: false,
348
- items: [{ shape: "rect", width: fit("6rem"), height: fit("3rem") }]
349
- },
350
- options.renderHints,
351
- options
352
- );
353
- }
354
- }
5
+ export { getSkeletonComponentKey, resolveSkeletonLayout } from "../logic/skeleton-layouts.js";
355
6
 
356
7
  const $$css = {
357
8
  hash: 'svelte-tl058d',
@@ -380,33 +31,37 @@ export default function Skeleton($$renderer, $$props) {
380
31
  ...rest
381
32
  } = $$props;
382
33
 
383
- function createResponsiveController() {
384
- return new ResponsiveController(responsive ?? {});
385
- }
386
-
387
- const responsiveController = createResponsiveController();
388
- const responsiveWidth = $.derived(() => responsiveController.props?.width ?? width);
389
- const responsiveHeight = $.derived(() => responsiveController.props?.height ?? height);
390
-
391
- const layout = $.derived(() => resolveSkeletonLayout({
392
- componentClass,
393
- renderHints,
394
- variant,
395
- width: responsiveWidth(),
396
- height: responsiveHeight()
397
- }));
398
-
399
- const groupStyle = $.derived(() => [
400
- `width: ${toCssLength(responsiveWidth() ?? renderHints?.width) ?? "100%"}`,
401
- responsiveHeight() !== undefined || renderHints?.height !== undefined
402
- ? `height: ${toCssLength(responsiveHeight() ?? renderHints?.height)}`
403
- : "",
404
- `border-radius: ${toCssLength(renderHints?.radius) ?? "var(--radius-3, 0.75rem)"}`,
405
- responsiveController.style,
406
- style
407
- ].filter(Boolean).join(";"));
34
+ let skeletonElement = undefined;
35
+ let responsiveController = undefined;
36
+ const responsiveStyle = $.derived(() => responsive ? responsiveController?.style : undefined);
37
+ const responsiveWidth = $.derived(() => (responsive ? responsiveController?.props?.width : undefined) ?? width);
38
+ const responsiveHeight = $.derived(() => (responsive ? responsiveController?.props?.height : undefined) ?? height);
39
+
40
+ const layout = $.derived(() => !group && loading
41
+ ? resolveSkeletonLayout({
42
+ componentClass,
43
+ renderHints,
44
+ variant,
45
+ width: responsiveWidth(),
46
+ height: responsiveHeight()
47
+ })
48
+ : EMPTY_SKELETON_LAYOUT);
49
+
50
+ const groupStyle = $.derived(() => group
51
+ ? [
52
+ `width: ${toCssLength(responsiveWidth() ?? renderHints?.width) ?? "100%"}`,
53
+ responsiveHeight() !== undefined || renderHints?.height !== undefined
54
+ ? `height: ${toCssLength(responsiveHeight() ?? renderHints?.height)}`
55
+ : "",
56
+ `border-radius: ${toCssLength(renderHints?.radius) ?? "var(--radius-3, 0.75rem)"}`,
57
+ responsiveStyle(),
58
+ style
59
+ ].filter(Boolean).join(";")
60
+ : undefined);
408
61
 
409
62
  const containerClass = $.derived(() => {
63
+ if (group || !loading) return "";
64
+
410
65
  return [
411
66
  "snowui-skeleton-layout",
412
67
  `snowui-skeleton-layout-${layout().key}`,
@@ -417,6 +72,8 @@ export default function Skeleton($$renderer, $$props) {
417
72
  });
418
73
 
419
74
  const containerStyle = $.derived(() => {
75
+ if (group || !loading) return undefined;
76
+
420
77
  if (layout().items.length === 1) {
421
78
  // Percentage hints need a containing block inside flex hosts.
422
79
  const item = layout().items[0];
@@ -432,7 +89,7 @@ export default function Skeleton($$renderer, $$props) {
432
89
  ? `--snowui-skeleton-layout-width: ${layout().items[0].width}`
433
90
  : "",
434
91
  style,
435
- responsiveController.style
92
+ responsiveStyle()
436
93
  ].filter(Boolean).join(";") || undefined;
437
94
  });
438
95
 
@@ -442,7 +99,7 @@ export default function Skeleton($$renderer, $$props) {
442
99
  item.height ? `--snowui-skeleton-height: ${item.height}` : "",
443
100
  item.radius ? `--snowui-skeleton-radius: ${item.radius}` : "",
444
101
  isSingle ? style : "",
445
- isSingle ? responsiveController.style : ""
102
+ isSingle ? responsiveStyle() : ""
446
103
  ].filter(Boolean).join(";") || undefined;
447
104
  }
448
105
 
@@ -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 Tooltip from "./Tooltip.js";
4
+ import type Tooltip 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>;
@@ -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
- Tooltip($$renderer, $.spread_props([
583
- tooltipConfig(),
584
- {
585
- children: ($$renderer) => {
586
- if (typeof tooltipContent() === "string") {
587
- $$renderer.push('<!--[0-->');
588
- $$renderer.push(`${$.escape(tooltipContent())}`);
589
- } else if (typeof tooltipContent() === "function") {
590
- $$renderer.push('<!--[1-->');
591
- tooltipContent()($$renderer);
592
- $$renderer.push(`<!---->`);
593
- } else {
594
- $$renderer.push('<!--[-1-->');
595
- }
596
-
597
- $$renderer.push(`<!--]-->`);
598
- },
599
- $$slots: { default: true }
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
  }
@@ -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;
@@ -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
  }
@@ -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";
@@ -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;
@@ -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: (_e: DragEvent) => void;
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;