@ui5/webcomponents-ai 0.0.0-f42e7c18c → 0.0.0-fd426fe8a

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.
Files changed (77) hide show
  1. package/CHANGELOG.md +437 -0
  2. package/README.md +2 -1
  3. package/cypress.config.js +3 -0
  4. package/dist/.tsbuildinfo +1 -0
  5. package/dist/Assets-fetch.d.ts +3 -0
  6. package/dist/Assets-fetch.js +6 -0
  7. package/dist/Assets-fetch.js.map +1 -0
  8. package/dist/Assets-node.d.ts +14 -0
  9. package/dist/Assets-node.js +17 -0
  10. package/dist/Assets-node.js.map +1 -0
  11. package/dist/Button.d.ts +78 -33
  12. package/dist/Button.js +165 -78
  13. package/dist/Button.js.map +1 -1
  14. package/dist/ButtonState.d.ts +10 -3
  15. package/dist/ButtonState.js +16 -3
  16. package/dist/ButtonState.js.map +1 -1
  17. package/dist/ButtonTemplate.js +2 -2
  18. package/dist/ButtonTemplate.js.map +1 -1
  19. package/dist/PromptInput.d.ts +6 -11
  20. package/dist/PromptInput.js +3 -13
  21. package/dist/PromptInput.js.map +1 -1
  22. package/dist/css/themes/Button.css +1 -1
  23. package/dist/custom-elements-internal.json +105 -14
  24. package/dist/custom-elements.json +95 -12
  25. package/dist/generated/assets/i18n/messagebundle_en.json +1 -1
  26. package/dist/generated/assets/i18n/messagebundle_en_US_saprigi.json +1 -1
  27. package/dist/generated/assets/i18n/messagebundle_id.json +1 -0
  28. package/dist/generated/assets/themes/sap_horizon/parameters-bundle.css.json +1 -1
  29. package/dist/generated/assets/themes/sap_horizon_dark/parameters-bundle.css.json +1 -1
  30. package/dist/generated/assets/themes/sap_horizon_hcb/parameters-bundle.css.json +1 -1
  31. package/dist/generated/assets/themes/sap_horizon_hcw/parameters-bundle.css.json +1 -1
  32. package/dist/generated/i18n/i18n-defaults.d.ts +2 -1
  33. package/dist/generated/i18n/i18n-defaults.js +2 -1
  34. package/dist/generated/i18n/i18n-defaults.js.map +1 -1
  35. package/dist/generated/json-imports/Themes-fetch.js +1 -1
  36. package/dist/generated/json-imports/Themes-fetch.js.map +1 -1
  37. package/dist/generated/json-imports/Themes-node.d.ts +1 -0
  38. package/dist/generated/json-imports/Themes-node.js +21 -0
  39. package/dist/generated/json-imports/Themes-node.js.map +1 -0
  40. package/dist/generated/json-imports/Themes.js +1 -1
  41. package/dist/generated/json-imports/Themes.js.map +1 -1
  42. package/dist/generated/json-imports/i18n-fetch.js +3 -1
  43. package/dist/generated/json-imports/i18n-fetch.js.map +1 -1
  44. package/dist/generated/json-imports/i18n-node.d.ts +1 -0
  45. package/dist/generated/json-imports/i18n-node.js +120 -0
  46. package/dist/generated/json-imports/i18n-node.js.map +1 -0
  47. package/dist/generated/json-imports/i18n.js +3 -1
  48. package/dist/generated/json-imports/i18n.js.map +1 -1
  49. package/dist/generated/themes/Button.css.d.ts +2 -3
  50. package/dist/generated/themes/Button.css.js +4 -5
  51. package/dist/generated/themes/Button.css.js.map +1 -1
  52. package/dist/generated/themes/PromptInput.css.d.ts +2 -3
  53. package/dist/generated/themes/PromptInput.css.js +4 -5
  54. package/dist/generated/themes/PromptInput.css.js.map +1 -1
  55. package/dist/generated/themes/sap_horizon/parameters-bundle.css.d.ts +2 -3
  56. package/dist/generated/themes/sap_horizon/parameters-bundle.css.js +1 -2
  57. package/dist/generated/themes/sap_horizon/parameters-bundle.css.js.map +1 -1
  58. package/dist/generated/themes/sap_horizon_dark/parameters-bundle.css.d.ts +2 -3
  59. package/dist/generated/themes/sap_horizon_dark/parameters-bundle.css.js +1 -2
  60. package/dist/generated/themes/sap_horizon_dark/parameters-bundle.css.js.map +1 -1
  61. package/dist/generated/themes/sap_horizon_hcb/parameters-bundle.css.d.ts +2 -3
  62. package/dist/generated/themes/sap_horizon_hcb/parameters-bundle.css.js +1 -2
  63. package/dist/generated/themes/sap_horizon_hcb/parameters-bundle.css.js.map +1 -1
  64. package/dist/generated/themes/sap_horizon_hcw/parameters-bundle.css.d.ts +2 -3
  65. package/dist/generated/themes/sap_horizon_hcw/parameters-bundle.css.js +1 -2
  66. package/dist/generated/themes/sap_horizon_hcw/parameters-bundle.css.js.map +1 -1
  67. package/dist/vscode.html-custom-data.json +19 -4
  68. package/dist/web-types.json +49 -8
  69. package/package-scripts.cjs +4 -0
  70. package/package.json +12 -8
  71. package/src/ButtonTemplate.tsx +9 -6
  72. package/src/i18n/messagebundle.properties +5 -1
  73. package/src/i18n/messagebundle_en.properties +7 -0
  74. package/src/i18n/messagebundle_en_US_saprigi.properties +3 -0
  75. package/src/themes/Button.css +75 -21
  76. package/tsconfig.json +25 -6
  77. package/dist/tsconfig.tsbuildinfo +0 -1
package/dist/Button.d.ts CHANGED
@@ -1,24 +1,36 @@
1
1
  import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
2
- import MainButton from "@ui5/webcomponents/dist/Button.js";
2
+ import type SplitButton from "@ui5/webcomponents/dist/SplitButton.js";
3
3
  import type ButtonDesign from "@ui5/webcomponents/dist/types/ButtonDesign.js";
4
- import ButtonState from "./ButtonState.js";
4
+ import type ButtonState from "./ButtonState.js";
5
+ import "./ButtonState.js";
6
+ import type I18nBundle from "@ui5/webcomponents-base/dist/i18nBundle.js";
7
+ import type { AccessibilityAttributes } from "@ui5/webcomponents-base/dist/types.js";
8
+ type AIButtonRootAccessibilityAttributes = Pick<AccessibilityAttributes, "hasPopup" | "roleDescription" | "title">;
9
+ type AIButtonArrowButtonAccessibilityAttributes = Pick<AccessibilityAttributes, "hasPopup" | "expanded" | "title">;
10
+ type AIButtonAccessibilityAttributes = {
11
+ root?: AIButtonRootAccessibilityAttributes;
12
+ arrowButton?: AIButtonArrowButtonAccessibilityAttributes;
13
+ };
5
14
  /**
6
15
  * @class
7
16
  *
8
17
  * ### Overview
9
18
  *
10
- * The `ui5-ai-button` component represents a button used in AI-related scenarios.
11
- * It enables users to trigger actions by clicking or tapping the `ui5-ai-button`, or by pressing
12
- * certain keyboard keys, such as Enter.
19
+ * The `ui5-ai-button` component serves as a button for AI-related scenarios. Users can trigger actions by clicking or tapping the `ui5-ai-button`
20
+ * or by pressing keyboard keys like [Enter] or [Space].
13
21
  *
14
22
  * ### Usage
15
23
  *
16
- * For the `ui5-ai-button` UI, you can define one or more states of the button by placing `ai-button-state` components in its default slot.
17
- * Each state have a name that identifies it and can have text, icon and end icon defined (in any combination) depending on the state purpose.
24
+ * For the `ui5-ai-button` user interface, you can define one or more button states by placing `ui5-ai-button-state` components in their default slot.
25
+ * Each state has a name for identification and can include text, an icon, and an end icon, as needed for its purpose.
26
+ * You can define a split mode for the `ui5-ai-button`, which will results in displaying an arrow button for additional actions.
18
27
  *
19
- * You can choose from a set of predefined designs (the same as for regular `ui5-button` component) that allow different styling to correspond to the triggered action.
28
+ * You can choose from a set of predefined designs for `ui5-ai-button` (as in `ui5-button`) to match the desired styling.
20
29
  *
21
- * `ui5-ai-button` can be activated by clicking or tapping it. The state can be changed in `click` event handler.
30
+ * The `ui5-ai-button` can be activated by clicking or tapping it. You can change the button state in the click event handler. When the button is
31
+ * in split mode, you can activate the default button action by clicking or tapping it, or by pressing keyboard keys like [Enter] or [Space].
32
+ * You can activate the arrow button by clicking or tapping it, or by pressing keyboard keys like [Arrow Up], [Arrow Down], or [F4].
33
+ * To display additional actions, you can attach a menu to the arrow button.
22
34
  *
23
35
  * ### ES6 Module Import
24
36
  *
@@ -32,7 +44,8 @@ import ButtonState from "./ButtonState.js";
32
44
  */
33
45
  declare class Button extends UI5Element {
34
46
  eventDetails: {
35
- click: void;
47
+ "click": void;
48
+ "arrow-button-click": void;
36
49
  };
37
50
  /**
38
51
  * Defines the component design.
@@ -56,34 +69,67 @@ declare class Button extends UI5Element {
56
69
  */
57
70
  state?: string;
58
71
  /**
59
- * Keeps the current state object of the component.
60
- * @private
61
- */
62
- _currentStateObject?: ButtonState;
63
- /**
64
- * Initiates button elements fade-out phase.
72
+ * Defines the active state of the arrow button in split mode.
73
+ * Set to true when the button is in split mode and a menu with additional options
74
+ * is opened by the arrow button. Set back to false when the menu is closed.
65
75
  * @default false
66
- * @private
76
+ * @public
77
+ * @since 2.6.0
67
78
  */
68
- fadeOut: boolean;
79
+ arrowButtonPressed: boolean;
69
80
  /**
70
- * Initiates button fade middle phase.
71
- * @default false
81
+ * Defines the additional accessibility attributes that will be applied to the component.
82
+ *
83
+ * This property allows for fine-tuned control of ARIA attributes for screen reader support.
84
+ * It accepts an object with the following optional fields:
85
+ *
86
+ * - **root**: Accessibility attributes that will be applied to the root element.
87
+ * - **hasPopup**: Indicates the availability and type of interactive popup element (such as a menu or dialog).
88
+ * Accepts string values: `"dialog"`, `"grid"`, `"listbox"`, `"menu"`, or `"tree"`.
89
+ * - **roleDescription**: Defines a human-readable description for the button's role.
90
+ * Accepts any string value.
91
+ *
92
+ * - **arrowButton**: Accessibility attributes that will be applied to the arrow (split) button element.
93
+ * - **hasPopup**: Indicates the type of popup triggered by the arrow button.
94
+ * Accepts string values: `"dialog"`, `"grid"`, `"listbox"`, `"menu"`, or `"tree"`.
95
+ * - **expanded**: Indicates whether the popup controlled by the arrow button is currently expanded.
96
+ * Accepts boolean values: `true` or `false`.
97
+ *
98
+ * @public
99
+ * @since 2.6.0
100
+ * @default {}
101
+ */
102
+ accessibilityAttributes: AIButtonAccessibilityAttributes;
103
+ /**
104
+ * Keeps the current state object of the component.
72
105
  * @private
73
106
  */
74
- fadeMid: boolean;
107
+ _currentStateObject?: ButtonState;
75
108
  /**
76
- * Initiates button elements fade-in phase.
109
+ * Determines if the button is in icon-only mode.
110
+ * This property is animation related only.
77
111
  * @default false
78
112
  * @private
79
113
  */
80
- fadeIn: boolean;
114
+ iconOnly?: boolean | undefined;
81
115
  /**
82
116
  * Defines the available states of the component.
83
- * **Note:** Although this slot accepts HTML Elements, it is strongly recommended that you only use `ui5-ai-button-state` components in order to preserve the intended design.
117
+ * **Note:** Although this slot accepts HTML Elements, it is strongly recommended that
118
+ * you only use `ui5-ai-button-state` components in order to preserve the intended design.
84
119
  * @public
85
120
  */
86
121
  states: Array<ButtonState>;
122
+ _splitButton?: SplitButton;
123
+ _hiddenSplitButton?: SplitButton;
124
+ static i18nBundle: I18nBundle;
125
+ get _hideArrowButton(): boolean;
126
+ get _effectiveState(): string;
127
+ get _effectiveStateObject(): ButtonState | undefined;
128
+ get _stateIconOnly(): boolean;
129
+ get _stateText(): string | undefined;
130
+ get _stateIcon(): string | undefined;
131
+ get _stateEndIcon(): string | undefined;
132
+ get _hasText(): boolean;
87
133
  onBeforeRendering(): void;
88
134
  /**
89
135
  * Starts the fade-out animation.
@@ -104,14 +150,13 @@ declare class Button extends UI5Element {
104
150
  * Handles the click event.
105
151
  * @private
106
152
  */
107
- _onclick(e: MouseEvent): void;
108
- get _mainButton(): MainButton;
109
- get _effectiveState(): string;
110
- get _effectiveStateObject(): ButtonState | undefined;
111
- get _stateIconOnly(): boolean;
112
- get _stateText(): string | undefined;
113
- get _stateIcon(): string | undefined;
114
- get _stateEndIcon(): string | undefined;
115
- get _hasText(): boolean;
153
+ _onClick(e: CustomEvent): void;
154
+ /**
155
+ * Handles the arrow-button-click event when `ui5-ai-button` is in split mode.
156
+ * @private
157
+ */
158
+ _onArrowClick(e: CustomEvent): void;
159
+ get _computedAccessibilityAttributes(): AIButtonAccessibilityAttributes;
116
160
  }
117
161
  export default Button;
162
+ export type { AIButtonAccessibilityAttributes, };
package/dist/Button.js CHANGED
@@ -4,36 +4,42 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
4
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
+ var Button_1;
7
8
  import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
8
9
  import { renderFinished } from "@ui5/webcomponents-base/dist/Render.js";
9
10
  import customElement from "@ui5/webcomponents-base/dist/decorators/customElement.js";
10
11
  import property from "@ui5/webcomponents-base/dist/decorators/property.js";
11
12
  import event from "@ui5/webcomponents-base/dist/decorators/event-strict.js";
12
13
  import slot from "@ui5/webcomponents-base/dist/decorators/slot.js";
14
+ import query from "@ui5/webcomponents-base/dist/decorators/query.js";
13
15
  import jsxRenderer from "@ui5/webcomponents-base/dist/renderer/JsxRenderer.js";
14
- import MainButton from "@ui5/webcomponents/dist/Button.js";
15
- import Icon from "@ui5/webcomponents/dist/Icon.js";
16
- import ButtonState from "./ButtonState.js";
16
+ import { BUTTON_TOOLTIP_TEXT } from "./generated/i18n/i18n-defaults.js";
17
+ import "./ButtonState.js";
17
18
  import ButtonTemplate from "./ButtonTemplate.js";
19
+ import { getEffectiveAriaLabelText, getAssociatedLabelForTexts, getAllAccessibleNameRefTexts, } from "@ui5/webcomponents-base/dist/util/AccessibilityTextsHelper.js";
18
20
  // Styles
19
21
  import ButtonCss from "./generated/themes/Button.css.js";
22
+ import { i18n } from "@ui5/webcomponents-base/dist/decorators.js";
20
23
  /**
21
24
  * @class
22
25
  *
23
26
  * ### Overview
24
27
  *
25
- * The `ui5-ai-button` component represents a button used in AI-related scenarios.
26
- * It enables users to trigger actions by clicking or tapping the `ui5-ai-button`, or by pressing
27
- * certain keyboard keys, such as Enter.
28
+ * The `ui5-ai-button` component serves as a button for AI-related scenarios. Users can trigger actions by clicking or tapping the `ui5-ai-button`
29
+ * or by pressing keyboard keys like [Enter] or [Space].
28
30
  *
29
31
  * ### Usage
30
32
  *
31
- * For the `ui5-ai-button` UI, you can define one or more states of the button by placing `ai-button-state` components in its default slot.
32
- * Each state have a name that identifies it and can have text, icon and end icon defined (in any combination) depending on the state purpose.
33
+ * For the `ui5-ai-button` user interface, you can define one or more button states by placing `ui5-ai-button-state` components in their default slot.
34
+ * Each state has a name for identification and can include text, an icon, and an end icon, as needed for its purpose.
35
+ * You can define a split mode for the `ui5-ai-button`, which will results in displaying an arrow button for additional actions.
33
36
  *
34
- * You can choose from a set of predefined designs (the same as for regular `ui5-button` component) that allow different styling to correspond to the triggered action.
37
+ * You can choose from a set of predefined designs for `ui5-ai-button` (as in `ui5-button`) to match the desired styling.
35
38
  *
36
- * `ui5-ai-button` can be activated by clicking or tapping it. The state can be changed in `click` event handler.
39
+ * The `ui5-ai-button` can be activated by clicking or tapping it. You can change the button state in the click event handler. When the button is
40
+ * in split mode, you can activate the default button action by clicking or tapping it, or by pressing keyboard keys like [Enter] or [Space].
41
+ * You can activate the arrow button by clicking or tapping it, or by pressing keyboard keys like [Arrow Up], [Arrow Down], or [F4].
42
+ * To display additional actions, you can attach a menu to the arrow button.
37
43
  *
38
44
  * ### ES6 Module Import
39
45
  *
@@ -45,7 +51,7 @@ import ButtonCss from "./generated/themes/Button.css.js";
45
51
  * @public
46
52
  * @experimental The Button and ButtonState web components are availabe since 2.0 under an experimental flag and their API and behaviour are subject to change.
47
53
  */
48
- let Button = class Button extends UI5Element {
54
+ let Button = Button_1 = class Button extends UI5Element {
49
55
  constructor() {
50
56
  super(...arguments);
51
57
  /**
@@ -63,32 +69,80 @@ let Button = class Button extends UI5Element {
63
69
  */
64
70
  this.disabled = false;
65
71
  /**
66
- * Initiates button elements fade-out phase.
72
+ * Defines the active state of the arrow button in split mode.
73
+ * Set to true when the button is in split mode and a menu with additional options
74
+ * is opened by the arrow button. Set back to false when the menu is closed.
67
75
  * @default false
68
- * @private
76
+ * @public
77
+ * @since 2.6.0
69
78
  */
70
- this.fadeOut = false;
79
+ this.arrowButtonPressed = false;
71
80
  /**
72
- * Initiates button fade middle phase.
73
- * @default false
74
- * @private
75
- */
76
- this.fadeMid = false;
81
+ * Defines the additional accessibility attributes that will be applied to the component.
82
+ *
83
+ * This property allows for fine-tuned control of ARIA attributes for screen reader support.
84
+ * It accepts an object with the following optional fields:
85
+ *
86
+ * - **root**: Accessibility attributes that will be applied to the root element.
87
+ * - **hasPopup**: Indicates the availability and type of interactive popup element (such as a menu or dialog).
88
+ * Accepts string values: `"dialog"`, `"grid"`, `"listbox"`, `"menu"`, or `"tree"`.
89
+ * - **roleDescription**: Defines a human-readable description for the button's role.
90
+ * Accepts any string value.
91
+ *
92
+ * - **arrowButton**: Accessibility attributes that will be applied to the arrow (split) button element.
93
+ * - **hasPopup**: Indicates the type of popup triggered by the arrow button.
94
+ * Accepts string values: `"dialog"`, `"grid"`, `"listbox"`, `"menu"`, or `"tree"`.
95
+ * - **expanded**: Indicates whether the popup controlled by the arrow button is currently expanded.
96
+ * Accepts boolean values: `true` or `false`.
97
+ *
98
+ * @public
99
+ * @since 2.6.0
100
+ * @default {}
101
+ */
102
+ this.accessibilityAttributes = {};
77
103
  /**
78
- * Initiates button elements fade-in phase.
104
+ * Determines if the button is in icon-only mode.
105
+ * This property is animation related only.
79
106
  * @default false
80
107
  * @private
81
108
  */
82
- this.fadeIn = false;
109
+ this.iconOnly = false;
110
+ }
111
+ get _hideArrowButton() {
112
+ return !this._effectiveStateObject?.showArrowButton;
113
+ }
114
+ get _effectiveState() {
115
+ return this.state || (this.states.length && this.states[0].name) || "";
116
+ }
117
+ get _effectiveStateObject() {
118
+ return this.states.find(state => state.name === this._effectiveState);
119
+ }
120
+ get _stateIconOnly() {
121
+ return !this._stateText && !!this._stateIcon;
122
+ }
123
+ get _stateText() {
124
+ return this._currentStateObject?.text;
125
+ }
126
+ get _stateIcon() {
127
+ return this._currentStateObject?.icon;
128
+ }
129
+ get _stateEndIcon() {
130
+ const endIcon = this._effectiveStateObject?.showArrowButton ? "" : this._effectiveStateObject?.endIcon;
131
+ return endIcon;
132
+ }
133
+ get _hasText() {
134
+ return !!this._stateText;
83
135
  }
84
136
  onBeforeRendering() {
85
- if (this.fadeOut || this.fadeIn) {
86
- return;
137
+ const splitButton = this._splitButton;
138
+ if (splitButton) {
139
+ splitButton.activeArrowButton = this.arrowButtonPressed;
87
140
  }
88
141
  if (!this._currentStateObject?.name) {
89
142
  this._currentStateObject = this._effectiveStateObject;
90
143
  }
91
144
  const currentStateName = this._currentStateObject?.name || "";
145
+ this.iconOnly = this._stateIconOnly;
92
146
  if (currentStateName !== "" && currentStateName !== this._effectiveState) {
93
147
  this._fadeOut();
94
148
  }
@@ -99,38 +153,50 @@ let Button = class Button extends UI5Element {
99
153
  */
100
154
  async _fadeOut() {
101
155
  const fadeOutDuration = 180;
102
- const button = this._mainButton;
156
+ const button = this._splitButton;
157
+ const hiddenButton = this._hiddenSplitButton;
103
158
  const newStateObject = this._effectiveStateObject;
104
159
  if (!newStateObject) {
105
160
  // eslint-disable-next-line no-console
106
161
  console.warn(`State with name="${this.state}" doesn't exist!`);
162
+ return;
163
+ }
164
+ if (!button || !hiddenButton) {
165
+ return;
166
+ }
167
+ const buttonWidth = button.offsetWidth;
168
+ const currentState = this._currentStateObject || {};
169
+ if ((!currentState.showArrowButton && newStateObject.showArrowButton) || (!currentState.endIcon && !!newStateObject.endIcon)) {
170
+ this.classList.add("ui5-ai-button-button-to-menu");
107
171
  }
108
- else if (button) {
109
- const buttonWidth = button.offsetWidth;
110
- const hiddenButton = this.shadowRoot?.querySelector(".ui5-ai-button-hidden");
111
- button.style.width = `${buttonWidth}px`;
112
- hiddenButton.icon = newStateObject.icon;
113
- hiddenButton.endIcon = newStateObject.endIcon;
114
- hiddenButton.textContent = newStateObject.text || null;
115
- await renderFinished();
116
- const hiddenButtonWidth = hiddenButton.offsetWidth;
117
- this.fadeOut = true;
118
- button.style.width = `${hiddenButtonWidth}px`;
119
- setTimeout(() => {
120
- this.fadeMid = true;
121
- this._currentStateObject = newStateObject;
122
- this._fadeIn();
123
- }, fadeOutDuration);
172
+ if ((currentState.showArrowButton && !newStateObject.showArrowButton) || (!!currentState.endIcon && !newStateObject.endIcon)) {
173
+ this.classList.add("ui5-ai-button-menu-to-button");
124
174
  }
175
+ this.style.width = `${buttonWidth}px`;
176
+ hiddenButton.icon = newStateObject.icon;
177
+ hiddenButton._endIcon = newStateObject.endIcon;
178
+ hiddenButton.textContent = newStateObject.text || null;
179
+ hiddenButton._hideArrowButton = this._hideArrowButton;
180
+ await renderFinished();
181
+ const hiddenButtonWidth = hiddenButton.offsetWidth;
182
+ this.style.width = `${hiddenButtonWidth}px`;
183
+ this.classList.add("ui5-ai-button-fade-out");
184
+ setTimeout(() => {
185
+ this.classList.add("ui5-ai-button-fade-mid");
186
+ button._hideArrowButton = this._hideArrowButton;
187
+ this._fadeIn();
188
+ }, fadeOutDuration);
125
189
  }
126
190
  /**
127
191
  * Starts the fade-in animation.
128
192
  * @private
129
193
  */
130
194
  _fadeIn() {
131
- const fadeInDuration = 60;
195
+ const fadeInDuration = 160;
132
196
  setTimeout(() => {
133
- this.fadeIn = true;
197
+ const newStateObject = this._effectiveStateObject;
198
+ this._currentStateObject = newStateObject;
199
+ this.classList.add("ui5-ai-button-fade-in");
134
200
  this._resetFade();
135
201
  }, fadeInDuration);
136
202
  }
@@ -141,12 +207,14 @@ let Button = class Button extends UI5Element {
141
207
  _resetFade() {
142
208
  const fadeResetDuration = 160;
143
209
  setTimeout(() => {
144
- this.fadeOut = false;
145
- this.fadeMid = false;
146
- this.fadeIn = false;
210
+ this.classList.remove("ui5-ai-button-fade-out");
211
+ this.classList.remove("ui5-ai-button-fade-mid");
212
+ this.classList.remove("ui5-ai-button-fade-in");
213
+ this.classList.remove("ui5-ai-button-button-to-menu");
214
+ this.classList.remove("ui5-ai-button-menu-to-button");
147
215
  }, fadeResetDuration);
148
216
  // reset the button's width after animations
149
- const button = this._mainButton;
217
+ const button = this._splitButton;
150
218
  if (button) {
151
219
  button.style.width = "";
152
220
  }
@@ -155,33 +223,34 @@ let Button = class Button extends UI5Element {
155
223
  * Handles the click event.
156
224
  * @private
157
225
  */
158
- _onclick(e) {
226
+ _onClick(e) {
159
227
  e.stopImmediatePropagation();
160
228
  this.fireDecoratorEvent("click");
161
229
  }
162
- get _mainButton() {
163
- return this.shadowRoot?.querySelector("[ui5-button]");
164
- }
165
- get _effectiveState() {
166
- return this.state || (this.states.length && this.states[0].name) || "";
167
- }
168
- get _effectiveStateObject() {
169
- return this.states.find(state => state.name === this._effectiveState);
170
- }
171
- get _stateIconOnly() {
172
- return !this._stateText && !!this._stateIcon;
173
- }
174
- get _stateText() {
175
- return this._currentStateObject?.text;
176
- }
177
- get _stateIcon() {
178
- return this._currentStateObject?.icon;
179
- }
180
- get _stateEndIcon() {
181
- return this._currentStateObject?.endIcon;
230
+ /**
231
+ * Handles the arrow-button-click event when `ui5-ai-button` is in split mode.
232
+ * @private
233
+ */
234
+ _onArrowClick(e) {
235
+ e.stopImmediatePropagation();
236
+ this.fireDecoratorEvent("arrow-button-click");
182
237
  }
183
- get _hasText() {
184
- return !!this._stateText;
238
+ get _computedAccessibilityAttributes() {
239
+ const labelRefTexts = getAllAccessibleNameRefTexts(this) || getEffectiveAriaLabelText(this) || getAssociatedLabelForTexts(this) || "";
240
+ const mainTitle = this._hasText ? Button_1.i18nBundle.getText(BUTTON_TOOLTIP_TEXT, this._stateText) : "";
241
+ const title = `${mainTitle} ${labelRefTexts}`.trim();
242
+ return {
243
+ root: {
244
+ hasPopup: this.accessibilityAttributes?.root?.hasPopup || "false",
245
+ roleDescription: this.accessibilityAttributes?.root?.roleDescription,
246
+ title: this.accessibilityAttributes?.root?.title || title,
247
+ },
248
+ arrowButton: {
249
+ hasPopup: this.accessibilityAttributes?.arrowButton?.hasPopup,
250
+ expanded: this.accessibilityAttributes?.arrowButton?.expanded,
251
+ title: this.accessibilityAttributes?.arrowButton?.title,
252
+ },
253
+ };
185
254
  }
186
255
  };
187
256
  __decorate([
@@ -194,28 +263,36 @@ __decorate([
194
263
  property()
195
264
  ], Button.prototype, "state", void 0);
196
265
  __decorate([
197
- property({ type: Object })
198
- ], Button.prototype, "_currentStateObject", void 0);
266
+ property({ type: Boolean, noAttribute: true })
267
+ ], Button.prototype, "arrowButtonPressed", void 0);
199
268
  __decorate([
200
- property({ type: Boolean })
201
- ], Button.prototype, "fadeOut", void 0);
269
+ property({ type: Object })
270
+ ], Button.prototype, "accessibilityAttributes", void 0);
202
271
  __decorate([
203
- property({ type: Boolean })
204
- ], Button.prototype, "fadeMid", void 0);
272
+ property({ type: Object })
273
+ ], Button.prototype, "_currentStateObject", void 0);
205
274
  __decorate([
206
275
  property({ type: Boolean })
207
- ], Button.prototype, "fadeIn", void 0);
276
+ ], Button.prototype, "iconOnly", void 0);
208
277
  __decorate([
209
278
  slot({ type: HTMLElement, "default": true })
210
279
  ], Button.prototype, "states", void 0);
211
- Button = __decorate([
280
+ __decorate([
281
+ query("[ui5-split-button]")
282
+ ], Button.prototype, "_splitButton", void 0);
283
+ __decorate([
284
+ query(".ui5-ai-button-hidden[ui5-split-button]")
285
+ ], Button.prototype, "_hiddenSplitButton", void 0);
286
+ __decorate([
287
+ i18n("@ui5/webcomponents")
288
+ ], Button, "i18nBundle", void 0);
289
+ Button = Button_1 = __decorate([
212
290
  customElement({
213
291
  tag: "ui5-ai-button",
214
292
  languageAware: true,
215
293
  renderer: jsxRenderer,
216
294
  template: ButtonTemplate,
217
295
  styles: ButtonCss,
218
- dependencies: [MainButton, Icon, ButtonState],
219
296
  shadowRootOptions: { delegatesFocus: true },
220
297
  })
221
298
  /**
@@ -227,6 +304,16 @@ Button = __decorate([
227
304
  event("click", {
228
305
  bubbles: true,
229
306
  })
307
+ /**
308
+ * Fired when the component is in split mode and after the arrow button
309
+ * is activated either by clicking or tapping it or by using the [Arrow Up] / [Arrow Down],
310
+ * [Alt] + [Arrow Up]/ [Arrow Down], or [F4] keyboard keys.
311
+ * @public
312
+ */
313
+ ,
314
+ event("arrow-button-click", {
315
+ bubbles: true,
316
+ })
230
317
  ], Button);
231
318
  Button.define();
232
319
  export default Button;
@@ -1 +1 @@
1
- {"version":3,"file":"Button.js","sourceRoot":"","sources":["../src/Button.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,UAAU,MAAM,4CAA4C,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACxE,OAAO,aAAa,MAAM,0DAA0D,CAAC;AACrF,OAAO,QAAQ,MAAM,qDAAqD,CAAC;AAC3E,OAAO,KAAK,MAAM,yDAA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I,CAAC;IACvC,CAAC;IAED,IAAI,aAAa;QAChB,OAAO,IAAI,CAAC,mBAAmB,EAAE,OAAO,CAAC;IAC1C,CAAC;IAED,IAAI,QAAQ;QACX,OAAO,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC;IAC1B,CAAC;CACD,CAAA;AAvLA;IADC,QAAQ,EAAE;sCAC2B;AAUtC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;wCACX;AASjB;IADC,QAAQ,EAAE;qCACI;AAOf;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mDACO;AAQlC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;uCACZ;AAQhB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;uCACZ;AAQhB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;sCACb;AAQf;IADC,IAAI,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;sCACjB;AApEvB,MAAM;IAlBX,aAAa,CAAC;QACd,GAAG,EAAE,eAAe;QACpB,aAAa,EAAE,IAAI;QACnB,QAAQ,EAAE,WAAW;QACrB,QAAQ,EAAE,cAAc;QACxB,MAAM,EAAE,SAAS;QACjB,YAAY,EAAE,CAAC,UAAU,EAAE,IAAI,EAAE,WAAW,CAAC;QAC7C,iBAAiB,EAAE,EAAE,cAAc,EAAE,IAAI,EAAE;KAC3C,CAAC;IAEF;;;;OAIG;;IACF,KAAK,CAAC,OAAO,EAAE;QACf,OAAO,EAAE,IAAI;KACb,CAAC;GACI,MAAM,CAiMX;AAED,MAAM,CAAC,MAAM,EAAE,CAAC;AAChB,eAAe,MAAM,CAAC","sourcesContent":["import UI5Element from \"@ui5/webcomponents-base/dist/UI5Element.js\";\nimport { renderFinished } from \"@ui5/webcomponents-base/dist/Render.js\";\nimport customElement from \"@ui5/webcomponents-base/dist/decorators/customElement.js\";\nimport property from \"@ui5/webcomponents-base/dist/decorators/property.js\";\nimport event from \"@ui5/webcomponents-base/dist/decorators/event-strict.js\";\nimport slot from \"@ui5/webcomponents-base/dist/decorators/slot.js\";\nimport jsxRenderer from \"@ui5/webcomponents-base/dist/renderer/JsxRenderer.js\";\nimport MainButton from \"@ui5/webcomponents/dist/Button.js\";\nimport Icon from \"@ui5/webcomponents/dist/Icon.js\";\nimport type ButtonDesign from \"@ui5/webcomponents/dist/types/ButtonDesign.js\";\nimport ButtonState from \"./ButtonState.js\";\n\nimport ButtonTemplate from \"./ButtonTemplate.js\";\n\n// Styles\nimport ButtonCss from \"./generated/themes/Button.css.js\";\n\n/**\n * @class\n *\n * ### Overview\n *\n * The `ui5-ai-button` component represents a button used in AI-related scenarios.\n * It enables users to trigger actions by clicking or tapping the `ui5-ai-button`, or by pressing\n * certain keyboard keys, such as Enter.\n *\n * ### Usage\n *\n * For the `ui5-ai-button` UI, you can define one or more states of the button by placing `ai-button-state` components in its default slot.\n * Each state have a name that identifies it and can have text, icon and end icon defined (in any combination) depending on the state purpose.\n *\n * You can choose from a set of predefined designs (the same as for regular `ui5-button` component) that allow different styling to correspond to the triggered action.\n *\n * `ui5-ai-button` can be activated by clicking or tapping it. The state can be changed in `click` event handler.\n *\n * ### ES6 Module Import\n *\n * `import \"@ui5/webcomponents-ai/dist/Button.js\";`\n *\n * @constructor\n * @extends UI5Element\n * @since 2.0.0\n * @public\n * @experimental The Button and ButtonState web components are availabe since 2.0 under an experimental flag and their API and behaviour are subject to change.\n */\n\n@customElement({\n\ttag: \"ui5-ai-button\",\n\tlanguageAware: true,\n\trenderer: jsxRenderer,\n\ttemplate: ButtonTemplate,\n\tstyles: ButtonCss,\n\tdependencies: [MainButton, Icon, ButtonState],\n\tshadowRootOptions: { delegatesFocus: true },\n})\n\n/**\n * Fired when the component is activated either with a\n * mouse/tap or by using the Enter or Space key.\n * @public\n */\n@event(\"click\", {\n\tbubbles: true,\n})\nclass Button extends UI5Element {\n\teventDetails!: {\n\t\tclick: void,\n\t}\n\t/**\n\t * Defines the component design.\n\t * @default \"Default\"\n\t * @public\n\t */\n\t@property()\n\tdesign?: `${ButtonDesign}` = \"Default\"\n\n\t/**\n\t * Defines whether the component is disabled.\n\t * A disabled component can't be pressed or\n\t * focused, and it is not in the tab chain.\n\t * @default false\n\t * @public\n\t */\n\t@property({ type: Boolean })\n\tdisabled = false;\n\n\t/**\n\t * Defines the current state of the component.\n\t *\n\t * @default undefined\n\t * @public\n\t */\n\t@property()\n\tstate?: string;\n\n\t/**\n\t * Keeps the current state object of the component.\n\t * @private\n\t */\n\t@property({ type: Object })\n\t_currentStateObject?: ButtonState;\n\n\t/**\n\t * Initiates button elements fade-out phase.\n\t * @default false\n\t * @private\n\t */\n\t@property({ type: Boolean })\n\tfadeOut = false;\n\n\t/**\n\t * Initiates button fade middle phase.\n\t * @default false\n\t * @private\n\t */\n\t@property({ type: Boolean })\n\tfadeMid = false;\n\n\t/**\n\t * Initiates button elements fade-in phase.\n\t * @default false\n\t * @private\n\t */\n\t@property({ type: Boolean })\n\tfadeIn = false;\n\n\t/**\n\t * Defines the available states of the component.\n\t * **Note:** Although this slot accepts HTML Elements, it is strongly recommended that you only use `ui5-ai-button-state` components in order to preserve the intended design.\n\t * @public\n\t */\n\t@slot({ type: HTMLElement, \"default\": true })\n\tstates!: Array<ButtonState>;\n\n\tonBeforeRendering(): void {\n\t\tif (this.fadeOut || this.fadeIn) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (!this._currentStateObject?.name) {\n\t\t\tthis._currentStateObject = this._effectiveStateObject;\n\t\t}\n\n\t\tconst currentStateName = this._currentStateObject?.name || \"\";\n\n\t\tif (currentStateName !== \"\" && currentStateName !== this._effectiveState) {\n\t\t\tthis._fadeOut();\n\t\t}\n\t}\n\n\t/**\n\t * Starts the fade-out animation.\n\t * @private\n\t */\n\tasync _fadeOut(): Promise<void> {\n\t\tconst fadeOutDuration = 180;\n\n\t\tconst button = this._mainButton;\n\t\tconst newStateObject = this._effectiveStateObject;\n\n\t\tif (!newStateObject) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.warn(`State with name=\"${this.state}\" doesn't exist!`);\n\t\t} else if (button) {\n\t\t\tconst buttonWidth = button.offsetWidth;\n\t\t\tconst hiddenButton = this.shadowRoot?.querySelector(\".ui5-ai-button-hidden\") as MainButton;\n\t\t\tbutton.style.width = `${buttonWidth}px`;\n\t\t\thiddenButton.icon = newStateObject.icon;\n\t\t\thiddenButton.endIcon = newStateObject.endIcon;\n\t\t\thiddenButton.textContent = newStateObject.text || null;\n\n\t\t\tawait renderFinished();\n\t\t\tconst hiddenButtonWidth = hiddenButton.offsetWidth;\n\t\t\tthis.fadeOut = true;\n\t\t\tbutton.style.width = `${hiddenButtonWidth}px`;\n\n\t\t\tsetTimeout(() => {\n\t\t\t\tthis.fadeMid = true;\n\t\t\t\tthis._currentStateObject = newStateObject;\n\t\t\t\tthis._fadeIn();\n\t\t\t}, fadeOutDuration);\n\t\t}\n\t}\n\n\t/**\n\t * Starts the fade-in animation.\n\t * @private\n\t */\n\t_fadeIn(): void {\n\t\tconst fadeInDuration = 60;\n\n\t\tsetTimeout(() => {\n\t\t\tthis.fadeIn = true;\n\t\t\tthis._resetFade();\n\t\t}, fadeInDuration);\n\t}\n\n\t/**\n\t * Resets the fade phases when the animation is completed.\n\t * @private\n\t */\n\t_resetFade(): void {\n\t\tconst fadeResetDuration = 160;\n\n\t\tsetTimeout(() => {\n\t\t\tthis.fadeOut = false;\n\t\t\tthis.fadeMid = false;\n\t\t\tthis.fadeIn = false;\n\t\t}, fadeResetDuration);\n\n\t\t// reset the button's width after animations\n\t\tconst button = this._mainButton;\n\t\tif (button) {\n\t\t\tbutton.style.width = \"\";\n\t\t}\n\t}\n\n\t/**\n\t * Handles the click event.\n\t * @private\n\t */\n\t_onclick(e: MouseEvent): void {\n\t\te.stopImmediatePropagation();\n\t\tthis.fireDecoratorEvent(\"click\");\n\t}\n\n\tget _mainButton() {\n\t\treturn this.shadowRoot?.querySelector(\"[ui5-button]\") as MainButton;\n\t}\n\n\tget _effectiveState() {\n\t\treturn this.state || (this.states.length && this.states[0].name) || \"\";\n\t}\n\n\tget _effectiveStateObject() {\n\t\treturn this.states.find(state => state.name === this._effectiveState);\n\t}\n\n\tget _stateIconOnly() {\n\t\treturn !this._stateText && !!this._stateIcon;\n\t}\n\n\tget _stateText() {\n\t\treturn this._currentStateObject?.text;\n\t}\n\n\tget _stateIcon() {\n\t\treturn this._currentStateObject?.icon;\n\t}\n\n\tget _stateEndIcon() {\n\t\treturn this._currentStateObject?.endIcon;\n\t}\n\n\tget _hasText() {\n\t\treturn !!this._stateText;\n\t}\n}\n\nButton.define();\nexport default Button;\n"]}
1
+ {"version":3,"file":"Button.js","sourceRoot":"","sources":["../src/Button.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,UAAU,MAAM,4CAA4C,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACxE,OAAO,aAAa,MAAM,0DAA0D,CAAC;AACrF,OAAO,QAAQ,MAAM,qDAAqD,CAAC;AAC3E,OAAO,KAAK,MAAM,yDAAyD,CAAC;AAC5E,OAAO,IAAI,MAAM,iDAAiD,CAAC;AACnE,OAAO,KAAK,MAAM,kDAAkD,CAAC;AACrE,OAAO,WAAW,MAAM,sDAAsD,CAAC;AAI/E,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,kBAAkB,CAAC;AAC1B,OAAO,cAAc,MAAM,qBAAqB,CAAC;AACjD,OAAO,EACN,yBAAyB,EACzB,0BAA0B,EAC1B,4BAA4B,GAC5B,MAAM,+DAA+D,CAAC;AAEvE,SAAS;AACT,OAAO,SAAS,MAAM,kCAAkC,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,4CAA4C,CAAC;AAQlE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AA8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DACO;AASlC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;wCACV;AASlB;IADC,IAAI,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;sCACjB;AAG5B;IADC,KAAK,CAAC,oBAAoB,CAAC;4CACD;AAG3B;IADC,KAAK,CAAC,yCAAyC,CAAC;kDAChB;AAG1B;IADN,IAAI,CAAC,oBAAoB,CAAC;gCACG;AApGzB,MAAM;IA5BX,aAAa,CAAC;QACd,GAAG,EAAE,eAAe;QACpB,aAAa,EAAE,IAAI;QACnB,QAAQ,EAAE,WAAW;QACrB,QAAQ,EAAE,cAAc;QACxB,MAAM,EAAE,SAAS;QACjB,iBAAiB,EAAE,EAAE,cAAc,EAAE,IAAI,EAAE;KAC3C,CAAC;IAEF;;;;OAIG;;IACF,KAAK,CAAC,OAAO,EAAE;QACf,OAAO,EAAE,IAAI;KACb,CAAC;IAEF;;;;;OAKG;;IACF,KAAK,CAAC,oBAAoB,EAAE;QAC5B,OAAO,EAAE,IAAI;KACb,CAAC;GAEI,MAAM,CAqRX;AAED,MAAM,CAAC,MAAM,EAAE,CAAC;AAChB,eAAe,MAAM,CAAC","sourcesContent":["import UI5Element from \"@ui5/webcomponents-base/dist/UI5Element.js\";\nimport { renderFinished } from \"@ui5/webcomponents-base/dist/Render.js\";\nimport customElement from \"@ui5/webcomponents-base/dist/decorators/customElement.js\";\nimport property from \"@ui5/webcomponents-base/dist/decorators/property.js\";\nimport event from \"@ui5/webcomponents-base/dist/decorators/event-strict.js\";\nimport slot from \"@ui5/webcomponents-base/dist/decorators/slot.js\";\nimport query from \"@ui5/webcomponents-base/dist/decorators/query.js\";\nimport jsxRenderer from \"@ui5/webcomponents-base/dist/renderer/JsxRenderer.js\";\nimport type SplitButton from \"@ui5/webcomponents/dist/SplitButton.js\";\nimport type ButtonDesign from \"@ui5/webcomponents/dist/types/ButtonDesign.js\";\nimport type ButtonState from \"./ButtonState.js\";\nimport { BUTTON_TOOLTIP_TEXT } from \"./generated/i18n/i18n-defaults.js\";\nimport \"./ButtonState.js\";\nimport ButtonTemplate from \"./ButtonTemplate.js\";\nimport {\n\tgetEffectiveAriaLabelText,\n\tgetAssociatedLabelForTexts,\n\tgetAllAccessibleNameRefTexts,\n} from \"@ui5/webcomponents-base/dist/util/AccessibilityTextsHelper.js\";\n\n// Styles\nimport ButtonCss from \"./generated/themes/Button.css.js\";\nimport { i18n } from \"@ui5/webcomponents-base/dist/decorators.js\";\nimport type I18nBundle from \"@ui5/webcomponents-base/dist/i18nBundle.js\";\nimport type { AccessibilityAttributes } from \"@ui5/webcomponents-base/dist/types.js\";\n\ntype AIButtonRootAccessibilityAttributes = Pick<AccessibilityAttributes, \"hasPopup\" | \"roleDescription\" | \"title\">;\ntype AIButtonArrowButtonAccessibilityAttributes = Pick<AccessibilityAttributes, \"hasPopup\" | \"expanded\" | \"title\">;\ntype AIButtonAccessibilityAttributes = { root?: AIButtonRootAccessibilityAttributes, arrowButton?: AIButtonArrowButtonAccessibilityAttributes}\n\n/**\n * @class\n *\n * ### Overview\n *\n * The `ui5-ai-button` component serves as a button for AI-related scenarios. Users can trigger actions by clicking or tapping the `ui5-ai-button`\n * or by pressing keyboard keys like [Enter] or [Space].\n *\n * ### Usage\n *\n * For the `ui5-ai-button` user interface, you can define one or more button states by placing `ui5-ai-button-state` components in their default slot.\n * Each state has a name for identification and can include text, an icon, and an end icon, as needed for its purpose.\n * You can define a split mode for the `ui5-ai-button`, which will results in displaying an arrow button for additional actions.\n *\n * You can choose from a set of predefined designs for `ui5-ai-button` (as in `ui5-button`) to match the desired styling.\n *\n * The `ui5-ai-button` can be activated by clicking or tapping it. You can change the button state in the click event handler. When the button is\n * in split mode, you can activate the default button action by clicking or tapping it, or by pressing keyboard keys like [Enter] or [Space].\n * You can activate the arrow button by clicking or tapping it, or by pressing keyboard keys like [Arrow Up], [Arrow Down], or [F4].\n * To display additional actions, you can attach a menu to the arrow button.\n *\n * ### ES6 Module Import\n *\n * `import \"@ui5/webcomponents-ai/dist/Button.js\";`\n *\n * @constructor\n * @extends UI5Element\n * @since 2.0.0\n * @public\n * @experimental The Button and ButtonState web components are availabe since 2.0 under an experimental flag and their API and behaviour are subject to change.\n */\n\n@customElement({\n\ttag: \"ui5-ai-button\",\n\tlanguageAware: true,\n\trenderer: jsxRenderer,\n\ttemplate: ButtonTemplate,\n\tstyles: ButtonCss,\n\tshadowRootOptions: { delegatesFocus: true },\n})\n\n/**\n * Fired when the component is activated either with a\n * mouse/tap or by using the Enter or Space key.\n * @public\n */\n@event(\"click\", {\n\tbubbles: true,\n})\n\n/**\n * Fired when the component is in split mode and after the arrow button\n * is activated either by clicking or tapping it or by using the [Arrow Up] / [Arrow Down],\n * [Alt] + [Arrow Up]/ [Arrow Down], or [F4] keyboard keys.\n * @public\n */\n@event(\"arrow-button-click\", {\n\tbubbles: true,\n})\n\nclass Button extends UI5Element {\n\teventDetails!: {\n\t\t\"click\": void;\n\t\t\"arrow-button-click\": void;\n\t}\n\t/**\n\t * Defines the component design.\n\t * @default \"Default\"\n\t * @public\n\t */\n\t@property()\n\tdesign?: `${ButtonDesign}` = \"Default\"\n\n\t/**\n\t * Defines whether the component is disabled.\n\t * A disabled component can't be pressed or\n\t * focused, and it is not in the tab chain.\n\t * @default false\n\t * @public\n\t */\n\t@property({ type: Boolean })\n\tdisabled = false;\n\n\t/**\n\t * Defines the current state of the component.\n\t *\n\t * @default undefined\n\t * @public\n\t */\n\t@property()\n\tstate?: string;\n\n\t/**\n\t * Defines the active state of the arrow button in split mode.\n\t * Set to true when the button is in split mode and a menu with additional options\n\t * is opened by the arrow button. Set back to false when the menu is closed.\n\t * @default false\n\t * @public\n\t * @since 2.6.0\n\t */\n\t@property({ type: Boolean, noAttribute: true })\n\tarrowButtonPressed = false;\n\n\t/**\n \t * Defines the additional accessibility attributes that will be applied to the component.\n\t *\n\t * This property allows for fine-tuned control of ARIA attributes for screen reader support.\n\t * It accepts an object with the following optional fields:\n\t *\n\t * - **root**: Accessibility attributes that will be applied to the root element.\n\t * - **hasPopup**: Indicates the availability and type of interactive popup element (such as a menu or dialog).\n\t * Accepts string values: `\"dialog\"`, `\"grid\"`, `\"listbox\"`, `\"menu\"`, or `\"tree\"`.\n\t * - **roleDescription**: Defines a human-readable description for the button's role.\n\t * Accepts any string value.\n\t *\n\t * - **arrowButton**: Accessibility attributes that will be applied to the arrow (split) button element.\n\t * - **hasPopup**: Indicates the type of popup triggered by the arrow button.\n\t * Accepts string values: `\"dialog\"`, `\"grid\"`, `\"listbox\"`, `\"menu\"`, or `\"tree\"`.\n\t * - **expanded**: Indicates whether the popup controlled by the arrow button is currently expanded.\n\t * Accepts boolean values: `true` or `false`.\n\t *\n\t * @public\n\t * @since 2.6.0\n\t * @default {}\n \t*/\n\t@property({ type: Object })\n\taccessibilityAttributes: AIButtonAccessibilityAttributes = {};\n\n\t/**\n\t * Keeps the current state object of the component.\n\t * @private\n\t */\n\t@property({ type: Object })\n\t_currentStateObject?: ButtonState;\n\n\t/**\n\t * Determines if the button is in icon-only mode.\n\t * This property is animation related only.\n\t * @default false\n\t * @private\n\t */\n\t@property({ type: Boolean })\n\ticonOnly? = false;\n\n\t/**\n\t * Defines the available states of the component.\n\t * **Note:** Although this slot accepts HTML Elements, it is strongly recommended that\n\t * you only use `ui5-ai-button-state` components in order to preserve the intended design.\n\t * @public\n\t */\n\t@slot({ type: HTMLElement, \"default\": true })\n\tstates!: Array<ButtonState>;\n\n\t@query(\"[ui5-split-button]\")\n\t_splitButton?: SplitButton;\n\n\t@query(\".ui5-ai-button-hidden[ui5-split-button]\")\n\t_hiddenSplitButton?: SplitButton;\n\n\t@i18n(\"@ui5/webcomponents\")\n\tstatic i18nBundle: I18nBundle;\n\n\tget _hideArrowButton() {\n\t\treturn !this._effectiveStateObject?.showArrowButton;\n\t}\n\n\tget _effectiveState() {\n\t\treturn this.state || (this.states.length && this.states[0].name) || \"\";\n\t}\n\n\tget _effectiveStateObject() {\n\t\treturn this.states.find(state => state.name === this._effectiveState);\n\t}\n\n\tget _stateIconOnly() {\n\t\treturn !this._stateText && !!this._stateIcon;\n\t}\n\n\tget _stateText() {\n\t\treturn this._currentStateObject?.text;\n\t}\n\n\tget _stateIcon() {\n\t\treturn this._currentStateObject?.icon;\n\t}\n\n\tget _stateEndIcon() {\n\t\tconst endIcon = this._effectiveStateObject?.showArrowButton ? \"\" : this._effectiveStateObject?.endIcon;\n\t\treturn endIcon;\n\t}\n\n\tget _hasText() {\n\t\treturn !!this._stateText;\n\t}\n\n\tonBeforeRendering(): void {\n\t\tconst splitButton = this._splitButton;\n\n\t\tif (splitButton) {\n\t\t\tsplitButton.activeArrowButton = this.arrowButtonPressed;\n\t\t}\n\n\t\tif (!this._currentStateObject?.name) {\n\t\t\tthis._currentStateObject = this._effectiveStateObject;\n\t\t}\n\n\t\tconst currentStateName = this._currentStateObject?.name || \"\";\n\n\t\tthis.iconOnly = this._stateIconOnly;\n\t\tif (currentStateName !== \"\" && currentStateName !== this._effectiveState) {\n\t\t\tthis._fadeOut();\n\t\t}\n\t}\n\n\t/**\n\t * Starts the fade-out animation.\n\t * @private\n\t */\n\tasync _fadeOut(): Promise<void> {\n\t\tconst fadeOutDuration = 180;\n\t\tconst button = this._splitButton;\n\t\tconst hiddenButton = this._hiddenSplitButton;\n\t\tconst newStateObject = this._effectiveStateObject;\n\n\t\tif (!newStateObject) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.warn(`State with name=\"${this.state}\" doesn't exist!`);\n\t\t\treturn;\n\t\t}\n\n\t\tif (!button || !hiddenButton) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst buttonWidth = button.offsetWidth;\n\t\tconst currentState: Partial<ButtonState> = this._currentStateObject || {};\n\n\t\tif ((!currentState.showArrowButton && newStateObject.showArrowButton) || (!currentState.endIcon && !!newStateObject.endIcon)) {\n\t\t\tthis.classList.add(\"ui5-ai-button-button-to-menu\");\n\t\t}\n\t\tif ((currentState.showArrowButton && !newStateObject.showArrowButton) || (!!currentState.endIcon && !newStateObject.endIcon)) {\n\t\t\tthis.classList.add(\"ui5-ai-button-menu-to-button\");\n\t\t}\n\n\t\tthis.style.width = `${buttonWidth}px`;\n\t\thiddenButton.icon = newStateObject.icon;\n\t\thiddenButton._endIcon = newStateObject.endIcon;\n\t\thiddenButton.textContent = newStateObject.text || null;\n\t\thiddenButton._hideArrowButton = this._hideArrowButton;\n\n\t\tawait renderFinished();\n\t\tconst hiddenButtonWidth = hiddenButton.offsetWidth;\n\t\tthis.style.width = `${hiddenButtonWidth}px`;\n\t\tthis.classList.add(\"ui5-ai-button-fade-out\");\n\n\t\tsetTimeout(() => {\n\t\t\tthis.classList.add(\"ui5-ai-button-fade-mid\");\n\t\t\tbutton._hideArrowButton = this._hideArrowButton;\n\t\t\tthis._fadeIn();\n\t\t}, fadeOutDuration);\n\t}\n\n\t/**\n\t * Starts the fade-in animation.\n\t * @private\n\t */\n\t_fadeIn(): void {\n\t\tconst fadeInDuration = 160;\n\n\t\tsetTimeout(() => {\n\t\t\tconst newStateObject = this._effectiveStateObject;\n\t\t\tthis._currentStateObject = newStateObject;\n\t\t\tthis.classList.add(\"ui5-ai-button-fade-in\");\n\t\t\tthis._resetFade();\n\t\t}, fadeInDuration);\n\t}\n\n\t/**\n\t * Resets the fade phases when the animation is completed.\n\t * @private\n\t */\n\t_resetFade(): void {\n\t\tconst fadeResetDuration = 160;\n\n\t\tsetTimeout(() => {\n\t\t\tthis.classList.remove(\"ui5-ai-button-fade-out\");\n\t\t\tthis.classList.remove(\"ui5-ai-button-fade-mid\");\n\t\t\tthis.classList.remove(\"ui5-ai-button-fade-in\");\n\t\t\tthis.classList.remove(\"ui5-ai-button-button-to-menu\");\n\t\t\tthis.classList.remove(\"ui5-ai-button-menu-to-button\");\n\t\t}, fadeResetDuration);\n\n\t\t// reset the button's width after animations\n\t\tconst button = this._splitButton;\n\n\t\tif (button) {\n\t\t\tbutton.style.width = \"\";\n\t\t}\n\t}\n\n\t/**\n\t * Handles the click event.\n\t * @private\n\t */\n\t_onClick(e: CustomEvent): void {\n\t\te.stopImmediatePropagation();\n\t\tthis.fireDecoratorEvent(\"click\");\n\t}\n\n\t/**\n\t * Handles the arrow-button-click event when `ui5-ai-button` is in split mode.\n\t * @private\n\t */\n\t_onArrowClick(e: CustomEvent): void {\n\t\te.stopImmediatePropagation();\n\t\tthis.fireDecoratorEvent(\"arrow-button-click\");\n\t}\n\n\tget _computedAccessibilityAttributes(): AIButtonAccessibilityAttributes {\n\t\tconst labelRefTexts = getAllAccessibleNameRefTexts(this) || getEffectiveAriaLabelText(this) || getAssociatedLabelForTexts(this) || \"\";\n\n\t\tconst mainTitle = this._hasText ? Button.i18nBundle.getText(BUTTON_TOOLTIP_TEXT, this._stateText as string) : \"\";\n\t\tconst title = `${mainTitle} ${labelRefTexts}`.trim();\n\n\t\treturn {\n\t\t\troot: {\n\t\t\t\thasPopup: this.accessibilityAttributes?.root?.hasPopup || \"false\",\n\t\t\t\troleDescription: this.accessibilityAttributes?.root?.roleDescription,\n\t\t\t\ttitle: this.accessibilityAttributes?.root?.title || title,\n\t\t\t},\n\t\t\tarrowButton: {\n\t\t\t\thasPopup: this.accessibilityAttributes?.arrowButton?.hasPopup,\n\t\t\t\texpanded: this.accessibilityAttributes?.arrowButton?.expanded,\n\t\t\t\ttitle: this.accessibilityAttributes?.arrowButton?.title,\n\t\t\t},\n\t\t};\n\t}\n}\n\nButton.define();\nexport default Button;\nexport type {\n\tAIButtonAccessibilityAttributes,\n};\n"]}
@@ -8,8 +8,8 @@ import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
8
8
  *
9
9
  * ### Usage
10
10
  *
11
- * `ui5-si-button-state` is an abstract element, representing a state of `ui5-ai-button`. It is meant to be used in the `states` slot
12
- * of `ui5-ai-button` and should be used as standalone component.
11
+ * `ui5-ai-button-state` is an abstract element, representing a state of `ui5-ai-button`. It is meant to be used in the `default` slot
12
+ * of `ui5-ai-button` and should not be used as standalone component.
13
13
  *
14
14
  * ### ES6 Module Import
15
15
  *
@@ -19,7 +19,7 @@ import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
19
19
  * @abstract
20
20
  * @since 2.0.0
21
21
  * @public
22
- * @experimental The Button and ButtonState web components are availabe since 2.0 under an experimental flag and their API and behaviour are subject to change.
22
+ * @experimental The Button and ButtonState web components are available since 2.0 under an experimental flag and their API and behaviour are subject to change.
23
23
  */
24
24
  declare class ButtonState extends UI5Element {
25
25
  /**
@@ -56,5 +56,12 @@ declare class ButtonState extends UI5Element {
56
56
  * @public
57
57
  */
58
58
  endIcon?: string;
59
+ /**
60
+ * Defines if the component is in split button mode.
61
+ * @default false
62
+ * @since 2.6.0
63
+ * @public
64
+ */
65
+ showArrowButton: boolean;
59
66
  }
60
67
  export default ButtonState;