@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.
@@ -1,16 +1,101 @@
1
- import { KdsButtonProps } from '../../buttons';
1
+ import { KdsIconName } from '../../accessories/Icon/types';
2
+ import { KdsButtonProps, KdsLinkButtonProps, KdsMenuButtonProps, KdsProgressButtonProps, KdsSplitButtonProps, KdsToggleButtonProps } from '../../buttons';
3
+ import { KdsProgressButtonState } from '../../buttons/KdsProgressButton/types';
2
4
  import { kdsResponsiveButtonGroupAlignment } from './enums';
3
5
  export type KdsResponsiveButtonGroupAlignment = (typeof kdsResponsiveButtonGroupAlignment)[keyof typeof kdsResponsiveButtonGroupAlignment];
4
- type MakeRequired<T, K extends keyof T> = T & Required<Pick<T, K>>;
5
- export type KdsResponsiveButtonGroupButton = Pick<MakeRequired<KdsButtonProps, "label">, "variant" | "label" | "disabled" | "leadingIcon" | "destructive" | "title"> & {
6
- /** will be emitted when the button is clicked in the `buttonClick` event */
7
- id: string;
6
+ type ButtonPropMap = {
7
+ KdsButton: KdsButtonProps;
8
+ KdsLinkButton: KdsLinkButtonProps;
9
+ KdsSplitButton: KdsSplitButtonProps;
10
+ KdsMenuButton: KdsMenuButtonProps;
11
+ KdsProgressButton: KdsProgressButtonProps & {
12
+ state?: KdsProgressButtonState;
13
+ };
14
+ KdsToggleButton: KdsToggleButtonProps & {
15
+ modelValue?: boolean;
16
+ };
8
17
  };
18
+ type EntryType = keyof ButtonPropMap;
19
+ type EntryMeta<T extends EntryType> = Omit<Extract<ButtonPropMap[T], {
20
+ label: string;
21
+ }>, "size">;
22
+ /**
23
+ * Splits a meta with an optional `leadingIcon` into two mutually exclusive
24
+ * branches:
25
+ *
26
+ * - icon-capable: `meta.leadingIcon` is required; `canBeIconOnly` defaults
27
+ * to true and may be set to false to opt out of icon-only collapse.
28
+ * - icon-incapable: `meta.leadingIcon` must be absent; `canBeIconOnly` must
29
+ * not be true (there is no icon to collapse to).
30
+ */
31
+ type WithIconCollapse<TMeta> = {
32
+ /**
33
+ * If true (default), the entry drops its label and renders icon-only
34
+ * once the row needs to shrink. Only valid when `meta.leadingIcon` is
35
+ * set. The label is promoted to `title` (unless `meta.title` is set)
36
+ * and `ariaLabel`.
37
+ * @default true
38
+ */
39
+ canBeIconOnly?: boolean;
40
+ meta: Omit<TMeta, "leadingIcon"> & {
41
+ leadingIcon: KdsIconName;
42
+ };
43
+ } | {
44
+ canBeIconOnly?: false;
45
+ meta: Omit<TMeta, "leadingIcon"> & {
46
+ leadingIcon?: never;
47
+ };
48
+ };
49
+ type EntryHandler<E> = (entry: E, event: MouseEvent | KeyboardEvent) => void;
50
+ type ToggleEntryHandler<E> = (entry: E, nextValue: boolean) => void;
51
+ /**
52
+ * One responsive-button-group entry. Discriminates on `type`; the meta and
53
+ * handler shape are derived from there.
54
+ *
55
+ * `KdsProgressButton` always has a required `leadingIcon` (the underlying
56
+ * button forces it), so it skips `WithIconCollapse` — `canBeIconOnly`
57
+ * remains unconstrained.
58
+ *
59
+ * `KdsLinkButton` and `KdsMenuButton` have no entry-level handler: link
60
+ * activation is native, menu activation lives on `meta.items`.
61
+ *
62
+ * `KdsToggleButton`'s handler receives the next boolean value instead of a
63
+ * DOM event — the underlying button is fully controlled, so the consumer
64
+ * must update `meta.modelValue` from this callback for the toggle state to
65
+ * actually change.
66
+ */
67
+ type Entry<T extends EntryType> = {
68
+ /** Stable identifier; used as the Vue v-for key and surfaced to consumers. */
69
+ id: string;
70
+ type: T;
71
+ /**
72
+ * If true (default), the entry is allowed to move into the overflow menu
73
+ * when the row runs out of space. Pinned (`false`) entries always render
74
+ * in the visible row.
75
+ * @default true
76
+ */
77
+ canMoveToMenu?: boolean;
78
+ } & (T extends "KdsProgressButton" ? {
79
+ /**
80
+ * If true (default), the entry drops its label and renders icon-only
81
+ * once the row needs to shrink.
82
+ * @default true
83
+ */
84
+ canBeIconOnly?: boolean;
85
+ meta: EntryMeta<T>;
86
+ } : WithIconCollapse<EntryMeta<T>>) & (T extends "KdsLinkButton" | "KdsMenuButton" ? {
87
+ handler?: never;
88
+ } : T extends "KdsToggleButton" ? {
89
+ handler: ToggleEntryHandler<Entry<T>>;
90
+ } : {
91
+ handler: EntryHandler<Entry<T>>;
92
+ });
93
+ export type KdsResponsiveButtonGroupButton = Entry<"KdsButton"> | Entry<"KdsLinkButton"> | Entry<"KdsSplitButton"> | Entry<"KdsMenuButton"> | Entry<"KdsProgressButton"> | Entry<"KdsToggleButton">;
9
94
  export type KdsResponsiveButtonGroupProps = {
10
95
  /**
11
- * Array of button objects, each requires `id` and `label`.
12
- *
13
- * Optional: `variant` (defaults to `outlined`), `disabled`, `leadingIcon`, `destructive`, `title`.
96
+ * Array of button entries. Each entry declares the button `type` and a
97
+ * `meta` object carrying that type's props, plus optional flags controlling
98
+ * how the entry participates in responsive collapse.
14
99
  */
15
100
  buttons: KdsResponsiveButtonGroupButton[];
16
101
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/patterns/ResponsiveButtonGroup/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,OAAO,EAAE,iCAAiC,EAAE,MAAM,SAAS,CAAC;AAE5D,MAAM,MAAM,iCAAiC,GAC3C,CAAC,OAAO,iCAAiC,CAAC,CAAC,MAAM,OAAO,iCAAiC,CAAC,CAAC;AAE7F,KAAK,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAEnE,MAAM,MAAM,8BAA8B,GAAG,IAAI,CAC/C,YAAY,CAAC,cAAc,EAAE,OAAO,CAAC,EACrC,SAAS,GAAG,OAAO,GAAG,UAAU,GAAG,aAAa,GAAG,aAAa,GAAG,OAAO,CAC3E,GAAG;IACF,4EAA4E;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,CAAC,CAAC,CAAC,CAAC,CAAA;CAAE,CAAC,CAAC;AAE7C,MAAM,MAAM,8BAA8B,GACtC,KAAK,CAAC,WAAW,CAAC,GAClB,KAAK,CAAC,eAAe,CAAC,GACtB,KAAK,CAAC,gBAAgB,CAAC,GACvB,KAAK,CAAC,eAAe,CAAC,GACtB,KAAK,CAAC,mBAAmB,CAAC,GAC1B,KAAK,CAAC,iBAAiB,CAAC,CAAC;AAE7B,MAAM,MAAM,6BAA6B,GAAG;IAC1C;;;;OAIG;IACH,OAAO,EAAE,8BAA8B,EAAE,CAAC;IAE1C;;;OAGG;IACH,SAAS,CAAC,EAAE,iCAAiC,CAAC;CAC/C,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knime/kds-components",
3
- "version": "0.31.3",
3
+ "version": "1.0.0",
4
4
  "description": "Package containing basic Vue components of the KNIME Design System",
5
5
  "repository": {
6
6
  "type": "git",
@@ -40,7 +40,7 @@
40
40
  "motion": "^12.39.0",
41
41
  "pretty-bytes": "^7.1.0",
42
42
  "temporal-polyfill": "^0.3.2",
43
- "@knime/kds-styles": "^0.31.3"
43
+ "@knime/kds-styles": "^1.0.0"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@storybook/vue3-vite": "^10.4.3",