@ui5/webcomponents-ai 0.0.0-d473b9686 → 0.0.0-dd5d66a9a

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 (195) hide show
  1. package/CHANGELOG.md +786 -0
  2. package/README.md +12 -13
  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 +156 -2
  12. package/dist/Button.js +297 -14
  13. package/dist/Button.js.map +1 -1
  14. package/dist/ButtonState.d.ts +67 -0
  15. package/dist/ButtonState.js +64 -0
  16. package/dist/ButtonState.js.map +1 -0
  17. package/dist/ButtonTemplate.d.ts +2 -0
  18. package/dist/ButtonTemplate.js +6 -0
  19. package/dist/ButtonTemplate.js.map +1 -0
  20. package/dist/PromptInput.d.ts +149 -0
  21. package/dist/PromptInput.js +225 -0
  22. package/dist/PromptInput.js.map +1 -0
  23. package/dist/PromptInputTemplate.d.ts +2 -0
  24. package/dist/PromptInputTemplate.js +12 -0
  25. package/dist/PromptInputTemplate.js.map +1 -0
  26. package/dist/bundle.esm.js +3 -1
  27. package/dist/bundle.esm.js.map +1 -1
  28. package/dist/bundle.scoped.config.d.ts +1 -0
  29. package/dist/bundle.scoped.config.js +3 -0
  30. package/dist/bundle.scoped.config.js.map +1 -0
  31. package/dist/bundle.scoped.esm.d.ts +2 -1
  32. package/dist/bundle.scoped.esm.js +2 -2
  33. package/dist/bundle.scoped.esm.js.map +1 -1
  34. package/dist/css/themes/Button.css +1 -0
  35. package/dist/css/themes/PromptInput.css +1 -0
  36. package/dist/custom-elements-internal.json +648 -1
  37. package/dist/custom-elements.json +574 -1
  38. package/dist/generated/assets/i18n/messagebundle_ar.json +1 -0
  39. package/dist/generated/assets/i18n/messagebundle_bg.json +1 -0
  40. package/dist/generated/assets/i18n/messagebundle_ca.json +1 -0
  41. package/dist/generated/assets/i18n/messagebundle_cnr.json +1 -0
  42. package/dist/generated/assets/i18n/messagebundle_cs.json +1 -0
  43. package/dist/generated/assets/i18n/messagebundle_cy.json +1 -0
  44. package/dist/generated/assets/i18n/messagebundle_da.json +1 -0
  45. package/dist/generated/assets/i18n/messagebundle_de.json +1 -0
  46. package/dist/generated/assets/i18n/messagebundle_el.json +1 -0
  47. package/dist/generated/assets/i18n/messagebundle_en.json +1 -0
  48. package/dist/generated/assets/i18n/messagebundle_en_GB.json +1 -0
  49. package/dist/generated/assets/i18n/messagebundle_en_US_sappsd.json +1 -0
  50. package/dist/generated/assets/i18n/messagebundle_en_US_saprigi.json +1 -0
  51. package/dist/generated/assets/i18n/messagebundle_en_US_saptrc.json +1 -0
  52. package/dist/generated/assets/i18n/messagebundle_es.json +1 -0
  53. package/dist/generated/assets/i18n/messagebundle_es_MX.json +1 -0
  54. package/dist/generated/assets/i18n/messagebundle_et.json +1 -0
  55. package/dist/generated/assets/i18n/messagebundle_fi.json +1 -0
  56. package/dist/generated/assets/i18n/messagebundle_fr.json +1 -0
  57. package/dist/generated/assets/i18n/messagebundle_fr_CA.json +1 -0
  58. package/dist/generated/assets/i18n/messagebundle_hi.json +1 -0
  59. package/dist/generated/assets/i18n/messagebundle_hr.json +1 -0
  60. package/dist/generated/assets/i18n/messagebundle_hu.json +1 -0
  61. package/dist/generated/assets/i18n/messagebundle_id.json +1 -0
  62. package/dist/generated/assets/i18n/messagebundle_it.json +1 -0
  63. package/dist/generated/assets/i18n/messagebundle_iw.json +1 -0
  64. package/dist/generated/assets/i18n/messagebundle_ja.json +1 -0
  65. package/dist/generated/assets/i18n/messagebundle_kk.json +1 -0
  66. package/dist/generated/assets/i18n/messagebundle_ko.json +1 -0
  67. package/dist/generated/assets/i18n/messagebundle_lt.json +1 -0
  68. package/dist/generated/assets/i18n/messagebundle_lv.json +1 -0
  69. package/dist/generated/assets/i18n/messagebundle_mk.json +1 -0
  70. package/dist/generated/assets/i18n/messagebundle_ms.json +1 -0
  71. package/dist/generated/assets/i18n/messagebundle_nl.json +1 -0
  72. package/dist/generated/assets/i18n/messagebundle_no.json +1 -0
  73. package/dist/generated/assets/i18n/messagebundle_pl.json +1 -0
  74. package/dist/generated/assets/i18n/messagebundle_pt.json +1 -0
  75. package/dist/generated/assets/i18n/messagebundle_pt_PT.json +1 -0
  76. package/dist/generated/assets/i18n/messagebundle_ro.json +1 -0
  77. package/dist/generated/assets/i18n/messagebundle_ru.json +1 -0
  78. package/dist/generated/assets/i18n/messagebundle_sh.json +1 -0
  79. package/dist/generated/assets/i18n/messagebundle_sk.json +1 -0
  80. package/dist/generated/assets/i18n/messagebundle_sl.json +1 -0
  81. package/dist/generated/assets/i18n/messagebundle_sr.json +1 -0
  82. package/dist/generated/assets/i18n/messagebundle_sv.json +1 -0
  83. package/dist/generated/assets/i18n/messagebundle_th.json +1 -0
  84. package/dist/generated/assets/i18n/messagebundle_tr.json +1 -0
  85. package/dist/generated/assets/i18n/messagebundle_uk.json +1 -0
  86. package/dist/generated/assets/i18n/messagebundle_vi.json +1 -0
  87. package/dist/generated/assets/i18n/messagebundle_zh_CN.json +1 -0
  88. package/dist/generated/assets/i18n/messagebundle_zh_TW.json +1 -0
  89. package/dist/generated/assets/themes/sap_horizon/parameters-bundle.css.json +1 -1
  90. package/dist/generated/assets/themes/sap_horizon_dark/parameters-bundle.css.json +1 -1
  91. package/dist/generated/assets/themes/sap_horizon_hcb/parameters-bundle.css.json +1 -1
  92. package/dist/generated/assets/themes/sap_horizon_hcw/parameters-bundle.css.json +1 -1
  93. package/dist/generated/i18n/i18n-defaults.d.ts +5 -1
  94. package/dist/generated/i18n/i18n-defaults.js +4 -1
  95. package/dist/generated/i18n/i18n-defaults.js.map +1 -1
  96. package/dist/generated/json-imports/Themes-fetch.d.ts +1 -0
  97. package/dist/generated/json-imports/Themes-fetch.js +21 -0
  98. package/dist/generated/json-imports/Themes-fetch.js.map +1 -0
  99. package/dist/generated/json-imports/Themes-node.d.ts +1 -0
  100. package/dist/generated/json-imports/Themes-node.js +21 -0
  101. package/dist/generated/json-imports/Themes-node.js.map +1 -0
  102. package/dist/generated/json-imports/Themes.js +1 -1
  103. package/dist/generated/json-imports/Themes.js.map +1 -1
  104. package/dist/generated/json-imports/i18n-fetch.d.ts +1 -0
  105. package/dist/generated/json-imports/i18n-fetch.js +120 -0
  106. package/dist/generated/json-imports/i18n-fetch.js.map +1 -0
  107. package/dist/generated/json-imports/i18n-node.d.ts +1 -0
  108. package/dist/generated/json-imports/i18n-node.js +120 -0
  109. package/dist/generated/json-imports/i18n-node.js.map +1 -0
  110. package/dist/generated/json-imports/i18n.d.ts +1 -0
  111. package/dist/generated/json-imports/i18n.js +119 -1
  112. package/dist/generated/json-imports/i18n.js.map +1 -1
  113. package/dist/generated/themes/Button.css.d.ts +2 -3
  114. package/dist/generated/themes/Button.css.js +4 -4
  115. package/dist/generated/themes/Button.css.js.map +1 -1
  116. package/dist/generated/themes/PromptInput.css.d.ts +2 -0
  117. package/dist/generated/themes/PromptInput.css.js +8 -0
  118. package/dist/generated/themes/PromptInput.css.js.map +1 -0
  119. package/dist/generated/themes/sap_horizon/parameters-bundle.css.d.ts +2 -3
  120. package/dist/generated/themes/sap_horizon/parameters-bundle.css.js +1 -2
  121. package/dist/generated/themes/sap_horizon/parameters-bundle.css.js.map +1 -1
  122. package/dist/generated/themes/sap_horizon_dark/parameters-bundle.css.d.ts +2 -3
  123. package/dist/generated/themes/sap_horizon_dark/parameters-bundle.css.js +1 -2
  124. package/dist/generated/themes/sap_horizon_dark/parameters-bundle.css.js.map +1 -1
  125. package/dist/generated/themes/sap_horizon_hcb/parameters-bundle.css.d.ts +2 -3
  126. package/dist/generated/themes/sap_horizon_hcb/parameters-bundle.css.js +1 -2
  127. package/dist/generated/themes/sap_horizon_hcb/parameters-bundle.css.js.map +1 -1
  128. package/dist/generated/themes/sap_horizon_hcw/parameters-bundle.css.d.ts +2 -3
  129. package/dist/generated/themes/sap_horizon_hcw/parameters-bundle.css.js +1 -2
  130. package/dist/generated/themes/sap_horizon_hcw/parameters-bundle.css.js.map +1 -1
  131. package/dist/vscode.html-custom-data.json +136 -1
  132. package/dist/web-types.json +328 -0
  133. package/package-scripts.cjs +4 -0
  134. package/package.json +12 -9
  135. package/src/ButtonTemplate.tsx +27 -0
  136. package/src/PromptInputTemplate.tsx +49 -0
  137. package/src/i18n/messagebundle.properties +10 -0
  138. package/src/i18n/messagebundle_ar.properties +4 -0
  139. package/src/i18n/messagebundle_bg.properties +4 -0
  140. package/src/i18n/messagebundle_ca.properties +4 -0
  141. package/src/i18n/messagebundle_cnr.properties +4 -0
  142. package/src/i18n/messagebundle_cs.properties +4 -0
  143. package/src/i18n/messagebundle_cy.properties +4 -0
  144. package/src/i18n/messagebundle_da.properties +4 -0
  145. package/src/i18n/messagebundle_de.properties +7 -0
  146. package/src/i18n/messagebundle_el.properties +4 -0
  147. package/src/i18n/messagebundle_en.properties +7 -0
  148. package/src/i18n/messagebundle_en_GB.properties +4 -0
  149. package/src/i18n/messagebundle_en_US_sappsd.properties +7 -0
  150. package/src/i18n/messagebundle_en_US_saprigi.properties +7 -0
  151. package/src/i18n/messagebundle_en_US_saptrc.properties +7 -0
  152. package/src/i18n/messagebundle_es.properties +4 -0
  153. package/src/i18n/messagebundle_es_MX.properties +4 -0
  154. package/src/i18n/messagebundle_et.properties +4 -0
  155. package/src/i18n/messagebundle_fi.properties +4 -0
  156. package/src/i18n/messagebundle_fr.properties +4 -0
  157. package/src/i18n/messagebundle_fr_CA.properties +4 -0
  158. package/src/i18n/messagebundle_hi.properties +4 -0
  159. package/src/i18n/messagebundle_hr.properties +4 -0
  160. package/src/i18n/messagebundle_hu.properties +4 -0
  161. package/src/i18n/messagebundle_id.properties +4 -0
  162. package/src/i18n/messagebundle_it.properties +4 -0
  163. package/src/i18n/messagebundle_iw.properties +4 -0
  164. package/src/i18n/messagebundle_ja.properties +4 -0
  165. package/src/i18n/messagebundle_kk.properties +4 -0
  166. package/src/i18n/messagebundle_ko.properties +4 -0
  167. package/src/i18n/messagebundle_lt.properties +4 -0
  168. package/src/i18n/messagebundle_lv.properties +4 -0
  169. package/src/i18n/messagebundle_mk.properties +4 -0
  170. package/src/i18n/messagebundle_ms.properties +4 -0
  171. package/src/i18n/messagebundle_nl.properties +4 -0
  172. package/src/i18n/messagebundle_no.properties +4 -0
  173. package/src/i18n/messagebundle_pl.properties +4 -0
  174. package/src/i18n/messagebundle_pt.properties +4 -0
  175. package/src/i18n/messagebundle_pt_PT.properties +4 -0
  176. package/src/i18n/messagebundle_ro.properties +4 -0
  177. package/src/i18n/messagebundle_ru.properties +4 -0
  178. package/src/i18n/messagebundle_sh.properties +4 -0
  179. package/src/i18n/messagebundle_sk.properties +4 -0
  180. package/src/i18n/messagebundle_sl.properties +4 -0
  181. package/src/i18n/messagebundle_sr.properties +4 -0
  182. package/src/i18n/messagebundle_sv.properties +4 -0
  183. package/src/i18n/messagebundle_th.properties +4 -0
  184. package/src/i18n/messagebundle_tr.properties +4 -0
  185. package/src/i18n/messagebundle_uk.properties +4 -0
  186. package/src/i18n/messagebundle_vi.properties +4 -0
  187. package/src/i18n/messagebundle_zh_CN.properties +4 -0
  188. package/src/i18n/messagebundle_zh_TW.properties +4 -0
  189. package/src/themes/Button.css +142 -0
  190. package/src/themes/PromptInput.css +30 -0
  191. package/tsconfig.json +55 -26
  192. package/dist/generated/templates/ButtonTemplate.lit.d.ts +0 -4
  193. package/dist/generated/templates/ButtonTemplate.lit.js +0 -5
  194. package/dist/generated/templates/ButtonTemplate.lit.js.map +0 -1
  195. package/src/Button.hbs +0 -3
package/dist/Button.d.ts CHANGED
@@ -1,11 +1,165 @@
1
1
  import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
2
+ import type SplitButton from "@ui5/webcomponents/dist/SplitButton.js";
3
+ import type ButtonDesign from "@ui5/webcomponents/dist/types/ButtonDesign.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" | "ariaKeyShortcuts">;
9
+ type AIButtonArrowButtonAccessibilityAttributes = Pick<AccessibilityAttributes, "hasPopup" | "expanded" | "title">;
10
+ type AIButtonAccessibilityAttributes = {
11
+ root?: AIButtonRootAccessibilityAttributes;
12
+ arrowButton?: AIButtonArrowButtonAccessibilityAttributes;
13
+ };
2
14
  /**
3
15
  * @class
16
+ *
17
+ * ### Overview
18
+ *
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].
21
+ *
22
+ * ### Usage
23
+ *
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.
27
+ *
28
+ * You can choose from a set of predefined designs for `ui5-ai-button` (as in `ui5-button`) to match the desired styling.
29
+ *
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.
34
+ *
35
+ * ### ES6 Module Import
36
+ *
37
+ * `import "@ui5/webcomponents-ai/dist/Button.js";`
38
+ *
4
39
  * @constructor
5
40
  * @extends UI5Element
41
+ * @since 2.0.0
42
+ * @public
43
+ * @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.
6
44
  */
7
45
  declare class Button extends UI5Element {
8
- icon: string;
9
- endIcon: string;
46
+ eventDetails: {
47
+ "click": void;
48
+ "arrow-button-click": void;
49
+ };
50
+ /**
51
+ * Defines the component design.
52
+ * @default "Default"
53
+ * @public
54
+ */
55
+ design?: `${ButtonDesign}`;
56
+ /**
57
+ * Defines whether the component is disabled.
58
+ * A disabled component can't be pressed or
59
+ * focused, and it is not in the tab chain.
60
+ * @default false
61
+ * @public
62
+ */
63
+ disabled: boolean;
64
+ /**
65
+ * Defines the current state of the component.
66
+ *
67
+ * @default undefined
68
+ * @public
69
+ */
70
+ state?: string;
71
+ /**
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.
75
+ * @default false
76
+ * @public
77
+ * @since 2.6.0
78
+ */
79
+ arrowButtonPressed: boolean;
80
+ /**
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
+ * - **title**: Specifies a tooltip or description for screen readers.
92
+ * Accepts any string value.
93
+ * - **ariaKeyShortcuts**: Defines keyboard shortcuts that activate or focus the button.
94
+ *
95
+ * - **arrowButton**: Accessibility attributes that will be applied to the arrow (split) button element.
96
+ * - **hasPopup**: Indicates the type of popup triggered by the arrow button.
97
+ * Accepts string values: `"dialog"`, `"grid"`, `"listbox"`, `"menu"`, or `"tree"`.
98
+ * - **expanded**: Indicates whether the popup controlled by the arrow button is currently expanded.
99
+ * Accepts boolean values: `true` or `false`.
100
+ *
101
+ * @public
102
+ * @since 2.6.0
103
+ * @default {}
104
+ */
105
+ accessibilityAttributes: AIButtonAccessibilityAttributes;
106
+ /**
107
+ * Keeps the current state object of the component.
108
+ * @private
109
+ */
110
+ _currentStateObject?: ButtonState;
111
+ /**
112
+ * Determines if the button is in icon-only mode.
113
+ * This property is animation related only.
114
+ * @default false
115
+ * @private
116
+ */
117
+ iconOnly?: boolean | undefined;
118
+ /**
119
+ * Defines the available states of the component.
120
+ * **Note:** Although this slot accepts HTML Elements, it is strongly recommended that
121
+ * you only use `ui5-ai-button-state` components in order to preserve the intended design.
122
+ * @public
123
+ */
124
+ states: Array<ButtonState>;
125
+ _splitButton?: SplitButton;
126
+ _hiddenSplitButton?: SplitButton;
127
+ static i18nBundle: I18nBundle;
128
+ get _hideArrowButton(): boolean;
129
+ get _effectiveState(): string;
130
+ get _effectiveStateObject(): ButtonState | undefined;
131
+ get _stateIconOnly(): boolean;
132
+ get _stateText(): string | undefined;
133
+ get _stateIcon(): string | undefined;
134
+ get _stateEndIcon(): string | undefined;
135
+ get _hasText(): boolean;
136
+ onBeforeRendering(): void;
137
+ /**
138
+ * Starts the fade-out animation.
139
+ * @private
140
+ */
141
+ _fadeOut(): Promise<void>;
142
+ /**
143
+ * Starts the fade-in animation.
144
+ * @private
145
+ */
146
+ _fadeIn(): void;
147
+ /**
148
+ * Resets the fade phases when the animation is completed.
149
+ * @private
150
+ */
151
+ _resetFade(): void;
152
+ /**
153
+ * Handles the click event.
154
+ * @private
155
+ */
156
+ _onClick(e: CustomEvent): void;
157
+ /**
158
+ * Handles the arrow-button-click event when `ui5-ai-button` is in split mode.
159
+ * @private
160
+ */
161
+ _onArrowClick(e: CustomEvent): void;
162
+ get _computedAccessibilityAttributes(): AIButtonAccessibilityAttributes;
10
163
  }
11
164
  export default Button;
165
+ export type { AIButtonAccessibilityAttributes, };
package/dist/Button.js CHANGED
@@ -4,36 +4,319 @@ 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";
9
+ import { renderFinished } from "@ui5/webcomponents-base/dist/Render.js";
8
10
  import customElement from "@ui5/webcomponents-base/dist/decorators/customElement.js";
9
11
  import property from "@ui5/webcomponents-base/dist/decorators/property.js";
10
- import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
11
- // Deps
12
- import MainButton from "@ui5/webcomponents/dist/Button.js";
13
- // Template
14
- import template from "./generated/templates/ButtonTemplate.lit.js";
12
+ import event from "@ui5/webcomponents-base/dist/decorators/event-strict.js";
13
+ import slot from "@ui5/webcomponents-base/dist/decorators/slot.js";
14
+ import query from "@ui5/webcomponents-base/dist/decorators/query.js";
15
+ import jsxRenderer from "@ui5/webcomponents-base/dist/renderer/JsxRenderer.js";
16
+ import { BUTTON_TOOLTIP_TEXT } from "./generated/i18n/i18n-defaults.js";
17
+ import "./ButtonState.js";
18
+ import ButtonTemplate from "./ButtonTemplate.js";
19
+ import { getEffectiveAriaLabelText, getAssociatedLabelForTexts, getAllAccessibleNameRefTexts, } from "@ui5/webcomponents-base/dist/util/AccessibilityTextsHelper.js";
15
20
  // Styles
16
- import styles from "./generated/themes/Button.css.js";
21
+ import ButtonCss from "./generated/themes/Button.css.js";
22
+ import { i18n } from "@ui5/webcomponents-base/dist/decorators.js";
17
23
  /**
18
24
  * @class
25
+ *
26
+ * ### Overview
27
+ *
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].
30
+ *
31
+ * ### Usage
32
+ *
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.
36
+ *
37
+ * You can choose from a set of predefined designs for `ui5-ai-button` (as in `ui5-button`) to match the desired styling.
38
+ *
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.
43
+ *
44
+ * ### ES6 Module Import
45
+ *
46
+ * `import "@ui5/webcomponents-ai/dist/Button.js";`
47
+ *
19
48
  * @constructor
20
49
  * @extends UI5Element
50
+ * @since 2.0.0
51
+ * @public
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.
21
53
  */
22
- let Button = class Button extends UI5Element {
54
+ let Button = Button_1 = class Button extends UI5Element {
55
+ constructor() {
56
+ super(...arguments);
57
+ /**
58
+ * Defines the component design.
59
+ * @default "Default"
60
+ * @public
61
+ */
62
+ this.design = "Default";
63
+ /**
64
+ * Defines whether the component is disabled.
65
+ * A disabled component can't be pressed or
66
+ * focused, and it is not in the tab chain.
67
+ * @default false
68
+ * @public
69
+ */
70
+ this.disabled = false;
71
+ /**
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.
75
+ * @default false
76
+ * @public
77
+ * @since 2.6.0
78
+ */
79
+ this.arrowButtonPressed = false;
80
+ /**
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
+ * - **title**: Specifies a tooltip or description for screen readers.
92
+ * Accepts any string value.
93
+ * - **ariaKeyShortcuts**: Defines keyboard shortcuts that activate or focus the button.
94
+ *
95
+ * - **arrowButton**: Accessibility attributes that will be applied to the arrow (split) button element.
96
+ * - **hasPopup**: Indicates the type of popup triggered by the arrow button.
97
+ * Accepts string values: `"dialog"`, `"grid"`, `"listbox"`, `"menu"`, or `"tree"`.
98
+ * - **expanded**: Indicates whether the popup controlled by the arrow button is currently expanded.
99
+ * Accepts boolean values: `true` or `false`.
100
+ *
101
+ * @public
102
+ * @since 2.6.0
103
+ * @default {}
104
+ */
105
+ this.accessibilityAttributes = {};
106
+ /**
107
+ * Determines if the button is in icon-only mode.
108
+ * This property is animation related only.
109
+ * @default false
110
+ * @private
111
+ */
112
+ this.iconOnly = false;
113
+ }
114
+ get _hideArrowButton() {
115
+ return !this._effectiveStateObject?.showArrowButton;
116
+ }
117
+ get _effectiveState() {
118
+ return this.state || (this.states.length && this.states[0].name) || "";
119
+ }
120
+ get _effectiveStateObject() {
121
+ return this.states.find(state => state.name === this._effectiveState);
122
+ }
123
+ get _stateIconOnly() {
124
+ return !this._stateText && !!this._stateIcon;
125
+ }
126
+ get _stateText() {
127
+ return this._currentStateObject?.text;
128
+ }
129
+ get _stateIcon() {
130
+ return this._currentStateObject?.icon;
131
+ }
132
+ get _stateEndIcon() {
133
+ const endIcon = this._effectiveStateObject?.showArrowButton ? "" : this._effectiveStateObject?.endIcon;
134
+ return endIcon;
135
+ }
136
+ get _hasText() {
137
+ return !!this._stateText;
138
+ }
139
+ onBeforeRendering() {
140
+ const splitButton = this._splitButton;
141
+ if (splitButton) {
142
+ splitButton.activeArrowButton = this.arrowButtonPressed;
143
+ }
144
+ if (!this._currentStateObject?.name) {
145
+ this._currentStateObject = this._effectiveStateObject;
146
+ }
147
+ const currentStateName = this._currentStateObject?.name || "";
148
+ this.iconOnly = this._stateIconOnly;
149
+ if (currentStateName !== "" && currentStateName !== this._effectiveState) {
150
+ this._fadeOut();
151
+ }
152
+ }
153
+ /**
154
+ * Starts the fade-out animation.
155
+ * @private
156
+ */
157
+ async _fadeOut() {
158
+ const fadeOutDuration = 180;
159
+ const button = this._splitButton;
160
+ const hiddenButton = this._hiddenSplitButton;
161
+ const newStateObject = this._effectiveStateObject;
162
+ if (!newStateObject) {
163
+ // eslint-disable-next-line no-console
164
+ console.warn(`State with name="${this.state}" doesn't exist!`);
165
+ return;
166
+ }
167
+ if (!button || !hiddenButton) {
168
+ return;
169
+ }
170
+ const buttonWidth = button.offsetWidth;
171
+ const currentState = this._currentStateObject || {};
172
+ if ((!currentState.showArrowButton && newStateObject.showArrowButton) || (!currentState.endIcon && !!newStateObject.endIcon)) {
173
+ this.classList.add("ui5-ai-button-button-to-menu");
174
+ }
175
+ if ((currentState.showArrowButton && !newStateObject.showArrowButton) || (!!currentState.endIcon && !newStateObject.endIcon)) {
176
+ this.classList.add("ui5-ai-button-menu-to-button");
177
+ }
178
+ this.style.width = `${buttonWidth}px`;
179
+ hiddenButton.icon = newStateObject.icon;
180
+ hiddenButton._endIcon = newStateObject.endIcon;
181
+ hiddenButton.textContent = newStateObject.text || null;
182
+ hiddenButton._hideArrowButton = this._hideArrowButton;
183
+ await renderFinished();
184
+ const hiddenButtonWidth = hiddenButton.offsetWidth;
185
+ this.style.width = `${hiddenButtonWidth}px`;
186
+ this.classList.add("ui5-ai-button-fade-out");
187
+ setTimeout(() => {
188
+ this.classList.add("ui5-ai-button-fade-mid");
189
+ button._hideArrowButton = this._hideArrowButton;
190
+ this._fadeIn();
191
+ }, fadeOutDuration);
192
+ }
193
+ /**
194
+ * Starts the fade-in animation.
195
+ * @private
196
+ */
197
+ _fadeIn() {
198
+ const fadeInDuration = 160;
199
+ setTimeout(() => {
200
+ const newStateObject = this._effectiveStateObject;
201
+ this._currentStateObject = newStateObject;
202
+ this.classList.add("ui5-ai-button-fade-in");
203
+ this._resetFade();
204
+ }, fadeInDuration);
205
+ }
206
+ /**
207
+ * Resets the fade phases when the animation is completed.
208
+ * @private
209
+ */
210
+ _resetFade() {
211
+ const fadeResetDuration = 160;
212
+ setTimeout(() => {
213
+ this.classList.remove("ui5-ai-button-fade-out");
214
+ this.classList.remove("ui5-ai-button-fade-mid");
215
+ this.classList.remove("ui5-ai-button-fade-in");
216
+ this.classList.remove("ui5-ai-button-button-to-menu");
217
+ this.classList.remove("ui5-ai-button-menu-to-button");
218
+ }, fadeResetDuration);
219
+ // reset the button's width after animations
220
+ const button = this._splitButton;
221
+ if (button) {
222
+ button.style.width = "";
223
+ }
224
+ }
225
+ /**
226
+ * Handles the click event.
227
+ * @private
228
+ */
229
+ _onClick(e) {
230
+ e.stopImmediatePropagation();
231
+ this.fireDecoratorEvent("click");
232
+ }
233
+ /**
234
+ * Handles the arrow-button-click event when `ui5-ai-button` is in split mode.
235
+ * @private
236
+ */
237
+ _onArrowClick(e) {
238
+ e.stopImmediatePropagation();
239
+ this.fireDecoratorEvent("arrow-button-click");
240
+ }
241
+ get _computedAccessibilityAttributes() {
242
+ const labelRefTexts = getAllAccessibleNameRefTexts(this) || getEffectiveAriaLabelText(this) || getAssociatedLabelForTexts(this) || "";
243
+ const mainTitle = this._hasText ? Button_1.i18nBundle.getText(BUTTON_TOOLTIP_TEXT, this._stateText) : "";
244
+ const title = `${mainTitle} ${labelRefTexts}`.trim();
245
+ return {
246
+ root: {
247
+ hasPopup: this.accessibilityAttributes?.root?.hasPopup || "false",
248
+ roleDescription: this.accessibilityAttributes?.root?.roleDescription,
249
+ title: this.accessibilityAttributes?.root?.title || title,
250
+ ariaKeyShortcuts: this.accessibilityAttributes?.root?.ariaKeyShortcuts,
251
+ },
252
+ arrowButton: {
253
+ hasPopup: this.accessibilityAttributes?.arrowButton?.hasPopup,
254
+ expanded: this.accessibilityAttributes?.arrowButton?.expanded,
255
+ title: this.accessibilityAttributes?.arrowButton?.title,
256
+ },
257
+ };
258
+ }
23
259
  };
24
260
  __decorate([
25
261
  property()
26
- ], Button.prototype, "icon", void 0);
262
+ ], Button.prototype, "design", void 0);
263
+ __decorate([
264
+ property({ type: Boolean })
265
+ ], Button.prototype, "disabled", void 0);
27
266
  __decorate([
28
267
  property()
29
- ], Button.prototype, "endIcon", void 0);
30
- Button = __decorate([
268
+ ], Button.prototype, "state", void 0);
269
+ __decorate([
270
+ property({ type: Boolean, noAttribute: true })
271
+ ], Button.prototype, "arrowButtonPressed", void 0);
272
+ __decorate([
273
+ property({ type: Object })
274
+ ], Button.prototype, "accessibilityAttributes", void 0);
275
+ __decorate([
276
+ property({ type: Object })
277
+ ], Button.prototype, "_currentStateObject", void 0);
278
+ __decorate([
279
+ property({ type: Boolean })
280
+ ], Button.prototype, "iconOnly", void 0);
281
+ __decorate([
282
+ slot({ type: HTMLElement, "default": true })
283
+ ], Button.prototype, "states", void 0);
284
+ __decorate([
285
+ query("[ui5-split-button]")
286
+ ], Button.prototype, "_splitButton", void 0);
287
+ __decorate([
288
+ query(".ui5-ai-button-hidden[ui5-split-button]")
289
+ ], Button.prototype, "_hiddenSplitButton", void 0);
290
+ __decorate([
291
+ i18n("@ui5/webcomponents")
292
+ ], Button, "i18nBundle", void 0);
293
+ Button = Button_1 = __decorate([
31
294
  customElement({
32
295
  tag: "ui5-ai-button",
33
- renderer: litRender,
34
- template,
35
- styles,
36
- dependencies: [MainButton],
296
+ languageAware: true,
297
+ renderer: jsxRenderer,
298
+ template: ButtonTemplate,
299
+ styles: ButtonCss,
300
+ shadowRootOptions: { delegatesFocus: true },
301
+ })
302
+ /**
303
+ * Fired when the component is activated either with a
304
+ * mouse/tap or by using the Enter or Space key.
305
+ * @public
306
+ */
307
+ ,
308
+ event("click", {
309
+ bubbles: true,
310
+ })
311
+ /**
312
+ * Fired when the component is in split mode and after the arrow button
313
+ * is activated either by clicking or tapping it or by using the [Arrow Up] / [Arrow Down],
314
+ * [Alt] + [Arrow Up]/ [Arrow Down], or [F4] keyboard keys.
315
+ * @public
316
+ */
317
+ ,
318
+ event("arrow-button-click", {
319
+ bubbles: true,
37
320
  })
38
321
  ], Button);
39
322
  Button.define();
@@ -1 +1 @@
1
- {"version":3,"file":"Button.js","sourceRoot":"","sources":["../src/Button.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,UAAU,MAAM,4CAA4C,CAAC;AACpE,OAAO,aAAa,MAAM,0DAA0D,CAAC;AACrF,OAAO,QAAQ,MAAM,qDAAqD,CAAC;AAC3E,OAAO,SAAS,MAAM,sDAAsD,CAAC;AAE7E,OAAO;AACP,OAAO,UAAU,MAAM,mCAAmC,CAAC;AAE3D,WAAW;AACX,OAAO,QAAQ,MAAM,6CAA6C,CAAC;AAEnE,SAAS;AACT,OAAO,MAAM,MAAM,kCAAkC,CAAC;AAEtD;;;;GAIG;AAQH,IAAM,MAAM,GAAZ,MAAM,MAAO,SAAQ,UAAU;CAM9B,CAAA;AAJA;IADC,QAAQ,EAAE;oCACG;AAGd;IADC,QAAQ,EAAE;uCACM;AALZ,MAAM;IAPX,aAAa,CAAC;QACd,GAAG,EAAE,eAAe;QACpB,QAAQ,EAAE,SAAS;QACnB,QAAQ;QACR,MAAM;QACN,YAAY,EAAE,CAAC,UAAU,CAAC;KAC1B,CAAC;GACI,MAAM,CAMX;AAED,MAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,eAAe,MAAM,CAAC","sourcesContent":["import UI5Element from \"@ui5/webcomponents-base/dist/UI5Element.js\";\nimport customElement from \"@ui5/webcomponents-base/dist/decorators/customElement.js\";\nimport property from \"@ui5/webcomponents-base/dist/decorators/property.js\";\nimport litRender from \"@ui5/webcomponents-base/dist/renderer/LitRenderer.js\";\n\n// Deps\nimport MainButton from \"@ui5/webcomponents/dist/Button.js\";\n\n// Template\nimport template from \"./generated/templates/ButtonTemplate.lit.js\";\n\n// Styles\nimport styles from \"./generated/themes/Button.css.js\";\n\n/**\n * @class\n * @constructor\n * @extends UI5Element\n */\n@customElement({\n\ttag: \"ui5-ai-button\",\n\trenderer: litRender,\n\ttemplate,\n\tstyles,\n\tdependencies: [MainButton],\n})\nclass Button extends UI5Element {\n\t@property()\n\ticon!: string;\n\n\t@property()\n\tendIcon!: string;\n}\n\nButton.define();\n\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;AA8BH,IAAM,MAAM,cAAZ,MAAM,MAAO,SAAQ,UAAU;IAA/B;;QAKC;;;;WAIG;QAEH,WAAM,GAAuB,SAAS,CAAA;QAEtC;;;;;;WAMG;QAEH,aAAQ,GAAG,KAAK,CAAC;QAWjB;;;;;;;WAOG;QAEH,uBAAkB,GAAG,KAAK,CAAC;QAE3B;;;;;;;;;;;;;;;;;;;;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5B;IADC,KAAK,CAAC,oBAAoB,CAAC;4CACD;AAG3B;IADC,KAAK,CAAC,yCAAyC,CAAC;kDAChB;AAG1B;IADN,IAAI,CAAC,oBAAoB,CAAC;gCACG;AAvGzB,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,CAyRX;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\" | \"ariaKeyShortcuts\">;\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 * - **title**: Specifies a tooltip or description for screen readers.\n\t * Accepts any string value.\n\t * - **ariaKeyShortcuts**: Defines keyboard shortcuts that activate or focus the button.\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\tariaKeyShortcuts: this.accessibilityAttributes?.root?.ariaKeyShortcuts,\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"]}
@@ -0,0 +1,67 @@
1
+ import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
2
+ /**
3
+ * @class
4
+ *
5
+ * ### Overview
6
+ *
7
+ * `ui5-ai-button-state` is the item to use for defining states of `ui5-ai-button` components.
8
+ *
9
+ * ### Usage
10
+ *
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
+ *
14
+ * ### ES6 Module Import
15
+ *
16
+ * `import "@ui5/webcomponents/dist/AiButtonState.js";`
17
+ * @constructor
18
+ * @extends UI5Element
19
+ * @abstract
20
+ * @since 2.0.0
21
+ * @public
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
+ */
24
+ declare class ButtonState extends UI5Element {
25
+ /**
26
+ * Defines the name of the button state.
27
+ * @default undefined
28
+ * @public
29
+ */
30
+ name?: string;
31
+ /**
32
+ * Defines the text of the button in this state.
33
+ * @default undefined
34
+ * @public
35
+ */
36
+ text?: string;
37
+ /**
38
+ * Defines the icon to be displayed as graphical element within the component before the text.
39
+ * The SAP-icons font provides numerous options.
40
+ *
41
+ * **Example:**
42
+ *
43
+ * See all the available icons in the [Icon Explorer](https://sdk.openui5.org/test-resources/sap/m/demokit/iconExplorer/webapp/index.html).
44
+ * @default undefined
45
+ * @public
46
+ */
47
+ icon?: string;
48
+ /**
49
+ * Defines the icon to be displayed as graphical element within the component after the text.
50
+ * The SAP-icons font provides numerous options.
51
+ *
52
+ * **Example:**
53
+ *
54
+ * See all the available icons in the [Icon Explorer](https://sdk.openui5.org/test-resources/sap/m/demokit/iconExplorer/webapp/index.html).
55
+ * @default undefined
56
+ * @public
57
+ */
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;
66
+ }
67
+ export default ButtonState;