@luxalgo/vela-ui 0.1.0 → 0.3.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.
Files changed (124) hide show
  1. package/CHANGELOG.md +89 -0
  2. package/README.md +5 -2
  3. package/dist/badge.js +1 -1
  4. package/dist/bar-chart.js +1 -1
  5. package/dist/button.d.ts +18 -4
  6. package/dist/button.js +4 -3
  7. package/dist/calendar.d.ts +3 -1
  8. package/dist/calendar.js +1 -1
  9. package/dist/callout-bubble.d.ts +6 -1
  10. package/dist/callout-bubble.js +12 -8
  11. package/dist/card.d.ts +52 -0
  12. package/dist/card.js +179 -0
  13. package/dist/checkbox.js +5 -5
  14. package/dist/{chunk-X4YPSIW6.js → chunk-5BJV5FY5.js} +1 -1
  15. package/dist/{chunk-FCO3YZLT.js → chunk-ALAHGSLC.js} +1 -1
  16. package/dist/{chunk-5QHXOAZA.js → chunk-B2EZB5ZG.js} +4 -4
  17. package/dist/{chunk-G7IQLY3A.js → chunk-C3PXY2SW.js} +5 -0
  18. package/dist/chunk-DXDCKZ2M.js +117 -0
  19. package/dist/{chunk-6NXY62JS.js → chunk-FYVQO5TN.js} +1 -1
  20. package/dist/{chunk-V6TTTMTE.js → chunk-GVRX3UAV.js} +4 -1
  21. package/dist/{chunk-XJAPCCOJ.js → chunk-IOOYDSSK.js} +4 -4
  22. package/dist/{chunk-OBLIX3VN.js → chunk-KKS6NEGI.js} +2 -2
  23. package/dist/{chunk-SAPURP46.js → chunk-OJ2SEMN6.js} +3 -3
  24. package/dist/{chunk-2Q4JRINP.js → chunk-OQXFQMZM.js} +3 -3
  25. package/dist/{chunk-AJ2IYSOI.js → chunk-TBXUF5YX.js} +35 -3
  26. package/dist/{chunk-ZB3BZHSN.js → chunk-UEO6W37Z.js} +4 -4
  27. package/dist/{chunk-CH3DV6FD.js → chunk-WWHNUKSZ.js} +5 -5
  28. package/dist/chunk-XBEL4K33.js +142 -0
  29. package/dist/collapsible.d.ts +49 -0
  30. package/dist/collapsible.js +106 -0
  31. package/dist/color-picker.js +5 -5
  32. package/dist/context-menu.js +5 -5
  33. package/dist/css.d.ts +3 -1
  34. package/dist/css.js +1 -1
  35. package/dist/data-table.d.ts +39 -2
  36. package/dist/data-table.js +1 -1
  37. package/dist/date-picker.js +3 -3
  38. package/dist/dialog.d.ts +8 -0
  39. package/dist/dialog.js +15 -5
  40. package/dist/donut.js +1 -1
  41. package/dist/drawer.js +2 -2
  42. package/dist/dropdown-menu.js +4 -4
  43. package/dist/empty.js +2 -2
  44. package/dist/field.js +13 -13
  45. package/dist/glyph-select.js +5 -5
  46. package/dist/h-Bl37qUis.d.ts +24 -0
  47. package/dist/hover-card.d.ts +1 -1
  48. package/dist/hover-card.js +3 -3
  49. package/dist/icons.js +1 -1
  50. package/dist/index.d.ts +10 -2
  51. package/dist/index.js +3 -3
  52. package/dist/input-group.js +4 -3
  53. package/dist/input.js +2 -2
  54. package/dist/item.d.ts +72 -0
  55. package/dist/item.js +131 -0
  56. package/dist/kbd.js +2 -2
  57. package/dist/line-chart.js +1 -1
  58. package/dist/manifest.json +1336 -65
  59. package/dist/month-grid.d.ts +45 -0
  60. package/dist/month-grid.js +157 -0
  61. package/dist/number-input.js +5 -5
  62. package/dist/popover.js +3 -3
  63. package/dist/scatter-chart.js +1 -1
  64. package/dist/select.js +7 -7
  65. package/dist/slider.d.ts +46 -0
  66. package/dist/slider.js +111 -0
  67. package/dist/sort-button.d.ts +41 -0
  68. package/dist/sort-button.js +88 -0
  69. package/dist/sparkline.js +1 -1
  70. package/dist/stat.js +1 -1
  71. package/dist/switch.js +3 -3
  72. package/dist/tabs.d.ts +3 -1
  73. package/dist/tabs.js +13 -8
  74. package/dist/text-area.js +2 -2
  75. package/dist/theme-Ct-q58xz.d.ts +341 -0
  76. package/dist/theme.d.ts +42 -181
  77. package/dist/theme.js +2 -2
  78. package/dist/theme.schema.json +541 -1
  79. package/dist/toast.d.ts +49 -0
  80. package/dist/toast.js +463 -0
  81. package/dist/toggle-group.js +4 -4
  82. package/dist/tooltip.js +2 -2
  83. package/dist/treemap.d.ts +80 -0
  84. package/dist/treemap.js +470 -0
  85. package/docs/theming.md +6 -0
  86. package/docs/writing-a-component.md +4 -1
  87. package/llms.txt +11 -3
  88. package/package.json +1 -1
  89. package/registry/button.ts +105 -21
  90. package/registry/callout-bubble.ts +14 -3
  91. package/registry/card.ts +379 -0
  92. package/registry/collapsible.ts +271 -0
  93. package/registry/dialog.ts +16 -0
  94. package/registry/dropdown-menu.ts +3 -3
  95. package/registry/item.ts +376 -0
  96. package/registry/month-grid.ts +328 -0
  97. package/registry/slider.ts +259 -0
  98. package/registry/sort-button.ts +189 -0
  99. package/registry/tabs.ts +38 -4
  100. package/registry/toast.ts +965 -0
  101. package/registry/treemap.ts +847 -0
  102. package/skills/using-vela-ui-components/SKILL.md +14 -9
  103. package/src/components/button.ts +105 -21
  104. package/src/components/callout-bubble.ts +14 -3
  105. package/src/components/card.ts +379 -0
  106. package/src/components/collapsible.ts +271 -0
  107. package/src/components/dialog.ts +16 -0
  108. package/src/components/dropdown-menu.ts +3 -3
  109. package/src/components/item.ts +376 -0
  110. package/src/components/month-grid.ts +328 -0
  111. package/src/components/slider.ts +259 -0
  112. package/src/components/sort-button.ts +189 -0
  113. package/src/components/tabs.ts +38 -4
  114. package/src/components/toast.ts +965 -0
  115. package/src/components/treemap.ts +847 -0
  116. package/src/lib/calendar.ts +5 -0
  117. package/src/lib/component-index.ts +34 -2
  118. package/src/lib/css.ts +6 -2
  119. package/src/lib/icons.ts +7 -0
  120. package/src/lib/scope.ts +135 -0
  121. package/src/lib/theme.ts +21 -5
  122. package/dist/chunk-EZQXTO6K.js +0 -89
  123. package/dist/chunk-IDA2BT7D.js +0 -29
  124. package/dist/data-table-DtU3FX9j.d.ts +0 -61
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: using-vela-ui-components
3
- description: Builds interface pieces with @luxalgo/vela-ui, the component kit behind Vela charts - buttons, tabs, toggle groups, badges, dialogs, drawers, dropdown and context menus, tooltips, hover cards, popovers, form controls (checkbox, switch, input, select, number input, date and color pickers) and data components (data table, stat, sparkline, bar, line and scatter charts). Use when adding or wiring these components on a page or next to a Vela chart, when a menu, dialog or tooltip from the kit renders unstyled or in the wrong place, or when the user wants UI that matches their Vela chart, even if they do not name the kit.
3
+ description: Builds interface pieces with @luxalgo/vela-ui, the component kit behind Vela charts - buttons, tabs, toggle groups, badges, dialogs, drawers, dropdown and context menus, tooltips, hover cards, popovers, toasts, collapsible sections, cards, list rows, form controls (checkbox, switch, slider, input, select, number input, date and color pickers) and data components (data table, sort buttons, month grid, stat, sparkline, bar, line and scatter charts, treemap). Use when adding or wiring these components on a page or next to a Vela chart, when a menu, dialog or tooltip from the kit renders unstyled or in the wrong place, or when the user wants UI that matches their Vela chart, even if they do not name the kit.
4
4
  license: Apache-2.0
5
5
  ---
6
6
 
@@ -40,15 +40,19 @@ To find a component, its props, parts and an example, search
40
40
 
41
41
  | Need | Component |
42
42
  | --- | --- |
43
- | An action | `button` (variants `default`, `outline`, `secondary`, `ghost`, `destructive`, `link`, `up`, `down`) |
44
- | Switch between views | `tabs`; a few exclusive options on one track: `toggle-group` |
43
+ | An action | `button` (variants `default`, `outline`, `secondary`, `ghost`, `destructive`, `link`, `up`, `down`, `favorite`; `keys` for key caps) |
44
+ | Switch between views | `tabs` (a `description` puts a second line under a label); a few exclusive options on one track: `toggle-group` |
45
45
  | A status or a count | `badge`, `stat`, `kbd` |
46
46
  | A list of actions from a button or a right-click | `dropdown-menu`, `context-menu` |
47
47
  | A label or a card on hover | `tooltip`, `hover-card` |
48
48
  | A modal or a sheet | `dialog`, `drawer` |
49
49
  | Floating content of your own | `popover` |
50
- | A form | `input`, `input-group`, `text-area`, `number-input`, `select`, `checkbox`, `switch`, `date-picker`, `color-picker` |
51
- | Data | `data-table`, `sparkline`, `line-chart`, `bar-chart`, `scatter-chart`, `donut`, `empty` |
50
+ | A notice that leaves on its own (saved, failed, an alert fired) | `toast`: raise it with `toast()` / `toast.success(…)` from anywhere, shown by one `createToaster()` |
51
+ | A section that folds | `collapsible` |
52
+ | A panel or tile of figures, a chart with its title | `card` (`inset` for tiles inside a card; `onSelect` makes it clickable) |
53
+ | Rows of a list (a watchlist, alerts, results) | `item`, stacked by `createItemGroup` |
54
+ | A form | `input`, `input-group`, `text-area`, `number-input`, `select`, `checkbox`, `switch`, `slider`, `date-picker`, `color-picker` |
55
+ | Data | `data-table`, `sort-button` (sorts a list that is not a table), `month-grid` (a figure per day), `sparkline`, `line-chart`, `bar-chart`, `scatter-chart`, `donut`, `treemap` (weighted tiles tinted by a value, in groups that can zoom), `empty` |
52
56
 
53
57
  ## Rules that prevent the common bugs
54
58
 
@@ -56,10 +60,11 @@ To find a component, its props, parts and an example, search
56
60
  takes it as `list: { host }`). Without it, the component looks for a host from the trigger,
57
61
  finds none, and mounts in `<body>`, unthemed. When unsure whether the trigger is in the page
58
62
  yet (inside a panel's `mount`, say), pass it.
59
- 2. **Start a value with `defaultValue` or `defaultChecked`, listen with `onValueChange` or
60
- `onCheckedChange`, and change it from code with `setValue` or `setChecked`.** The setters
61
- never call the listeners, so a host can refresh a control without loops. A select's options
62
- are fixed: build a new one to change them.
63
+ 2. **Start a value with `defaultValue`, `defaultChecked`, `defaultOpen` or `defaultPressed`,
64
+ listen with the matching `on…Change`, and change it from code with `setValue`,
65
+ `setChecked`, `setOpen` or `setPressed`.** The setters never call the listeners, so a host
66
+ can refresh a control without loops. A select's options are fixed: build a new one to
67
+ change them. A slider also reports `onValueCommit` once a drag ends: run costly work there.
63
68
  3. **Every floating part takes the same placement props:** `side`, `align`, `sideOffset`,
64
69
  `alignOffset`, `avoidCollisions`, `collisionPadding`, `collisionBoundary`.
65
70
  4. **Release what you discard.** Controls that run a state machine keep page-wide listeners
@@ -1,20 +1,24 @@
1
- // Button: a <button> with optional icons before and after its text. `default` is filled with
2
- // the selection color (OK, Apply), `outline` bordered (the dialogs' Cancel), `secondary` a
3
- // sunken fill, `ghost` bare until hovered (toolbar and header icons), `destructive` tinted
4
- // with the danger color, `link` text that underlines on hover, `up` and `down` filled with the
5
- // market's colors (buy and sell). Heights: `xs` 26px, `sm` 30px
6
- // (panels), `default` 34px (dialog footers), `lg` 40px (touch); the `icon*` sizes are the
7
- // same heights, square, for an icon alone, which `label` names.
1
+ // Button: a <button> with optional icons and key caps before and after its text (`↵ Open`,
2
+ // `Esc Close` in a picker's footer). `default` is filled with the selection color (OK, Apply),
3
+ // `outline` bordered (the dialogs' Cancel), `secondary` a sunken fill, `ghost` bare until
4
+ // hovered (toolbar and header icons), `destructive` tinted with the danger color, `link` text
5
+ // that underlines on hover, `up` and `down` filled with the market's colors (buy and sell),
6
+ // `favorite` a bare star whose pressed state takes the favorites color. Heights: `xs` 26px,
7
+ // `sm` 30px (panels), `default` 34px (dialog footers), `lg` 40px (touch); the `icon*` sizes
8
+ // are the same heights, square, for an icon alone, which `label` names. A toggle button
9
+ // (`pressed`, `defaultPressed` or `onPressedChange`) says its state through `aria-pressed`;
10
+ // uncontrolled it flips on a press, given `pressed` it only asks, until `setPressed` moves it.
8
11
  import { iconEl } from '../lib/icons';
9
12
  import { css, defineStyles } from '../lib/css';
10
13
  import { defineComponent } from '../lib/define';
11
14
  import { h } from '../lib/h';
12
15
  import { t } from '../lib/t';
13
16
  import { variants, type VariantProps } from '../lib/variants';
17
+ import { createKbd } from './kbd';
14
18
 
15
19
  export const buttonDef = defineComponent({
16
20
  name: 'button',
17
- parts: ['root', 'icon'],
21
+ parts: ['root', 'icon', 'keys'],
18
22
  settings: {
19
23
  radius: t.radius.md,
20
24
  height: '34px',
@@ -28,7 +32,7 @@ export const buttonDef = defineComponent({
28
32
  });
29
33
 
30
34
  export const buttonVariants = variants({
31
- variant: ['default', 'outline', 'secondary', 'ghost', 'destructive', 'link', 'up', 'down'],
35
+ variant: ['default', 'outline', 'secondary', 'ghost', 'destructive', 'link', 'up', 'down', 'favorite'],
32
36
  size: ['default', 'xs', 'sm', 'lg', 'icon', 'icon-xs', 'icon-sm', 'icon-lg'],
33
37
  });
34
38
 
@@ -38,14 +42,27 @@ export type ButtonSize = (typeof buttonVariants.spec.size)[number];
38
42
  export interface ButtonProps extends VariantProps<typeof buttonVariants> {
39
43
  /** The visible text (the `icon*` sizes show none; `label` names them). */
40
44
  text?: string;
41
- /** Icon id from the kit's registry, before the text (the icon of an `icon*` size). */
45
+ /** Icon id from the kit's registry, before the text (the icon of an `icon*` size).
46
+ * `favorite` defaults to `star`. */
42
47
  icon?: string;
48
+ /** The icon while pressed (`star-filled` for `star`). `favorite` defaults to `star-filled`. */
49
+ iconPressed?: string;
43
50
  /** Icon id after the text (a menu trigger's chevron). */
44
51
  iconEnd?: string;
52
+ /** Key caps before the text, one per key (`['↑', '↓']`). */
53
+ keys?: readonly string[];
54
+ /** Key caps after the text. */
55
+ keysEnd?: readonly string[];
45
56
  /** Accessible name; required for the `icon*` sizes, defaults to `text`. */
46
57
  label?: string;
47
- /** A toggle button's state (`aria-pressed`). Omitted: not a toggle. */
58
+ /** A controlled toggle's state (`aria-pressed`): a press only calls `onPressedChange`, and
59
+ * `setPressed` moves it. Omitted with `defaultPressed` and `onPressedChange`: not a toggle. */
48
60
  pressed?: boolean;
61
+ /** An uncontrolled toggle's first state: a press flips it and calls `onPressedChange`. */
62
+ defaultPressed?: boolean;
63
+ /** A press asked for this state (a toggle without `pressed` or `defaultPressed` starts
64
+ * unpressed). */
65
+ onPressedChange?: (pressed: boolean) => void;
49
66
  disabled?: boolean;
50
67
  onClick?: (e: MouseEvent) => void;
51
68
  /** Extra class names (layout hooks). */
@@ -55,6 +72,7 @@ export interface ButtonProps extends VariantProps<typeof buttonVariants> {
55
72
  export interface ButtonHandle {
56
73
  readonly el: HTMLButtonElement;
57
74
  readonly pressed: boolean | undefined;
75
+ /** Show a toggle's state, without calling `onPressedChange`. */
58
76
  setPressed(pressed: boolean): void;
59
77
  setDisabled(disabled: boolean): void;
60
78
  /** New text (or, for an `icon*` size, a new accessible name). */
@@ -107,6 +125,21 @@ export const BUTTON_CSS = css`
107
125
  &[data-size='icon-xs'] > [data-icon] {
108
126
  font-size: 12px;
109
127
  }
128
+ & > [data-keys] {
129
+ flex: none;
130
+ gap: 2px;
131
+ }
132
+ & > [data-keys]:where(:not([hidden])) {
133
+ display: inline-flex;
134
+ }
135
+ /* A key cap's own colors vanish on a fill that matches them (the solid
136
+ variants): inside a button it takes the button's text and draws only its outline. */
137
+ & > [data-keys] > [data-slot='kbd'] {
138
+ border-color: ${t.border};
139
+ background: transparent;
140
+ color: inherit;
141
+ box-shadow: none;
142
+ }
110
143
  &[data-size='sm'],
111
144
  &[data-size='icon-sm'] {
112
145
  height: ${buttonDef.vars['height-sm']};
@@ -225,43 +258,85 @@ export const BUTTON_CSS = css`
225
258
  background: ${t.active};
226
259
  color: ${t.fg.bright};
227
260
  }
261
+ &[data-variant='favorite'] {
262
+ border-color: transparent;
263
+ color: ${t.fg.muted};
264
+ }
265
+ &[data-variant='favorite']:not(:disabled):hover {
266
+ border-color: transparent;
267
+ }
268
+ &[data-variant='favorite'][data-pressed] {
269
+ background: transparent;
270
+ color: ${t.highlight};
271
+ }
272
+ &[data-variant='favorite'][data-pressed]:where(:not(:disabled)):hover {
273
+ background: ${t.hover};
274
+ color: ${t.highlight};
275
+ }
228
276
  }
229
277
  }
230
278
  `;
231
279
 
232
280
  const injectStyles = defineStyles(BUTTON_STYLE_ID, BUTTON_CSS);
233
281
 
282
+ const iconPart = (id: string, side: 'inline-start' | 'inline-end'): HTMLElement => {
283
+ const el = iconEl(id, document);
284
+ el.dataset.slot = buttonDef.slot('icon');
285
+ el.dataset.icon = side;
286
+ return el;
287
+ };
288
+
289
+ const keysPart = (keys: readonly string[] | undefined, side: 'inline-start' | 'inline-end'): HTMLElement | null =>
290
+ keys?.length ? h('span', { slot: buttonDef.slot('keys'), data: { keys: side } }, ...keys.map((key) => createKbd({ text: key }).el)) : null;
291
+
234
292
  class ButtonImpl implements ButtonHandle {
235
293
  readonly el: HTMLButtonElement;
236
294
  private readonly iconOnly: boolean;
237
295
  private readonly textNode: Text | null;
296
+ private readonly toggle: boolean;
297
+ private readonly controlled: boolean;
298
+ private readonly icon: string | undefined;
299
+ private readonly iconPressed: string | undefined;
300
+ private iconStart: HTMLElement | null;
301
+ private shownIcon: string | undefined;
238
302
  private label: string | undefined;
239
303
  private pressedState: boolean | undefined;
240
304
 
241
305
  constructor(props: ButtonProps) {
242
306
  injectStyles(document);
243
307
  const { variant, size } = buttonVariants.resolve(props);
308
+ const favorite = variant === 'favorite';
244
309
  this.iconOnly = size.startsWith('icon');
245
310
  this.label = props.label ?? props.text;
246
- this.pressedState = props.pressed;
247
- const icon = (id: string, side: 'inline-start' | 'inline-end'): HTMLElement => {
248
- const el = iconEl(id, document);
249
- el.dataset.slot = buttonDef.slot('icon');
250
- el.dataset.icon = side;
251
- return el;
252
- };
311
+ this.controlled = props.pressed !== undefined;
312
+ this.toggle = this.controlled || props.defaultPressed !== undefined || props.onPressedChange !== undefined;
313
+ this.pressedState = props.pressed ?? props.defaultPressed ?? (this.toggle ? false : undefined);
314
+ this.icon = props.icon ?? (favorite ? 'star' : undefined);
315
+ this.iconPressed = props.iconPressed ?? (favorite ? 'star-filled' : undefined);
316
+ this.iconStart = this.icon ? iconPart(this.icon, 'inline-start') : null;
317
+ this.shownIcon = this.icon;
253
318
  this.textNode = !this.iconOnly && props.text !== undefined ? document.createTextNode(props.text) : null;
319
+ const onClick = (e: MouseEvent): void => {
320
+ if (this.toggle) {
321
+ const next = !this.pressedState;
322
+ if (!this.controlled) this.setPressed(next);
323
+ props.onPressedChange?.(next);
324
+ }
325
+ props.onClick?.(e);
326
+ };
254
327
  this.el = h(
255
328
  'button',
256
329
  {
257
330
  className: props.className ? `vela-btn ${props.className}` : 'vela-btn',
258
331
  slot: buttonDef.slot('root'),
259
332
  attrs: { type: 'button', ...buttonVariants({ variant, size }) },
260
- on: props.onClick ? { click: props.onClick } : undefined,
333
+ on: this.toggle || props.onClick ? { click: onClick } : undefined,
261
334
  },
262
- props.icon ? icon(props.icon, 'inline-start') : null,
335
+ this.iconStart,
336
+ this.iconOnly ? null : keysPart(props.keys, 'inline-start'),
263
337
  this.textNode,
264
- props.iconEnd && !this.iconOnly ? icon(props.iconEnd, 'inline-end') : null,
338
+ this.iconOnly ? null : keysPart(props.keysEnd, 'inline-end'),
339
+ props.iconEnd && !this.iconOnly ? iconPart(props.iconEnd, 'inline-end') : null,
265
340
  );
266
341
  this.el.disabled = props.disabled ?? false;
267
342
  this.paint();
@@ -290,6 +365,15 @@ class ButtonImpl implements ButtonHandle {
290
365
 
291
366
  private paint(): void {
292
367
  const el = this.el;
368
+ if (this.iconStart && this.iconPressed) {
369
+ const icon = this.pressedState ? this.iconPressed : this.icon!;
370
+ if (icon !== this.shownIcon) {
371
+ const next = iconPart(icon, 'inline-start');
372
+ this.iconStart.replaceWith(next);
373
+ this.iconStart = next;
374
+ this.shownIcon = icon;
375
+ }
376
+ }
293
377
  el.toggleAttribute('data-pressed', this.pressedState === true);
294
378
  if (this.pressedState === undefined) el.removeAttribute('aria-pressed');
295
379
  else el.setAttribute('aria-pressed', String(this.pressedState));
@@ -7,6 +7,7 @@ import { iconAt } from '../lib/icons';
7
7
  import type { ChartTheme } from '../lib/tokens';
8
8
  import { css, defineStyles } from '../lib/css';
9
9
  import { defineComponent } from '../lib/define';
10
+ import { addSlot } from '../lib/h';
10
11
  import { t } from '../lib/t';
11
12
  import { Popover, type PlacementProps, type PopoverBoundary } from './popover';
12
13
 
@@ -185,6 +186,17 @@ export const CALLOUT_CSS = css`
185
186
 
186
187
  const injectStyles = defineStyles(CALLOUT_STYLE_ID, CALLOUT_CSS);
187
188
 
189
+ /** A part of the deployed panel, as {@link calloutPart} gives it. */
190
+ export type CalloutPanelPart = Exclude<(typeof calloutBubbleDef.parts)[number], 'root'>;
191
+
192
+ /** Make `el` a part of a deployed panel, with the panel's look: for a panel built without a
193
+ * bubble, such as a chart's timeline-mark popup. Returns `el`. */
194
+ export function calloutPart<E extends HTMLElement>(el: E, part: CalloutPanelPart): E {
195
+ injectStyles(el.ownerDocument);
196
+ addSlot(el, calloutBubbleDef.slot(part));
197
+ return el;
198
+ }
199
+
188
200
  export class CalloutBubble {
189
201
  readonly el: HTMLElement;
190
202
  private spec: CalloutBubbleSpec;
@@ -294,11 +306,10 @@ export class CalloutBubble {
294
306
 
295
307
  private buildPanel(body: HTMLElement, panel: CalloutPanel): void {
296
308
  const doc = body.ownerDocument;
297
- const part = <K extends keyof HTMLElementTagNameMap>(tag: K, className: string, name: (typeof calloutBubbleDef.parts)[number]): HTMLElementTagNameMap[K] => {
309
+ const part = <K extends keyof HTMLElementTagNameMap>(tag: K, className: string, name: CalloutPanelPart): HTMLElementTagNameMap[K] => {
298
310
  const el = doc.createElement(tag);
299
311
  el.className = className;
300
- el.dataset.slot = calloutBubbleDef.slot(name);
301
- return el;
312
+ return calloutPart(el, name);
302
313
  };
303
314
  const root = part('div', 'vela-callout-panel', 'panel');
304
315
  if (panel.title) {