@kong/kongponents 9.29.7 → 9.29.8

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,229 +1,21 @@
1
- import type { DropdownItem, DropdownItemRenderedRecord, DropdownItemRenderedType } from '../../../types';
2
- import type { PropType } from 'vue';
3
- declare const label: import("vue").ComputedRef<string>;
4
- declare const componentType: import("vue").ComputedRef<DropdownItemRenderedType>;
5
- declare const availableComponents: import("vue").ComputedRef<DropdownItemRenderedRecord>;
6
- declare const __VLS_ctx: InstanceType<__VLS_PickNotAny<typeof __VLS_self, new () => {}>>;
7
- declare var __VLS_9: {};
8
- type __VLS_Slots = __VLS_PrettifyGlobal<__VLS_OmitStringIndex<typeof __VLS_ctx.$slots> & {
9
- default?: (props: typeof __VLS_9) => any;
10
- }>;
11
- declare const __VLS_self: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
12
- item: {
13
- type: PropType<DropdownItem>;
14
- default: null;
15
- validator: (item: DropdownItem) => boolean;
16
- };
17
- /**
18
- * Use this prop to add a divider above the item.
19
- */
20
- hasDivider: {
21
- type: BooleanConstructor;
22
- default: boolean;
23
- };
24
- danger: {
25
- type: BooleanConstructor;
26
- default: boolean;
27
- };
28
- disabled: {
29
- type: BooleanConstructor;
30
- default: boolean;
31
- };
32
- selected: {
33
- type: BooleanConstructor;
34
- default: boolean;
35
- };
36
- /**
37
- * Internal use only - for tracking selection in conjunction with items prop.
38
- */
39
- selectionMenuChild: {
40
- type: BooleanConstructor;
41
- default: boolean;
42
- };
43
- onClick: {
44
- type: FunctionConstructor;
45
- default: undefined;
46
- };
47
- /**
48
- * @deprecated in favor of `danger`
49
- */
50
- isDangerous: {
51
- type: BooleanConstructor;
52
- default: boolean;
53
- validator: (value: boolean) => boolean;
54
- };
55
- }>, {
56
- label: typeof label;
57
- componentType: typeof componentType;
58
- availableComponents: typeof availableComponents;
59
- }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
60
- click: (val: Event) => any;
61
- change: (item: DropdownItem) => any;
62
- }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
63
- item: {
64
- type: PropType<DropdownItem>;
65
- default: null;
66
- validator: (item: DropdownItem) => boolean;
67
- };
68
- /**
69
- * Use this prop to add a divider above the item.
70
- */
71
- hasDivider: {
72
- type: BooleanConstructor;
73
- default: boolean;
74
- };
75
- danger: {
76
- type: BooleanConstructor;
77
- default: boolean;
78
- };
79
- disabled: {
80
- type: BooleanConstructor;
81
- default: boolean;
82
- };
83
- selected: {
84
- type: BooleanConstructor;
85
- default: boolean;
86
- };
87
- /**
88
- * Internal use only - for tracking selection in conjunction with items prop.
89
- */
90
- selectionMenuChild: {
91
- type: BooleanConstructor;
92
- default: boolean;
93
- };
94
- onClick: {
95
- type: FunctionConstructor;
96
- default: undefined;
97
- };
98
- /**
99
- * @deprecated in favor of `danger`
100
- */
101
- isDangerous: {
102
- type: BooleanConstructor;
103
- default: boolean;
104
- validator: (value: boolean) => boolean;
105
- };
106
- }>> & Readonly<{
107
- onClick?: ((val: Event) => any) | undefined;
108
- onChange?: ((item: DropdownItem) => any) | undefined;
109
- }>, {
110
- danger: boolean;
111
- disabled: boolean;
112
- selected: boolean;
113
- onClick: Function;
114
- item: DropdownItem;
115
- hasDivider: boolean;
116
- selectionMenuChild: boolean;
117
- isDangerous: boolean;
118
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
119
- declare const __VLS_component: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
120
- item: {
121
- type: PropType<DropdownItem>;
122
- default: null;
123
- validator: (item: DropdownItem) => boolean;
124
- };
125
- /**
126
- * Use this prop to add a divider above the item.
127
- */
128
- hasDivider: {
129
- type: BooleanConstructor;
130
- default: boolean;
131
- };
132
- danger: {
133
- type: BooleanConstructor;
134
- default: boolean;
135
- };
136
- disabled: {
137
- type: BooleanConstructor;
138
- default: boolean;
139
- };
140
- selected: {
141
- type: BooleanConstructor;
142
- default: boolean;
143
- };
144
- /**
145
- * Internal use only - for tracking selection in conjunction with items prop.
146
- */
147
- selectionMenuChild: {
148
- type: BooleanConstructor;
149
- default: boolean;
150
- };
151
- onClick: {
152
- type: FunctionConstructor;
153
- default: undefined;
154
- };
155
- /**
156
- * @deprecated in favor of `danger`
157
- */
158
- isDangerous: {
159
- type: BooleanConstructor;
160
- default: boolean;
161
- validator: (value: boolean) => boolean;
162
- };
163
- }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
164
- click: (val: Event) => any;
165
- change: (item: DropdownItem) => any;
166
- }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
167
- item: {
168
- type: PropType<DropdownItem>;
169
- default: null;
170
- validator: (item: DropdownItem) => boolean;
171
- };
172
- /**
173
- * Use this prop to add a divider above the item.
174
- */
175
- hasDivider: {
176
- type: BooleanConstructor;
177
- default: boolean;
178
- };
179
- danger: {
180
- type: BooleanConstructor;
181
- default: boolean;
182
- };
183
- disabled: {
184
- type: BooleanConstructor;
185
- default: boolean;
186
- };
187
- selected: {
188
- type: BooleanConstructor;
189
- default: boolean;
190
- };
191
- /**
192
- * Internal use only - for tracking selection in conjunction with items prop.
193
- */
194
- selectionMenuChild: {
195
- type: BooleanConstructor;
196
- default: boolean;
197
- };
198
- onClick: {
199
- type: FunctionConstructor;
200
- default: undefined;
201
- };
202
- /**
203
- * @deprecated in favor of `danger`
204
- */
205
- isDangerous: {
206
- type: BooleanConstructor;
207
- default: boolean;
208
- validator: (value: boolean) => boolean;
209
- };
210
- }>> & Readonly<{
211
- onClick?: ((val: Event) => any) | undefined;
212
- onChange?: ((item: DropdownItem) => any) | undefined;
213
- }>, {
214
- danger: boolean;
215
- disabled: boolean;
216
- selected: boolean;
217
- onClick: Function;
218
- item: DropdownItem;
219
- hasDivider: boolean;
220
- selectionMenuChild: boolean;
221
- isDangerous: boolean;
222
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
223
- declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
224
- export default _default;
225
- type __VLS_WithSlots<T, S> = T & {
226
- new (): {
227
- $slots: S;
228
- };
1
+ import type { DropdownItem, DropdownItemProps } from '../../../types';
2
+ declare const _default: <T extends DropdownItem<string | number> | null = null>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
3
+ props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
4
+ readonly onClick?: ((event: MouseEvent) => any) | undefined;
5
+ readonly onChange?: ((item: T) => any) | undefined;
6
+ } & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, never>, "onChange" | "onClick"> & DropdownItemProps<T> & Partial<{}>> & import("vue").PublicProps;
7
+ expose(exposed: import("vue").ShallowUnwrapRef<{}>): void;
8
+ attrs: any;
9
+ slots: {
10
+ default?: ((props: {}) => any) | undefined;
11
+ };
12
+ emit: ((evt: "click", event: MouseEvent) => void) & ((evt: "change", item: T) => void);
13
+ }>) => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
14
+ [key: string]: any;
15
+ }> & {
16
+ __ctx?: Awaited<typeof __VLS_setup>;
229
17
  };
18
+ export default _default;
19
+ type __VLS_PrettifyLocal<T> = {
20
+ [K in keyof T]: T[K];
21
+ } & {};
@@ -50,10 +50,10 @@ declare const boundKPopAttributes: import("vue").ComputedRef<{
50
50
  maxWidth: string;
51
51
  disabled: boolean;
52
52
  placement: import("../../../types").PopPlacement;
53
- offset?: string | undefined;
54
- 'data-testid'?: string | undefined;
55
53
  popoverTimeout: number;
54
+ offset?: string | undefined;
56
55
  hideCaret: boolean;
56
+ 'data-testid'?: string | undefined;
57
57
  }>;
58
58
  declare const placeholderText: import("vue").ComputedRef<string>;
59
59
  declare const isClearVisible: import("vue").ComputedRef<boolean>;
@@ -1,8 +1,10 @@
1
1
  import type { Component } from 'vue';
2
- export interface DropdownItem {
2
+ import type { ButtonAppearance } from './button';
3
+ import type { PopoverAttributes } from './popover';
4
+ export interface DropdownItem<T extends string | number = string | number> {
3
5
  label: string;
4
6
  to?: string | object;
5
- value?: string | number;
7
+ value?: T;
6
8
  selected?: boolean;
7
9
  hasDivider?: boolean;
8
10
  danger?: boolean;
@@ -11,7 +13,7 @@ export type DropdownItemType = 'link' | 'button' | 'default';
11
13
  export type DropdownItemRenderedType = 'link' | 'router-link' | 'button' | 'div';
12
14
  export interface DropdownItemRenderedComponent {
13
15
  tag: string | Component;
14
- onClick?: ((event: Event) => void);
16
+ onClick?: ((event: MouseEvent) => void);
15
17
  attrs: {
16
18
  type?: 'button';
17
19
  class?: string;
@@ -22,3 +24,147 @@ export interface DropdownItemRenderedComponent {
22
24
  };
23
25
  }
24
26
  export type DropdownItemRenderedRecord = Record<DropdownItemRenderedType, DropdownItemRenderedComponent>;
27
+ export interface DropdownItemProps<T extends DropdownItem<string | number> | null> {
28
+ /**
29
+ * See `DropdownItem`.
30
+ * @default null
31
+ */
32
+ item?: T;
33
+ /**
34
+ * Use this prop to add a divider above the item.
35
+ * @default false
36
+ */
37
+ hasDivider?: boolean;
38
+ /**
39
+ * Whether to apply danger styles to the item.
40
+ * @default false
41
+ */
42
+ danger?: boolean;
43
+ /**
44
+ * Whether the item is disabled.
45
+ * @default false
46
+ */
47
+ disabled?: boolean;
48
+ /**
49
+ * Whether the item is selected.
50
+ * @default false
51
+ */
52
+ selected?: boolean;
53
+ /**
54
+ * Internal use only - for tracking selection in conjunction with items prop.
55
+ * @internal
56
+ * @default false
57
+ */
58
+ selectionMenuChild?: boolean;
59
+ /**
60
+ * The event handler that triggers when the item is clicked.
61
+ */
62
+ onClick?: (event: MouseEvent) => any;
63
+ /**
64
+ * Triggers when the item is clicked.
65
+ */
66
+ /**
67
+ * Whether to apply danger styles to the item.
68
+ * @deprecated Use `danger` instead.
69
+ * @default false
70
+ */
71
+ isDangerous?: boolean;
72
+ }
73
+ export interface DropdownItemEmits<T extends DropdownItem<string | number> | null> {
74
+ /**
75
+ * Triggers when the item is clicked.
76
+ */
77
+ click: [event: MouseEvent];
78
+ /**
79
+ * Triggers when the item is clicked when `selectionMenuChild` is true.
80
+ * Returns the selected menu item object or `null`.
81
+ */
82
+ change: [item: T];
83
+ }
84
+ export interface DropdownItemSlots {
85
+ /**
86
+ * The label of the item.
87
+ */
88
+ default?: () => any;
89
+ }
90
+ export interface DropdownProps<T extends string | number> {
91
+ /**
92
+ * Use this prop when a visual indication of the currently selected menu item is needed.
93
+ * @default false
94
+ */
95
+ selectionMenu?: boolean;
96
+ /**
97
+ * Use this prop to customize the default trigger KButton's `appearance` prop.
98
+ * @default 'primary'
99
+ */
100
+ appearance?: ButtonAppearance;
101
+ /**
102
+ * The text for the dropdown trigger button.
103
+ * @default ''
104
+ */
105
+ triggerText?: string;
106
+ /**
107
+ * Whether the trigger button should show a caret icon.
108
+ * @default false
109
+ */
110
+ showCaret?: boolean;
111
+ /**
112
+ * The width of the dropdown body (defaults to `''`).
113
+ * @default ''
114
+ */
115
+ width?: string;
116
+ /**
117
+ * Use the `kpopAttributes` prop to configure the KPop props dropdown.
118
+ * @default {}
119
+ */
120
+ kpopAttributes?: Omit<PopoverAttributes, 'target' | 'trigger'>;
121
+ /**
122
+ * An array of objects containing a required `label` property and other optional properties which will render a menu of KDropdownItems.
123
+ * @default []
124
+ */
125
+ items?: DropdownItem<T>[];
126
+ /**
127
+ * Whether the dropdown is disabled.
128
+ * @default false
129
+ */
130
+ disabled?: boolean;
131
+ /**
132
+ * Text to display on hover if dropdown is disabled.
133
+ * @default ''
134
+ */
135
+ disabledTooltip?: string;
136
+ /**
137
+ * The text for the dropdown trigger button.
138
+ * @deprecated Use `triggerText` instead.
139
+ */
140
+ label?: string;
141
+ }
142
+ export interface DropdownEmits<T extends string | number> {
143
+ /**
144
+ * Triggers when dropdown is opened/closed.
145
+ */
146
+ toggleDropdown: [open: boolean];
147
+ /**
148
+ * Triggers when an item is selected.
149
+ */
150
+ change: [item: DropdownItem<T>];
151
+ }
152
+ export interface DropdownSlots {
153
+ /**
154
+ * The trigger element for opening/closing the menu.
155
+ */
156
+ default?: () => any;
157
+ /**
158
+ * You can customize the appearance of dropdown items using this slot.
159
+ */
160
+ items?: (props: {
161
+ /**
162
+ * Function that triggers dropdown close.
163
+ */
164
+ closeDropdown: () => void;
165
+ /**
166
+ * Function that lets KDropdown track selected item when selectionMenu is true.
167
+ */
168
+ handleSelection: (item: DropdownItem) => void;
169
+ }) => any;
170
+ }
@@ -146,7 +146,7 @@ export interface PopSlots {
146
146
  */
147
147
  footer?: () => any;
148
148
  }
149
- export type PopoverAttributes = Pick<PopProps, 'placement' | 'popoverClasses' | 'offset' | 'width'
149
+ export type PopoverAttributes = Pick<PopProps, 'placement' | 'popoverClasses' | 'popoverTimeout' | 'offset' | 'width' | 'hideCaret'
150
150
  /** Not supported in KDropdown, KSelect and KMultiselect */
151
151
  | 'target' | 'trigger'> & {
152
152
  'data-testid'?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kong/kongponents",
3
- "version": "9.29.7",
3
+ "version": "9.29.8",
4
4
  "description": "Kong Component library",
5
5
  "type": "module",
6
6
  "repository": {