@knime/kds-components 0.31.3 → 1.0.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/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { defineComponent, createPropsRestProxy, ref, watch, computed, openBlock, createElementBlock, normalizeClass, createElementVNode, toDisplayString, Fragment, renderList, createBlock, normalizeStyle, createCommentVNode, shallowRef, markRaw, readonly, toRef, unref, resolveDynamicComponent, mergeProps, useTemplateRef, createVNode, withCtx, renderSlot, h as h$1, useSlots, getCurrentInstance, useModel, mergeModels, onMounted, onUnmounted, nextTick, useId, withModifiers, inject, provide, resolveComponent, withKeys, watchEffect, useAttrs, defineAsyncComponent, toRefs, useCssVars, normalizeProps, guardReactiveProps, createSlots, withDirectives, vShow, onBeforeUpdate, onBeforeUnmount, isRef, vModelText, createTextVNode, effectScope } from 'vue';
1
+ import { defineComponent, createPropsRestProxy, ref, watch, computed, openBlock, createElementBlock, normalizeClass, createElementVNode, toDisplayString, Fragment, renderList, createBlock, normalizeStyle, createCommentVNode, shallowRef, markRaw, readonly, toRef, unref, resolveDynamicComponent, mergeProps, useTemplateRef, createVNode, renderSlot, createTextVNode, withCtx, h as h$1, useSlots, getCurrentInstance, useModel, mergeModels, onMounted, onUnmounted, nextTick, useId, withModifiers, inject, provide, resolveComponent, withKeys, watchEffect, useAttrs, defineAsyncComponent, toRefs, useCssVars, normalizeProps, guardReactiveProps, createSlots, withDirectives, vShow, onBeforeUpdate, onBeforeUnmount, isRef, vModelText, effectScope } from 'vue';
2
2
  import { useLocalStorage, useDark, usePreferredDark, useResizeObserver, useMutationObserver, onClickOutside, useVirtualList, useElementSize, useMousePressed, useTemplateRefsList, useEventListener } from '@vueuse/core';
3
3
 
4
4
  import './index.css';const kdsAvatarSize = {
@@ -1101,13 +1101,17 @@ const _sfc_main$1A = /* @__PURE__ */ defineComponent({
1101
1101
  }, null, 8, ["name"]),
1102
1102
  createElementVNode("div", _hoisted_3$t, toDisplayString(props.headline), 1)
1103
1103
  ]),
1104
- props.description ? (openBlock(), createElementBlock("div", _hoisted_4$p, toDisplayString(props.description), 1)) : createCommentVNode("", true)
1104
+ props.description || _ctx.$slots.default ? (openBlock(), createElementBlock("div", _hoisted_4$p, [
1105
+ renderSlot(_ctx.$slots, "default", {}, () => [
1106
+ createTextVNode(toDisplayString(props.description), 1)
1107
+ ], true)
1108
+ ])) : createCommentVNode("", true)
1105
1109
  ], 10, _hoisted_1$10);
1106
1110
  };
1107
1111
  }
1108
1112
  });
1109
1113
 
1110
- const KdsInlineMessage = /* @__PURE__ */ _export_sfc(_sfc_main$1A, [["__scopeId", "data-v-194a0dfd"]]);
1114
+ const KdsInlineMessage = /* @__PURE__ */ _export_sfc(_sfc_main$1A, [["__scopeId", "data-v-c54ea4b4"]]);
1111
1115
 
1112
1116
  const kdsInlineMessageVariant = {
1113
1117
  ERROR: "error",
@@ -2271,7 +2275,7 @@ const _sfc_main$1p = /* @__PURE__ */ defineComponent({
2271
2275
  }
2272
2276
  });
2273
2277
 
2274
- const KdsListItem = /* @__PURE__ */ _export_sfc(_sfc_main$1p, [["__scopeId", "data-v-a3d6c86f"]]);
2278
+ const KdsListItem = /* @__PURE__ */ _export_sfc(_sfc_main$1p, [["__scopeId", "data-v-a582a5cb"]]);
2275
2279
 
2276
2280
  const _hoisted_1$V = { class: "kds-list-item-section-title" };
2277
2281
  const _hoisted_2$A = {
@@ -20290,7 +20294,8 @@ const _sfc_main$J = /* @__PURE__ */ defineComponent({
20290
20294
  disabled: { type: Boolean, default: false },
20291
20295
  autocomplete: {},
20292
20296
  results: {},
20293
- resultsMaxHeight: {}
20297
+ resultsMaxHeight: {},
20298
+ leadingIcon: { default: "search" }
20294
20299
  }, {
20295
20300
  "modelValue": { default: "" },
20296
20301
  "modelModifiers": {}
@@ -20303,7 +20308,7 @@ const _sfc_main$J = /* @__PURE__ */ defineComponent({
20303
20308
  const KdsListContainer = defineAsyncComponent(
20304
20309
  () => Promise.resolve().then(() => KdsListContainer$1)
20305
20310
  );
20306
- const props = createPropsRestProxy(__props, ["placeholder", "disabled", "error", "validating", "preserveSubTextSpace"]);
20311
+ const props = createPropsRestProxy(__props, ["placeholder", "disabled", "leadingIcon", "error", "validating", "preserveSubTextSpace"]);
20307
20312
  const modelValue = useModel(__props, "modelValue");
20308
20313
  const emit = __emit;
20309
20314
  const baseInput = useTemplateRef("baseInput");
@@ -20375,7 +20380,7 @@ const _sfc_main$J = /* @__PURE__ */ defineComponent({
20375
20380
  disabled: __props.disabled,
20376
20381
  error: __props.error,
20377
20382
  autocomplete: __props.autocomplete,
20378
- "leading-icon": "search",
20383
+ "leading-icon": __props.leadingIcon,
20379
20384
  clearable: true,
20380
20385
  style: popoverEl.value?.anchorStyle,
20381
20386
  role: __props.results ? "combobox" : void 0,
@@ -20387,7 +20392,7 @@ const _sfc_main$J = /* @__PURE__ */ defineComponent({
20387
20392
  onFocus,
20388
20393
  onBlur,
20389
20394
  onClick
20390
- }), null, 16, ["modelValue", "placeholder", "disabled", "error", "autocomplete", "style", "role", "aria-activedescendant", "aria-haspopup", "aria-controls", "aria-expanded"]),
20395
+ }), null, 16, ["modelValue", "placeholder", "disabled", "error", "autocomplete", "leading-icon", "style", "role", "aria-activedescendant", "aria-haspopup", "aria-controls", "aria-expanded"]),
20391
20396
  __props.results ? (openBlock(), createBlock(unref(KdsPopover), {
20392
20397
  key: 0,
20393
20398
  ref: "popover",
@@ -20427,7 +20432,7 @@ const _sfc_main$J = /* @__PURE__ */ defineComponent({
20427
20432
  }
20428
20433
  });
20429
20434
 
20430
- const KdsSearchInput = /* @__PURE__ */ _export_sfc(_sfc_main$J, [["__scopeId", "data-v-8930f00a"]]);
20435
+ const KdsSearchInput = /* @__PURE__ */ _export_sfc(_sfc_main$J, [["__scopeId", "data-v-f7236e9c"]]);
20431
20436
 
20432
20437
  const _hoisted_1$x = ["rows", "placeholder", "disabled", "autocomplete"];
20433
20438
  const DEFAULT_ROWS = 3;
@@ -24902,7 +24907,8 @@ const kdsCardVariants = Object.values(kdsCardVariant);
24902
24907
  const kdsPanelBodyOverflow = {
24903
24908
  AUTO: "auto",
24904
24909
  HIDDEN: "hidden",
24905
- VISIBLE: "visible"
24910
+ VISIBLE: "visible",
24911
+ CLIP: "clip"
24906
24912
  };
24907
24913
  const kdsPanelBodyOverflows = Object.values(kdsPanelBodyOverflow);
24908
24914
  const kdsPanelBodyVariant = {
@@ -24945,14 +24951,14 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
24945
24951
  },
24946
24952
  setup(__props) {
24947
24953
  useCssVars((_ctx) => ({
24948
- "v2ddcad1c": _ctx.bodyOverflow
24954
+ "d76547d6": _ctx.bodyOverflow
24949
24955
  }));
24950
24956
  const headlineId = useId();
24951
24957
  const hasHeader = computed(
24952
24958
  () => Boolean(__props.headline) || Boolean(__props.headlineTrailingActions?.length)
24953
24959
  );
24954
24960
  const isBodyKeyboardFocusable = computed(
24955
- () => __props.bodyOverflow !== kdsPanelBodyOverflow.HIDDEN
24961
+ () => __props.bodyOverflow !== kdsPanelBodyOverflow.HIDDEN && __props.bodyOverflow !== kdsPanelBodyOverflow.CLIP
24956
24962
  );
24957
24963
  const bodyAriaLabel = computed(
24958
24964
  () => isBodyKeyboardFocusable.value && __props.ariaLabel ? __props.ariaLabel : void 0
@@ -25045,7 +25051,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
25045
25051
  }
25046
25052
  });
25047
25053
 
25048
- const KdsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["__scopeId", "data-v-d3124a50"]]);
25054
+ const KdsPanel = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["__scopeId", "data-v-64966fb2"]]);
25049
25055
 
25050
25056
  const _sfc_main$c = /* @__PURE__ */ defineComponent({
25051
25057
  __name: "TabBarItemAccessory",
@@ -25378,7 +25384,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
25378
25384
  }
25379
25385
  });
25380
25386
 
25381
- const LoadingSkeletonItem = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["__scopeId", "data-v-86829b28"]]);
25387
+ const LoadingSkeletonItem = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["__scopeId", "data-v-b7565402"]]);
25382
25388
 
25383
25389
  const _hoisted_1$8 = {
25384
25390
  key: 0,
@@ -25405,7 +25411,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
25405
25411
  },
25406
25412
  setup(__props) {
25407
25413
  useCssVars((_ctx) => ({
25408
- "v59c08829": _ctx.repeatGap
25414
+ "v18b57ee8": _ctx.repeatGap
25409
25415
  }));
25410
25416
  return (_ctx, _cache) => {
25411
25417
  return __props.loading ? (openBlock(), createElementBlock("div", _hoisted_1$8, [
@@ -25428,7 +25434,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
25428
25434
  shape: "label",
25429
25435
  class: "label"
25430
25436
  }),
25431
- createVNode(LoadingSkeletonItem, { shape: "input-with-label" })
25437
+ createVNode(LoadingSkeletonItem, { shape: "input" })
25432
25438
  ])) : __props.variant?.startsWith("list-item-") ? (openBlock(), createElementBlock("div", {
25433
25439
  key: 2,
25434
25440
  class: normalizeClass([
@@ -25463,7 +25469,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
25463
25469
  }
25464
25470
  });
25465
25471
 
25466
- const KdsLoadingSkeleton = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__scopeId", "data-v-e6597718"]]);
25472
+ const KdsLoadingSkeleton = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__scopeId", "data-v-326c25f0"]]);
25467
25473
 
25468
25474
  const loadingSkeletonItemShape = {
25469
25475
  TEXT: "text",
@@ -25476,10 +25482,11 @@ const loadingSkeletonItemShape = {
25476
25482
  BUTTON_SMALL: "button-small",
25477
25483
  BUTTON_XSMALL: "button-xsmall",
25478
25484
  CARD: "card",
25479
- INPUT_WITH_LABEL: "input-with-label"
25485
+ INPUT: "input"
25480
25486
  };
25481
25487
  const kdsLoadingSkeletonVariant = {
25482
25488
  ...loadingSkeletonItemShape,
25489
+ INPUT_WITH_LABEL: "input-with-label",
25483
25490
  HEADLINE_WITH_PARAGRAPH: "headline-with-paragraph",
25484
25491
  LIST_ITEM_LARGE: "list-item-large",
25485
25492
  LIST_ITEM_LARGE_WITH_SUBTEXT: "list-item-large-with-subtext",
@@ -25934,7 +25941,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
25934
25941
  },
25935
25942
  setup(__props) {
25936
25943
  useCssVars((_ctx) => ({
25937
- "v81addf0a": _ctx.overflow
25944
+ "d8a22254": _ctx.overflow
25938
25945
  }));
25939
25946
  const props = createPropsRestProxy(__props, ["headline", "variant", "overflow"]);
25940
25947
  return (_ctx, _cache) => {
@@ -25969,7 +25976,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
25969
25976
  }
25970
25977
  });
25971
25978
 
25972
- const KdsModalLayout = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-62740dc9"]]);
25979
+ const KdsModalLayout = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-36cbff95"]]);
25973
25980
 
25974
25981
  const _hoisted_1$3 = ["closedby"];
25975
25982
  const _sfc_main$3 = /* @__PURE__ */ defineComponent({
@@ -26448,6 +26455,106 @@ const vKdsTooltip = {
26448
26455
  }
26449
26456
  };
26450
26457
 
26458
+ const typeToComponent = {
26459
+ KdsButton: _sfc_main$1v,
26460
+ KdsLinkButton: _sfc_main$1u,
26461
+ KdsSplitButton,
26462
+ KdsMenuButton: _sfc_main$1k,
26463
+ KdsProgressButton,
26464
+ KdsToggleButton: _sfc_main$1s
26465
+ };
26466
+ const fullBindings = (entry) => ({
26467
+ ...entry.meta
26468
+ });
26469
+ const iconOnlyBindings = (entry, leadingIcon, ariaLabel) => {
26470
+ const {
26471
+ label: _label,
26472
+ trailingIcon: _trailingIcon,
26473
+ ariaLabel: _ariaLabel,
26474
+ title,
26475
+ leadingIcon: _leadingIcon,
26476
+ ...rest
26477
+ } = entry.meta;
26478
+ return {
26479
+ ...rest,
26480
+ leadingIcon,
26481
+ ariaLabel,
26482
+ title: title ?? ariaLabel
26483
+ };
26484
+ };
26485
+ const hasLeadingIcon = (entry) => "leadingIcon" in entry.meta && Boolean(entry.meta.leadingIcon);
26486
+ const isIconCapable = (entry) => entry.canBeIconOnly !== false && hasLeadingIcon(entry);
26487
+ const accessoryFor = (entry) => "leadingIcon" in entry.meta && entry.meta.leadingIcon ? { type: "icon", name: entry.meta.leadingIcon } : void 0;
26488
+ const toMenuItem = (entry) => {
26489
+ switch (entry.type) {
26490
+ case "KdsButton":
26491
+ return {
26492
+ id: entry.id,
26493
+ text: entry.meta.label,
26494
+ disabled: entry.meta.disabled,
26495
+ accessory: accessoryFor(entry),
26496
+ handler: (_item, ev) => entry.handler(entry, ev)
26497
+ };
26498
+ case "KdsProgressButton":
26499
+ return {
26500
+ id: entry.id,
26501
+ text: entry.meta.label,
26502
+ disabled: entry.meta.disabled,
26503
+ accessory: accessoryFor(entry),
26504
+ handler: (_item, ev) => entry.handler(entry, ev)
26505
+ };
26506
+ case "KdsToggleButton":
26507
+ return {
26508
+ id: entry.id,
26509
+ text: entry.meta.label,
26510
+ disabled: entry.meta.disabled,
26511
+ accessory: accessoryFor(entry),
26512
+ trailingIcon: entry.meta.modelValue ? "checkmark" : void 0,
26513
+ handler: () => entry.handler(entry, !entry.meta.modelValue)
26514
+ };
26515
+ case "KdsLinkButton":
26516
+ return {
26517
+ id: entry.id,
26518
+ text: entry.meta.label,
26519
+ disabled: entry.meta.disabled,
26520
+ accessory: accessoryFor(entry),
26521
+ to: entry.meta.to,
26522
+ target: entry.meta.target,
26523
+ rel: entry.meta.rel,
26524
+ download: entry.meta.download
26525
+ };
26526
+ case "KdsSplitButton":
26527
+ return {
26528
+ id: entry.id,
26529
+ text: entry.meta.label,
26530
+ disabled: entry.meta.disabled,
26531
+ accessory: accessoryFor(entry),
26532
+ children: [
26533
+ {
26534
+ id: `${entry.id}__primary`,
26535
+ text: entry.meta.label,
26536
+ accessory: accessoryFor(entry),
26537
+ separator: true,
26538
+ handler: (_item, ev) => entry.handler(entry, ev)
26539
+ },
26540
+ ...entry.meta.items
26541
+ ]
26542
+ };
26543
+ case "KdsMenuButton":
26544
+ return {
26545
+ id: entry.id,
26546
+ text: entry.meta.label,
26547
+ disabled: entry.meta.disabled,
26548
+ accessory: accessoryFor(entry),
26549
+ children: entry.meta.items
26550
+ };
26551
+ default: {
26552
+ const _exhaustive = entry;
26553
+ return _exhaustive;
26554
+ }
26555
+ }
26556
+ };
26557
+
26451
26558
  const _hoisted_1$1 = {
26452
26559
  ref: "measureContainer",
26453
26560
  class: "kds-button-group-measure",
@@ -26461,77 +26568,138 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
26461
26568
  buttons: {},
26462
26569
  alignment: { default: "left" }
26463
26570
  },
26464
- emits: ["buttonClick"],
26465
- setup(__props, { emit: __emit }) {
26466
- const emit = __emit;
26571
+ setup(__props) {
26467
26572
  const measureContainerEl = useTemplateRef("measureContainer");
26468
- const measureButtonEls = useTemplateRef("measureButton");
26573
+ const measureFullEls = useTemplateRef("measureFullEntry");
26574
+ const measureIconEls = useTemplateRef("measureIconEntry");
26469
26575
  const measureMenuButtonEl = useTemplateRef("measureMenuButton");
26470
26576
  const buttonsContainerEl = useTemplateRef("buttonsContainer");
26471
26577
  const { width: containerWidth } = useElementSize(buttonsContainerEl);
26472
26578
  const gap = ref(0);
26473
- const buttonWidths = ref([]);
26579
+ const fullWidths = ref([]);
26580
+ const iconOnlyWidths = ref([]);
26474
26581
  const menuButtonWidth = ref(0);
26475
- const splitIndex = computed(() => {
26476
- const availableSpace = containerWidth.value;
26477
- const widths = buttonWidths.value;
26478
- const buttonsCount = __props.buttons.length;
26479
- if (!availableSpace || buttonsCount === 0) {
26480
- return 0;
26481
- }
26482
- let buttonsWidth = 0;
26483
- for (let i = 0; i < buttonsCount; i++) {
26484
- if (i > 0) {
26485
- buttonsWidth += gap.value;
26582
+ const iconOnlyEligibleEntries = computed(() => {
26583
+ const result = [];
26584
+ __props.buttons.forEach((entry, index) => {
26585
+ if (!isIconCapable(entry)) {
26586
+ return;
26486
26587
  }
26487
- buttonsWidth += widths[i] ?? 0;
26488
- }
26489
- if (buttonsWidth <= availableSpace) {
26490
- return buttonsCount;
26491
- }
26492
- let usedWidth = menuButtonWidth.value;
26493
- let count = 0;
26494
- for (let i = 0; i < buttonsCount; i++) {
26495
- const buttonWidth = widths[i] ?? 0;
26496
- const gapBefore = count > 0 ? gap.value : 0;
26497
- const gapAfterForMenu = gap.value;
26498
- const totalWidth = usedWidth + gapBefore + buttonWidth + gapAfterForMenu;
26499
- if (totalWidth > availableSpace) {
26500
- break;
26588
+ const meta = entry.meta;
26589
+ if (!meta.leadingIcon) {
26590
+ return;
26501
26591
  }
26502
- usedWidth += gapBefore + buttonWidth;
26503
- count++;
26504
- }
26505
- return count;
26592
+ result.push({
26593
+ entry,
26594
+ index,
26595
+ leadingIcon: meta.leadingIcon,
26596
+ label: meta.label
26597
+ });
26598
+ });
26599
+ return result;
26506
26600
  });
26507
- const visibleButtons = computed(() => {
26508
- return __props.buttons.slice(0, splitIndex.value);
26601
+ const layout = computed(() => {
26602
+ const available = containerWidth.value;
26603
+ const n = __props.buttons.length;
26604
+ if (n === 0) {
26605
+ return { mode: "full", inMenu: /* @__PURE__ */ new Set() };
26606
+ }
26607
+ const gapTotal = (count) => gap.value * Math.max(0, count - 1);
26608
+ const sumFull = fullWidths.value.reduce((acc, w) => acc + (w ?? 0), 0) + gapTotal(n);
26609
+ if (!available || sumFull <= available) {
26610
+ return { mode: "full", inMenu: /* @__PURE__ */ new Set() };
26611
+ }
26612
+ const effectiveWidths = __props.buttons.map(
26613
+ (entry, i) => isIconCapable(entry) ? iconOnlyWidths.value[i] ?? fullWidths.value[i] ?? 0 : fullWidths.value[i] ?? 0
26614
+ );
26615
+ const sumCollapsed = effectiveWidths.reduce((acc, w) => acc + w, 0) + gapTotal(n);
26616
+ if (sumCollapsed <= available) {
26617
+ return { mode: "icon-only", inMenu: /* @__PURE__ */ new Set() };
26618
+ }
26619
+ const inMenu = /* @__PURE__ */ new Set();
26620
+ for (let i = n - 1; i >= 0; i--) {
26621
+ if (__props.buttons[i].canMoveToMenu === false) {
26622
+ continue;
26623
+ }
26624
+ inMenu.add(i);
26625
+ let visibleSum = 0;
26626
+ let visibleCount = 0;
26627
+ for (let j = 0; j < n; j++) {
26628
+ if (inMenu.has(j)) {
26629
+ continue;
26630
+ }
26631
+ visibleSum += effectiveWidths[j];
26632
+ visibleCount++;
26633
+ }
26634
+ const width = visibleSum + gapTotal(visibleCount) + menuButtonWidth.value + (visibleCount > 0 ? gap.value : 0);
26635
+ if (width <= available) {
26636
+ return { mode: "partial", inMenu };
26637
+ }
26638
+ }
26639
+ return { mode: "overflow", inMenu };
26509
26640
  });
26510
- const overflowButtons = computed(() => {
26511
- return __props.buttons.slice(splitIndex.value);
26641
+ const visibleEntries = computed(() => {
26642
+ const collapseIcons = layout.value.mode !== "full";
26643
+ const result = [];
26644
+ __props.buttons.forEach((entry, index) => {
26645
+ if (layout.value.inMenu.has(index)) {
26646
+ return;
26647
+ }
26648
+ const meta = entry.meta;
26649
+ const iconOnly = collapseIcons && isIconCapable(entry) && meta.leadingIcon ? { leadingIcon: meta.leadingIcon, ariaLabel: meta.label } : void 0;
26650
+ result.push({ entry, iconOnly });
26651
+ });
26652
+ return result;
26512
26653
  });
26513
26654
  const overflowMenuItems = computed(() => {
26514
- return overflowButtons.value.map((a) => ({
26515
- id: a.id,
26516
- text: a.label,
26517
- disabled: a.disabled,
26518
- accessory: a.leadingIcon ? { type: "icon", name: a.leadingIcon } : void 0
26519
- }));
26655
+ const indices = Array.from(layout.value.inMenu).sort((a, b) => a - b);
26656
+ return indices.map((i) => toMenuItem(__props.buttons[i]));
26520
26657
  });
26521
- const onMenuItemClick = (id) => {
26522
- if (id) {
26523
- emit("buttonClick", id);
26658
+ const refOffsetWidth = (instance) => {
26659
+ if (!instance) {
26660
+ return 0;
26524
26661
  }
26662
+ if (instance.menuButtonEl?.$el) {
26663
+ return instance.menuButtonEl.$el.offsetWidth ?? 0;
26664
+ }
26665
+ return instance.$el?.offsetWidth ?? 0;
26525
26666
  };
26526
26667
  const measureButtons = async () => {
26527
26668
  await nextTick();
26528
26669
  if (!measureContainerEl.value) {
26529
26670
  return;
26530
26671
  }
26531
- buttonWidths.value = Array.from(measureButtonEls.value ?? []).map(
26532
- (button) => button?.$el.offsetWidth
26533
- );
26534
- menuButtonWidth.value = measureMenuButtonEl.value?.menuButtonEl?.$el.offsetWidth ?? 0;
26672
+ fullWidths.value = Array.from(measureFullEls.value ?? []).map(refOffsetWidth);
26673
+ const iconWidthByIndex = new Array(__props.buttons.length);
26674
+ const eligibleIndices = iconOnlyEligibleEntries.value.map((e) => e.index);
26675
+ const iconRefs = Array.from(measureIconEls.value ?? []);
26676
+ eligibleIndices.forEach((buttonIndex, measureIndex) => {
26677
+ iconWidthByIndex[buttonIndex] = refOffsetWidth(iconRefs[measureIndex]);
26678
+ });
26679
+ iconOnlyWidths.value = iconWidthByIndex;
26680
+ menuButtonWidth.value = refOffsetWidth(measureMenuButtonEl.value);
26681
+ };
26682
+ const visibleBindings = (visible) => {
26683
+ const base = visible.iconOnly ? iconOnlyBindings(
26684
+ visible.entry,
26685
+ visible.iconOnly.leadingIcon,
26686
+ visible.iconOnly.ariaLabel
26687
+ ) : fullBindings(visible.entry);
26688
+ const entry = visible.entry;
26689
+ if (entry.type === "KdsToggleButton") {
26690
+ return {
26691
+ ...base,
26692
+ "onUpdate:modelValue": (next) => entry.handler(entry, next)
26693
+ };
26694
+ }
26695
+ if ("handler" in entry && typeof entry.handler === "function") {
26696
+ const handler = entry.handler;
26697
+ return {
26698
+ ...base,
26699
+ onClick: (ev) => handler(entry, ev)
26700
+ };
26701
+ }
26702
+ return base;
26535
26703
  };
26536
26704
  watch(() => __props.buttons, measureButtons, { deep: true });
26537
26705
  onMounted(() => {
@@ -26544,14 +26712,22 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
26544
26712
  return openBlock(), createElementBlock(Fragment, null, [
26545
26713
  createElementVNode("div", _hoisted_1$1, [
26546
26714
  (openBlock(true), createElementBlock(Fragment, null, renderList(__props.buttons, (button) => {
26547
- return openBlock(), createBlock(_sfc_main$1v, {
26715
+ return openBlock(), createBlock(resolveDynamicComponent(unref(typeToComponent)[button.type]), mergeProps({
26716
+ key: `full-${button.id}`,
26548
26717
  ref_for: true,
26549
- ref: "measureButton",
26550
- key: button.id,
26551
- label: button.label,
26552
- variant: button.variant ?? "outlined",
26553
- "leading-icon": button.leadingIcon
26554
- }, null, 8, ["label", "variant", "leading-icon"]);
26718
+ ref: "measureFullEntry"
26719
+ }, { ref_for: true }, unref(fullBindings)(button)), null, 16);
26720
+ }), 128)),
26721
+ (openBlock(true), createElementBlock(Fragment, null, renderList(iconOnlyEligibleEntries.value, (iconItem) => {
26722
+ return openBlock(), createBlock(resolveDynamicComponent(unref(typeToComponent)[iconItem.entry.type]), mergeProps(
26723
+ {
26724
+ key: `icon-${iconItem.entry.id}`,
26725
+ ref_for: true,
26726
+ ref: "measureIconEntry"
26727
+ },
26728
+ { ref_for: true },
26729
+ unref(iconOnlyBindings)(iconItem.entry, iconItem.leadingIcon, iconItem.label)
26730
+ ), null, 16);
26555
26731
  }), 128)),
26556
26732
  createVNode(_sfc_main$1k, {
26557
26733
  ref: "measureMenuButton",
@@ -26563,24 +26739,16 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
26563
26739
  createElementVNode("div", mergeProps({ ref: "buttonsContainer" }, _ctx.$attrs, {
26564
26740
  class: ["kds-button-group", __props.alignment]
26565
26741
  }), [
26566
- (openBlock(true), createElementBlock(Fragment, null, renderList(visibleButtons.value, (button) => {
26567
- return openBlock(), createBlock(_sfc_main$1v, {
26568
- key: button.id,
26569
- label: button.label,
26570
- variant: button.variant ?? "outlined",
26571
- disabled: button.disabled,
26572
- "leading-icon": button.leadingIcon,
26573
- destructive: button.destructive,
26574
- title: button.title,
26575
- onClick: ($event) => emit("buttonClick", button.id)
26576
- }, null, 8, ["label", "variant", "disabled", "leading-icon", "destructive", "title", "onClick"]);
26742
+ (openBlock(true), createElementBlock(Fragment, null, renderList(visibleEntries.value, (visible) => {
26743
+ return openBlock(), createBlock(resolveDynamicComponent(unref(typeToComponent)[visible.entry.type]), mergeProps({
26744
+ key: visible.entry.id
26745
+ }, { ref_for: true }, visibleBindings(visible)), null, 16);
26577
26746
  }), 128)),
26578
- overflowButtons.value.length ? (openBlock(), createBlock(_sfc_main$1k, {
26747
+ overflowMenuItems.value.length ? (openBlock(), createBlock(_sfc_main$1k, {
26579
26748
  key: 0,
26580
26749
  "leading-icon": "more-actions",
26581
26750
  ariaLabel: "More actions",
26582
- items: overflowMenuItems.value,
26583
- onItemClick: onMenuItemClick
26751
+ items: overflowMenuItems.value
26584
26752
  }, null, 8, ["items"])) : createCommentVNode("", true)
26585
26753
  ], 16)
26586
26754
  ], 64);
@@ -26588,7 +26756,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
26588
26756
  }
26589
26757
  });
26590
26758
 
26591
- const KdsResponsiveButtonGroup = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-a945c295"]]);
26759
+ const KdsResponsiveButtonGroup = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-ccdbc564"]]);
26592
26760
 
26593
26761
  const kdsResponsiveButtonGroupAlignment = {
26594
26762
  LEFT: "left",