@knime/kds-components 6.9.0 → 6.11.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 CHANGED
@@ -1,5 +1,47 @@
1
1
  # @knime/kds-components
2
2
 
3
+ ## 6.11.0
4
+
5
+ ### Patch Changes
6
+
7
+ - @knime/kds-styles@6.11.0
8
+
9
+ ## 6.10.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 6d050de: Expose badges, section titles and dividers through the list-based selection
14
+ components, matching what the menu already supported.
15
+
16
+ - `KdsListContainer`: accept a `badge` on options (`KdsListOption`), rendered at
17
+ the end of the row alongside the selected/missing trailing icon.
18
+ - `KdsDropdownOption` — shared by `KdsDropdown`, `KdsMultiSelectDropdown`,
19
+ `KdsSelectButton` and `KdsMultiSelectButton`:
20
+ - accept a `badge`, rendered at the end of the row.
21
+ - accept `sectionHeadline`, `sectionHeadlineIcon` and `separator`, so options
22
+ can be grouped with non-selectable section titles and dividers.
23
+ - match the search query against options only: a section title is never
24
+ matched by its own text, and is dropped when no option beneath it survives
25
+ the filter.
26
+ - model the option as a discriminated union on `sectionHeadline`, mirroring
27
+ `KdsMenuItem`, so a section title cannot declare decoration the row does not
28
+ render (`badge`, `accessory`, `subText`, `disabled`) and a selectable option
29
+ cannot declare `sectionHeadlineIcon`. The two arms are exported as
30
+ `KdsDropdownSectionHeadlineOption` and `KdsDropdownSelectableOption`.
31
+ - `KdsMultiSelectDropdown`:
32
+ - keep the declared option order (instead of moving selected options to the
33
+ top) when section titles or separators are present, so grouped options stay
34
+ under their headline.
35
+ - exclude section titles from the select-all / clear-all actions.
36
+ - exclude section titles from the "Selected (n/total)" count.
37
+ - exclude unselected `disabled` options from the "Selected (n/total)" count,
38
+ so a list containing a disabled option now reports a smaller total than
39
+ before.
40
+
41
+ ### Patch Changes
42
+
43
+ - @knime/kds-styles@6.10.0
44
+
3
45
  ## 6.9.0
4
46
 
5
47
  ### Patch Changes
package/dist/index.css CHANGED
@@ -1464,7 +1464,7 @@ body:has(dialog.modal[open]) {
1464
1464
  }
1465
1465
 
1466
1466
  .kds-list-container {
1467
- &[data-v-17aec579] {
1467
+ &[data-v-182cc69b] {
1468
1468
  position: relative;
1469
1469
  display: flex;
1470
1470
  flex-direction: column;
@@ -1473,23 +1473,23 @@ body:has(dialog.modal[open]) {
1473
1473
  padding: var(--kds-spacing-container-0-25x);
1474
1474
  overflow-y: auto;
1475
1475
  }
1476
- &.with-border[data-v-17aec579] {
1476
+ &.with-border[data-v-182cc69b] {
1477
1477
  border: var(--kds-border-base-subtle);
1478
1478
  border-radius: var(--kds-border-radius-container-0-31x);
1479
1479
  }
1480
- &[data-v-17aec579]:focus-visible {
1480
+ &[data-v-182cc69b]:focus-visible {
1481
1481
  outline: var(--kds-border-action-focused);
1482
1482
  outline-offset: var(--kds-spacing-offset-focus);
1483
1483
  border-radius: var(--kds-border-radius-container-0-31x);
1484
1484
  }
1485
1485
  }
1486
- .kds-list-container-empty[data-v-17aec579] {
1486
+ .kds-list-container-empty[data-v-182cc69b] {
1487
1487
  display: flex;
1488
1488
  flex: 1;
1489
1489
  align-items: center;
1490
1490
  justify-content: center;
1491
1491
  }
1492
- .kds-list-item-divider[data-v-17aec579] {
1492
+ .kds-list-item-divider[data-v-182cc69b] {
1493
1493
  flex-shrink: 0;
1494
1494
  width: 100%;
1495
1495
  padding: 0;
@@ -1671,7 +1671,7 @@ body:has(dialog.modal[open]) {
1671
1671
  margin-left: var(--kds-spacing-container-0-12x);
1672
1672
  }
1673
1673
 
1674
- .kds-multi-select-dropdown-options[data-v-268304fc] {
1674
+ .kds-multi-select-dropdown-options[data-v-94c4074f] {
1675
1675
  display: flex;
1676
1676
  flex-direction: column;
1677
1677
  min-width: var(--kds-dimension-component-width-12x);
@@ -1679,24 +1679,24 @@ body:has(dialog.modal[open]) {
1679
1679
  border-radius: var(--kds-border-radius-container-0-50x);
1680
1680
  box-shadow: var(--kds-elevation-level-3);
1681
1681
  }
1682
- .kds-multi-select-dropdown-search[data-v-268304fc] {
1682
+ .kds-multi-select-dropdown-search[data-v-94c4074f] {
1683
1683
  padding: var(--kds-spacing-container-0-25x);
1684
1684
  border-bottom: var(--kds-border-base-subtle);
1685
1685
  }
1686
1686
  .kds-multi-select-dropdown-list {
1687
- &[data-v-268304fc] {
1687
+ &[data-v-94c4074f] {
1688
1688
  max-height: var(--kds-dimension-component-height-12x);
1689
1689
  }
1690
- &.multiline[data-v-268304fc] {
1690
+ &.multiline[data-v-94c4074f] {
1691
1691
  max-height: var(--kds-dimension-component-height-20x);
1692
1692
  }
1693
1693
  }
1694
- .kds-multi-select-dropdown-footer[data-v-268304fc] {
1694
+ .kds-multi-select-dropdown-footer[data-v-94c4074f] {
1695
1695
  padding: var(--kds-spacing-container-0-25x);
1696
1696
  border-top: var(--kds-border-base-subtle);
1697
1697
  }
1698
1698
 
1699
- .kds-dropdown-container[data-v-97356e02] {
1699
+ .kds-dropdown-container[data-v-06ce6f08] {
1700
1700
  display: flex;
1701
1701
  flex-direction: column;
1702
1702
  min-width: var(--kds-dimension-component-width-12x);
@@ -1704,16 +1704,16 @@ body:has(dialog.modal[open]) {
1704
1704
  border-radius: var(--kds-border-radius-container-0-50x);
1705
1705
  box-shadow: var(--kds-elevation-level-3);
1706
1706
  }
1707
- .kds-dropdown-container-sticky-top[data-v-97356e02] {
1707
+ .kds-dropdown-container-sticky-top[data-v-06ce6f08] {
1708
1708
  padding: var(--kds-spacing-container-0-25x);
1709
1709
  background-color: var(--kds-color-surface-default);
1710
1710
  border-bottom: var(--kds-border-base-subtle);
1711
1711
  }
1712
1712
  .kds-dropdown-container-list {
1713
- &[data-v-97356e02] {
1713
+ &[data-v-06ce6f08] {
1714
1714
  max-height: var(--kds-dimension-component-height-12x);
1715
1715
  }
1716
- &.multiline[data-v-97356e02] {
1716
+ &.multiline[data-v-06ce6f08] {
1717
1717
  max-height: var(--kds-dimension-component-height-20x);
1718
1718
  }
1719
1719
  }
package/dist/index.js CHANGED
@@ -12094,6 +12094,7 @@ var KdsListContainer_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/
12094
12094
  special: item.special,
12095
12095
  missing: item.missing,
12096
12096
  variant: __props.variant,
12097
+ badge: item.badge,
12097
12098
  "trailing-icon": item.missing && !item.disabled ? "trash" : item.selected ? "checkmark" : void 0,
12098
12099
  role: "option",
12099
12100
  onMousedown: _cache[0] || (_cache[0] = ($event) => props.controlledExternally && $event.preventDefault()),
@@ -12110,6 +12111,7 @@ var KdsListContainer_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/
12110
12111
  "special",
12111
12112
  "missing",
12112
12113
  "variant",
12114
+ "badge",
12113
12115
  "trailing-icon",
12114
12116
  "onClick",
12115
12117
  "onMouseenter"
@@ -12136,7 +12138,7 @@ var KdsListContainer_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/
12136
12138
  //#endregion
12137
12139
  //#region src/components/lists/ListContainer/KdsListContainer.vue
12138
12140
  var KdsListContainer_exports = /* @__PURE__ */ __exportAll$1({ default: () => KdsListContainer_default });
12139
- var KdsListContainer_default = /*#__PURE__*/ _plugin_vue_export_helper_default(KdsListContainer_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-17aec579"]]);
12141
+ var KdsListContainer_default = /*#__PURE__*/ _plugin_vue_export_helper_default(KdsListContainer_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-182cc69b"]]);
12140
12142
  //#endregion
12141
12143
  //#region src/components/lists/ListContainer/ListItem/ListItemButton/KdsListItemButton.vue?vue&type=script&setup=true&lang.ts
12142
12144
  var _hoisted_1$61 = ["disabled"];
@@ -13018,6 +13020,49 @@ focus: focusInput });
13018
13020
  }
13019
13021
  }), [["__scopeId", "data-v-3ad80634"]]);
13020
13022
  //#endregion
13023
+ //#region src/components/forms/selects/Dropdown/filterOptions.ts
13024
+ /**
13025
+ * Filters dropdown options by a search query while keeping the declared section
13026
+ * grouping intact:
13027
+ *
13028
+ * - Section headlines (`sectionHeadline`) are structural, not selectable, so they
13029
+ * are never matched against the query directly. A headline is kept only when at
13030
+ * least one of the options grouped beneath it survives the filter — a search can
13031
+ * therefore never leave an orphan headline with no items, nor detach items from
13032
+ * their headline.
13033
+ * - Regular options are kept when their `text` contains the query.
13034
+ *
13035
+ * Separators travel with the option that carries them; the list renderer omits a
13036
+ * separator below the last rendered row, so no dangling dividers remain.
13037
+ */
13038
+ var filterOptionsPreservingSections = (options, query) => {
13039
+ const normalizedQuery = query.trim().toLowerCase();
13040
+ if (normalizedQuery.length === 0) return options;
13041
+ const result = [];
13042
+ let pendingHeadline;
13043
+ for (const option of options) {
13044
+ if (option.sectionHeadline) {
13045
+ pendingHeadline = option;
13046
+ continue;
13047
+ }
13048
+ if (option.text.toLowerCase().includes(normalizedQuery)) {
13049
+ if (pendingHeadline) {
13050
+ result.push(pendingHeadline);
13051
+ pendingHeadline = void 0;
13052
+ }
13053
+ result.push(option);
13054
+ }
13055
+ }
13056
+ return result;
13057
+ };
13058
+ /**
13059
+ * Number of options a search field would actually filter. Section headlines are
13060
+ * structural rather than searchable, so they must not push a list over
13061
+ * `DROPDOWN_SEARCH_THRESHOLD` — otherwise the search field would appear based on
13062
+ * how much grouping a list declares rather than how many options it holds.
13063
+ */
13064
+ var countSearchableOptions = (options) => options.filter((option) => !option.sectionHeadline).length;
13065
+ //#endregion
13021
13066
  //#region src/components/forms/selects/Dropdown/MultiSelectDropdownContainer.vue?vue&type=script&setup=true&lang.ts
13022
13067
  var _hoisted_1$59 = { class: "kds-multi-select-dropdown-options" };
13023
13068
  var _hoisted_2$36 = {
@@ -13065,13 +13110,15 @@ var MultiSelectDropdownContainer_default = /*#__PURE__*/ _plugin_vue_export_help
13065
13110
  id,
13066
13111
  text: id
13067
13112
  })));
13068
- const filteredOptions = computed(() => {
13069
- const normalizedQuery = searchValue.value.trim().toLowerCase();
13070
- if (normalizedQuery.length === 0) return props.possibleValues;
13071
- return props.possibleValues.filter((option) => option.text.toLowerCase().includes(normalizedQuery));
13072
- });
13113
+ const filteredOptions = computed(() => filterOptionsPreservingSections(props.possibleValues, searchValue.value));
13114
+ /**
13115
+ * Whether the declared list carries structure (section titles or separators).
13116
+ * Derived from `possibleValues` rather than the filtered list so the ordering
13117
+ * stays stable while the user types.
13118
+ */
13119
+ const hasSectionsOrSeparators = computed(() => props.possibleValues.some((option) => option.sectionHeadline || option.separator));
13073
13120
  const searchable = computed(() => {
13074
- return __props.allowNewValues || props.possibleValues.length >= 12;
13121
+ return __props.allowNewValues || countSearchableOptions(props.possibleValues) >= 12;
13075
13122
  });
13076
13123
  const canAddNewValue = computed(() => {
13077
13124
  const trimmed = searchValue.value.trim();
@@ -13099,22 +13146,27 @@ var MultiSelectDropdownContainer_default = /*#__PURE__*/ _plugin_vue_export_help
13099
13146
  selected: true,
13100
13147
  missing: true
13101
13148
  }));
13102
- const regularItems = filteredOptions.value.map((option) => ({
13149
+ const mappedItems = filteredOptions.value.map((option) => ({
13103
13150
  id: option.id,
13104
13151
  text: option.text,
13105
13152
  subText: option.subText,
13106
13153
  special: option.special,
13107
13154
  accessory: option.accessory,
13155
+ badge: option.badge,
13156
+ sectionHeadline: option.sectionHeadline,
13157
+ sectionHeadlineIcon: option.sectionHeadlineIcon,
13158
+ separator: option.separator,
13108
13159
  selected: selectedSet.has(option.id),
13109
13160
  disabled: option.disabled
13110
- })).slice().sort((a, b) => Number(initialSelectedIds.value.has(b.id)) - Number(initialSelectedIds.value.has(a.id)));
13161
+ }));
13162
+ const regularItems = hasSectionsOrSeparators.value ? mappedItems : mappedItems.sort((a, b) => Number(initialSelectedIds.value.has(b.id)) - Number(initialSelectedIds.value.has(a.id)));
13111
13163
  return [
13112
13164
  ...addNewItem,
13113
13165
  ...missingItems,
13114
13166
  ...regularItems
13115
13167
  ];
13116
13168
  });
13117
- const visibleEnabledIds = computed(() => filteredOptions.value.filter((o) => !o.disabled).map((o) => o.id));
13169
+ const visibleEnabledIds = computed(() => filteredOptions.value.filter((o) => !o.disabled && !o.sectionHeadline).map((o) => o.id));
13118
13170
  const anyVisibleSelected = computed(() => visibleEnabledIds.value.some((id) => modelValue.value.includes(id)));
13119
13171
  const onItemClick = (id) => {
13120
13172
  if (id === ADD_NEW_VALUE_ID) {
@@ -13192,7 +13244,7 @@ var MultiSelectDropdownContainer_default = /*#__PURE__*/ _plugin_vue_export_help
13192
13244
  ]);
13193
13245
  };
13194
13246
  }
13195
- }), [["__scopeId", "data-v-268304fc"]]);
13247
+ }), [["__scopeId", "data-v-94c4074f"]]);
13196
13248
  //#endregion
13197
13249
  //#region src/components/buttons/KdsMultiSelectButton/KdsMultiSelectButton.vue
13198
13250
  var KdsMultiSelectButton_default = /* @__PURE__ */ defineComponent({
@@ -13361,7 +13413,7 @@ var DropdownContainer_default = /*#__PURE__*/ _plugin_vue_export_helper_default(
13361
13413
  const props = __props;
13362
13414
  const emit = __emit;
13363
13415
  const modelValue = useModel(__props, "modelValue");
13364
- const searchable = computed(() => props.possibleValues.length >= 12);
13416
+ const searchable = computed(() => countSearchableOptions(props.possibleValues) >= 12);
13365
13417
  const searchValue = ref("");
13366
13418
  const searchEl = useTemplateRef("searchEl");
13367
13419
  const listContainerRef = useTemplateRef("listContainer");
@@ -13374,12 +13426,7 @@ var DropdownContainer_default = /*#__PURE__*/ _plugin_vue_export_helper_default(
13374
13426
  missing: true
13375
13427
  }, ...props.possibleValues];
13376
13428
  });
13377
- const filteredOptions = computed(() => {
13378
- const normalizedQuery = searchValue.value.trim().toLowerCase();
13379
- const base = optionsWithSyntheticMissing.value;
13380
- if (normalizedQuery.length === 0) return base;
13381
- return base.filter((option) => option.text.toLowerCase().includes(normalizedQuery));
13382
- });
13429
+ const filteredOptions = computed(() => filterOptionsPreservingSections(optionsWithSyntheticMissing.value, searchValue.value));
13383
13430
  const listOptions = computed(() => filteredOptions.value.map((option) => ({
13384
13431
  id: option.id,
13385
13432
  text: option.text,
@@ -13388,7 +13435,11 @@ var DropdownContainer_default = /*#__PURE__*/ _plugin_vue_export_helper_default(
13388
13435
  disabled: option.disabled || option.missing,
13389
13436
  selected: option.id === modelValue.value,
13390
13437
  special: option.special,
13391
- missing: option.missing
13438
+ missing: option.missing,
13439
+ badge: option.badge,
13440
+ sectionHeadline: option.sectionHeadline,
13441
+ sectionHeadlineIcon: option.sectionHeadlineIcon,
13442
+ separator: option.separator
13392
13443
  })));
13393
13444
  const hasMultiline = computed(() => props.possibleValues.some((o) => o.subText !== void 0));
13394
13445
  const onItemClick = (id) => {
@@ -13435,7 +13486,7 @@ var DropdownContainer_default = /*#__PURE__*/ _plugin_vue_export_helper_default(
13435
13486
  ])]);
13436
13487
  };
13437
13488
  }
13438
- }), [["__scopeId", "data-v-97356e02"]]);
13489
+ }), [["__scopeId", "data-v-06ce6f08"]]);
13439
13490
  //#endregion
13440
13491
  //#region src/components/buttons/KdsSelectButton/KdsSelectButton.vue
13441
13492
  var KdsSelectButton_default = /* @__PURE__ */ defineComponent({
@@ -24208,12 +24259,13 @@ var KdsMultiSelectDropdown_default = /* @__PURE__ */ defineComponent({
24208
24259
  return [...props.possibleValues, ...deduped];
24209
24260
  });
24210
24261
  const optionById = computed(() => new Map(allPossibleValues.value.map((item) => [item.id, item])));
24262
+ const selectableCount = computed(() => allPossibleValues.value.filter((o) => !o.sectionHeadline && (!o.disabled || modelValue.value.includes(o.id))).length);
24211
24263
  const missingIds = computed(() => modelValue.value.filter((id) => !optionById.value.has(id)));
24212
24264
  const summary = computed(() => {
24213
24265
  if (modelValue.value.length === 0) return;
24214
24266
  if (missingIds.value.length > 0) return `(Missing) ${missingIds.value[0]}`;
24215
24267
  if (modelValue.value.length === 1) return optionById.value.get(modelValue.value[0])?.text;
24216
- return `Selected (${modelValue.value.length}/${allPossibleValues.value.length})`;
24268
+ return `Selected (${modelValue.value.length}/${selectableCount.value})`;
24217
24269
  });
24218
24270
  const onAddValue = (text) => {
24219
24271
  addedOptions.value = [...addedOptions.value, {