@ui5/webcomponents-ai 0.0.0-9261ac932 → 0.0.0-b804b8982
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +286 -0
- package/README.md +6 -4
- package/cypress/specs/Button.cy.tsx +14 -0
- package/cypress/support/commands.ts +40 -0
- package/cypress/support/component-index.html +12 -0
- package/cypress/support/component.ts +36 -0
- package/cypress/tsconfig.json +43 -0
- package/cypress.config.js +3 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/Button.d.ts +46 -32
- package/dist/Button.js +119 -82
- package/dist/Button.js.map +1 -1
- package/dist/ButtonState.d.ts +10 -3
- package/dist/ButtonState.js +16 -3
- package/dist/ButtonState.js.map +1 -1
- package/dist/ButtonTemplate.d.ts +2 -0
- package/dist/ButtonTemplate.js +6 -0
- package/dist/ButtonTemplate.js.map +1 -0
- package/dist/PromptInput.d.ts +11 -12
- package/dist/PromptInput.js +7 -18
- package/dist/PromptInput.js.map +1 -1
- package/dist/PromptInputTemplate.d.ts +2 -0
- package/dist/PromptInputTemplate.js +12 -0
- package/dist/PromptInputTemplate.js.map +1 -0
- package/dist/css/themes/Button.css +1 -1
- package/dist/custom-elements-internal.json +60 -8
- package/dist/custom-elements.json +52 -7
- package/dist/generated/assets/i18n/messagebundle_en_US_saptrc.json +1 -1
- package/dist/generated/assets/themes/sap_horizon/parameters-bundle.css.json +1 -1
- package/dist/generated/assets/themes/sap_horizon_dark/parameters-bundle.css.json +1 -1
- package/dist/generated/assets/themes/sap_horizon_hcb/parameters-bundle.css.json +1 -1
- package/dist/generated/assets/themes/sap_horizon_hcw/parameters-bundle.css.json +1 -1
- package/dist/generated/themes/Button.css.d.ts +2 -3
- package/dist/generated/themes/Button.css.js +2 -3
- package/dist/generated/themes/Button.css.js.map +1 -1
- package/dist/generated/themes/PromptInput.css.d.ts +2 -3
- package/dist/generated/themes/PromptInput.css.js +2 -3
- package/dist/generated/themes/PromptInput.css.js.map +1 -1
- package/dist/generated/themes/sap_horizon/parameters-bundle.css.d.ts +2 -3
- package/dist/generated/themes/sap_horizon/parameters-bundle.css.js +1 -2
- package/dist/generated/themes/sap_horizon/parameters-bundle.css.js.map +1 -1
- package/dist/generated/themes/sap_horizon_dark/parameters-bundle.css.d.ts +2 -3
- package/dist/generated/themes/sap_horizon_dark/parameters-bundle.css.js +1 -2
- package/dist/generated/themes/sap_horizon_dark/parameters-bundle.css.js.map +1 -1
- package/dist/generated/themes/sap_horizon_hcb/parameters-bundle.css.d.ts +2 -3
- package/dist/generated/themes/sap_horizon_hcb/parameters-bundle.css.js +1 -2
- package/dist/generated/themes/sap_horizon_hcb/parameters-bundle.css.js.map +1 -1
- package/dist/generated/themes/sap_horizon_hcw/parameters-bundle.css.d.ts +2 -3
- package/dist/generated/themes/sap_horizon_hcw/parameters-bundle.css.js +1 -2
- package/dist/generated/themes/sap_horizon_hcw/parameters-bundle.css.js.map +1 -1
- package/dist/vscode.html-custom-data.json +14 -4
- package/dist/web-types.json +36 -8
- package/package.json +12 -8
- package/src/ButtonTemplate.tsx +26 -0
- package/src/PromptInputTemplate.tsx +49 -0
- package/src/i18n/messagebundle_en_US_saptrc.properties +2 -2
- package/src/themes/Button.css +75 -21
- package/tsconfig.json +25 -4
- package/dist/generated/templates/ButtonTemplate.lit.d.ts +0 -4
- package/dist/generated/templates/ButtonTemplate.lit.js +0 -6
- package/dist/generated/templates/ButtonTemplate.lit.js.map +0 -1
- package/dist/generated/templates/PromptInputTemplate.lit.d.ts +0 -4
- package/dist/generated/templates/PromptInputTemplate.lit.js +0 -8
- package/dist/generated/templates/PromptInputTemplate.lit.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/src/Button.hbs +0 -17
- package/src/PromptInput.hbs +0 -36
package/dist/Button.js
CHANGED
@@ -8,13 +8,12 @@ import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
|
|
8
8
|
import { renderFinished } from "@ui5/webcomponents-base/dist/Render.js";
|
9
9
|
import customElement from "@ui5/webcomponents-base/dist/decorators/customElement.js";
|
10
10
|
import property from "@ui5/webcomponents-base/dist/decorators/property.js";
|
11
|
-
import event from "@ui5/webcomponents-base/dist/decorators/event.js";
|
11
|
+
import event from "@ui5/webcomponents-base/dist/decorators/event-strict.js";
|
12
12
|
import slot from "@ui5/webcomponents-base/dist/decorators/slot.js";
|
13
|
-
import
|
14
|
-
import
|
15
|
-
import
|
16
|
-
import
|
17
|
-
import ButtonTemplate from "./generated/templates/ButtonTemplate.lit.js";
|
13
|
+
import query from "@ui5/webcomponents-base/dist/decorators/query.js";
|
14
|
+
import jsxRenderer from "@ui5/webcomponents-base/dist/renderer/JsxRenderer.js";
|
15
|
+
import "./ButtonState.js";
|
16
|
+
import ButtonTemplate from "./ButtonTemplate.js";
|
18
17
|
// Styles
|
19
18
|
import ButtonCss from "./generated/themes/Button.css.js";
|
20
19
|
/**
|
@@ -22,18 +21,21 @@ import ButtonCss from "./generated/themes/Button.css.js";
|
|
22
21
|
*
|
23
22
|
* ### Overview
|
24
23
|
*
|
25
|
-
* The `ui5-ai-button` component
|
26
|
-
*
|
27
|
-
* 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].
|
28
26
|
*
|
29
27
|
* ### Usage
|
30
28
|
*
|
31
|
-
* For the `ui5-ai-button`
|
32
|
-
* Each state
|
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.
|
33
32
|
*
|
34
|
-
* You can choose from a set of predefined designs
|
33
|
+
* You can choose from a set of predefined designs for `ui5-ai-button` (as in `ui5-button`) to match the desired styling.
|
35
34
|
*
|
36
|
-
* `ui5-ai-button` can be activated by clicking or tapping it.
|
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.
|
37
39
|
*
|
38
40
|
* ### ES6 Module Import
|
39
41
|
*
|
@@ -63,32 +65,57 @@ let Button = class Button extends UI5Element {
|
|
63
65
|
*/
|
64
66
|
this.disabled = false;
|
65
67
|
/**
|
66
|
-
*
|
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.
|
67
71
|
* @default false
|
68
|
-
* @
|
69
|
-
|
70
|
-
this.fadeOut = false;
|
71
|
-
/**
|
72
|
-
* Initiates button fade middle phase.
|
73
|
-
* @default false
|
74
|
-
* @private
|
72
|
+
* @public
|
73
|
+
* @since 2.6.0
|
75
74
|
*/
|
76
|
-
this.
|
75
|
+
this.arrowButtonPressed = false;
|
77
76
|
/**
|
78
|
-
*
|
77
|
+
* Determines if the button is in icon-only mode.
|
78
|
+
* This property is animation related only.
|
79
79
|
* @default false
|
80
80
|
* @private
|
81
81
|
*/
|
82
|
-
this.
|
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;
|
83
108
|
}
|
84
109
|
onBeforeRendering() {
|
85
|
-
|
86
|
-
|
110
|
+
const splitButton = this._splitButton;
|
111
|
+
if (splitButton) {
|
112
|
+
splitButton.activeArrowButton = this.arrowButtonPressed;
|
87
113
|
}
|
88
114
|
if (!this._currentStateObject?.name) {
|
89
115
|
this._currentStateObject = this._effectiveStateObject;
|
90
116
|
}
|
91
117
|
const currentStateName = this._currentStateObject?.name || "";
|
118
|
+
this.iconOnly = this._stateIconOnly;
|
92
119
|
if (currentStateName !== "" && currentStateName !== this._effectiveState) {
|
93
120
|
this._fadeOut();
|
94
121
|
}
|
@@ -99,38 +126,50 @@ let Button = class Button extends UI5Element {
|
|
99
126
|
*/
|
100
127
|
async _fadeOut() {
|
101
128
|
const fadeOutDuration = 180;
|
102
|
-
const button = this.
|
129
|
+
const button = this._splitButton;
|
130
|
+
const hiddenButton = this._hiddenSplitButton;
|
103
131
|
const newStateObject = this._effectiveStateObject;
|
104
132
|
if (!newStateObject) {
|
105
133
|
// eslint-disable-next-line no-console
|
106
134
|
console.warn(`State with name="${this.state}" doesn't exist!`);
|
135
|
+
return;
|
136
|
+
}
|
137
|
+
if (!button || !hiddenButton) {
|
138
|
+
return;
|
107
139
|
}
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
hiddenButton.icon = newStateObject.icon;
|
113
|
-
hiddenButton.endIcon = newStateObject.endIcon;
|
114
|
-
hiddenButton.textContent = newStateObject.text || null;
|
115
|
-
await renderFinished();
|
116
|
-
const hiddenButtonWidth = hiddenButton.offsetWidth;
|
117
|
-
this.fadeOut = true;
|
118
|
-
button.style.width = `${hiddenButtonWidth}px`;
|
119
|
-
setTimeout(() => {
|
120
|
-
this.fadeMid = true;
|
121
|
-
this._currentStateObject = newStateObject;
|
122
|
-
this._fadeIn();
|
123
|
-
}, fadeOutDuration);
|
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");
|
124
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);
|
125
162
|
}
|
126
163
|
/**
|
127
164
|
* Starts the fade-in animation.
|
128
165
|
* @private
|
129
166
|
*/
|
130
167
|
_fadeIn() {
|
131
|
-
const fadeInDuration =
|
168
|
+
const fadeInDuration = 160;
|
132
169
|
setTimeout(() => {
|
133
|
-
|
170
|
+
const newStateObject = this._effectiveStateObject;
|
171
|
+
this._currentStateObject = newStateObject;
|
172
|
+
this.classList.add("ui5-ai-button-fade-in");
|
134
173
|
this._resetFade();
|
135
174
|
}, fadeInDuration);
|
136
175
|
}
|
@@ -141,12 +180,14 @@ let Button = class Button extends UI5Element {
|
|
141
180
|
_resetFade() {
|
142
181
|
const fadeResetDuration = 160;
|
143
182
|
setTimeout(() => {
|
144
|
-
this.
|
145
|
-
this.
|
146
|
-
this.
|
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");
|
147
188
|
}, fadeResetDuration);
|
148
189
|
// reset the button's width after animations
|
149
|
-
const button = this.
|
190
|
+
const button = this._splitButton;
|
150
191
|
if (button) {
|
151
192
|
button.style.width = "";
|
152
193
|
}
|
@@ -155,33 +196,17 @@ let Button = class Button extends UI5Element {
|
|
155
196
|
* Handles the click event.
|
156
197
|
* @private
|
157
198
|
*/
|
158
|
-
|
199
|
+
_onClick(e) {
|
159
200
|
e.stopImmediatePropagation();
|
160
201
|
this.fireDecoratorEvent("click");
|
161
202
|
}
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
return this.states.find(state => state.name === this._effectiveState);
|
170
|
-
}
|
171
|
-
get _stateIconOnly() {
|
172
|
-
return !this._stateText && !!this._stateIcon;
|
173
|
-
}
|
174
|
-
get _stateText() {
|
175
|
-
return this._currentStateObject?.text;
|
176
|
-
}
|
177
|
-
get _stateIcon() {
|
178
|
-
return this._currentStateObject?.icon;
|
179
|
-
}
|
180
|
-
get _stateEndIcon() {
|
181
|
-
return this._currentStateObject?.endIcon;
|
182
|
-
}
|
183
|
-
get _hasText() {
|
184
|
-
return !!this._stateText;
|
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");
|
185
210
|
}
|
186
211
|
};
|
187
212
|
__decorate([
|
@@ -193,29 +218,31 @@ __decorate([
|
|
193
218
|
__decorate([
|
194
219
|
property()
|
195
220
|
], Button.prototype, "state", void 0);
|
221
|
+
__decorate([
|
222
|
+
property({ type: Boolean, noAttribute: true })
|
223
|
+
], Button.prototype, "arrowButtonPressed", void 0);
|
196
224
|
__decorate([
|
197
225
|
property({ type: Object })
|
198
226
|
], Button.prototype, "_currentStateObject", void 0);
|
199
227
|
__decorate([
|
200
228
|
property({ type: Boolean })
|
201
|
-
], Button.prototype, "
|
202
|
-
__decorate([
|
203
|
-
property({ type: Boolean })
|
204
|
-
], Button.prototype, "fadeMid", void 0);
|
205
|
-
__decorate([
|
206
|
-
property({ type: Boolean })
|
207
|
-
], Button.prototype, "fadeIn", void 0);
|
229
|
+
], Button.prototype, "iconOnly", void 0);
|
208
230
|
__decorate([
|
209
231
|
slot({ type: HTMLElement, "default": true })
|
210
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);
|
211
239
|
Button = __decorate([
|
212
240
|
customElement({
|
213
241
|
tag: "ui5-ai-button",
|
214
242
|
languageAware: true,
|
215
|
-
renderer:
|
243
|
+
renderer: jsxRenderer,
|
216
244
|
template: ButtonTemplate,
|
217
245
|
styles: ButtonCss,
|
218
|
-
dependencies: [MainButton, Icon, ButtonState],
|
219
246
|
shadowRootOptions: { delegatesFocus: true },
|
220
247
|
})
|
221
248
|
/**
|
@@ -227,6 +254,16 @@ Button = __decorate([
|
|
227
254
|
event("click", {
|
228
255
|
bubbles: true,
|
229
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,
|
266
|
+
})
|
230
267
|
], Button);
|
231
268
|
Button.define();
|
232
269
|
export default Button;
|
package/dist/Button.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../src/Button.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,UAAU,MAAM,4CAA4C,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACxE,OAAO,aAAa,MAAM,0DAA0D,CAAC;AACrF,OAAO,QAAQ,MAAM,qDAAqD,CAAC;AAC3E,OAAO,KAAK,MAAM,kDAAkD,CAAC;AACrE,OAAO,IAAI,MAAM,iDAAiD,CAAC;AACnE,OAAO,SAAS,MAAM,sDAAsD,CAAC;AAC7E,OAAO,UAAU,MAAM,mCAAmC,CAAC;AAC3D,OAAO,IAAI,MAAM,iCAAiC,CAAC;AAEnD,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAE3C,OAAO,cAAc,MAAM,6CAA6C,CAAC;AAEzE,SAAS;AACT,OAAO,SAAS,MAAM,kCAAkC,CAAC;AAEzD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAoBH,IAAM,MAAM,GAAZ,MAAM,MAAO,SAAQ,UAAU;IAA/B;;QACC;;;;WAIG;QAEH,WAAM,GAAuB,SAAS,CAAA;QAEtC;;;;;;WAMG;QAEH,aAAQ,GAAG,KAAK,CAAC;QAkBjB;;;;WAIG;QAEH,YAAO,GAAG,KAAK,CAAC;QAEhB;;;;WAIG;QAEH,YAAO,GAAG,KAAK,CAAC;QAEhB;;;;WAIG;QAEH,WAAM,GAAG,KAAK,CAAC;IAqIhB,CAAC;IA3H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,EAAE,CAAC;sCACjB;AAjEvB,MAAM;IAlBX,aAAa,CAAC;QACd,GAAG,EAAE,eAAe;QACpB,aAAa,EAAE,IAAI;QACnB,QAAQ,EAAE,SAAS;QACnB,QAAQ,EAAE,cAAc;QACxB,MAAM,EAAE,SAAS;QACjB,YAAY,EAAE,CAAC,UAAU,EAAE,IAAI,EAAE,WAAW,CAAC;QAC7C,iBAAiB,EAAE,EAAE,cAAc,EAAE,IAAI,EAAE;KAC3C,CAAC;IAEF;;;;OAIG;;IACF,KAAK,CAAC,OAAO,EAAE;QACf,OAAO,EAAE,IAAI;KACb,CAAC;GACI,MAAM,CA8LX;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.js\";\nimport slot from \"@ui5/webcomponents-base/dist/decorators/slot.js\";\nimport litRender from \"@ui5/webcomponents-base/dist/renderer/LitRenderer.js\";\nimport MainButton from \"@ui5/webcomponents/dist/Button.js\";\nimport Icon from \"@ui5/webcomponents/dist/Icon.js\";\nimport type ButtonDesign from \"@ui5/webcomponents/dist/types/ButtonDesign.js\";\nimport ButtonState from \"./ButtonState.js\";\n\nimport ButtonTemplate from \"./generated/templates/ButtonTemplate.lit.js\";\n\n// Styles\nimport ButtonCss from \"./generated/themes/Button.css.js\";\n\n/**\n * @class\n *\n * ### Overview\n *\n * The `ui5-ai-button` component represents a button used in AI-related scenarios.\n * It enables users to trigger actions by clicking or tapping the `ui5-ai-button`, or by pressing\n * certain keyboard keys, such as Enter.\n *\n * ### Usage\n *\n * For the `ui5-ai-button` UI, you can define one or more states of the button by placing `ai-button-state` components in its default slot.\n * Each state have a name that identifies it and can have text, icon and end icon defined (in any combination) depending on the state purpose.\n *\n * You can choose from a set of predefined designs (the same as for regular `ui5-button` component) that allow different styling to correspond to the triggered action.\n *\n * `ui5-ai-button` can be activated by clicking or tapping it. The state can be changed in `click` event handler.\n *\n * ### ES6 Module Import\n *\n * `import \"@ui5/webcomponents-ai/dist/Button.js\";`\n *\n * @constructor\n * @extends UI5Element\n * @since 2.0.0\n * @public\n * @experimental The Button and ButtonState web components are availabe since 2.0 under an experimental flag and their API and behaviour are subject to change.\n */\n\n@customElement({\n\ttag: \"ui5-ai-button\",\n\tlanguageAware: true,\n\trenderer: litRender,\n\ttemplate: ButtonTemplate,\n\tstyles: ButtonCss,\n\tdependencies: [MainButton, Icon, ButtonState],\n\tshadowRootOptions: { delegatesFocus: true },\n})\n\n/**\n * Fired when the component is activated either with a\n * mouse/tap or by using the Enter or Space key.\n * @public\n */\n@event(\"click\", {\n\tbubbles: true,\n})\nclass Button extends UI5Element {\n\t/**\n\t * Defines the component design.\n\t * @default \"Default\"\n\t * @public\n\t */\n\t@property()\n\tdesign?: `${ButtonDesign}` = \"Default\"\n\n\t/**\n\t * Defines whether the component is disabled.\n\t * A disabled component can't be pressed or\n\t * focused, and it is not in the tab chain.\n\t * @default false\n\t * @public\n\t */\n\t@property({ type: Boolean })\n\tdisabled = false;\n\n\t/**\n\t * Defines the current state of the component.\n\t *\n\t * @default undefined\n\t * @public\n\t */\n\t@property()\n\tstate?: string;\n\n\t/**\n\t * Keeps the current state object of the component.\n\t * @private\n\t */\n\t@property({ type: Object })\n\t_currentStateObject?: ButtonState;\n\n\t/**\n\t * Initiates button elements fade-out phase.\n\t * @default false\n\t * @private\n\t */\n\t@property({ type: Boolean })\n\tfadeOut = false;\n\n\t/**\n\t * Initiates button fade middle phase.\n\t * @default false\n\t * @private\n\t */\n\t@property({ type: Boolean })\n\tfadeMid = false;\n\n\t/**\n\t * Initiates button elements fade-in phase.\n\t * @default false\n\t * @private\n\t */\n\t@property({ type: Boolean })\n\tfadeIn = false;\n\n\t/**\n\t * Defines the available states of the component.\n\t * **Note:** Although this slot accepts HTML Elements, it is strongly recommended that you only use `ui5-ai-button-state` components in order to preserve the intended design.\n\t * @public\n\t */\n\t@slot({ type: HTMLElement, \"default\": true })\n\tstates!: Array<ButtonState>;\n\n\tonBeforeRendering(): void {\n\t\tif (this.fadeOut || this.fadeIn) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (!this._currentStateObject?.name) {\n\t\t\tthis._currentStateObject = this._effectiveStateObject;\n\t\t}\n\n\t\tconst currentStateName = this._currentStateObject?.name || \"\";\n\n\t\tif (currentStateName !== \"\" && currentStateName !== this._effectiveState) {\n\t\t\tthis._fadeOut();\n\t\t}\n\t}\n\n\t/**\n\t * Starts the fade-out animation.\n\t * @private\n\t */\n\tasync _fadeOut(): Promise<void> {\n\t\tconst fadeOutDuration = 180;\n\n\t\tconst button = this._mainButton;\n\t\tconst newStateObject = this._effectiveStateObject;\n\n\t\tif (!newStateObject) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.warn(`State with name=\"${this.state}\" doesn't exist!`);\n\t\t} else if (button) {\n\t\t\tconst buttonWidth = button.offsetWidth;\n\t\t\tconst hiddenButton = this.shadowRoot?.querySelector(\".ui5-ai-button-hidden\") as MainButton;\n\t\t\tbutton.style.width = `${buttonWidth}px`;\n\t\t\thiddenButton.icon = newStateObject.icon;\n\t\t\thiddenButton.endIcon = newStateObject.endIcon;\n\t\t\thiddenButton.textContent = newStateObject.text || null;\n\n\t\t\tawait renderFinished();\n\t\t\tconst hiddenButtonWidth = hiddenButton.offsetWidth;\n\t\t\tthis.fadeOut = true;\n\t\t\tbutton.style.width = `${hiddenButtonWidth}px`;\n\n\t\t\tsetTimeout(() => {\n\t\t\t\tthis.fadeMid = true;\n\t\t\t\tthis._currentStateObject = newStateObject;\n\t\t\t\tthis._fadeIn();\n\t\t\t}, fadeOutDuration);\n\t\t}\n\t}\n\n\t/**\n\t * Starts the fade-in animation.\n\t * @private\n\t */\n\t_fadeIn(): void {\n\t\tconst fadeInDuration = 60;\n\n\t\tsetTimeout(() => {\n\t\t\tthis.fadeIn = true;\n\t\t\tthis._resetFade();\n\t\t}, fadeInDuration);\n\t}\n\n\t/**\n\t * Resets the fade phases when the animation is completed.\n\t * @private\n\t */\n\t_resetFade(): void {\n\t\tconst fadeResetDuration = 160;\n\n\t\tsetTimeout(() => {\n\t\t\tthis.fadeOut = false;\n\t\t\tthis.fadeMid = false;\n\t\t\tthis.fadeIn = false;\n\t\t}, fadeResetDuration);\n\n\t\t// reset the button's width after animations\n\t\tconst button = this._mainButton;\n\t\tif (button) {\n\t\t\tbutton.style.width = \"\";\n\t\t}\n\t}\n\n\t/**\n\t * Handles the click event.\n\t * @private\n\t */\n\t_onclick(e: MouseEvent): void {\n\t\te.stopImmediatePropagation();\n\t\tthis.fireDecoratorEvent(\"click\");\n\t}\n\n\tget _mainButton() {\n\t\treturn this.shadowRoot?.querySelector(\"[ui5-button]\") as MainButton;\n\t}\n\n\tget _effectiveState() {\n\t\treturn this.state || (this.states.length && this.states[0].name) || \"\";\n\t}\n\n\tget _effectiveStateObject() {\n\t\treturn this.states.find(state => state.name === this._effectiveState);\n\t}\n\n\tget _stateIconOnly() {\n\t\treturn !this._stateText && !!this._stateIcon;\n\t}\n\n\tget _stateText() {\n\t\treturn this._currentStateObject?.text;\n\t}\n\n\tget _stateIcon() {\n\t\treturn this._currentStateObject?.icon;\n\t}\n\n\tget _stateEndIcon() {\n\t\treturn this._currentStateObject?.endIcon;\n\t}\n\n\tget _hasText() {\n\t\treturn !!this._stateText;\n\t}\n}\n\nButton.define();\nexport default Button;\n"]}
|
1
|
+
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../src/Button.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,UAAU,MAAM,4CAA4C,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACxE,OAAO,aAAa,MAAM,0DAA0D,CAAC;AACrF,OAAO,QA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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"]}
|
package/dist/ButtonState.d.ts
CHANGED
@@ -8,8 +8,8 @@ import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
|
|
8
8
|
*
|
9
9
|
* ### Usage
|
10
10
|
*
|
11
|
-
* `ui5-
|
12
|
-
* of `ui5-ai-button` and should be used as standalone component.
|
11
|
+
* `ui5-ai-button-state` is an abstract element, representing a state of `ui5-ai-button`. It is meant to be used in the `default` slot
|
12
|
+
* of `ui5-ai-button` and should not be used as standalone component.
|
13
13
|
*
|
14
14
|
* ### ES6 Module Import
|
15
15
|
*
|
@@ -19,7 +19,7 @@ import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
|
|
19
19
|
* @abstract
|
20
20
|
* @since 2.0.0
|
21
21
|
* @public
|
22
|
-
* @experimental The Button and ButtonState web components are
|
22
|
+
* @experimental The Button and ButtonState web components are available since 2.0 under an experimental flag and their API and behaviour are subject to change.
|
23
23
|
*/
|
24
24
|
declare class ButtonState extends UI5Element {
|
25
25
|
/**
|
@@ -56,5 +56,12 @@ declare class ButtonState extends UI5Element {
|
|
56
56
|
* @public
|
57
57
|
*/
|
58
58
|
endIcon?: string;
|
59
|
+
/**
|
60
|
+
* Defines if the component is in split button mode.
|
61
|
+
* @default false
|
62
|
+
* @since 2.6.0
|
63
|
+
* @public
|
64
|
+
*/
|
65
|
+
showArrowButton: boolean;
|
59
66
|
}
|
60
67
|
export default ButtonState;
|
package/dist/ButtonState.js
CHANGED
@@ -16,8 +16,8 @@ import property from "@ui5/webcomponents-base/dist/decorators/property.js";
|
|
16
16
|
*
|
17
17
|
* ### Usage
|
18
18
|
*
|
19
|
-
* `ui5-
|
20
|
-
* of `ui5-ai-button` and should be used as standalone component.
|
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
21
|
*
|
22
22
|
* ### ES6 Module Import
|
23
23
|
*
|
@@ -27,9 +27,19 @@ import property from "@ui5/webcomponents-base/dist/decorators/property.js";
|
|
27
27
|
* @abstract
|
28
28
|
* @since 2.0.0
|
29
29
|
* @public
|
30
|
-
* @experimental The Button and ButtonState web components are
|
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
31
|
*/
|
32
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
|
+
}
|
33
43
|
};
|
34
44
|
__decorate([
|
35
45
|
property()
|
@@ -43,6 +53,9 @@ __decorate([
|
|
43
53
|
__decorate([
|
44
54
|
property()
|
45
55
|
], ButtonState.prototype, "endIcon", void 0);
|
56
|
+
__decorate([
|
57
|
+
property({ type: Boolean })
|
58
|
+
], ButtonState.prototype, "showArrowButton", void 0);
|
46
59
|
ButtonState = __decorate([
|
47
60
|
customElement("ui5-ai-button-state")
|
48
61
|
], ButtonState);
|
package/dist/ButtonState.js.map
CHANGED
@@ -1 +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;
|
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,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"]}
|
package/dist/PromptInput.d.ts
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
|
2
2
|
import type I18nBundle from "@ui5/webcomponents-base/dist/i18nBundle.js";
|
3
3
|
import type ValueState from "@ui5/webcomponents-base/dist/types/ValueState.js";
|
4
|
-
import "@ui5/webcomponents
|
5
|
-
import type
|
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";
|
6
7
|
/**
|
7
8
|
* @class
|
8
9
|
* ### Overview
|
@@ -13,7 +14,7 @@ import type { IInputSuggestionItem, InputEventDetail } from "@ui5/webcomponents/
|
|
13
14
|
*
|
14
15
|
* ### ES6 Module Import
|
15
16
|
*
|
16
|
-
* `import "@ui5/webcomponents-ai/dist/PromptInput.js
|
17
|
+
* `import "@ui5/webcomponents-ai/dist/PromptInput.js"`
|
17
18
|
* @class
|
18
19
|
* @constructor
|
19
20
|
* @public
|
@@ -21,6 +22,11 @@ import type { IInputSuggestionItem, InputEventDetail } from "@ui5/webcomponents/
|
|
21
22
|
* @experimental The **@ui5/webcomponents-ai** package is under development and considered experimental - components' APIs are subject to change.
|
22
23
|
*/
|
23
24
|
declare class PromptInput extends UI5Element {
|
25
|
+
eventDetails: {
|
26
|
+
submit: void;
|
27
|
+
input: void;
|
28
|
+
change: void;
|
29
|
+
};
|
24
30
|
/**
|
25
31
|
* Defines the value of the component.
|
26
32
|
*
|
@@ -102,8 +108,6 @@ declare class PromptInput extends UI5Element {
|
|
102
108
|
/**
|
103
109
|
* Defines whether the component should show suggestions, if such are present.
|
104
110
|
*
|
105
|
-
* **Note:** You need to import the `InputSuggestions` module
|
106
|
-
* from `"@ui5/webcomponents/dist/features/InputSuggestions.js"` to enable this functionality.
|
107
111
|
* @default false
|
108
112
|
* @public
|
109
113
|
*/
|
@@ -116,11 +120,6 @@ declare class PromptInput extends UI5Element {
|
|
116
120
|
*
|
117
121
|
* **Note:** The `<ui5-suggestion-item>`, `<ui5-suggestion-item-group>` and `ui5-suggestion-item-custom` are recommended to be used as suggestion items.
|
118
122
|
*
|
119
|
-
* **Note:** Importing the Input Suggestions Support feature:
|
120
|
-
*
|
121
|
-
* `import "@ui5/webcomponents/dist/features/InputSuggestions.js";`
|
122
|
-
*
|
123
|
-
* automatically imports the `<ui5-suggestion-item>` and `<ui5-suggestion-item-group>` for your convenience.
|
124
123
|
* @public
|
125
124
|
*/
|
126
125
|
suggestionItems: Array<IInputSuggestionItem>;
|
@@ -139,10 +138,10 @@ declare class PromptInput extends UI5Element {
|
|
139
138
|
valueStateMessage: Array<HTMLElement>;
|
140
139
|
static i18nBundle: I18nBundle;
|
141
140
|
_onkeydown(e: KeyboardEvent): void;
|
142
|
-
_onInnerInput(e:
|
141
|
+
_onInnerInput(e: UI5CustomEvent<Input, "input">): void;
|
143
142
|
_onInnerChange(): void;
|
144
143
|
_onButtonClick(): void;
|
145
|
-
_onTypeAhead(e:
|
144
|
+
_onTypeAhead(e: UI5CustomEvent<Input, "type-ahead">): void;
|
146
145
|
get _exceededText(): string | undefined;
|
147
146
|
get _maxLenght(): number | undefined;
|
148
147
|
get _submitButtonDisabled(): boolean;
|
package/dist/PromptInput.js
CHANGED
@@ -8,17 +8,13 @@ var PromptInput_1;
|
|
8
8
|
import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
|
9
9
|
import customElement from "@ui5/webcomponents-base/dist/decorators/customElement.js";
|
10
10
|
import property from "@ui5/webcomponents-base/dist/decorators/property.js";
|
11
|
-
import event from "@ui5/webcomponents-base/dist/decorators/event.js";
|
11
|
+
import event from "@ui5/webcomponents-base/dist/decorators/event-strict.js";
|
12
12
|
import slot from "@ui5/webcomponents-base/dist/decorators/slot.js";
|
13
13
|
import i18n from "@ui5/webcomponents-base/dist/decorators/i18n.js";
|
14
|
-
import
|
15
|
-
import "@ui5/webcomponents-icons/dist/paper-plane.js";
|
16
|
-
import Input from "@ui5/webcomponents/dist/Input.js";
|
17
|
-
import Label from "@ui5/webcomponents/dist/Label.js";
|
18
|
-
import Button from "@ui5/webcomponents/dist/Button.js";
|
14
|
+
import jsxRenderer from "@ui5/webcomponents-base/dist/renderer/JsxRenderer.js";
|
19
15
|
import { isEnter, } from "@ui5/webcomponents-base/dist/Keys.js";
|
20
16
|
import { PROMPT_INPUT_CHARACTERS_LEFT, PROMPT_INPUT_CHARACTERS_EXCEEDED, } from "./generated/i18n/i18n-defaults.js";
|
21
|
-
import PromptInputTemplate from "./
|
17
|
+
import PromptInputTemplate from "./PromptInputTemplate.js";
|
22
18
|
// Styles
|
23
19
|
import PromptInputCss from "./generated/themes/PromptInput.css.js";
|
24
20
|
/**
|
@@ -31,7 +27,7 @@ import PromptInputCss from "./generated/themes/PromptInput.css.js";
|
|
31
27
|
*
|
32
28
|
* ### ES6 Module Import
|
33
29
|
*
|
34
|
-
* `import "@ui5/webcomponents-ai/dist/PromptInput.js
|
30
|
+
* `import "@ui5/webcomponents-ai/dist/PromptInput.js"`
|
35
31
|
* @class
|
36
32
|
* @constructor
|
37
33
|
* @public
|
@@ -98,8 +94,6 @@ let PromptInput = PromptInput_1 = class PromptInput extends UI5Element {
|
|
98
94
|
/**
|
99
95
|
* Defines whether the component should show suggestions, if such are present.
|
100
96
|
*
|
101
|
-
* **Note:** You need to import the `InputSuggestions` module
|
102
|
-
* from `"@ui5/webcomponents/dist/features/InputSuggestions.js"` to enable this functionality.
|
103
97
|
* @default false
|
104
98
|
* @public
|
105
99
|
*/
|
@@ -111,7 +105,7 @@ let PromptInput = PromptInput_1 = class PromptInput extends UI5Element {
|
|
111
105
|
}
|
112
106
|
}
|
113
107
|
_onInnerInput(e) {
|
114
|
-
this.value = e.
|
108
|
+
this.value = e.currentTarget.value;
|
115
109
|
this.fireDecoratorEvent("input");
|
116
110
|
}
|
117
111
|
_onInnerChange() {
|
@@ -121,7 +115,7 @@ let PromptInput = PromptInput_1 = class PromptInput extends UI5Element {
|
|
121
115
|
this.fireDecoratorEvent("submit");
|
122
116
|
}
|
123
117
|
_onTypeAhead(e) {
|
124
|
-
this.value = e.
|
118
|
+
this.value = e.currentTarget.value;
|
125
119
|
}
|
126
120
|
get _exceededText() {
|
127
121
|
if (this.showExceededText) {
|
@@ -188,14 +182,9 @@ __decorate([
|
|
188
182
|
PromptInput = PromptInput_1 = __decorate([
|
189
183
|
customElement({
|
190
184
|
tag: "ui5-ai-prompt-input",
|
191
|
-
renderer:
|
185
|
+
renderer: jsxRenderer,
|
192
186
|
styles: PromptInputCss,
|
193
187
|
template: PromptInputTemplate,
|
194
|
-
dependencies: [
|
195
|
-
Input,
|
196
|
-
Label,
|
197
|
-
Button,
|
198
|
-
],
|
199
188
|
})
|
200
189
|
/**
|
201
190
|
* Fired when the input operation has finished by pressing Enter
|