@ui5/webcomponents-ai 0.0.0-9261ac932 → 0.0.0-acc6fea96

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 (59) hide show
  1. package/CHANGELOG.md +160 -0
  2. package/README.md +4 -3
  3. package/dist/Button.d.ts +45 -32
  4. package/dist/Button.js +118 -82
  5. package/dist/Button.js.map +1 -1
  6. package/dist/ButtonState.d.ts +7 -0
  7. package/dist/ButtonState.js +13 -0
  8. package/dist/ButtonState.js.map +1 -1
  9. package/dist/ButtonTemplate.d.ts +2 -0
  10. package/dist/ButtonTemplate.js +6 -0
  11. package/dist/ButtonTemplate.js.map +1 -0
  12. package/dist/PromptInput.d.ts +5 -1
  13. package/dist/PromptInput.js +4 -13
  14. package/dist/PromptInput.js.map +1 -1
  15. package/dist/PromptInputTemplate.d.ts +2 -0
  16. package/dist/PromptInputTemplate.js +12 -0
  17. package/dist/PromptInputTemplate.js.map +1 -0
  18. package/dist/css/themes/Button.css +1 -1
  19. package/dist/custom-elements-internal.json +54 -2
  20. package/dist/custom-elements.json +47 -2
  21. package/dist/generated/assets/i18n/messagebundle_en_US_saptrc.json +1 -1
  22. package/dist/generated/assets/themes/sap_horizon/parameters-bundle.css.json +1 -1
  23. package/dist/generated/assets/themes/sap_horizon_dark/parameters-bundle.css.json +1 -1
  24. package/dist/generated/assets/themes/sap_horizon_hcb/parameters-bundle.css.json +1 -1
  25. package/dist/generated/assets/themes/sap_horizon_hcw/parameters-bundle.css.json +1 -1
  26. package/dist/generated/themes/Button.css.d.ts +2 -3
  27. package/dist/generated/themes/Button.css.js +2 -3
  28. package/dist/generated/themes/Button.css.js.map +1 -1
  29. package/dist/generated/themes/PromptInput.css.d.ts +2 -3
  30. package/dist/generated/themes/PromptInput.css.js +2 -3
  31. package/dist/generated/themes/PromptInput.css.js.map +1 -1
  32. package/dist/generated/themes/sap_horizon/parameters-bundle.css.d.ts +2 -3
  33. package/dist/generated/themes/sap_horizon/parameters-bundle.css.js +1 -2
  34. package/dist/generated/themes/sap_horizon/parameters-bundle.css.js.map +1 -1
  35. package/dist/generated/themes/sap_horizon_dark/parameters-bundle.css.d.ts +2 -3
  36. package/dist/generated/themes/sap_horizon_dark/parameters-bundle.css.js +1 -2
  37. package/dist/generated/themes/sap_horizon_dark/parameters-bundle.css.js.map +1 -1
  38. package/dist/generated/themes/sap_horizon_hcb/parameters-bundle.css.d.ts +2 -3
  39. package/dist/generated/themes/sap_horizon_hcb/parameters-bundle.css.js +1 -2
  40. package/dist/generated/themes/sap_horizon_hcb/parameters-bundle.css.js.map +1 -1
  41. package/dist/generated/themes/sap_horizon_hcw/parameters-bundle.css.d.ts +2 -3
  42. package/dist/generated/themes/sap_horizon_hcw/parameters-bundle.css.js +1 -2
  43. package/dist/generated/themes/sap_horizon_hcw/parameters-bundle.css.js.map +1 -1
  44. package/dist/tsconfig.tsbuildinfo +1 -1
  45. package/dist/vscode.html-custom-data.json +11 -1
  46. package/dist/web-types.json +31 -3
  47. package/package.json +7 -7
  48. package/src/ButtonTemplate.tsx +26 -0
  49. package/src/PromptInputTemplate.tsx +49 -0
  50. package/src/i18n/messagebundle_en_US_saptrc.properties +2 -2
  51. package/src/themes/Button.css +75 -21
  52. package/dist/generated/templates/ButtonTemplate.lit.d.ts +0 -4
  53. package/dist/generated/templates/ButtonTemplate.lit.js +0 -6
  54. package/dist/generated/templates/ButtonTemplate.lit.js.map +0 -1
  55. package/dist/generated/templates/PromptInputTemplate.lit.d.ts +0 -4
  56. package/dist/generated/templates/PromptInputTemplate.lit.js +0 -8
  57. package/dist/generated/templates/PromptInputTemplate.lit.js.map +0 -1
  58. package/src/Button.hbs +0 -17
  59. package/src/PromptInput.hbs +0 -36
package/CHANGELOG.md CHANGED
@@ -3,6 +3,166 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [2.6.0](https://github.com/SAP/ui5-webcomponents/compare/v2.6.0-rc.5...v2.6.0) (2025-01-07)
7
+
8
+ **Note:** Version bump only for package @ui5/webcomponents-ai
9
+
10
+
11
+
12
+
13
+
14
+ # [2.6.0-rc.5](https://github.com/SAP/ui5-webcomponents/compare/v2.6.0-rc.4...v2.6.0-rc.5) (2025-01-07)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * remove dependencies for TSX components and fix features ([#10449](https://github.com/SAP/ui5-webcomponents/issues/10449)) ([a2b5f6f](https://github.com/SAP/ui5-webcomponents/commit/a2b5f6fb768499a8b757a9b7abad5f19033a33a7))
20
+
21
+
22
+
23
+
24
+
25
+ # [2.6.0-rc.4](https://github.com/SAP/ui5-webcomponents/compare/v2.6.0-rc.3...v2.6.0-rc.4) (2025-01-02)
26
+
27
+ **Note:** Version bump only for package @ui5/webcomponents-ai
28
+
29
+
30
+
31
+
32
+
33
+ # [2.6.0-rc.3](https://github.com/SAP/ui5-webcomponents/compare/v2.6.0-rc.2...v2.6.0-rc.3) (2024-12-26)
34
+
35
+
36
+ ### Features
37
+
38
+ * **ui5-ai-button:** implement split button functionality ([#10242](https://github.com/SAP/ui5-webcomponents/issues/10242)) ([55c9e4d](https://github.com/SAP/ui5-webcomponents/commit/55c9e4d67800d82a0d357eda8859b78d69dc25ab))
39
+
40
+
41
+
42
+
43
+
44
+ # [2.6.0-rc.2](https://github.com/SAP/ui5-webcomponents/compare/v2.6.0-rc.1...v2.6.0-rc.2) (2024-12-19)
45
+
46
+ **Note:** Version bump only for package @ui5/webcomponents-ai
47
+
48
+
49
+
50
+
51
+
52
+ # [2.6.0-rc.1](https://github.com/SAP/ui5-webcomponents/compare/v2.6.0-rc.0...v2.6.0-rc.1) (2024-12-16)
53
+
54
+ **Note:** Version bump only for package @ui5/webcomponents-ai
55
+
56
+
57
+
58
+
59
+
60
+ # [2.6.0-rc.0](https://github.com/SAP/ui5-webcomponents/compare/v2.5.0...v2.6.0-rc.0) (2024-12-12)
61
+
62
+
63
+ ### Features
64
+
65
+ * **framework:** add JSX template support with TypeScript ([#10046](https://github.com/SAP/ui5-webcomponents/issues/10046)) ([f42e7c1](https://github.com/SAP/ui5-webcomponents/commit/f42e7c18c846f923df4fec6ae02f1b4c20c006fa))
66
+
67
+
68
+
69
+
70
+
71
+ # [2.5.0](https://github.com/SAP/ui5-webcomponents/compare/v2.5.0-rc.3...v2.5.0) (2024-12-05)
72
+
73
+ **Note:** Version bump only for package @ui5/webcomponents-ai
74
+
75
+
76
+
77
+
78
+
79
+ # [2.5.0-rc.3](https://github.com/SAP/ui5-webcomponents/compare/v2.5.0-rc.2...v2.5.0-rc.3) (2024-12-05)
80
+
81
+
82
+ ### Features
83
+
84
+ * **framework:** add strict event type checking ([#10235](https://github.com/SAP/ui5-webcomponents/issues/10235)) ([4ff8ab7](https://github.com/SAP/ui5-webcomponents/commit/4ff8ab7c34db5058b92511767be1b96c69a91cb5))
85
+
86
+
87
+
88
+
89
+
90
+ # [2.5.0-rc.2](https://github.com/SAP/ui5-webcomponents/compare/v2.5.0-rc.1...v2.5.0-rc.2) (2024-11-28)
91
+
92
+ **Note:** Version bump only for package @ui5/webcomponents-ai
93
+
94
+
95
+
96
+
97
+
98
+ # [2.5.0-rc.1](https://github.com/SAP/ui5-webcomponents/compare/v2.5.0-rc.0...v2.5.0-rc.1) (2024-11-21)
99
+
100
+ **Note:** Version bump only for package @ui5/webcomponents-ai
101
+
102
+
103
+
104
+
105
+
106
+ # [2.5.0-rc.0](https://github.com/SAP/ui5-webcomponents/compare/v2.4.1-rc.0...v2.5.0-rc.0) (2024-11-14)
107
+
108
+ **Note:** Version bump only for package @ui5/webcomponents-ai
109
+
110
+
111
+
112
+
113
+
114
+ ## [2.4.1-rc.0](https://github.com/SAP/ui5-webcomponents/compare/v2.4.0...v2.4.1-rc.0) (2024-11-07)
115
+
116
+ **Note:** Version bump only for package @ui5/webcomponents-ai
117
+
118
+
119
+
120
+
121
+
122
+ # [2.4.0](https://github.com/SAP/ui5-webcomponents/compare/v2.4.0-rc.4...v2.4.0) (2024-11-03)
123
+
124
+ **Note:** Version bump only for package @ui5/webcomponents-ai
125
+
126
+
127
+
128
+
129
+
130
+ # [2.4.0-rc.4](https://github.com/SAP/ui5-webcomponents/compare/v2.4.0-rc.3...v2.4.0-rc.4) (2024-10-31)
131
+
132
+ **Note:** Version bump only for package @ui5/webcomponents-ai
133
+
134
+
135
+
136
+
137
+
138
+ # [2.4.0-rc.3](https://github.com/SAP/ui5-webcomponents/compare/v2.4.0-rc.2...v2.4.0-rc.3) (2024-10-28)
139
+
140
+ **Note:** Version bump only for package @ui5/webcomponents-ai
141
+
142
+
143
+
144
+
145
+
146
+ # [2.4.0-rc.2](https://github.com/SAP/ui5-webcomponents/compare/v2.4.0-rc.1...v2.4.0-rc.2) (2024-10-24)
147
+
148
+ **Note:** Version bump only for package @ui5/webcomponents-ai
149
+
150
+
151
+
152
+
153
+
154
+ # [2.4.0-rc.1](https://github.com/SAP/ui5-webcomponents/compare/v2.4.0-rc.0...v2.4.0-rc.1) (2024-10-17)
155
+
156
+
157
+ ### Bug Fixes
158
+
159
+ * scoping issues and document how scoping is used correctly ([#10023](https://github.com/SAP/ui5-webcomponents/issues/10023)) ([ee808c3](https://github.com/SAP/ui5-webcomponents/commit/ee808c309f316fe145b05d292c92328396c655ab))
160
+ * **tools:** revert tsconfig moduleResolution to node ([#10014](https://github.com/SAP/ui5-webcomponents/issues/10014)) ([0724b92](https://github.com/SAP/ui5-webcomponents/commit/0724b9289ad04f88972d4978ed37e76f13abca13))
161
+
162
+
163
+
164
+
165
+
6
166
  # [2.4.0-rc.0](https://github.com/SAP/ui5-webcomponents/compare/v2.3.1-rc.0...v2.4.0-rc.0) (2024-10-10)
7
167
 
8
168
 
package/README.md CHANGED
@@ -10,9 +10,10 @@ Provides web components implementing AI-related visual and interaction.
10
10
 
11
11
  ## Provided components
12
12
 
13
- | Web Component | Tag name | Module import |
14
- |--------------------------|-----------------------------|------------------------------------------------------------|
15
-
13
+ | Web Component | Tag name | Module import |
14
+ |--------------------------|--------------------------------|---------------------------------------------------------|
15
+ | Button | `ui5-ai-button` | `import "@ui5/webcomponents-ai/dist/Button.js";` |
16
+ | PromptInput | `ui5-ai-prompt-input` | `import "@ui5/webcomponents-ai/dist/PromptInput.js";` |
16
17
 
17
18
  ## Provided assets
18
19
 
package/dist/Button.d.ts CHANGED
@@ -1,24 +1,27 @@
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
5
  /**
6
6
  * @class
7
7
  *
8
8
  * ### Overview
9
9
  *
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.
10
+ * 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`
11
+ * or by pressing keyboard keys like [Enter] or [Space].
13
12
  *
14
13
  * ### Usage
15
14
  *
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.
15
+ * 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.
16
+ * Each state has a name for identification and can include text, an icon, and an end icon, as needed for its purpose.
17
+ * You can define a split mode for the `ui5-ai-button`, which will results in displaying an arrow button for additional actions.
18
18
  *
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.
19
+ * You can choose from a set of predefined designs for `ui5-ai-button` (as in `ui5-button`) to match the desired styling.
20
20
  *
21
- * `ui5-ai-button` can be activated by clicking or tapping it. The state can be changed in `click` event handler.
21
+ * 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
22
+ * in split mode, you can activate the default button action by clicking or tapping it, or by pressing keyboard keys like [Enter] or [Space].
23
+ * You can activate the arrow button by clicking or tapping it, or by pressing keyboard keys like [Arrow Up], [Arrow Down], or [F4].
24
+ * To display additional actions, you can attach a menu to the arrow button.
22
25
  *
23
26
  * ### ES6 Module Import
24
27
  *
@@ -31,6 +34,10 @@ import ButtonState from "./ButtonState.js";
31
34
  * @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.
32
35
  */
33
36
  declare class Button extends UI5Element {
37
+ eventDetails: {
38
+ "click": void;
39
+ "arrow-click": void;
40
+ };
34
41
  /**
35
42
  * Defines the component design.
36
43
  * @default "Default"
@@ -53,34 +60,43 @@ declare class Button extends UI5Element {
53
60
  */
54
61
  state?: string;
55
62
  /**
56
- * Keeps the current state object of the component.
57
- * @private
58
- */
59
- _currentStateObject?: ButtonState;
60
- /**
61
- * Initiates button elements fade-out phase.
63
+ * Defines the active state of the arrow button in split mode.
64
+ * Set to true when the button is in split mode and a menu with additional options
65
+ * is opened by the arrow button. Set back to false when the menu is closed.
62
66
  * @default false
63
- * @private
67
+ * @public
68
+ * @since 2.6.0
64
69
  */
65
- fadeOut: boolean;
70
+ activeArrowButton: boolean;
66
71
  /**
67
- * Initiates button fade middle phase.
68
- * @default false
72
+ * Keeps the current state object of the component.
69
73
  * @private
70
74
  */
71
- fadeMid: boolean;
75
+ _currentStateObject?: ButtonState;
72
76
  /**
73
- * Initiates button elements fade-in phase.
77
+ * Determines if the button is in icon-only mode.
78
+ * This property is animation related only.
74
79
  * @default false
75
80
  * @private
76
81
  */
77
- fadeIn: boolean;
82
+ iconOnly?: boolean | undefined;
78
83
  /**
79
84
  * Defines the available states of the component.
80
- * **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.
85
+ * **Note:** Although this slot accepts HTML Elements, it is strongly recommended that
86
+ * you only use `ui5-ai-button-state` components in order to preserve the intended design.
81
87
  * @public
82
88
  */
83
89
  states: Array<ButtonState>;
90
+ _splitButton?: SplitButton;
91
+ _hiddenSplitButton?: SplitButton;
92
+ get _hideArrowButton(): boolean;
93
+ get _effectiveState(): string;
94
+ get _effectiveStateObject(): ButtonState | undefined;
95
+ get _stateIconOnly(): boolean;
96
+ get _stateText(): string | undefined;
97
+ get _stateIcon(): string | undefined;
98
+ get _stateEndIcon(): string | undefined;
99
+ get _hasText(): boolean;
84
100
  onBeforeRendering(): void;
85
101
  /**
86
102
  * Starts the fade-out animation.
@@ -101,14 +117,11 @@ declare class Button extends UI5Element {
101
117
  * Handles the click event.
102
118
  * @private
103
119
  */
104
- _onclick(e: MouseEvent): void;
105
- get _mainButton(): MainButton;
106
- get _effectiveState(): string;
107
- get _effectiveStateObject(): ButtonState | undefined;
108
- get _stateIconOnly(): boolean;
109
- get _stateText(): string | undefined;
110
- get _stateIcon(): string | undefined;
111
- get _stateEndIcon(): string | undefined;
112
- get _hasText(): boolean;
120
+ _onClick(e: CustomEvent): void;
121
+ /**
122
+ * Handles the arrow-click event when `ui5-ai-button` is in split mode.
123
+ * @private
124
+ */
125
+ _onArrowClick(e: CustomEvent): void;
113
126
  }
114
127
  export default Button;
package/dist/Button.js CHANGED
@@ -8,13 +8,11 @@ import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
8
8
  import { renderFinished } from "@ui5/webcomponents-base/dist/Render.js";
9
9
  import customElement from "@ui5/webcomponents-base/dist/decorators/customElement.js";
10
10
  import property from "@ui5/webcomponents-base/dist/decorators/property.js";
11
- import event from "@ui5/webcomponents-base/dist/decorators/event.js";
11
+ import event from "@ui5/webcomponents-base/dist/decorators/event-strict.js";
12
12
  import slot from "@ui5/webcomponents-base/dist/decorators/slot.js";
13
- import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.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";
17
- import ButtonTemplate from "./generated/templates/ButtonTemplate.lit.js";
13
+ import query from "@ui5/webcomponents-base/dist/decorators/query.js";
14
+ import jsxRenderer from "@ui5/webcomponents-base/dist/renderer/JsxRenderer.js";
15
+ import ButtonTemplate from "./ButtonTemplate.js";
18
16
  // Styles
19
17
  import ButtonCss from "./generated/themes/Button.css.js";
20
18
  /**
@@ -22,18 +20,21 @@ import ButtonCss from "./generated/themes/Button.css.js";
22
20
  *
23
21
  * ### Overview
24
22
  *
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.
23
+ * 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`
24
+ * or by pressing keyboard keys like [Enter] or [Space].
28
25
  *
29
26
  * ### Usage
30
27
  *
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.
28
+ * 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.
29
+ * Each state has a name for identification and can include text, an icon, and an end icon, as needed for its purpose.
30
+ * You can define a split mode for the `ui5-ai-button`, which will results in displaying an arrow button for additional actions.
33
31
  *
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.
32
+ * You can choose from a set of predefined designs for `ui5-ai-button` (as in `ui5-button`) to match the desired styling.
35
33
  *
36
- * `ui5-ai-button` can be activated by clicking or tapping it. The state can be changed in `click` event handler.
34
+ * 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
35
+ * in split mode, you can activate the default button action by clicking or tapping it, or by pressing keyboard keys like [Enter] or [Space].
36
+ * You can activate the arrow button by clicking or tapping it, or by pressing keyboard keys like [Arrow Up], [Arrow Down], or [F4].
37
+ * To display additional actions, you can attach a menu to the arrow button.
37
38
  *
38
39
  * ### ES6 Module Import
39
40
  *
@@ -63,32 +64,57 @@ let Button = class Button extends UI5Element {
63
64
  */
64
65
  this.disabled = false;
65
66
  /**
66
- * Initiates button elements fade-out phase.
67
+ * Defines the active state of the arrow button in split mode.
68
+ * Set to true when the button is in split mode and a menu with additional options
69
+ * is opened by the arrow button. Set back to false when the menu is closed.
67
70
  * @default false
68
- * @private
69
- */
70
- this.fadeOut = false;
71
- /**
72
- * Initiates button fade middle phase.
73
- * @default false
74
- * @private
71
+ * @public
72
+ * @since 2.6.0
75
73
  */
76
- this.fadeMid = false;
74
+ this.activeArrowButton = false;
77
75
  /**
78
- * Initiates button elements fade-in phase.
76
+ * Determines if the button is in icon-only mode.
77
+ * This property is animation related only.
79
78
  * @default false
80
79
  * @private
81
80
  */
82
- this.fadeIn = false;
81
+ this.iconOnly = false;
82
+ }
83
+ get _hideArrowButton() {
84
+ return !this._effectiveStateObject?.splitMode;
85
+ }
86
+ get _effectiveState() {
87
+ return this.state || (this.states.length && this.states[0].name) || "";
88
+ }
89
+ get _effectiveStateObject() {
90
+ return this.states.find(state => state.name === this._effectiveState);
91
+ }
92
+ get _stateIconOnly() {
93
+ return !this._stateText && !!this._stateIcon;
94
+ }
95
+ get _stateText() {
96
+ return this._currentStateObject?.text;
97
+ }
98
+ get _stateIcon() {
99
+ return this._currentStateObject?.icon;
100
+ }
101
+ get _stateEndIcon() {
102
+ const endIcon = this._effectiveStateObject?.splitMode ? "" : this._effectiveStateObject?.endIcon;
103
+ return endIcon;
104
+ }
105
+ get _hasText() {
106
+ return !!this._stateText;
83
107
  }
84
108
  onBeforeRendering() {
85
- if (this.fadeOut || this.fadeIn) {
86
- return;
109
+ const splitButton = this._splitButton;
110
+ if (splitButton) {
111
+ splitButton.activeArrowButton = this.activeArrowButton;
87
112
  }
88
113
  if (!this._currentStateObject?.name) {
89
114
  this._currentStateObject = this._effectiveStateObject;
90
115
  }
91
116
  const currentStateName = this._currentStateObject?.name || "";
117
+ this.iconOnly = this._stateIconOnly;
92
118
  if (currentStateName !== "" && currentStateName !== this._effectiveState) {
93
119
  this._fadeOut();
94
120
  }
@@ -99,38 +125,50 @@ let Button = class Button extends UI5Element {
99
125
  */
100
126
  async _fadeOut() {
101
127
  const fadeOutDuration = 180;
102
- const button = this._mainButton;
128
+ const button = this._splitButton;
129
+ const hiddenButton = this._hiddenSplitButton;
103
130
  const newStateObject = this._effectiveStateObject;
104
131
  if (!newStateObject) {
105
132
  // eslint-disable-next-line no-console
106
133
  console.warn(`State with name="${this.state}" doesn't exist!`);
134
+ return;
135
+ }
136
+ if (!button || !hiddenButton) {
137
+ return;
107
138
  }
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);
139
+ const buttonWidth = button.offsetWidth;
140
+ const currentState = this._currentStateObject || {};
141
+ if ((!currentState.splitMode && newStateObject.splitMode) || (!currentState.endIcon && !!newStateObject.endIcon)) {
142
+ this.classList.add("ui5-ai-button-button-to-menu");
124
143
  }
144
+ if ((currentState.splitMode && !newStateObject.splitMode) || (!!currentState.endIcon && !newStateObject.endIcon)) {
145
+ this.classList.add("ui5-ai-button-menu-to-button");
146
+ }
147
+ this.style.width = `${buttonWidth}px`;
148
+ hiddenButton.icon = newStateObject.icon;
149
+ hiddenButton._endIcon = newStateObject.endIcon;
150
+ hiddenButton.textContent = newStateObject.text || null;
151
+ hiddenButton._hideArrowButton = this._hideArrowButton;
152
+ await renderFinished();
153
+ const hiddenButtonWidth = hiddenButton.offsetWidth;
154
+ this.style.width = `${hiddenButtonWidth}px`;
155
+ this.classList.add("ui5-ai-button-fade-out");
156
+ setTimeout(() => {
157
+ this.classList.add("ui5-ai-button-fade-mid");
158
+ button._hideArrowButton = this._hideArrowButton;
159
+ this._fadeIn();
160
+ }, fadeOutDuration);
125
161
  }
126
162
  /**
127
163
  * Starts the fade-in animation.
128
164
  * @private
129
165
  */
130
166
  _fadeIn() {
131
- const fadeInDuration = 60;
167
+ const fadeInDuration = 160;
132
168
  setTimeout(() => {
133
- this.fadeIn = true;
169
+ const newStateObject = this._effectiveStateObject;
170
+ this._currentStateObject = newStateObject;
171
+ this.classList.add("ui5-ai-button-fade-in");
134
172
  this._resetFade();
135
173
  }, fadeInDuration);
136
174
  }
@@ -141,12 +179,14 @@ let Button = class Button extends UI5Element {
141
179
  _resetFade() {
142
180
  const fadeResetDuration = 160;
143
181
  setTimeout(() => {
144
- this.fadeOut = false;
145
- this.fadeMid = false;
146
- this.fadeIn = false;
182
+ this.classList.remove("ui5-ai-button-fade-out");
183
+ this.classList.remove("ui5-ai-button-fade-mid");
184
+ this.classList.remove("ui5-ai-button-fade-in");
185
+ this.classList.remove("ui5-ai-button-button-to-menu");
186
+ this.classList.remove("ui5-ai-button-menu-to-button");
147
187
  }, fadeResetDuration);
148
188
  // reset the button's width after animations
149
- const button = this._mainButton;
189
+ const button = this._splitButton;
150
190
  if (button) {
151
191
  button.style.width = "";
152
192
  }
@@ -155,33 +195,17 @@ let Button = class Button extends UI5Element {
155
195
  * Handles the click event.
156
196
  * @private
157
197
  */
158
- _onclick(e) {
198
+ _onClick(e) {
159
199
  e.stopImmediatePropagation();
160
200
  this.fireDecoratorEvent("click");
161
201
  }
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;
182
- }
183
- get _hasText() {
184
- return !!this._stateText;
202
+ /**
203
+ * Handles the arrow-click event when `ui5-ai-button` is in split mode.
204
+ * @private
205
+ */
206
+ _onArrowClick(e) {
207
+ e.stopImmediatePropagation();
208
+ this.fireDecoratorEvent("arrow-click");
185
209
  }
186
210
  };
187
211
  __decorate([
@@ -193,29 +217,31 @@ __decorate([
193
217
  __decorate([
194
218
  property()
195
219
  ], Button.prototype, "state", void 0);
220
+ __decorate([
221
+ property({ type: Boolean, noAttribute: true })
222
+ ], Button.prototype, "activeArrowButton", void 0);
196
223
  __decorate([
197
224
  property({ type: Object })
198
225
  ], Button.prototype, "_currentStateObject", void 0);
199
226
  __decorate([
200
227
  property({ type: Boolean })
201
- ], Button.prototype, "fadeOut", void 0);
202
- __decorate([
203
- property({ type: Boolean })
204
- ], Button.prototype, "fadeMid", void 0);
205
- __decorate([
206
- property({ type: Boolean })
207
- ], Button.prototype, "fadeIn", void 0);
228
+ ], Button.prototype, "iconOnly", void 0);
208
229
  __decorate([
209
230
  slot({ type: HTMLElement, "default": true })
210
231
  ], Button.prototype, "states", void 0);
232
+ __decorate([
233
+ query("[ui5-split-button]")
234
+ ], Button.prototype, "_splitButton", void 0);
235
+ __decorate([
236
+ query(".ui5-ai-button-hidden[ui5-split-button]")
237
+ ], Button.prototype, "_hiddenSplitButton", void 0);
211
238
  Button = __decorate([
212
239
  customElement({
213
240
  tag: "ui5-ai-button",
214
241
  languageAware: true,
215
- renderer: litRender,
242
+ renderer: jsxRenderer,
216
243
  template: ButtonTemplate,
217
244
  styles: ButtonCss,
218
- dependencies: [MainButton, Icon, ButtonState],
219
245
  shadowRootOptions: { delegatesFocus: true },
220
246
  })
221
247
  /**
@@ -227,6 +253,16 @@ Button = __decorate([
227
253
  event("click", {
228
254
  bubbles: true,
229
255
  })
256
+ /**
257
+ * Fired when the component is in split mode and after the arrow button
258
+ * is activated either by clicking or tapping it or by using the [Arrow Up] / [Arrow Down],
259
+ * [Alt] + [Arrow Up]/ [Arrow Down], or [F4] keyboard keys.
260
+ * @public
261
+ */
262
+ ,
263
+ event("arrow-click", {
264
+ bubbles: true,
265
+ })
230
266
  ], Button);
231
267
  Button.define();
232
268
  export default Button;