@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,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 // Button 仍接收完整兼容 Props;透明测量外壳只同步公开 data-* 标记,
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,43 @@ 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);
162
+ let measureMounted = $.state(false);
127
163
  const mode = $.derived(() => owner?.getMode($$props.id) ?? "full");
128
164
  const resolvedDisabled = $.derived(() => disabled() || owner?.disabled === true);
165
+
166
+ // Button 仍接收完整兼容 Props;透明测量外壳只同步公开 data-* 标记,
167
+ // 避免把 onclick / motion 等交互能力重复绑定到两层宿主。
129
168
  const frameRestProps = $.derived(() => Object.fromEntries(Object.entries(rest).filter(([key]) => key.startsWith("data-"))));
130
169
 
131
170
  function execute(event) {
@@ -134,6 +173,8 @@ export default function OverflowAction($$anchor, $$props) {
134
173
  }
135
174
 
136
175
  onMount(() => {
176
+ $.set(measureMounted, true);
177
+
137
178
  if (as() !== "item" || !owner) {
138
179
  if (false && as() === "item" && !owner) {
139
180
  console.warn(`[SnowUI OverflowAction] id="${$$props.id}" requires an OverflowActions parent.`);
@@ -183,7 +224,7 @@ export default function OverflowAction($$anchor, $$props) {
183
224
  try {
184
225
  const element = control()
185
226
  ? $.get(visualElement)
186
- : mode === "compact"
227
+ : mode === "compact" && !iconOnly()
187
228
  ? $.get(compactMeasureElement)
188
229
  : $.get(fullMeasureElement);
189
230
 
@@ -226,7 +267,10 @@ export default function OverflowAction($$anchor, $$props) {
226
267
  enableResponsive: false,
227
268
  enableContext: false,
228
269
  enableScaleObserver: false,
229
- enableDefaultMotion: false
270
+ enableDefaultMotion: false,
271
+ get componentParts() {
272
+ return $.get(resolvedBuiltInParts);
273
+ }
230
274
  },
231
275
  () => $.get(frameRestProps),
232
276
  {
@@ -246,11 +290,16 @@ export default function OverflowAction($$anchor, $$props) {
246
290
 
247
291
  {
248
292
  var consequent_4 = ($$anchor) => {
249
- var fragment_9 = $.comment();
250
- var node_6 = $.first_child(fragment_9);
293
+ ComponentPartsBoundary($$anchor, {
294
+ children: ($$anchor, $$slotProps) => {
295
+ var fragment_10 = $.comment();
296
+ var node_6 = $.first_child(fragment_10);
251
297
 
252
- $.snippet(node_6, control, () => execute, () => $.get(resolvedDisabled));
253
- $.append($$anchor, fragment_9);
298
+ $.snippet(node_6, control, () => execute, () => $.get(resolvedDisabled));
299
+ $.append($$anchor, fragment_10);
300
+ },
301
+ $$slots: { default: true }
302
+ });
254
303
  };
255
304
 
256
305
  var consequent_5 = ($$anchor) => {
@@ -260,8 +309,8 @@ export default function OverflowAction($$anchor, $$props) {
260
309
  return $$props.label;
261
310
  },
262
311
 
263
- get title() {
264
- return $$props.label;
312
+ get tooltip() {
313
+ return $.get(effectiveTooltip);
265
314
  },
266
315
 
267
316
  get disabled() {
@@ -292,6 +341,10 @@ export default function OverflowAction($$anchor, $$props) {
292
341
  return $.get($0);
293
342
  },
294
343
 
344
+ get tooltip() {
345
+ return $.get(resolvedFullButtonTooltip);
346
+ },
347
+
295
348
  get disabled() {
296
349
  return $.get(resolvedDisabled);
297
350
  },
@@ -335,6 +388,7 @@ export default function OverflowAction($$anchor, $$props) {
335
388
  get 'aria-label'() {
336
389
  return $.get($0);
337
390
  },
391
+ tooltip: false,
338
392
  tabindex: -1,
339
393
  children: ($$anchor, $$slotProps) => {
340
394
  renderFull($$anchor);
@@ -355,6 +409,7 @@ export default function OverflowAction($$anchor, $$props) {
355
409
 
356
410
  Button(node_10, $.spread_props(() => $.get(resolvedButtonProps), {
357
411
  iconOnly: true,
412
+ tooltip: false,
358
413
  tabindex: -1,
359
414
  get 'aria-label'() {
360
415
  return $$props.label;
@@ -372,7 +427,7 @@ export default function OverflowAction($$anchor, $$props) {
372
427
  };
373
428
 
374
429
  $.if(node_9, ($$render) => {
375
- if (icon()) $$render(consequent_6);
430
+ if (icon() && !iconOnly()) $$render(consequent_6);
376
431
  });
377
432
  }
378
433
 
@@ -381,7 +436,7 @@ export default function OverflowAction($$anchor, $$props) {
381
436
  };
382
437
 
383
438
  $.if(node_7, ($$render) => {
384
- if (!control()) $$render(consequent_7);
439
+ if (!control() && $.get(measureMounted)) $$render(consequent_7);
385
440
  });
386
441
  }
387
442
 
@@ -1,11 +1,13 @@
1
1
  import { type ComponentProps, type Snippet } from "svelte";
2
2
  import { type FrameProps } from "./Frame.js";
3
3
  import Button from "./Button.js";
4
- import SelectButton from "./SelectButton.js";
5
- import Listbox from "./Listbox.js";
6
- import MenuItem from "./MenuItem.js";
4
+ import type SelectButtonType from "./SelectButton.js";
5
+ import type ListboxType from "./Listbox.js";
6
+ import type MenuItemType 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"];
@@ -37,10 +40,11 @@ export interface OverflowActionsActionEvent {
37
40
  }
38
41
  type Parts = ComponentPartsOf<{
39
42
  Button: typeof Button;
40
- SelectButton: typeof SelectButton;
41
- Listbox: typeof Listbox;
42
- MenuItem: typeof MenuItem;
43
+ SelectButton: typeof SelectButtonType;
44
+ Listbox: typeof ListboxType;
45
+ MenuItem: typeof MenuItemType;
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;