@ui5/webcomponents-ai 0.0.0-bf8366eb6 → 0.0.0-d160e83dd

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 (189) hide show
  1. package/CHANGELOG.md +496 -0
  2. package/README.md +7 -8
  3. package/cypress/specs/Button.cy.tsx +14 -0
  4. package/cypress/support/commands.ts +40 -0
  5. package/cypress/support/component-index.html +12 -0
  6. package/cypress/support/component.ts +36 -0
  7. package/cypress/tsconfig.json +43 -0
  8. package/cypress.config.js +3 -0
  9. package/dist/.tsbuildinfo +1 -0
  10. package/dist/Button.d.ts +97 -11
  11. package/dist/Button.js +225 -22
  12. package/dist/Button.js.map +1 -1
  13. package/dist/ButtonState.d.ts +67 -0
  14. package/dist/ButtonState.js +64 -0
  15. package/dist/ButtonState.js.map +1 -0
  16. package/dist/ButtonTemplate.d.ts +2 -0
  17. package/dist/ButtonTemplate.js +6 -0
  18. package/dist/ButtonTemplate.js.map +1 -0
  19. package/dist/PromptInput.d.ts +131 -7
  20. package/dist/PromptInput.js +195 -17
  21. package/dist/PromptInput.js.map +1 -1
  22. package/dist/PromptInputTemplate.d.ts +2 -0
  23. package/dist/PromptInputTemplate.js +12 -0
  24. package/dist/PromptInputTemplate.js.map +1 -0
  25. package/dist/bundle.esm.js +3 -2
  26. package/dist/bundle.esm.js.map +1 -1
  27. package/dist/bundle.scoped.config.d.ts +1 -0
  28. package/dist/bundle.scoped.config.js +3 -0
  29. package/dist/bundle.scoped.config.js.map +1 -0
  30. package/dist/bundle.scoped.esm.d.ts +2 -1
  31. package/dist/bundle.scoped.esm.js +2 -2
  32. package/dist/bundle.scoped.esm.js.map +1 -1
  33. package/dist/css/themes/Button.css +1 -0
  34. package/dist/css/themes/PromptInput.css +1 -0
  35. package/dist/custom-elements-internal.json +508 -24
  36. package/dist/custom-elements.json +438 -21
  37. package/dist/generated/assets/i18n/messagebundle_ar.json +1 -0
  38. package/dist/generated/assets/i18n/messagebundle_bg.json +1 -0
  39. package/dist/generated/assets/i18n/messagebundle_ca.json +1 -0
  40. package/dist/generated/assets/i18n/messagebundle_cnr.json +1 -0
  41. package/dist/generated/assets/i18n/messagebundle_cs.json +1 -0
  42. package/dist/generated/assets/i18n/messagebundle_cy.json +1 -0
  43. package/dist/generated/assets/i18n/messagebundle_da.json +1 -0
  44. package/dist/generated/assets/i18n/messagebundle_de.json +1 -0
  45. package/dist/generated/assets/i18n/messagebundle_el.json +1 -0
  46. package/dist/generated/assets/i18n/messagebundle_en.json +1 -0
  47. package/dist/generated/assets/i18n/messagebundle_en_GB.json +1 -0
  48. package/dist/generated/assets/i18n/messagebundle_en_US_sappsd.json +1 -0
  49. package/dist/generated/assets/i18n/messagebundle_en_US_saprigi.json +1 -0
  50. package/dist/generated/assets/i18n/messagebundle_en_US_saptrc.json +1 -0
  51. package/dist/generated/assets/i18n/messagebundle_es.json +1 -0
  52. package/dist/generated/assets/i18n/messagebundle_es_MX.json +1 -0
  53. package/dist/generated/assets/i18n/messagebundle_et.json +1 -0
  54. package/dist/generated/assets/i18n/messagebundle_fi.json +1 -0
  55. package/dist/generated/assets/i18n/messagebundle_fr.json +1 -0
  56. package/dist/generated/assets/i18n/messagebundle_fr_CA.json +1 -0
  57. package/dist/generated/assets/i18n/messagebundle_hi.json +1 -0
  58. package/dist/generated/assets/i18n/messagebundle_hr.json +1 -0
  59. package/dist/generated/assets/i18n/messagebundle_hu.json +1 -0
  60. package/dist/generated/assets/i18n/messagebundle_it.json +1 -0
  61. package/dist/generated/assets/i18n/messagebundle_iw.json +1 -0
  62. package/dist/generated/assets/i18n/messagebundle_ja.json +1 -0
  63. package/dist/generated/assets/i18n/messagebundle_kk.json +1 -0
  64. package/dist/generated/assets/i18n/messagebundle_ko.json +1 -0
  65. package/dist/generated/assets/i18n/messagebundle_lt.json +1 -0
  66. package/dist/generated/assets/i18n/messagebundle_lv.json +1 -0
  67. package/dist/generated/assets/i18n/messagebundle_mk.json +1 -0
  68. package/dist/generated/assets/i18n/messagebundle_ms.json +1 -0
  69. package/dist/generated/assets/i18n/messagebundle_nl.json +1 -0
  70. package/dist/generated/assets/i18n/messagebundle_no.json +1 -0
  71. package/dist/generated/assets/i18n/messagebundle_pl.json +1 -0
  72. package/dist/generated/assets/i18n/messagebundle_pt.json +1 -0
  73. package/dist/generated/assets/i18n/messagebundle_pt_PT.json +1 -0
  74. package/dist/generated/assets/i18n/messagebundle_ro.json +1 -0
  75. package/dist/generated/assets/i18n/messagebundle_ru.json +1 -0
  76. package/dist/generated/assets/i18n/messagebundle_sh.json +1 -0
  77. package/dist/generated/assets/i18n/messagebundle_sk.json +1 -0
  78. package/dist/generated/assets/i18n/messagebundle_sl.json +1 -0
  79. package/dist/generated/assets/i18n/messagebundle_sr.json +1 -0
  80. package/dist/generated/assets/i18n/messagebundle_sv.json +1 -0
  81. package/dist/generated/assets/i18n/messagebundle_th.json +1 -0
  82. package/dist/generated/assets/i18n/messagebundle_tr.json +1 -0
  83. package/dist/generated/assets/i18n/messagebundle_uk.json +1 -0
  84. package/dist/generated/assets/i18n/messagebundle_vi.json +1 -0
  85. package/dist/generated/assets/i18n/messagebundle_zh_CN.json +1 -0
  86. package/dist/generated/assets/i18n/messagebundle_zh_TW.json +1 -0
  87. package/dist/generated/assets/themes/sap_horizon/parameters-bundle.css.json +1 -1
  88. package/dist/generated/assets/themes/sap_horizon_dark/parameters-bundle.css.json +1 -1
  89. package/dist/generated/assets/themes/sap_horizon_hcb/parameters-bundle.css.json +1 -1
  90. package/dist/generated/assets/themes/sap_horizon_hcw/parameters-bundle.css.json +1 -1
  91. package/dist/generated/i18n/i18n-defaults.d.ts +4 -1
  92. package/dist/generated/i18n/i18n-defaults.js +3 -1
  93. package/dist/generated/i18n/i18n-defaults.js.map +1 -1
  94. package/dist/generated/json-imports/Themes-fetch.d.ts +1 -0
  95. package/dist/generated/json-imports/Themes-fetch.js +21 -0
  96. package/dist/generated/json-imports/Themes-fetch.js.map +1 -0
  97. package/dist/generated/json-imports/Themes.js.map +1 -1
  98. package/dist/generated/json-imports/i18n-fetch.d.ts +1 -0
  99. package/dist/generated/json-imports/i18n-fetch.js +118 -0
  100. package/dist/generated/json-imports/i18n-fetch.js.map +1 -0
  101. package/dist/generated/json-imports/i18n.d.ts +1 -0
  102. package/dist/generated/json-imports/i18n.js +117 -1
  103. package/dist/generated/json-imports/i18n.js.map +1 -1
  104. package/dist/generated/themes/Button.css.d.ts +2 -3
  105. package/dist/generated/themes/Button.css.js +2 -2
  106. package/dist/generated/themes/Button.css.js.map +1 -1
  107. package/dist/generated/themes/PromptInput.css.d.ts +2 -0
  108. package/dist/generated/themes/PromptInput.css.js +8 -0
  109. package/dist/generated/themes/PromptInput.css.js.map +1 -0
  110. package/dist/generated/themes/sap_horizon/parameters-bundle.css.d.ts +2 -3
  111. package/dist/generated/themes/sap_horizon/parameters-bundle.css.js +1 -2
  112. package/dist/generated/themes/sap_horizon/parameters-bundle.css.js.map +1 -1
  113. package/dist/generated/themes/sap_horizon_dark/parameters-bundle.css.d.ts +2 -3
  114. package/dist/generated/themes/sap_horizon_dark/parameters-bundle.css.js +1 -2
  115. package/dist/generated/themes/sap_horizon_dark/parameters-bundle.css.js.map +1 -1
  116. package/dist/generated/themes/sap_horizon_hcb/parameters-bundle.css.d.ts +2 -3
  117. package/dist/generated/themes/sap_horizon_hcb/parameters-bundle.css.js +1 -2
  118. package/dist/generated/themes/sap_horizon_hcb/parameters-bundle.css.js.map +1 -1
  119. package/dist/generated/themes/sap_horizon_hcw/parameters-bundle.css.d.ts +2 -3
  120. package/dist/generated/themes/sap_horizon_hcw/parameters-bundle.css.js +1 -2
  121. package/dist/generated/themes/sap_horizon_hcw/parameters-bundle.css.js.map +1 -1
  122. package/dist/vscode.html-custom-data.json +108 -3
  123. package/dist/web-types.json +261 -8
  124. package/package-scripts.cjs +4 -0
  125. package/package.json +12 -8
  126. package/src/ButtonTemplate.tsx +26 -0
  127. package/src/PromptInputTemplate.tsx +49 -0
  128. package/src/i18n/messagebundle.properties +6 -0
  129. package/src/i18n/messagebundle_ar.properties +4 -0
  130. package/src/i18n/messagebundle_bg.properties +4 -0
  131. package/src/i18n/messagebundle_ca.properties +4 -0
  132. package/src/i18n/messagebundle_cnr.properties +4 -0
  133. package/src/i18n/messagebundle_cs.properties +4 -0
  134. package/src/i18n/messagebundle_cy.properties +4 -0
  135. package/src/i18n/messagebundle_da.properties +4 -0
  136. package/src/i18n/messagebundle_de.properties +4 -0
  137. package/src/i18n/messagebundle_el.properties +4 -0
  138. package/src/i18n/messagebundle_en.properties +4 -0
  139. package/src/i18n/messagebundle_en_GB.properties +4 -0
  140. package/src/i18n/messagebundle_en_US_sappsd.properties +4 -0
  141. package/src/i18n/messagebundle_en_US_saprigi.properties +4 -0
  142. package/src/i18n/messagebundle_en_US_saptrc.properties +4 -0
  143. package/src/i18n/messagebundle_es.properties +4 -0
  144. package/src/i18n/messagebundle_es_MX.properties +4 -0
  145. package/src/i18n/messagebundle_et.properties +4 -0
  146. package/src/i18n/messagebundle_fi.properties +4 -0
  147. package/src/i18n/messagebundle_fr.properties +4 -0
  148. package/src/i18n/messagebundle_fr_CA.properties +4 -0
  149. package/src/i18n/messagebundle_hi.properties +4 -0
  150. package/src/i18n/messagebundle_hr.properties +4 -0
  151. package/src/i18n/messagebundle_hu.properties +4 -0
  152. package/src/i18n/messagebundle_id.properties +4 -0
  153. package/src/i18n/messagebundle_it.properties +4 -0
  154. package/src/i18n/messagebundle_iw.properties +4 -0
  155. package/src/i18n/messagebundle_ja.properties +4 -0
  156. package/src/i18n/messagebundle_kk.properties +4 -0
  157. package/src/i18n/messagebundle_ko.properties +4 -0
  158. package/src/i18n/messagebundle_lt.properties +4 -0
  159. package/src/i18n/messagebundle_lv.properties +4 -0
  160. package/src/i18n/messagebundle_mk.properties +4 -0
  161. package/src/i18n/messagebundle_ms.properties +4 -0
  162. package/src/i18n/messagebundle_nl.properties +4 -0
  163. package/src/i18n/messagebundle_no.properties +4 -0
  164. package/src/i18n/messagebundle_pl.properties +4 -0
  165. package/src/i18n/messagebundle_pt.properties +4 -0
  166. package/src/i18n/messagebundle_pt_PT.properties +4 -0
  167. package/src/i18n/messagebundle_ro.properties +4 -0
  168. package/src/i18n/messagebundle_ru.properties +4 -0
  169. package/src/i18n/messagebundle_sh.properties +4 -0
  170. package/src/i18n/messagebundle_sk.properties +4 -0
  171. package/src/i18n/messagebundle_sl.properties +4 -0
  172. package/src/i18n/messagebundle_sr.properties +4 -0
  173. package/src/i18n/messagebundle_sv.properties +4 -0
  174. package/src/i18n/messagebundle_th.properties +4 -0
  175. package/src/i18n/messagebundle_tr.properties +4 -0
  176. package/src/i18n/messagebundle_uk.properties +4 -0
  177. package/src/i18n/messagebundle_vi.properties +4 -0
  178. package/src/i18n/messagebundle_zh_CN.properties +4 -0
  179. package/src/i18n/messagebundle_zh_TW.properties +4 -0
  180. package/src/themes/Button.css +142 -0
  181. package/src/themes/PromptInput.css +30 -0
  182. package/tsconfig.json +55 -26
  183. package/dist/PromtInput.d.ts +0 -4
  184. package/dist/PromtInput.js +0 -28
  185. package/dist/PromtInput.js.map +0 -1
  186. package/dist/generated/templates/ButtonTemplate.lit.d.ts +0 -4
  187. package/dist/generated/templates/ButtonTemplate.lit.js +0 -5
  188. package/dist/generated/templates/ButtonTemplate.lit.js.map +0 -1
  189. package/src/Button.hbs +0 -3
package/dist/Button.js CHANGED
@@ -5,33 +5,37 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
7
  import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
8
+ import { renderFinished } from "@ui5/webcomponents-base/dist/Render.js";
8
9
  import customElement from "@ui5/webcomponents-base/dist/decorators/customElement.js";
9
10
  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";
11
+ import event from "@ui5/webcomponents-base/dist/decorators/event-strict.js";
12
+ import slot from "@ui5/webcomponents-base/dist/decorators/slot.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 "./ButtonState.js";
16
+ import ButtonTemplate from "./ButtonTemplate.js";
15
17
  // Styles
16
- import styles from "./generated/themes/Button.css.js";
18
+ import ButtonCss from "./generated/themes/Button.css.js";
17
19
  /**
18
20
  * @class
19
21
  *
20
22
  * ### Overview
21
23
  *
22
- * The `ui5-ai-button` component represents a button used in AI-related scenarios.
23
- * It enables users to trigger actions by clicking or tapping the `ui5-ai-button`, or by pressing
24
- * certain keyboard keys, such as Enter.
24
+ * 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`
25
+ * or by pressing keyboard keys like [Enter] or [Space].
25
26
  *
26
27
  * ### Usage
27
28
  *
28
- * 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.
29
- * Each state have a key that identifies it and can have text, icon, end icon, next state and hasPopup type defined (in any combination) depending on the state purpose.
29
+ * 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.
30
+ * Each state has a name for identification and can include text, an icon, and an end icon, as needed for its purpose.
31
+ * You can define a split mode for the `ui5-ai-button`, which will results in displaying an arrow button for additional actions.
30
32
  *
31
- * You can choose from a set of predefined designs that offer different styling to correspond to the triggered action.
33
+ * You can choose from a set of predefined designs for `ui5-ai-button` (as in `ui5-button`) to match the desired styling.
32
34
  *
33
- * You can set the `ui5-ai-button` as enabled or disabled. An enabled `ui5-ai-button` can be pressed by clicking or tapping it. On press `ui5-ai-button` changes its state to the next one (if defined).
34
- * the mouse cursor. A disabled `ui5-ai-button` appears inactive and cannot be pressed.
35
+ * 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
36
+ * in split mode, you can activate the default button action by clicking or tapping it, or by pressing keyboard keys like [Enter] or [Space].
37
+ * You can activate the arrow button by clicking or tapping it, or by pressing keyboard keys like [Arrow Up], [Arrow Down], or [F4].
38
+ * To display additional actions, you can attach a menu to the arrow button.
35
39
  *
36
40
  * ### ES6 Module Import
37
41
  *
@@ -39,27 +43,226 @@ import styles from "./generated/themes/Button.css.js";
39
43
  *
40
44
  * @constructor
41
45
  * @extends UI5Element
42
- * @since 2.0
46
+ * @since 2.0.0
43
47
  * @public
48
+ * @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.
44
49
  */
45
50
  let Button = class Button extends UI5Element {
51
+ constructor() {
52
+ super(...arguments);
53
+ /**
54
+ * Defines the component design.
55
+ * @default "Default"
56
+ * @public
57
+ */
58
+ this.design = "Default";
59
+ /**
60
+ * Defines whether the component is disabled.
61
+ * A disabled component can't be pressed or
62
+ * focused, and it is not in the tab chain.
63
+ * @default false
64
+ * @public
65
+ */
66
+ this.disabled = false;
67
+ /**
68
+ * Defines the active state of the arrow button in split mode.
69
+ * Set to true when the button is in split mode and a menu with additional options
70
+ * is opened by the arrow button. Set back to false when the menu is closed.
71
+ * @default false
72
+ * @public
73
+ * @since 2.6.0
74
+ */
75
+ this.arrowButtonPressed = false;
76
+ /**
77
+ * Determines if the button is in icon-only mode.
78
+ * This property is animation related only.
79
+ * @default false
80
+ * @private
81
+ */
82
+ this.iconOnly = false;
83
+ }
84
+ get _hideArrowButton() {
85
+ return !this._effectiveStateObject?.showArrowButton;
86
+ }
87
+ get _effectiveState() {
88
+ return this.state || (this.states.length && this.states[0].name) || "";
89
+ }
90
+ get _effectiveStateObject() {
91
+ return this.states.find(state => state.name === this._effectiveState);
92
+ }
93
+ get _stateIconOnly() {
94
+ return !this._stateText && !!this._stateIcon;
95
+ }
96
+ get _stateText() {
97
+ return this._currentStateObject?.text;
98
+ }
99
+ get _stateIcon() {
100
+ return this._currentStateObject?.icon;
101
+ }
102
+ get _stateEndIcon() {
103
+ const endIcon = this._effectiveStateObject?.showArrowButton ? "" : this._effectiveStateObject?.endIcon;
104
+ return endIcon;
105
+ }
106
+ get _hasText() {
107
+ return !!this._stateText;
108
+ }
109
+ onBeforeRendering() {
110
+ const splitButton = this._splitButton;
111
+ if (splitButton) {
112
+ splitButton.activeArrowButton = this.arrowButtonPressed;
113
+ }
114
+ if (!this._currentStateObject?.name) {
115
+ this._currentStateObject = this._effectiveStateObject;
116
+ }
117
+ const currentStateName = this._currentStateObject?.name || "";
118
+ this.iconOnly = this._stateIconOnly;
119
+ if (currentStateName !== "" && currentStateName !== this._effectiveState) {
120
+ this._fadeOut();
121
+ }
122
+ }
123
+ /**
124
+ * Starts the fade-out animation.
125
+ * @private
126
+ */
127
+ async _fadeOut() {
128
+ const fadeOutDuration = 180;
129
+ const button = this._splitButton;
130
+ const hiddenButton = this._hiddenSplitButton;
131
+ const newStateObject = this._effectiveStateObject;
132
+ if (!newStateObject) {
133
+ // eslint-disable-next-line no-console
134
+ console.warn(`State with name="${this.state}" doesn't exist!`);
135
+ return;
136
+ }
137
+ if (!button || !hiddenButton) {
138
+ return;
139
+ }
140
+ const buttonWidth = button.offsetWidth;
141
+ const currentState = this._currentStateObject || {};
142
+ if ((!currentState.showArrowButton && newStateObject.showArrowButton) || (!currentState.endIcon && !!newStateObject.endIcon)) {
143
+ this.classList.add("ui5-ai-button-button-to-menu");
144
+ }
145
+ if ((currentState.showArrowButton && !newStateObject.showArrowButton) || (!!currentState.endIcon && !newStateObject.endIcon)) {
146
+ this.classList.add("ui5-ai-button-menu-to-button");
147
+ }
148
+ this.style.width = `${buttonWidth}px`;
149
+ hiddenButton.icon = newStateObject.icon;
150
+ hiddenButton._endIcon = newStateObject.endIcon;
151
+ hiddenButton.textContent = newStateObject.text || null;
152
+ hiddenButton._hideArrowButton = this._hideArrowButton;
153
+ await renderFinished();
154
+ const hiddenButtonWidth = hiddenButton.offsetWidth;
155
+ this.style.width = `${hiddenButtonWidth}px`;
156
+ this.classList.add("ui5-ai-button-fade-out");
157
+ setTimeout(() => {
158
+ this.classList.add("ui5-ai-button-fade-mid");
159
+ button._hideArrowButton = this._hideArrowButton;
160
+ this._fadeIn();
161
+ }, fadeOutDuration);
162
+ }
163
+ /**
164
+ * Starts the fade-in animation.
165
+ * @private
166
+ */
167
+ _fadeIn() {
168
+ const fadeInDuration = 160;
169
+ setTimeout(() => {
170
+ const newStateObject = this._effectiveStateObject;
171
+ this._currentStateObject = newStateObject;
172
+ this.classList.add("ui5-ai-button-fade-in");
173
+ this._resetFade();
174
+ }, fadeInDuration);
175
+ }
176
+ /**
177
+ * Resets the fade phases when the animation is completed.
178
+ * @private
179
+ */
180
+ _resetFade() {
181
+ const fadeResetDuration = 160;
182
+ setTimeout(() => {
183
+ this.classList.remove("ui5-ai-button-fade-out");
184
+ this.classList.remove("ui5-ai-button-fade-mid");
185
+ this.classList.remove("ui5-ai-button-fade-in");
186
+ this.classList.remove("ui5-ai-button-button-to-menu");
187
+ this.classList.remove("ui5-ai-button-menu-to-button");
188
+ }, fadeResetDuration);
189
+ // reset the button's width after animations
190
+ const button = this._splitButton;
191
+ if (button) {
192
+ button.style.width = "";
193
+ }
194
+ }
195
+ /**
196
+ * Handles the click event.
197
+ * @private
198
+ */
199
+ _onClick(e) {
200
+ e.stopImmediatePropagation();
201
+ this.fireDecoratorEvent("click");
202
+ }
203
+ /**
204
+ * Handles the arrow-button-click event when `ui5-ai-button` is in split mode.
205
+ * @private
206
+ */
207
+ _onArrowClick(e) {
208
+ e.stopImmediatePropagation();
209
+ this.fireDecoratorEvent("arrow-button-click");
210
+ }
46
211
  };
212
+ __decorate([
213
+ property()
214
+ ], Button.prototype, "design", void 0);
47
215
  __decorate([
48
216
  property({ type: Boolean })
49
217
  ], Button.prototype, "disabled", void 0);
50
218
  __decorate([
51
219
  property()
52
- ], Button.prototype, "icon", void 0);
220
+ ], Button.prototype, "state", void 0);
53
221
  __decorate([
54
- property()
55
- ], Button.prototype, "endIcon", void 0);
222
+ property({ type: Boolean, noAttribute: true })
223
+ ], Button.prototype, "arrowButtonPressed", void 0);
224
+ __decorate([
225
+ property({ type: Object })
226
+ ], Button.prototype, "_currentStateObject", void 0);
227
+ __decorate([
228
+ property({ type: Boolean })
229
+ ], Button.prototype, "iconOnly", void 0);
230
+ __decorate([
231
+ slot({ type: HTMLElement, "default": true })
232
+ ], Button.prototype, "states", void 0);
233
+ __decorate([
234
+ query("[ui5-split-button]")
235
+ ], Button.prototype, "_splitButton", void 0);
236
+ __decorate([
237
+ query(".ui5-ai-button-hidden[ui5-split-button]")
238
+ ], Button.prototype, "_hiddenSplitButton", void 0);
56
239
  Button = __decorate([
57
240
  customElement({
58
241
  tag: "ui5-ai-button",
59
- renderer: litRender,
60
- template,
61
- styles,
62
- dependencies: [MainButton],
242
+ languageAware: true,
243
+ renderer: jsxRenderer,
244
+ template: ButtonTemplate,
245
+ styles: ButtonCss,
246
+ shadowRootOptions: { delegatesFocus: true },
247
+ })
248
+ /**
249
+ * Fired when the component is activated either with a
250
+ * mouse/tap or by using the Enter or Space key.
251
+ * @public
252
+ */
253
+ ,
254
+ event("click", {
255
+ bubbles: true,
256
+ })
257
+ /**
258
+ * Fired when the component is in split mode and after the arrow button
259
+ * is activated either by clicking or tapping it or by using the [Arrow Up] / [Arrow Down],
260
+ * [Alt] + [Arrow Up]/ [Arrow Down], or [F4] keyboard keys.
261
+ * @public
262
+ */
263
+ ,
264
+ event("arrow-button-click", {
265
+ bubbles: true,
63
266
  })
64
267
  ], Button);
65
268
  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;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAQH,IAAM,MAAM,GAAZ,MAAM,MAAO,SAAQ,UAAU;CAgB9B,CAAA;AAPA;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;wCACT;AAGnB;IADC,QAAQ,EAAE;oCACG;AAGd;IADC,QAAQ,EAAE;uCACM;AAfZ,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,CAgBX;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 *\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 key that identifies it and can have text, icon, end icon, next state and hasPopup type defined (in any combination) depending on the state purpose.\n *\n * You can choose from a set of predefined designs that offer different styling to correspond to the triggered action.\n *\n * You can set the `ui5-ai-button` as enabled or disabled. An enabled `ui5-ai-button` can be pressed by clicking or tapping it. On press `ui5-ai-button` changes its state to the next one (if defined).\n * the mouse cursor. A disabled `ui5-ai-button` appears inactive and cannot be pressed.\n *\n * ### ES6 Module Import\n *\n * `import \"@ui5/webcomponents-ai/dist/Button.js\";`\n *\n * @constructor\n * @extends UI5Element\n * @since 2.0\n * @public\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/**\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!: boolean;\n\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,kBAAkB,CAAC;AAE1B,OAAO,cAAc,MAAM,qBAAqB,CAAC;AAEjD,SAAS;AACT,OAAO,SAAS,MAAM,kCAAkC,CAAC;AAEzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AA8BH,IAAM,MAAM,GAAZ,MAAM,MAAO,SAAQ,UAAU;IAA/B;;QAKC;;;;WAIG;QAEH,WAAM,GAAuB,SAA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,WAAW,EAAE,IAAI,EAAE,CAAC;kDACpB;AAO3B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mDACO;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;AAxE5B,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,CAqOX;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 \"./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 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 * 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\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\nButton.define();\nexport default Button;\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;
@@ -0,0 +1,64 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
8
+ import customElement from "@ui5/webcomponents-base/dist/decorators/customElement.js";
9
+ import property from "@ui5/webcomponents-base/dist/decorators/property.js";
10
+ /**
11
+ * @class
12
+ *
13
+ * ### Overview
14
+ *
15
+ * `ui5-ai-button-state` is the item to use for defining states of `ui5-ai-button` components.
16
+ *
17
+ * ### Usage
18
+ *
19
+ * `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
20
+ * of `ui5-ai-button` and should not be used as standalone component.
21
+ *
22
+ * ### ES6 Module Import
23
+ *
24
+ * `import "@ui5/webcomponents/dist/AiButtonState.js";`
25
+ * @constructor
26
+ * @extends UI5Element
27
+ * @abstract
28
+ * @since 2.0.0
29
+ * @public
30
+ * @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.
31
+ */
32
+ let ButtonState = class ButtonState extends UI5Element {
33
+ constructor() {
34
+ super(...arguments);
35
+ /**
36
+ * Defines if the component is in split button mode.
37
+ * @default false
38
+ * @since 2.6.0
39
+ * @public
40
+ */
41
+ this.showArrowButton = false;
42
+ }
43
+ };
44
+ __decorate([
45
+ property()
46
+ ], ButtonState.prototype, "name", void 0);
47
+ __decorate([
48
+ property()
49
+ ], ButtonState.prototype, "text", void 0);
50
+ __decorate([
51
+ property()
52
+ ], ButtonState.prototype, "icon", void 0);
53
+ __decorate([
54
+ property()
55
+ ], ButtonState.prototype, "endIcon", void 0);
56
+ __decorate([
57
+ property({ type: Boolean })
58
+ ], ButtonState.prototype, "showArrowButton", void 0);
59
+ ButtonState = __decorate([
60
+ customElement("ui5-ai-button-state")
61
+ ], ButtonState);
62
+ ButtonState.define();
63
+ export default ButtonState;
64
+ //# sourceMappingURL=ButtonState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ButtonState.js","sourceRoot":"","sources":["../src/ButtonState.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,UAAU,MAAM,4CAA4C,CAAC;AACpE,OAAO,aAAa,MAAM,0DAA0D,CAAC;AACrF,OAAO,QAAQ,MAAM,qDAAqD,CAAC;AAE3E;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,UAAU;IAApC;;QA2CC;;;;;WAKG;QAEH,oBAAe,GAAG,KAAK,CAAC;IACzB,CAAC;CAAA,CAAA;AA5CA;IADC,QAAQ,EAAE;yCACG;AAQd;IADC,QAAQ,EAAE;yCACG;AAad;IADC,QAAQ,EAAE;yCACG;AAad;IADC,QAAQ,EAAE;4CACM;AASjB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;oDACJ;AAlDnB,WAAW;IADhB,aAAa,CAAC,qBAAqB,CAAC;GAC/B,WAAW,CAmDhB;AAED,WAAW,CAAC,MAAM,EAAE,CAAC;AACrB,eAAe,WAAW,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\";\n\n/**\n * @class\n *\n * ### Overview\n *\n * `ui5-ai-button-state` is the item to use for defining states of `ui5-ai-button` components.\n *\n * ### Usage\n *\n * `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\n * of `ui5-ai-button` and should not be used as standalone component.\n *\n * ### ES6 Module Import\n *\n * `import \"@ui5/webcomponents/dist/AiButtonState.js\";`\n * @constructor\n * @extends UI5Element\n * @abstract\n * @since 2.0.0\n * @public\n * @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.\n */\n@customElement(\"ui5-ai-button-state\")\nclass ButtonState extends UI5Element {\n\t/**\n\t * Defines the name of the button state.\n\t * @default undefined\n\t * @public\n\t */\n\t@property()\n\tname?: string;\n\n\t/**\n\t * Defines the text of the button in this state.\n\t * @default undefined\n\t * @public\n\t */\n\t@property()\n\ttext?: string;\n\n\t/**\n\t * Defines the icon to be displayed as graphical element within the component before the text.\n\t * The SAP-icons font provides numerous options.\n\t *\n\t * **Example:**\n\t *\n\t * See all the available icons in the [Icon Explorer](https://sdk.openui5.org/test-resources/sap/m/demokit/iconExplorer/webapp/index.html).\n\t * @default undefined\n\t * @public\n\t */\n\t@property()\n\ticon?: string;\n\n\t/**\n\t * Defines the icon to be displayed as graphical element within the component after the text.\n\t * The SAP-icons font provides numerous options.\n\t *\n\t * **Example:**\n\t *\n\t * See all the available icons in the [Icon Explorer](https://sdk.openui5.org/test-resources/sap/m/demokit/iconExplorer/webapp/index.html).\n\t * @default undefined\n\t * @public\n\t */\n\t@property()\n\tendIcon?: string;\n\n\t/**\n\t * Defines if the component is in split button mode.\n\t * @default false\n\t * @since 2.6.0\n\t * @public\n\t */\n\t@property({ type: Boolean })\n\tshowArrowButton = false;\n}\n\nButtonState.define();\nexport default ButtonState;\n"]}
@@ -0,0 +1,2 @@
1
+ import type Button from "./Button.js";
2
+ export default function ButtonTemplate(this: Button): import("@ui5/webcomponents-base/jsx-runtime").JSX.Element;
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@ui5/webcomponents-base/jsx-runtime";
2
+ import SplitButton from "@ui5/webcomponents/dist/SplitButton.js";
3
+ export default function ButtonTemplate() {
4
+ return (_jsxs(_Fragment, { children: [_jsx(SplitButton, { class: "ui5-ai-button-inner", design: this.design, icon: this._stateIcon, disabled: this.disabled, _endIcon: this._stateEndIcon, _hideArrowButton: this._hideArrowButton, onClick: this._onClick, onArrowClick: this._onArrowClick, children: this._hasText && (_jsx("div", { class: "ui5-ai-button-text", children: this._stateText })) }), _jsx(SplitButton, { class: "ui5-ai-button-hidden", design: this.design })] }));
5
+ }
6
+ //# sourceMappingURL=ButtonTemplate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ButtonTemplate.js","sourceRoot":"","sources":["../src/ButtonTemplate.tsx"],"names":[],"mappings":";AAAA,OAAO,WAAW,MAAM,wCAAwC,CAAC;AAGjE,MAAM,CAAC,OAAO,UAAU,cAAc;IACrC,OAAO,CAAC,8BACP,KAAC,WAAW,IACX,KAAK,EAAC,qBAAqB,EAC3B,MAAM,EAAE,IAAI,CAAC,MAAM,EACnB,IAAI,EAAE,IAAI,CAAC,UAAU,EACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,QAAQ,EAAE,IAAI,CAAC,aAAa,EAC5B,gBAAgB,EAAE,IAAI,CAAC,gBAAgB,EACvC,OAAO,EAAE,IAAI,CAAC,QAAQ,EACtB,YAAY,EAAE,IAAI,CAAC,aAAa,YAE/B,IAAI,CAAC,QAAQ,IAAI,CACjB,cAAK,KAAK,EAAC,oBAAoB,YAAE,IAAI,CAAC,UAAU,GAAO,CACvD,GACY,EAEd,KAAC,WAAW,IACX,KAAK,EAAC,sBAAsB,EAC5B,MAAM,EAAE,IAAI,CAAC,MAAM,GAClB,IACA,CAAC,CAAC;AACN,CAAC","sourcesContent":["import SplitButton from \"@ui5/webcomponents/dist/SplitButton.js\";\nimport type Button from \"./Button.js\";\n\nexport default function ButtonTemplate(this: Button) {\n\treturn (<>\n\t\t<SplitButton\n\t\t\tclass=\"ui5-ai-button-inner\"\n\t\t\tdesign={this.design}\n\t\t\ticon={this._stateIcon}\n\t\t\tdisabled={this.disabled}\n\t\t\t_endIcon={this._stateEndIcon}\n\t\t\t_hideArrowButton={this._hideArrowButton}\n\t\t\tonClick={this._onClick}\n\t\t\tonArrowClick={this._onArrowClick}\n\t\t>\n\t\t\t{this._hasText && (\n\t\t\t\t<div class=\"ui5-ai-button-text\">{this._stateText}</div>\n\t\t\t)}\n\t\t</SplitButton>\n\n\t\t<SplitButton\n\t\t\tclass=\"ui5-ai-button-hidden\"\n\t\t\tdesign={this.design}\n\t\t/>\n\t</>);\n}\n"]}
@@ -1,25 +1,149 @@
1
1
  import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
2
+ import type I18nBundle from "@ui5/webcomponents-base/dist/i18nBundle.js";
3
+ import type ValueState from "@ui5/webcomponents-base/dist/types/ValueState.js";
4
+ import type { IInputSuggestionItem } from "@ui5/webcomponents/dist/Input.js";
5
+ import type Input from "@ui5/webcomponents/dist/Input.js";
6
+ import type { UI5CustomEvent } from "@ui5/webcomponents-base/dist/index.js";
2
7
  /**
3
8
  * @class
4
- *
5
9
  * ### Overview
6
10
  *
7
- * The PromptInput is an AI component.
11
+ * The `ui5-ai-prompt-input` component allows the user to write custom instructions in natural language, so that AI is guided to generate content tailored to user needs.
12
+ *
13
+ * **Note:** The web component is in an experimental state
8
14
  *
9
15
  * ### ES6 Module Import
10
16
  *
11
- * `import "@ui5/webcomponents-ai/dist/PromptInput.js";`
17
+ * `import "@ui5/webcomponents-ai/dist/PromptInput.js"`
18
+ * @class
12
19
  * @constructor
13
- * @extends UI5Element
14
- * @since 2.0
15
20
  * @public
21
+ * @extends UI5Element
22
+ * @experimental The **@ui5/webcomponents-ai** package is under development and considered experimental - components' APIs are subject to change.
16
23
  */
17
24
  declare class PromptInput extends UI5Element {
25
+ eventDetails: {
26
+ submit: void;
27
+ input: void;
28
+ change: void;
29
+ };
18
30
  /**
19
- * Defines the value of the PromptInput.
20
- * @public
31
+ * Defines the value of the component.
32
+ *
21
33
  * @default ""
34
+ * @since 2.0.0
35
+ * @public
22
36
  */
23
37
  value: string;
38
+ /**
39
+ * Defines a short hint intended to aid the user with data entry when the
40
+ * component has no value.
41
+ * @default undefined
42
+ * @since 2.0.0
43
+ * @public
44
+ */
45
+ placeholder?: string;
46
+ /**
47
+ * Defines the label of the input field.
48
+ *
49
+ * @default undefined
50
+ * @since 2.0.0
51
+ * @public
52
+ */
53
+ label?: string;
54
+ /**
55
+ * Defines whether the clear icon of the input will be shown.
56
+ * @default false
57
+ * @public
58
+ * @since 2.0.0
59
+ */
60
+ showClearIcon: boolean;
61
+ /**
62
+ * Determines whether the characters exceeding the maximum allowed character count are visible
63
+ * in the component.
64
+ *
65
+ * If set to `false`, the user is not allowed to enter more characters than what is set in the
66
+ * `maxlength` property.
67
+ * If set to `true` the characters exceeding the `maxlength` value are selected on
68
+ * paste and the counter below the component displays their number.
69
+ * @default false
70
+ * @public
71
+ * @since 2.0.0
72
+ */
73
+ showExceededText: boolean;
74
+ /**
75
+ * Defines whether the component is in disabled state.
76
+ *
77
+ * **Note:** A disabled component is completely noninteractive.
78
+ * @default false
79
+ * @public
80
+ * @since 2.0.0
81
+ */
82
+ disabled: boolean;
83
+ /**
84
+ * Defines whether the component is read-only.
85
+ *
86
+ * **Note:** A read-only component is not editable,
87
+ * but still provides visual feedback upon user interaction.
88
+ * @default false
89
+ * @public
90
+ * @since 2.0.0
91
+ */
92
+ readonly: boolean;
93
+ /**
94
+ * Sets the maximum number of characters available in the input field.
95
+ *
96
+ * @default undefined
97
+ * @since 2.0.0
98
+ * @public
99
+ */
100
+ maxlength?: number;
101
+ /**
102
+ * Defines the value state of the component.
103
+ * @default "None"
104
+ * @since 2.0.0
105
+ * @public
106
+ */
107
+ valueState: `${ValueState}`;
108
+ /**
109
+ * Defines whether the component should show suggestions, if such are present.
110
+ *
111
+ * @default false
112
+ * @public
113
+ */
114
+ showSuggestions: boolean;
115
+ /**
116
+ * Defines the suggestion items.
117
+ *
118
+ * **Note:** The suggestions would be displayed only if the `showSuggestions`
119
+ * property is set to `true`.
120
+ *
121
+ * **Note:** The `<ui5-suggestion-item>`, `<ui5-suggestion-item-group>` and `ui5-suggestion-item-custom` are recommended to be used as suggestion items.
122
+ *
123
+ * @public
124
+ */
125
+ suggestionItems: Array<IInputSuggestionItem>;
126
+ /**
127
+ * Defines the value state message that will be displayed as pop up under the component.
128
+ * The value state message slot should contain only one root element.
129
+ *
130
+ * **Note:** If not specified, a default text (in the respective language) will be displayed.
131
+ *
132
+ * **Note:** The `valueStateMessage` would be displayed,
133
+ * when the component is in `Information`, `Critical` or `Negative` value state.
134
+ *
135
+ * @since 2.0.0
136
+ * @public
137
+ */
138
+ valueStateMessage: Array<HTMLElement>;
139
+ static i18nBundle: I18nBundle;
140
+ _onkeydown(e: KeyboardEvent): void;
141
+ _onInnerInput(e: UI5CustomEvent<Input, "input">): void;
142
+ _onInnerChange(): void;
143
+ _onButtonClick(): void;
144
+ _onTypeAhead(e: UI5CustomEvent<Input, "type-ahead">): void;
145
+ get _exceededText(): string | undefined;
146
+ get _maxLenght(): number | undefined;
147
+ get _submitButtonDisabled(): boolean;
24
148
  }
25
149
  export default PromptInput;