@aurodesignsystem/auro-formkit 5.8.1 → 5.9.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 +7 -15
- package/components/checkbox/demo/api.min.js +1 -1
- package/components/checkbox/demo/index.min.js +1 -1
- package/components/checkbox/dist/index.js +1 -1
- package/components/checkbox/dist/registered.js +1 -1
- package/components/combobox/demo/api.md +7 -6
- package/components/combobox/demo/api.min.js +1651 -987
- package/components/combobox/demo/index.min.js +1651 -987
- package/components/combobox/dist/auro-combobox.d.ts +9 -8
- package/components/combobox/dist/index.js +86 -85
- package/components/combobox/dist/registered.js +86 -85
- package/components/counter/demo/api.min.js +2 -2
- package/components/counter/demo/index.min.js +2 -2
- package/components/counter/dist/index.js +2 -2
- package/components/counter/dist/registered.js +2 -2
- package/components/datepicker/demo/api.min.js +4 -3
- package/components/datepicker/demo/index.min.js +4 -3
- package/components/datepicker/dist/index.js +4 -3
- package/components/datepicker/dist/registered.js +4 -3
- package/components/dropdown/demo/api.min.js +1 -1
- package/components/dropdown/demo/index.min.js +1 -1
- package/components/dropdown/dist/index.js +1 -1
- package/components/dropdown/dist/registered.js +1 -1
- package/components/input/demo/api.min.js +2 -1
- package/components/input/demo/index.min.js +2 -1
- package/components/input/dist/index.js +2 -1
- package/components/input/dist/registered.js +2 -1
- package/components/menu/demo/api.js +4 -0
- package/components/menu/demo/api.md +271 -26
- package/components/menu/demo/api.min.js +1591 -863
- package/components/menu/demo/index.html +1 -0
- package/components/menu/demo/index.js +2 -0
- package/components/menu/demo/index.md +95 -1
- package/components/menu/demo/index.min.js +1524 -810
- package/components/menu/dist/auro-menu.context.d.ts +222 -0
- package/components/menu/dist/auro-menu.d.ts +93 -53
- package/components/menu/dist/auro-menuoption.d.ts +115 -13
- package/components/menu/dist/index.js +1441 -798
- package/components/menu/dist/registered.js +1440 -809
- package/components/radio/demo/api.min.js +1 -1
- package/components/radio/demo/index.min.js +1 -1
- package/components/radio/dist/index.js +1 -1
- package/components/radio/dist/registered.js +1 -1
- package/components/select/demo/api.md +8 -7
- package/components/select/demo/api.min.js +1573 -1006
- package/components/select/demo/index.min.js +1573 -1006
- package/components/select/dist/auro-select.d.ts +11 -35
- package/components/select/dist/index.js +64 -160
- package/components/select/dist/registered.js +64 -160
- package/package.json +2 -1
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
export class MenuService {
|
|
2
|
+
/**
|
|
3
|
+
* CONSTRUCTOR
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Creates a new MenuService instance.
|
|
7
|
+
* @param {Object} options - The options object.
|
|
8
|
+
* @param {AuroMenu} options.host - The host element that this service will control. Required.
|
|
9
|
+
* @throws {Error} If the host is not provided.
|
|
10
|
+
*/
|
|
11
|
+
constructor({ host }?: {
|
|
12
|
+
host: AuroMenu;
|
|
13
|
+
});
|
|
14
|
+
/**
|
|
15
|
+
* PROPERTIES AND GETTERS
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Gets the list of registered menu options.
|
|
19
|
+
* @returns {AuroMenuOption[]}
|
|
20
|
+
*/
|
|
21
|
+
get menuOptions(): AuroMenuOption[];
|
|
22
|
+
/**
|
|
23
|
+
* Gets the currently highlighted option.
|
|
24
|
+
* @returns {AuroMenuOption|null}
|
|
25
|
+
*/
|
|
26
|
+
get highlightedOption(): AuroMenuOption | null;
|
|
27
|
+
/**
|
|
28
|
+
* Gets the current value(s) of the selected option(s).
|
|
29
|
+
* @returns {string|string[]|undefined}
|
|
30
|
+
*/
|
|
31
|
+
get currentValue(): string | string[] | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Gets the string representation of the current value(s).
|
|
34
|
+
* For multi-select, this is a JSON stringified array.
|
|
35
|
+
* @returns {string|undefined}
|
|
36
|
+
*/
|
|
37
|
+
get stringValue(): string | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Gets the key(s) of the currently selected option(s).
|
|
40
|
+
* @returns {string|string[]|undefined}
|
|
41
|
+
*/
|
|
42
|
+
get currentKeys(): string | string[] | undefined;
|
|
43
|
+
host: AuroMenu;
|
|
44
|
+
size: any;
|
|
45
|
+
shape: any;
|
|
46
|
+
noCheckmark: any;
|
|
47
|
+
disabled: any;
|
|
48
|
+
matchWord: any;
|
|
49
|
+
multiSelect: any;
|
|
50
|
+
allowDeselect: any;
|
|
51
|
+
selectAllMatchingOptions: any;
|
|
52
|
+
highlightedIndex: number;
|
|
53
|
+
_menuOptions: any[];
|
|
54
|
+
_subscribers: any[];
|
|
55
|
+
internalUpdateInProgress: boolean;
|
|
56
|
+
selectedOptions: any[];
|
|
57
|
+
/**
|
|
58
|
+
* PROPERTY SYNCING
|
|
59
|
+
*/
|
|
60
|
+
/**
|
|
61
|
+
* Handles host updates.
|
|
62
|
+
* This is a lit reactive lifecycle method.
|
|
63
|
+
* This comes from the Lit controller interface provided by adding this service as a controller to the host.
|
|
64
|
+
* See constructor for `this.host.addController(this)`
|
|
65
|
+
* You can read more about Lit reactive controllers here: https://lit.dev/docs/composition/controllers/
|
|
66
|
+
*/
|
|
67
|
+
hostUpdated(): void;
|
|
68
|
+
/**
|
|
69
|
+
* Handles host disconnection and memory cleanup.
|
|
70
|
+
*/
|
|
71
|
+
hostDisconnected(): void;
|
|
72
|
+
/**
|
|
73
|
+
* Sets a property value if it exists on the instance and the value has changed.
|
|
74
|
+
* @param {string} property
|
|
75
|
+
* @param {any} value
|
|
76
|
+
*/
|
|
77
|
+
setProperty(property: string, value: any): void;
|
|
78
|
+
/**
|
|
79
|
+
* Sets multiple properties on the instance.
|
|
80
|
+
* @param {Object} properties - Key-value pairs of properties to set.
|
|
81
|
+
*/
|
|
82
|
+
setProperties(properties: any): void;
|
|
83
|
+
/**
|
|
84
|
+
* MENU OPTION HIGHLIGHTING
|
|
85
|
+
*/
|
|
86
|
+
/**
|
|
87
|
+
* Highlights the next active option in the menu.
|
|
88
|
+
*/
|
|
89
|
+
highlightNext(): void;
|
|
90
|
+
/**
|
|
91
|
+
* Highlights the previous active option in the menu.
|
|
92
|
+
*/
|
|
93
|
+
highlightPrevious(): void;
|
|
94
|
+
/**
|
|
95
|
+
* Moves the highlighted option in the specified direction.
|
|
96
|
+
* @param {string} direction - The direction to move the highlight ("next" or "previous").
|
|
97
|
+
*/
|
|
98
|
+
moveHighlightedOption(direction: string): void;
|
|
99
|
+
/**
|
|
100
|
+
* Sets the highlighted index to the specified option.
|
|
101
|
+
* @param {AuroMenuOption} option - The option to highlight.
|
|
102
|
+
*/
|
|
103
|
+
setHighlightedOption(option: AuroMenuOption): void;
|
|
104
|
+
/**
|
|
105
|
+
* Sets the highlighted option to the option at the specified index if it exists.
|
|
106
|
+
* @param {number} index
|
|
107
|
+
*/
|
|
108
|
+
setHighlightedIndex(index: number): void;
|
|
109
|
+
/**
|
|
110
|
+
* Selects the currently highlighted option.
|
|
111
|
+
*/
|
|
112
|
+
selectHighlightedOption(): void;
|
|
113
|
+
/**
|
|
114
|
+
* SELECTION AND DESELECTION METHODS
|
|
115
|
+
*/
|
|
116
|
+
/**
|
|
117
|
+
* Selects one or more options in a batch operation
|
|
118
|
+
* @param {AuroMenuOption|AuroMenuOption[]} options - Single option or array of options to select
|
|
119
|
+
*/
|
|
120
|
+
selectOptions(options: AuroMenuOption | AuroMenuOption[]): void;
|
|
121
|
+
/**
|
|
122
|
+
* Deselects one or more options in a batch operation
|
|
123
|
+
* @param {AuroMenuOption|AuroMenuOption[]} options - Single option or array of options to deselect
|
|
124
|
+
*/
|
|
125
|
+
deselectOptions(options: AuroMenuOption | AuroMenuOption[]): void;
|
|
126
|
+
/**
|
|
127
|
+
* Selects a single option.
|
|
128
|
+
* @param {AuroMenuOption} option
|
|
129
|
+
*/
|
|
130
|
+
selectOption(option: AuroMenuOption): void;
|
|
131
|
+
/**
|
|
132
|
+
* Deselects a single option.
|
|
133
|
+
* @param {AuroMenuOption} option
|
|
134
|
+
*/
|
|
135
|
+
deselectOption(option: AuroMenuOption): void;
|
|
136
|
+
/**
|
|
137
|
+
* Toggles the selection state of a single option.
|
|
138
|
+
* @param {AuroMenuOption} option
|
|
139
|
+
*/
|
|
140
|
+
toggleOption(option: AuroMenuOption): void;
|
|
141
|
+
/**
|
|
142
|
+
* Selects options based on their value(s) when compared to a passed value or values.
|
|
143
|
+
* Value or values are normalized to an array of strings that can be matched to option keys.
|
|
144
|
+
* @param {string|number|Array<string|number>} value - The value(s) to select.
|
|
145
|
+
*/
|
|
146
|
+
selectByValue(value: string | number | Array<string | number>): void;
|
|
147
|
+
/**
|
|
148
|
+
* Resets the selected options to an empty array.
|
|
149
|
+
*/
|
|
150
|
+
reset(): void;
|
|
151
|
+
/**
|
|
152
|
+
* SUBSCRIPTION, NOTIFICATION AND EVENT DISPATCH METHODS
|
|
153
|
+
*/
|
|
154
|
+
/**
|
|
155
|
+
* Subscribes a callback to menu service events.
|
|
156
|
+
* @param {Function} callback - The callback to invoke on events.
|
|
157
|
+
*/
|
|
158
|
+
subscribe(callback: Function): void;
|
|
159
|
+
/**
|
|
160
|
+
* Remove a previously subscribed callback from menu service events.
|
|
161
|
+
* @param {Function} callback
|
|
162
|
+
*/
|
|
163
|
+
unsubscribe(callback: Function): void;
|
|
164
|
+
/**
|
|
165
|
+
* Stages an update to notify subscribers of state and value changes.
|
|
166
|
+
*/
|
|
167
|
+
stageUpdate(): void;
|
|
168
|
+
/**
|
|
169
|
+
* Notifies subscribers of a menu service event.
|
|
170
|
+
* All notifications are sent to all subscribers.
|
|
171
|
+
* @param {string} event - The event to send to subscribers.
|
|
172
|
+
*/
|
|
173
|
+
notify(event: string): void;
|
|
174
|
+
/**
|
|
175
|
+
* Notifies subscribers of a state change (selected options has changed).
|
|
176
|
+
*/
|
|
177
|
+
notifyStateChange(): void;
|
|
178
|
+
/**
|
|
179
|
+
* Notifies subscribers of a value change (current value has changed).
|
|
180
|
+
*/
|
|
181
|
+
notifyValueChange(): void;
|
|
182
|
+
/**
|
|
183
|
+
* Dispatches a custom event from the host element.
|
|
184
|
+
* @param {string} eventName
|
|
185
|
+
* @param {any} detail
|
|
186
|
+
*/
|
|
187
|
+
dispatchChangeEvent(eventName: string, detail: any): void;
|
|
188
|
+
/**
|
|
189
|
+
* MENU OPTION MANAGEMENT METHODS
|
|
190
|
+
*/
|
|
191
|
+
/**
|
|
192
|
+
* Adds a menu option to the service's list.
|
|
193
|
+
* @param {AuroMenuOption} option - the option to track
|
|
194
|
+
*/
|
|
195
|
+
addMenuOption(option: AuroMenuOption): void;
|
|
196
|
+
/**
|
|
197
|
+
* Removes a menu option from the service's list.
|
|
198
|
+
* @param {AuroMenuOption} option - the option to remove
|
|
199
|
+
*/
|
|
200
|
+
removeMenuOption(option: AuroMenuOption): void;
|
|
201
|
+
/**
|
|
202
|
+
* UTILITIES
|
|
203
|
+
*/
|
|
204
|
+
/**
|
|
205
|
+
* Normalizes a value or array of values into an array of strings for option selection.
|
|
206
|
+
* This function ensures that input values are consistently formatted for matching menu options.
|
|
207
|
+
*
|
|
208
|
+
* @param {string|number|Array<string|number>} value - The value(s) to normalize.
|
|
209
|
+
* @returns {Array<string>} An array of string values suitable for option matching.
|
|
210
|
+
* @throws {Error} If any value is not a string or number.
|
|
211
|
+
*/
|
|
212
|
+
_getNormalizedValues(value: string | number | Array<string | number>): Array<string>;
|
|
213
|
+
/**
|
|
214
|
+
* Returns whether two arrays of options contain the same elements.
|
|
215
|
+
* @param {AuroMenuOption[]} arr1 - First array of options.
|
|
216
|
+
* @param {AuroMenuOption[]} arr2 - Second array of options.
|
|
217
|
+
* @returns {boolean} True if arrays match, false otherwise.
|
|
218
|
+
*/
|
|
219
|
+
optionsArraysMatch(arr1: AuroMenuOption[], arr2: AuroMenuOption[]): boolean;
|
|
220
|
+
}
|
|
221
|
+
export const MenuContext: import("@lit/context").Context<"menu-context", any>;
|
|
222
|
+
import { AuroMenuOption } from "./auro-menuoption";
|
|
@@ -7,6 +7,10 @@
|
|
|
7
7
|
* @attr {boolean} nocheckmark - When true, selected option will not show the checkmark.
|
|
8
8
|
* @attr {boolean} loading - When true, displays a loading state using the loadingIcon and loadingText slots if provided.
|
|
9
9
|
* @attr {boolean} multiselect - When true, the selected option can be multiple options.
|
|
10
|
+
* @attr {boolean} selectAllMatchingOptions - When true, selects all options that match the provided value/key when setting value and multiselect is enabled.
|
|
11
|
+
* @attr {string} value - The value of the selected option. In multi-select mode, this is a JSON stringified array of selected option values.
|
|
12
|
+
* @prop {string} size - Sets the size of the menu. Accepted values are 'sm' and 'md'. Default is 'sm'.
|
|
13
|
+
* @prop {string} shape - Sets the shape of the menu options. Accepted values are 'box' and 'round'. Default is 'box'.
|
|
10
14
|
* @prop {boolean} hasLoadingPlaceholder - Indicates whether the menu has a loadingIcon or loadingText to render when in a loading state.
|
|
11
15
|
* @event {CustomEvent<Element>} auroMenu-activatedOption - Notifies that a menuoption has been made `active`.
|
|
12
16
|
* @event {CustomEvent<any>} auroMenu-customEventFired - Notifies that a custom event has been fired.
|
|
@@ -20,6 +24,13 @@
|
|
|
20
24
|
*/
|
|
21
25
|
export class AuroMenu extends AuroElement {
|
|
22
26
|
static get properties(): {
|
|
27
|
+
/**
|
|
28
|
+
* Allows deselecting an already selected option when clicked again in single-select mode.
|
|
29
|
+
*/
|
|
30
|
+
allowDeselect: {
|
|
31
|
+
type: BooleanConstructor;
|
|
32
|
+
reflect: boolean;
|
|
33
|
+
};
|
|
23
34
|
noCheckmark: {
|
|
24
35
|
type: BooleanConstructor;
|
|
25
36
|
reflect: boolean;
|
|
@@ -49,6 +60,10 @@ export class AuroMenu extends AuroElement {
|
|
|
49
60
|
reflect: boolean;
|
|
50
61
|
attribute: string;
|
|
51
62
|
};
|
|
63
|
+
selectAllMatchingOptions: {
|
|
64
|
+
type: BooleanConstructor;
|
|
65
|
+
reflect: boolean;
|
|
66
|
+
};
|
|
52
67
|
/**
|
|
53
68
|
* Value selected for the component.
|
|
54
69
|
*/
|
|
@@ -66,6 +81,11 @@ export class AuroMenu extends AuroElement {
|
|
|
66
81
|
reflect: boolean;
|
|
67
82
|
attribute: boolean;
|
|
68
83
|
};
|
|
84
|
+
options: {
|
|
85
|
+
type: ArrayConstructor;
|
|
86
|
+
reflect: boolean;
|
|
87
|
+
attribute: boolean;
|
|
88
|
+
};
|
|
69
89
|
layout: {
|
|
70
90
|
type: StringConstructor;
|
|
71
91
|
attribute: string;
|
|
@@ -94,9 +114,11 @@ export class AuroMenu extends AuroElement {
|
|
|
94
114
|
optionSelected: any;
|
|
95
115
|
matchWord: any;
|
|
96
116
|
noCheckmark: boolean;
|
|
97
|
-
optionActive:
|
|
117
|
+
optionActive: any;
|
|
98
118
|
loading: boolean;
|
|
99
119
|
multiSelect: boolean;
|
|
120
|
+
allowDeselect: boolean;
|
|
121
|
+
selectAllMatchingOptions: boolean;
|
|
100
122
|
/**
|
|
101
123
|
* Handles keyboard navigation.
|
|
102
124
|
* @private
|
|
@@ -104,22 +126,24 @@ export class AuroMenu extends AuroElement {
|
|
|
104
126
|
*/
|
|
105
127
|
private handleKeyDown;
|
|
106
128
|
/**
|
|
107
|
-
* Handles
|
|
129
|
+
* Handles slot change events.
|
|
108
130
|
* @private
|
|
109
|
-
* @param {MouseEvent} event - Event object from the browser.
|
|
110
131
|
*/
|
|
111
|
-
private
|
|
132
|
+
private handleSlotChange;
|
|
112
133
|
/**
|
|
113
|
-
*
|
|
114
|
-
* @
|
|
115
|
-
* @
|
|
134
|
+
* @readonly
|
|
135
|
+
* @returns {Array<HTMLElement>} - Returns the array of available menu options.
|
|
136
|
+
* @deprecated use `options` property instead.
|
|
116
137
|
*/
|
|
117
|
-
|
|
138
|
+
readonly get items(): Array<HTMLElement>;
|
|
118
139
|
/**
|
|
119
|
-
*
|
|
120
|
-
* @private
|
|
140
|
+
* @param {number} value - Sets the index of the currently active option.
|
|
121
141
|
*/
|
|
122
|
-
|
|
142
|
+
set index(value: number);
|
|
143
|
+
/**
|
|
144
|
+
* @returns {number} - Returns the index of the currently active option.
|
|
145
|
+
*/
|
|
146
|
+
get index(): number;
|
|
123
147
|
/**
|
|
124
148
|
* Formatted value based on `multiSelect` state.
|
|
125
149
|
* Default type is `String`, changing to `Array<String>` when `multiSelect` is true.
|
|
@@ -127,45 +151,75 @@ export class AuroMenu extends AuroElement {
|
|
|
127
151
|
* @returns {String|Array<String>}
|
|
128
152
|
*/
|
|
129
153
|
private get formattedValue();
|
|
154
|
+
/**
|
|
155
|
+
* Gets the current property values for the menu service.
|
|
156
|
+
* @private
|
|
157
|
+
* @returns {Object}
|
|
158
|
+
*/
|
|
159
|
+
private get propertyValues();
|
|
160
|
+
/**
|
|
161
|
+
* Provides the menu context to child components.
|
|
162
|
+
* Initializes the MenuService and subscribes to menu changes.
|
|
163
|
+
* @protected
|
|
164
|
+
*/
|
|
165
|
+
protected provideContext(): void;
|
|
166
|
+
menuService: MenuService;
|
|
167
|
+
_contextProvider: ContextProvider<import("@lit/context").Context<"menu-context", any>, this>;
|
|
168
|
+
/**
|
|
169
|
+
* Updates the currently active option in the menu.
|
|
170
|
+
* @param {HTMLElement} option - The option to set as active.
|
|
171
|
+
*/
|
|
172
|
+
updateActiveOption(option: HTMLElement): void;
|
|
173
|
+
/**
|
|
174
|
+
* Sets the internal value and manages update state.
|
|
175
|
+
* @param {String|Array<String>} value - The value to set.
|
|
176
|
+
* @protected
|
|
177
|
+
*/
|
|
178
|
+
protected setInternalValue(value: string | Array<string>): void;
|
|
179
|
+
internalUpdateInProgress: boolean;
|
|
180
|
+
/**
|
|
181
|
+
* Handles changes from the menu service and updates component state.
|
|
182
|
+
* @param {Object} event - The event object from the menu service.
|
|
183
|
+
* @protected
|
|
184
|
+
*/
|
|
185
|
+
protected handleMenuChange(event: any): void;
|
|
186
|
+
_index: any;
|
|
187
|
+
options: any;
|
|
188
|
+
/**
|
|
189
|
+
* Gets the currently selected options.
|
|
190
|
+
* @returns {Array<HTMLElement>}
|
|
191
|
+
*/
|
|
192
|
+
get selectedOptions(): Array<HTMLElement>;
|
|
193
|
+
/**
|
|
194
|
+
* Gets the first selected option, or null if none.
|
|
195
|
+
* @returns {HTMLElement|null}
|
|
196
|
+
*/
|
|
197
|
+
get selectedOption(): HTMLElement | null;
|
|
130
198
|
firstUpdated(): void;
|
|
131
199
|
loadingSlots: NodeListOf<Element>;
|
|
200
|
+
updated(changedProperties: any): void;
|
|
132
201
|
/**
|
|
133
202
|
* Sets an attribute that matches the default tag name if the tag name is not the default.
|
|
134
203
|
* @param {string} tagName - The tag name to set as an attribute.
|
|
135
204
|
* @private
|
|
136
205
|
*/
|
|
137
206
|
private setTagAttribute;
|
|
138
|
-
updated(changedProperties: any): void;
|
|
139
|
-
index: any;
|
|
140
207
|
/**
|
|
141
|
-
*
|
|
142
|
-
* @
|
|
143
|
-
* @
|
|
208
|
+
* Sets the loading state and dispatches a loading change event.
|
|
209
|
+
* @param {boolean} isLoading - Whether the menu is loading.
|
|
210
|
+
* @protected
|
|
144
211
|
*/
|
|
145
|
-
|
|
212
|
+
protected setLoadingState(isLoading: boolean): void;
|
|
146
213
|
/**
|
|
147
214
|
* Initializes the menu's state and structure.
|
|
148
215
|
* @private
|
|
149
216
|
*/
|
|
150
217
|
private initializeMenu;
|
|
151
218
|
/**
|
|
152
|
-
*
|
|
153
|
-
* @
|
|
154
|
-
*/
|
|
155
|
-
private initItems;
|
|
156
|
-
items: Element[];
|
|
157
|
-
/**
|
|
158
|
-
* Updates menu state when an option is selected.
|
|
159
|
-
* @private
|
|
160
|
-
* @param {HTMLElement} option - The option element to select.
|
|
161
|
-
*/
|
|
162
|
-
private handleSelectState;
|
|
163
|
-
/**
|
|
164
|
-
* Deselects a menu option and updates related state.
|
|
165
|
-
* @private
|
|
166
|
-
* @param {HTMLElement} option - The menuoption to be deselected.
|
|
219
|
+
* Selects the currently highlighted option.
|
|
220
|
+
* @protected
|
|
167
221
|
*/
|
|
168
|
-
|
|
222
|
+
protected makeSelection(): void;
|
|
169
223
|
/**
|
|
170
224
|
* Resets all options to their default state.
|
|
171
225
|
* @private
|
|
@@ -184,28 +238,12 @@ export class AuroMenu extends AuroElement {
|
|
|
184
238
|
*/
|
|
185
239
|
private handleNestedMenus;
|
|
186
240
|
/**
|
|
187
|
-
*
|
|
188
|
-
* @
|
|
189
|
-
|
|
190
|
-
private makeSelection;
|
|
191
|
-
/**
|
|
192
|
-
* Toggle the selection state of the menuoption.
|
|
193
|
-
* @private
|
|
194
|
-
* @param {HTMLElement} option - The menuoption to toggle.
|
|
241
|
+
* Navigates the menu options in the specified direction.
|
|
242
|
+
* @param {'up'|'down'} direction - The direction to navigate.
|
|
243
|
+
* @protected
|
|
195
244
|
*/
|
|
196
|
-
|
|
245
|
+
protected navigateOptions(direction: "up" | "down"): void;
|
|
197
246
|
rootMenu: boolean;
|
|
198
|
-
/**
|
|
199
|
-
* Navigates through options using keyboard.
|
|
200
|
-
* @private
|
|
201
|
-
* @param {string} direction - 'up' or 'down'.
|
|
202
|
-
*/
|
|
203
|
-
private navigateOptions;
|
|
204
|
-
/**
|
|
205
|
-
* Updates the active option state and dispatches events.
|
|
206
|
-
* @param {number} index - Index of the option to make active.
|
|
207
|
-
*/
|
|
208
|
-
updateActiveOption(index: number): void;
|
|
209
247
|
/**
|
|
210
248
|
* Handles custom events defined on options.
|
|
211
249
|
* @private
|
|
@@ -244,3 +282,5 @@ export class AuroMenu extends AuroElement {
|
|
|
244
282
|
protected renderLayout(): void;
|
|
245
283
|
}
|
|
246
284
|
import { AuroElement } from "../../layoutElement/src/auroElement.js";
|
|
285
|
+
import { MenuService } from "./auro-menu.context.js";
|
|
286
|
+
import { ContextProvider } from "@lit/context";
|
|
@@ -9,27 +9,52 @@
|
|
|
9
9
|
* @slot - Specifies text for an option, but is not the value.
|
|
10
10
|
*/
|
|
11
11
|
export class AuroMenuOption extends AuroElement {
|
|
12
|
+
/**
|
|
13
|
+
* This will register this element with the browser.
|
|
14
|
+
* @param {string} [name="auro-menuoption"] - The name of element that you want to register to.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* AuroMenuOption.register("custom-menuoption") // this will register this element to <custom-menuoption/>
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
static register(name?: string): void;
|
|
12
21
|
static get properties(): {
|
|
13
|
-
|
|
22
|
+
disabled: {
|
|
14
23
|
type: BooleanConstructor;
|
|
15
24
|
reflect: boolean;
|
|
16
25
|
};
|
|
17
|
-
|
|
18
|
-
type:
|
|
26
|
+
event: {
|
|
27
|
+
type: StringConstructor;
|
|
19
28
|
reflect: boolean;
|
|
20
29
|
};
|
|
21
|
-
|
|
22
|
-
type:
|
|
30
|
+
key: {
|
|
31
|
+
type: StringConstructor;
|
|
23
32
|
reflect: boolean;
|
|
24
33
|
};
|
|
25
|
-
|
|
34
|
+
menuService: {
|
|
35
|
+
type: ObjectConstructor;
|
|
36
|
+
state: boolean;
|
|
37
|
+
};
|
|
38
|
+
matchWord: {
|
|
26
39
|
type: StringConstructor;
|
|
40
|
+
state: boolean;
|
|
41
|
+
};
|
|
42
|
+
nocheckmark: {
|
|
43
|
+
type: BooleanConstructor;
|
|
44
|
+
reflect: boolean;
|
|
45
|
+
};
|
|
46
|
+
selected: {
|
|
47
|
+
type: BooleanConstructor;
|
|
27
48
|
reflect: boolean;
|
|
28
49
|
};
|
|
29
50
|
tabIndex: {
|
|
30
51
|
type: NumberConstructor;
|
|
31
52
|
reflect: boolean;
|
|
32
53
|
};
|
|
54
|
+
value: {
|
|
55
|
+
type: StringConstructor;
|
|
56
|
+
reflect: boolean;
|
|
57
|
+
};
|
|
33
58
|
layout: {
|
|
34
59
|
type: StringConstructor;
|
|
35
60
|
attribute: string;
|
|
@@ -38,14 +63,11 @@ export class AuroMenuOption extends AuroElement {
|
|
|
38
63
|
};
|
|
39
64
|
static get styles(): import("lit").CSSResult[];
|
|
40
65
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* AuroMenuOption.register("custom-menuoption") // this will register this element to <custom-menuoption/>
|
|
46
|
-
*
|
|
66
|
+
* Returns whether the menu option is currently active and selectable.
|
|
67
|
+
* An option is considered active if it is not hidden, not disabled, and not static.
|
|
68
|
+
* @returns {boolean} True if the option is active, false otherwise.
|
|
47
69
|
*/
|
|
48
|
-
|
|
70
|
+
get isActive(): boolean;
|
|
49
71
|
/**
|
|
50
72
|
* @private
|
|
51
73
|
*/
|
|
@@ -62,8 +84,87 @@ export class AuroMenuOption extends AuroElement {
|
|
|
62
84
|
* @private
|
|
63
85
|
*/
|
|
64
86
|
private runtimeUtils;
|
|
87
|
+
menuService: any;
|
|
88
|
+
unsubscribe: any;
|
|
89
|
+
/**
|
|
90
|
+
* Handles changes from the menu service and updates the option's state.
|
|
91
|
+
* This function synchronizes the option's properties and selection/highlight state with menu events.
|
|
92
|
+
* @param {Object} event - The event object from the menu service.
|
|
93
|
+
*/
|
|
94
|
+
handleMenuChange(event: any): void;
|
|
95
|
+
_contextConsumer: ContextConsumer<import("@lit/context").Context<"menu-context", any>, this>;
|
|
96
|
+
key: any;
|
|
65
97
|
firstUpdated(): void;
|
|
66
98
|
updated(changedProperties: any): void;
|
|
99
|
+
/**
|
|
100
|
+
* Sets up event listeners for user interaction with the menu option.
|
|
101
|
+
* This function enables click and mouse enter events to trigger selection and highlighting logic.
|
|
102
|
+
*/
|
|
103
|
+
bindEvents(): void;
|
|
104
|
+
/**
|
|
105
|
+
* Attaches this menu option to a menu service and subscribes to its events.
|
|
106
|
+
* This method enables the option to participate in menu selection and highlighting logic.
|
|
107
|
+
* @param {Object} service - The menu service instance to attach to.
|
|
108
|
+
*/
|
|
109
|
+
attachTo(service: any): void;
|
|
110
|
+
active: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* Updates the internal selected state of the menu option bypassing 'updated' and triggers custom events if selected.
|
|
113
|
+
* This function ensures the option's selection state is synchronized with menu logic and notifies listeners.
|
|
114
|
+
* @param {boolean} isSelected - Whether the option should be marked as selected.
|
|
115
|
+
*/
|
|
116
|
+
setInternalSelected(isSelected: boolean): void;
|
|
117
|
+
internalUpdateInProgress: boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Sets the selected state of the menu option.
|
|
120
|
+
* This function updates whether the option is currently selected.
|
|
121
|
+
* @param {boolean} isSelected - Whether the option should be marked as selected.
|
|
122
|
+
* @deprecated Simply modify the `selected` property directly instead.
|
|
123
|
+
*/
|
|
124
|
+
setSelected(isSelected: boolean): void;
|
|
125
|
+
/**
|
|
126
|
+
* Updates the active state and visual highlighting of the menu option.
|
|
127
|
+
* This function toggles the option's active status and applies or removes the active CSS class.
|
|
128
|
+
* @param {boolean} isActive - Whether the option should be marked as active.
|
|
129
|
+
* @deprecated Simply modify the `active` property directly instead.
|
|
130
|
+
*/
|
|
131
|
+
updateActive(isActive: boolean): void;
|
|
132
|
+
/**
|
|
133
|
+
* Updates the CSS class for the menu option based on its active state.
|
|
134
|
+
* This function adds or removes the 'active' class to visually indicate the option's active status.
|
|
135
|
+
* @private
|
|
136
|
+
*/
|
|
137
|
+
private updateActiveClasses;
|
|
138
|
+
/**
|
|
139
|
+
* Updates the visual highlighting of text within the menu option based on the current match word.
|
|
140
|
+
* This function highlights matching text segments and manages nested spacers for display formatting.
|
|
141
|
+
* @private
|
|
142
|
+
*/
|
|
143
|
+
private updateTextHighlight;
|
|
144
|
+
/**
|
|
145
|
+
* Handles click events on the menu option, toggling its selected state.
|
|
146
|
+
* This function dispatches a click event and updates selection if the option is not disabled.
|
|
147
|
+
* @private
|
|
148
|
+
*/
|
|
149
|
+
private handleClick;
|
|
150
|
+
/**
|
|
151
|
+
* Handles mouse enter events to highlight the menu option.
|
|
152
|
+
* This function updates the menu service to set this option as the currently highlighted item if not disabled.
|
|
153
|
+
* @private
|
|
154
|
+
*/
|
|
155
|
+
private handleMouseEnter;
|
|
156
|
+
/**
|
|
157
|
+
* Dispatches custom events defined for this menu option.
|
|
158
|
+
* This function notifies listeners when a custom event is triggered by the option.
|
|
159
|
+
* @private
|
|
160
|
+
*/
|
|
161
|
+
private handleCustomEvent;
|
|
162
|
+
/**
|
|
163
|
+
* Dispatches a click event for this menu option.
|
|
164
|
+
* This function notifies listeners that the option has been clicked.
|
|
165
|
+
* @private
|
|
166
|
+
*/
|
|
167
|
+
private dispatchClickEvent;
|
|
67
168
|
/**
|
|
68
169
|
* Generates an HTML element containing an SVG icon based on the provided `svgContent`.
|
|
69
170
|
*
|
|
@@ -80,3 +181,4 @@ export class AuroMenuOption extends AuroElement {
|
|
|
80
181
|
protected renderLayout(): void;
|
|
81
182
|
}
|
|
82
183
|
import { AuroElement } from "../../layoutElement/src/auroElement.js";
|
|
184
|
+
import { ContextConsumer } from '@lit/context';
|