@knime/kds-components 0.31.4 → 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/CHANGELOG.md +18 -0
- package/dist/index.css +38 -38
- package/dist/index.js +235 -74
- package/dist/index.js.map +1 -1
- package/dist/src/patterns/ResponsiveButtonGroup/KdsResponsiveButtonGroup.vue.d.ts +37 -91
- package/dist/src/patterns/ResponsiveButtonGroup/KdsResponsiveButtonGroup.vue.d.ts.map +1 -1
- package/dist/src/patterns/ResponsiveButtonGroup/mapping.d.ts +150 -0
- package/dist/src/patterns/ResponsiveButtonGroup/mapping.d.ts.map +1 -0
- package/dist/src/patterns/ResponsiveButtonGroup/types.d.ts +93 -8
- package/dist/src/patterns/ResponsiveButtonGroup/types.d.ts.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @knime/kds-components
|
|
2
2
|
|
|
3
|
+
## 1.0.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- a05b472: `KdsResponsiveButtonGroup`: accept five new entry types in addition to `KdsButton` — `KdsLinkButton`, `KdsSplitButton`, `KdsMenuButton`, `KdsProgressButton`, `KdsToggleButton`. Split/menu buttons collapse into the overflow menu as submenus; toggle button's `modelValue` state maps to a checkmark trailing icon to represent toggled state.
|
|
8
|
+
|
|
9
|
+
**Breaking**: the group's `buttonClick(id)` event is removed. Each entry now carries a top-level `handler: (entry, event) => void` (required where the underlying button has a primary click affordance; forbidden on link and menu-button entries). Existing call sites should move their click handling from the group-level event listener into per-entry handlers.
|
|
10
|
+
|
|
11
|
+
Style: Improve responsive behavior;
|
|
12
|
+
- First collapse buttons to icon-only (only applies to buttons with icons)
|
|
13
|
+
- If there is still not enough space, hide buttons behind a menu
|
|
14
|
+
- Possible to configure certain buttons that don't collapse or hide
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- 8f7a331: KdsListItem: Fix vertical text alignment
|
|
19
|
+
- @knime/kds-styles@1.0.0
|
|
20
|
+
|
|
3
21
|
## 0.31.4
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/dist/index.css
CHANGED
|
@@ -996,7 +996,7 @@ html.kds-legacy {
|
|
|
996
996
|
}
|
|
997
997
|
|
|
998
998
|
.kds-list-item {
|
|
999
|
-
&[data-v-
|
|
999
|
+
&[data-v-a582a5cb] {
|
|
1000
1000
|
position: relative;
|
|
1001
1001
|
display: flex;
|
|
1002
1002
|
flex-shrink: 0;
|
|
@@ -1013,36 +1013,36 @@ html.kds-legacy {
|
|
|
1013
1013
|
border-radius: var(--kds-border-radius-container-0-31x);
|
|
1014
1014
|
}
|
|
1015
1015
|
&.small {
|
|
1016
|
-
&[data-v-
|
|
1016
|
+
&[data-v-a582a5cb] {
|
|
1017
1017
|
gap: var(--kds-spacing-container-0-25x);
|
|
1018
|
-
align-items: flex-start;
|
|
1019
1018
|
padding: var(--kds-spacing-container-0-25x)
|
|
1020
1019
|
var(--kds-spacing-container-0-5x);
|
|
1021
1020
|
font: var(--kds-font-base-interactive-small);
|
|
1022
1021
|
}
|
|
1023
|
-
.accessory[data-v-
|
|
1022
|
+
.accessory[data-v-a582a5cb] {
|
|
1024
1023
|
display: flex;
|
|
1025
1024
|
padding: var(--kds-spacing-container-0-12x) 0;
|
|
1025
|
+
margin-bottom: auto;
|
|
1026
1026
|
}
|
|
1027
1027
|
}
|
|
1028
1028
|
&.large {
|
|
1029
|
-
&[data-v-
|
|
1029
|
+
&[data-v-a582a5cb] {
|
|
1030
1030
|
font: var(--kds-font-base-interactive-small-strong);
|
|
1031
1031
|
}
|
|
1032
|
-
.accessory[data-v-
|
|
1032
|
+
.accessory[data-v-a582a5cb] {
|
|
1033
1033
|
display: flex;
|
|
1034
1034
|
align-items: center;
|
|
1035
1035
|
}
|
|
1036
1036
|
}
|
|
1037
1037
|
.content {
|
|
1038
|
-
&[data-v-
|
|
1038
|
+
&[data-v-a582a5cb] {
|
|
1039
1039
|
display: flex;
|
|
1040
1040
|
flex: 1 1 auto;
|
|
1041
1041
|
flex-direction: column;
|
|
1042
1042
|
gap: var(--kds-spacing-container-0-12x);
|
|
1043
1043
|
min-width: 0;
|
|
1044
1044
|
}
|
|
1045
|
-
.large &[data-v-
|
|
1045
|
+
.large &[data-v-a582a5cb] {
|
|
1046
1046
|
justify-content: center;
|
|
1047
1047
|
min-height: calc(
|
|
1048
1048
|
var(--kds-dimension-component-height-2-5x) - 2 *
|
|
@@ -1050,19 +1050,19 @@ html.kds-legacy {
|
|
|
1050
1050
|
);
|
|
1051
1051
|
}
|
|
1052
1052
|
.label {
|
|
1053
|
-
&[data-v-
|
|
1053
|
+
&[data-v-a582a5cb] {
|
|
1054
1054
|
overflow: hidden;
|
|
1055
1055
|
text-overflow: ellipsis;
|
|
1056
1056
|
white-space: nowrap;
|
|
1057
1057
|
}
|
|
1058
|
-
.prefix[data-v-
|
|
1058
|
+
.prefix[data-v-a582a5cb] {
|
|
1059
1059
|
flex-shrink: 0;
|
|
1060
1060
|
}
|
|
1061
|
-
.special[data-v-
|
|
1061
|
+
.special[data-v-a582a5cb] {
|
|
1062
1062
|
font: var(--kds-font-base-interactive-small-italic);
|
|
1063
1063
|
}
|
|
1064
1064
|
}
|
|
1065
|
-
.subtext[data-v-
|
|
1065
|
+
.subtext[data-v-a582a5cb] {
|
|
1066
1066
|
display: -webkit-box;
|
|
1067
1067
|
overflow: hidden;
|
|
1068
1068
|
-webkit-line-clamp: 2;
|
|
@@ -1073,7 +1073,7 @@ html.kds-legacy {
|
|
|
1073
1073
|
}
|
|
1074
1074
|
}
|
|
1075
1075
|
.trailing-item {
|
|
1076
|
-
&[data-v-
|
|
1076
|
+
&[data-v-a582a5cb] {
|
|
1077
1077
|
display: flex;
|
|
1078
1078
|
flex-shrink: 0;
|
|
1079
1079
|
gap: var(--kds-spacing-container-0-12x);
|
|
@@ -1081,69 +1081,69 @@ html.kds-legacy {
|
|
|
1081
1081
|
align-self: center;
|
|
1082
1082
|
justify-content: flex-end;
|
|
1083
1083
|
}
|
|
1084
|
-
.shortcut[data-v-
|
|
1084
|
+
.shortcut[data-v-a582a5cb] {
|
|
1085
1085
|
flex-shrink: 0;
|
|
1086
1086
|
font: var(--kds-font-base-interactive-xsmall-strong);
|
|
1087
1087
|
color: var(--kds-color-text-and-icon-muted);
|
|
1088
1088
|
text-align: right;
|
|
1089
1089
|
white-space: nowrap;
|
|
1090
1090
|
}
|
|
1091
|
-
.trailing-item-reserve-space[data-v-
|
|
1091
|
+
.trailing-item-reserve-space[data-v-a582a5cb] {
|
|
1092
1092
|
width: var(--kds-dimension-icon-0-75x);
|
|
1093
1093
|
}
|
|
1094
1094
|
}
|
|
1095
|
-
&[data-v-
|
|
1096
|
-
&.active[data-v-
|
|
1095
|
+
&[data-v-a582a5cb]:hover:not(.disabled),
|
|
1096
|
+
&.active[data-v-a582a5cb]:not(.disabled) {
|
|
1097
1097
|
background: var(--kds-color-background-neutral-hover);
|
|
1098
1098
|
}
|
|
1099
|
-
&[data-v-
|
|
1099
|
+
&[data-v-a582a5cb]:active:not(.disabled) {
|
|
1100
1100
|
background: var(--kds-color-background-neutral-active);
|
|
1101
1101
|
}
|
|
1102
1102
|
&.selected {
|
|
1103
|
-
&[data-v-
|
|
1103
|
+
&[data-v-a582a5cb] {
|
|
1104
1104
|
color: var(--kds-color-text-and-icon-selected);
|
|
1105
1105
|
background: var(--kds-color-background-selected-initial);
|
|
1106
1106
|
}
|
|
1107
|
-
.subtext[data-v-
|
|
1107
|
+
.subtext[data-v-a582a5cb] {
|
|
1108
1108
|
color: var(--kds-color-text-and-icon-selected);
|
|
1109
1109
|
}
|
|
1110
|
-
&[data-v-
|
|
1111
|
-
&.active[data-v-
|
|
1110
|
+
&[data-v-a582a5cb]:hover,
|
|
1111
|
+
&.active[data-v-a582a5cb] {
|
|
1112
1112
|
background: var(--kds-color-background-selected-hover);
|
|
1113
1113
|
}
|
|
1114
|
-
&[data-v-
|
|
1114
|
+
&[data-v-a582a5cb]:active {
|
|
1115
1115
|
background: var(--kds-color-background-selected-active);
|
|
1116
1116
|
}
|
|
1117
|
-
&.disabled[data-v-
|
|
1117
|
+
&.disabled[data-v-a582a5cb] {
|
|
1118
1118
|
background: var(--kds-color-background-selected-initial);
|
|
1119
1119
|
}
|
|
1120
1120
|
}
|
|
1121
1121
|
&.missing {
|
|
1122
|
-
&[data-v-
|
|
1122
|
+
&[data-v-a582a5cb] {
|
|
1123
1123
|
color: var(--kds-color-text-and-icon-danger);
|
|
1124
1124
|
background: var(--kds-color-background-danger-initial);
|
|
1125
1125
|
}
|
|
1126
|
-
.subtext[data-v-
|
|
1126
|
+
.subtext[data-v-a582a5cb] {
|
|
1127
1127
|
color: var(--kds-color-text-and-icon-danger);
|
|
1128
1128
|
}
|
|
1129
|
-
&[data-v-
|
|
1130
|
-
&.active[data-v-
|
|
1129
|
+
&[data-v-a582a5cb]:hover,
|
|
1130
|
+
&.active[data-v-a582a5cb] {
|
|
1131
1131
|
background: var(--kds-color-background-danger-hover);
|
|
1132
1132
|
}
|
|
1133
|
-
&[data-v-
|
|
1133
|
+
&[data-v-a582a5cb]:active {
|
|
1134
1134
|
background: var(--kds-color-background-danger-active);
|
|
1135
1135
|
}
|
|
1136
|
-
&.disabled[data-v-
|
|
1136
|
+
&.disabled[data-v-a582a5cb] {
|
|
1137
1137
|
background: var(--kds-color-background-danger-initial);
|
|
1138
1138
|
}
|
|
1139
1139
|
}
|
|
1140
1140
|
&.disabled {
|
|
1141
|
-
&[data-v-
|
|
1141
|
+
&[data-v-a582a5cb] {
|
|
1142
1142
|
color: var(--kds-color-text-and-icon-disabled);
|
|
1143
1143
|
cursor: default;
|
|
1144
1144
|
}
|
|
1145
|
-
.shortcut[data-v-
|
|
1146
|
-
.subtext[data-v-
|
|
1145
|
+
.shortcut[data-v-a582a5cb],
|
|
1146
|
+
.subtext[data-v-a582a5cb] {
|
|
1147
1147
|
color: var(--kds-color-text-and-icon-disabled);
|
|
1148
1148
|
}
|
|
1149
1149
|
}
|
|
@@ -4538,7 +4538,7 @@ body:has(dialog.modal[open]) {
|
|
|
4538
4538
|
var(--kds-spacing-container-0-25x) 0;
|
|
4539
4539
|
}
|
|
4540
4540
|
|
|
4541
|
-
.kds-button-group-measure[data-v-
|
|
4541
|
+
.kds-button-group-measure[data-v-ccdbc564] {
|
|
4542
4542
|
position: absolute;
|
|
4543
4543
|
display: flex;
|
|
4544
4544
|
visibility: hidden;
|
|
@@ -4546,20 +4546,20 @@ body:has(dialog.modal[open]) {
|
|
|
4546
4546
|
white-space: nowrap;
|
|
4547
4547
|
}
|
|
4548
4548
|
.kds-button-group {
|
|
4549
|
-
&[data-v-
|
|
4549
|
+
&[data-v-ccdbc564] {
|
|
4550
4550
|
display: flex;
|
|
4551
4551
|
gap: var(--kds-spacing-container-0-5x);
|
|
4552
4552
|
align-items: center;
|
|
4553
4553
|
justify-content: flex-end;
|
|
4554
4554
|
width: 100%;
|
|
4555
4555
|
}
|
|
4556
|
-
&.left[data-v-
|
|
4556
|
+
&.left[data-v-ccdbc564] {
|
|
4557
4557
|
justify-content: flex-start;
|
|
4558
4558
|
}
|
|
4559
|
-
&.right[data-v-
|
|
4559
|
+
&.right[data-v-ccdbc564] {
|
|
4560
4560
|
justify-content: flex-end;
|
|
4561
4561
|
}
|
|
4562
|
-
&.middle[data-v-
|
|
4562
|
+
&.middle[data-v-ccdbc564] {
|
|
4563
4563
|
justify-content: center;
|
|
4564
4564
|
}
|
|
4565
4565
|
}
|
package/dist/index.js
CHANGED
|
@@ -2275,7 +2275,7 @@ const _sfc_main$1p = /* @__PURE__ */ defineComponent({
|
|
|
2275
2275
|
}
|
|
2276
2276
|
});
|
|
2277
2277
|
|
|
2278
|
-
const KdsListItem = /* @__PURE__ */ _export_sfc(_sfc_main$1p, [["__scopeId", "data-v-
|
|
2278
|
+
const KdsListItem = /* @__PURE__ */ _export_sfc(_sfc_main$1p, [["__scopeId", "data-v-a582a5cb"]]);
|
|
2279
2279
|
|
|
2280
2280
|
const _hoisted_1$V = { class: "kds-list-item-section-title" };
|
|
2281
2281
|
const _hoisted_2$A = {
|
|
@@ -26455,6 +26455,106 @@ const vKdsTooltip = {
|
|
|
26455
26455
|
}
|
|
26456
26456
|
};
|
|
26457
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
|
+
|
|
26458
26558
|
const _hoisted_1$1 = {
|
|
26459
26559
|
ref: "measureContainer",
|
|
26460
26560
|
class: "kds-button-group-measure",
|
|
@@ -26468,77 +26568,138 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
26468
26568
|
buttons: {},
|
|
26469
26569
|
alignment: { default: "left" }
|
|
26470
26570
|
},
|
|
26471
|
-
|
|
26472
|
-
setup(__props, { emit: __emit }) {
|
|
26473
|
-
const emit = __emit;
|
|
26571
|
+
setup(__props) {
|
|
26474
26572
|
const measureContainerEl = useTemplateRef("measureContainer");
|
|
26475
|
-
const
|
|
26573
|
+
const measureFullEls = useTemplateRef("measureFullEntry");
|
|
26574
|
+
const measureIconEls = useTemplateRef("measureIconEntry");
|
|
26476
26575
|
const measureMenuButtonEl = useTemplateRef("measureMenuButton");
|
|
26477
26576
|
const buttonsContainerEl = useTemplateRef("buttonsContainer");
|
|
26478
26577
|
const { width: containerWidth } = useElementSize(buttonsContainerEl);
|
|
26479
26578
|
const gap = ref(0);
|
|
26480
|
-
const
|
|
26579
|
+
const fullWidths = ref([]);
|
|
26580
|
+
const iconOnlyWidths = ref([]);
|
|
26481
26581
|
const menuButtonWidth = ref(0);
|
|
26482
|
-
const
|
|
26483
|
-
const
|
|
26484
|
-
|
|
26485
|
-
|
|
26486
|
-
|
|
26487
|
-
return 0;
|
|
26488
|
-
}
|
|
26489
|
-
let buttonsWidth = 0;
|
|
26490
|
-
for (let i = 0; i < buttonsCount; i++) {
|
|
26491
|
-
if (i > 0) {
|
|
26492
|
-
buttonsWidth += gap.value;
|
|
26582
|
+
const iconOnlyEligibleEntries = computed(() => {
|
|
26583
|
+
const result = [];
|
|
26584
|
+
__props.buttons.forEach((entry, index) => {
|
|
26585
|
+
if (!isIconCapable(entry)) {
|
|
26586
|
+
return;
|
|
26493
26587
|
}
|
|
26494
|
-
|
|
26495
|
-
|
|
26496
|
-
|
|
26497
|
-
return buttonsCount;
|
|
26498
|
-
}
|
|
26499
|
-
let usedWidth = menuButtonWidth.value;
|
|
26500
|
-
let count = 0;
|
|
26501
|
-
for (let i = 0; i < buttonsCount; i++) {
|
|
26502
|
-
const buttonWidth = widths[i] ?? 0;
|
|
26503
|
-
const gapBefore = count > 0 ? gap.value : 0;
|
|
26504
|
-
const gapAfterForMenu = gap.value;
|
|
26505
|
-
const totalWidth = usedWidth + gapBefore + buttonWidth + gapAfterForMenu;
|
|
26506
|
-
if (totalWidth > availableSpace) {
|
|
26507
|
-
break;
|
|
26588
|
+
const meta = entry.meta;
|
|
26589
|
+
if (!meta.leadingIcon) {
|
|
26590
|
+
return;
|
|
26508
26591
|
}
|
|
26509
|
-
|
|
26510
|
-
|
|
26511
|
-
|
|
26512
|
-
|
|
26592
|
+
result.push({
|
|
26593
|
+
entry,
|
|
26594
|
+
index,
|
|
26595
|
+
leadingIcon: meta.leadingIcon,
|
|
26596
|
+
label: meta.label
|
|
26597
|
+
});
|
|
26598
|
+
});
|
|
26599
|
+
return result;
|
|
26513
26600
|
});
|
|
26514
|
-
const
|
|
26515
|
-
|
|
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 };
|
|
26516
26640
|
});
|
|
26517
|
-
const
|
|
26518
|
-
|
|
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;
|
|
26519
26653
|
});
|
|
26520
26654
|
const overflowMenuItems = computed(() => {
|
|
26521
|
-
|
|
26522
|
-
|
|
26523
|
-
text: a.label,
|
|
26524
|
-
disabled: a.disabled,
|
|
26525
|
-
accessory: a.leadingIcon ? { type: "icon", name: a.leadingIcon } : void 0
|
|
26526
|
-
}));
|
|
26655
|
+
const indices = Array.from(layout.value.inMenu).sort((a, b) => a - b);
|
|
26656
|
+
return indices.map((i) => toMenuItem(__props.buttons[i]));
|
|
26527
26657
|
});
|
|
26528
|
-
const
|
|
26529
|
-
if (
|
|
26530
|
-
|
|
26658
|
+
const refOffsetWidth = (instance) => {
|
|
26659
|
+
if (!instance) {
|
|
26660
|
+
return 0;
|
|
26661
|
+
}
|
|
26662
|
+
if (instance.menuButtonEl?.$el) {
|
|
26663
|
+
return instance.menuButtonEl.$el.offsetWidth ?? 0;
|
|
26531
26664
|
}
|
|
26665
|
+
return instance.$el?.offsetWidth ?? 0;
|
|
26532
26666
|
};
|
|
26533
26667
|
const measureButtons = async () => {
|
|
26534
26668
|
await nextTick();
|
|
26535
26669
|
if (!measureContainerEl.value) {
|
|
26536
26670
|
return;
|
|
26537
26671
|
}
|
|
26538
|
-
|
|
26539
|
-
|
|
26540
|
-
);
|
|
26541
|
-
|
|
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;
|
|
26542
26703
|
};
|
|
26543
26704
|
watch(() => __props.buttons, measureButtons, { deep: true });
|
|
26544
26705
|
onMounted(() => {
|
|
@@ -26551,14 +26712,22 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
26551
26712
|
return openBlock(), createElementBlock(Fragment, null, [
|
|
26552
26713
|
createElementVNode("div", _hoisted_1$1, [
|
|
26553
26714
|
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.buttons, (button) => {
|
|
26554
|
-
return openBlock(), createBlock(
|
|
26715
|
+
return openBlock(), createBlock(resolveDynamicComponent(unref(typeToComponent)[button.type]), mergeProps({
|
|
26716
|
+
key: `full-${button.id}`,
|
|
26555
26717
|
ref_for: true,
|
|
26556
|
-
ref: "
|
|
26557
|
-
|
|
26558
|
-
|
|
26559
|
-
|
|
26560
|
-
|
|
26561
|
-
|
|
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);
|
|
26562
26731
|
}), 128)),
|
|
26563
26732
|
createVNode(_sfc_main$1k, {
|
|
26564
26733
|
ref: "measureMenuButton",
|
|
@@ -26570,24 +26739,16 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
26570
26739
|
createElementVNode("div", mergeProps({ ref: "buttonsContainer" }, _ctx.$attrs, {
|
|
26571
26740
|
class: ["kds-button-group", __props.alignment]
|
|
26572
26741
|
}), [
|
|
26573
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(
|
|
26574
|
-
return openBlock(), createBlock(
|
|
26575
|
-
key:
|
|
26576
|
-
|
|
26577
|
-
variant: button.variant ?? "outlined",
|
|
26578
|
-
disabled: button.disabled,
|
|
26579
|
-
"leading-icon": button.leadingIcon,
|
|
26580
|
-
destructive: button.destructive,
|
|
26581
|
-
title: button.title,
|
|
26582
|
-
onClick: ($event) => emit("buttonClick", button.id)
|
|
26583
|
-
}, 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);
|
|
26584
26746
|
}), 128)),
|
|
26585
|
-
|
|
26747
|
+
overflowMenuItems.value.length ? (openBlock(), createBlock(_sfc_main$1k, {
|
|
26586
26748
|
key: 0,
|
|
26587
26749
|
"leading-icon": "more-actions",
|
|
26588
26750
|
ariaLabel: "More actions",
|
|
26589
|
-
items: overflowMenuItems.value
|
|
26590
|
-
onItemClick: onMenuItemClick
|
|
26751
|
+
items: overflowMenuItems.value
|
|
26591
26752
|
}, null, 8, ["items"])) : createCommentVNode("", true)
|
|
26592
26753
|
], 16)
|
|
26593
26754
|
], 64);
|
|
@@ -26595,7 +26756,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
26595
26756
|
}
|
|
26596
26757
|
});
|
|
26597
26758
|
|
|
26598
|
-
const KdsResponsiveButtonGroup = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-
|
|
26759
|
+
const KdsResponsiveButtonGroup = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-ccdbc564"]]);
|
|
26599
26760
|
|
|
26600
26761
|
const kdsResponsiveButtonGroupAlignment = {
|
|
26601
26762
|
LEFT: "left",
|