@ui5/webcomponents-ai 0.0.0-093de5dd1
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/.env.production +1 -0
- package/.env.testing +4 -0
- package/.npsrc.json +3 -0
- package/.ui5-cem-aliases.json +4 -0
- package/CHANGELOG.md +1004 -0
- package/LICENSE.txt +201 -0
- package/README.md +40 -0
- package/cypress.config.js +3 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/Assets-fetch.d.ts +3 -0
- package/dist/Assets-fetch.js +6 -0
- package/dist/Assets-fetch.js.map +1 -0
- package/dist/Assets-node.d.ts +14 -0
- package/dist/Assets-node.js +17 -0
- package/dist/Assets-node.js.map +1 -0
- package/dist/Assets.d.ts +3 -0
- package/dist/Assets.js +6 -0
- package/dist/Assets.js.map +1 -0
- package/dist/Button.d.ts +166 -0
- package/dist/Button.js +325 -0
- package/dist/Button.js.map +1 -0
- package/dist/ButtonState.d.ts +68 -0
- package/dist/ButtonState.js +65 -0
- package/dist/ButtonState.js.map +1 -0
- package/dist/ButtonTemplate.d.ts +2 -0
- package/dist/ButtonTemplate.js +6 -0
- package/dist/ButtonTemplate.js.map +1 -0
- package/dist/Input.d.ts +144 -0
- package/dist/Input.js +289 -0
- package/dist/Input.js.map +1 -0
- package/dist/InputTemplate.d.ts +10 -0
- package/dist/InputTemplate.js +28 -0
- package/dist/InputTemplate.js.map +1 -0
- package/dist/PromptInput.d.ts +150 -0
- package/dist/PromptInput.js +226 -0
- package/dist/PromptInput.js.map +1 -0
- package/dist/PromptInputTemplate.d.ts +2 -0
- package/dist/PromptInputTemplate.js +12 -0
- package/dist/PromptInputTemplate.js.map +1 -0
- package/dist/TextArea.d.ts +124 -0
- package/dist/TextArea.js +272 -0
- package/dist/TextArea.js.map +1 -0
- package/dist/TextAreaTemplate.d.ts +2 -0
- package/dist/TextAreaTemplate.js +13 -0
- package/dist/TextAreaTemplate.js.map +1 -0
- package/dist/ToolbarLabel.d.ts +39 -0
- package/dist/ToolbarLabel.js +67 -0
- package/dist/ToolbarLabel.js.map +1 -0
- package/dist/ToolbarLabelTemplate.d.ts +2 -0
- package/dist/ToolbarLabelTemplate.js +5 -0
- package/dist/ToolbarLabelTemplate.js.map +1 -0
- package/dist/Versioning.d.ts +95 -0
- package/dist/Versioning.js +187 -0
- package/dist/Versioning.js.map +1 -0
- package/dist/VersioningTemplate.d.ts +4 -0
- package/dist/VersioningTemplate.js +9 -0
- package/dist/VersioningTemplate.js.map +1 -0
- package/dist/WritingAssistant.d.ts +101 -0
- package/dist/WritingAssistant.js +201 -0
- package/dist/WritingAssistant.js.map +1 -0
- package/dist/WritingAssistantTemplate.d.ts +2 -0
- package/dist/WritingAssistantTemplate.js +12 -0
- package/dist/WritingAssistantTemplate.js.map +1 -0
- package/dist/bundle.esm.d.ts +3 -0
- package/dist/bundle.esm.js +11 -0
- package/dist/bundle.esm.js.map +1 -0
- package/dist/bundle.scoped.config.d.ts +1 -0
- package/dist/bundle.scoped.config.js +3 -0
- package/dist/bundle.scoped.config.js.map +1 -0
- package/dist/bundle.scoped.esm.d.ts +2 -0
- package/dist/bundle.scoped.esm.js +3 -0
- package/dist/bundle.scoped.esm.js.map +1 -0
- package/dist/css/themes/Button.css +1 -0
- package/dist/css/themes/Input.css +1 -0
- package/dist/css/themes/PromptInput.css +1 -0
- package/dist/css/themes/TextArea.css +1 -0
- package/dist/css/themes/Versioning.css +1 -0
- package/dist/css/themes/WritingAssistant.css +1 -0
- package/dist/css/themes/sap_horizon/parameters-bundle.css +0 -0
- package/dist/css/themes/sap_horizon_dark/parameters-bundle.css +0 -0
- package/dist/css/themes/sap_horizon_hcb/parameters-bundle.css +0 -0
- package/dist/css/themes/sap_horizon_hcw/parameters-bundle.css +0 -0
- package/dist/custom-elements-internal.json +1949 -0
- package/dist/custom-elements.json +1698 -0
- package/dist/generated/assets/i18n/messagebundle_ar.json +1 -0
- package/dist/generated/assets/i18n/messagebundle_bg.json +1 -0
- package/dist/generated/assets/i18n/messagebundle_ca.json +1 -0
- package/dist/generated/assets/i18n/messagebundle_cnr.json +1 -0
- package/dist/generated/assets/i18n/messagebundle_cs.json +1 -0
- package/dist/generated/assets/i18n/messagebundle_cy.json +1 -0
- package/dist/generated/assets/i18n/messagebundle_da.json +1 -0
- package/dist/generated/assets/i18n/messagebundle_de.json +1 -0
- package/dist/generated/assets/i18n/messagebundle_el.json +1 -0
- package/dist/generated/assets/i18n/messagebundle_en.json +1 -0
- package/dist/generated/assets/i18n/messagebundle_en_GB.json +1 -0
- package/dist/generated/assets/i18n/messagebundle_en_US_sappsd.json +1 -0
- package/dist/generated/assets/i18n/messagebundle_en_US_saprigi.json +1 -0
- package/dist/generated/assets/i18n/messagebundle_en_US_saptrc.json +1 -0
- package/dist/generated/assets/i18n/messagebundle_es.json +1 -0
- package/dist/generated/assets/i18n/messagebundle_es_MX.json +1 -0
- package/dist/generated/assets/i18n/messagebundle_et.json +1 -0
- package/dist/generated/assets/i18n/messagebundle_fi.json +1 -0
- package/dist/generated/assets/i18n/messagebundle_fr.json +1 -0
- package/dist/generated/assets/i18n/messagebundle_fr_CA.json +1 -0
- package/dist/generated/assets/i18n/messagebundle_hi.json +1 -0
- package/dist/generated/assets/i18n/messagebundle_hr.json +1 -0
- package/dist/generated/assets/i18n/messagebundle_hu.json +1 -0
- package/dist/generated/assets/i18n/messagebundle_id.json +1 -0
- package/dist/generated/assets/i18n/messagebundle_it.json +1 -0
- package/dist/generated/assets/i18n/messagebundle_iw.json +1 -0
- package/dist/generated/assets/i18n/messagebundle_ja.json +1 -0
- package/dist/generated/assets/i18n/messagebundle_kk.json +1 -0
- package/dist/generated/assets/i18n/messagebundle_ko.json +1 -0
- package/dist/generated/assets/i18n/messagebundle_lt.json +1 -0
- package/dist/generated/assets/i18n/messagebundle_lv.json +1 -0
- package/dist/generated/assets/i18n/messagebundle_mk.json +1 -0
- package/dist/generated/assets/i18n/messagebundle_ms.json +1 -0
- package/dist/generated/assets/i18n/messagebundle_nl.json +1 -0
- package/dist/generated/assets/i18n/messagebundle_no.json +1 -0
- package/dist/generated/assets/i18n/messagebundle_pl.json +1 -0
- package/dist/generated/assets/i18n/messagebundle_pt.json +1 -0
- package/dist/generated/assets/i18n/messagebundle_pt_PT.json +1 -0
- package/dist/generated/assets/i18n/messagebundle_ro.json +1 -0
- package/dist/generated/assets/i18n/messagebundle_ru.json +1 -0
- package/dist/generated/assets/i18n/messagebundle_sh.json +1 -0
- package/dist/generated/assets/i18n/messagebundle_sk.json +1 -0
- package/dist/generated/assets/i18n/messagebundle_sl.json +1 -0
- package/dist/generated/assets/i18n/messagebundle_sr.json +1 -0
- package/dist/generated/assets/i18n/messagebundle_sv.json +1 -0
- package/dist/generated/assets/i18n/messagebundle_th.json +1 -0
- package/dist/generated/assets/i18n/messagebundle_tr.json +1 -0
- package/dist/generated/assets/i18n/messagebundle_uk.json +1 -0
- package/dist/generated/assets/i18n/messagebundle_vi.json +1 -0
- package/dist/generated/assets/i18n/messagebundle_zh_CN.json +1 -0
- package/dist/generated/assets/i18n/messagebundle_zh_TW.json +1 -0
- package/dist/generated/assets/themes/sap_horizon/parameters-bundle.css.json +1 -0
- package/dist/generated/assets/themes/sap_horizon_dark/parameters-bundle.css.json +1 -0
- package/dist/generated/assets/themes/sap_horizon_hcb/parameters-bundle.css.json +1 -0
- package/dist/generated/assets/themes/sap_horizon_hcw/parameters-bundle.css.json +1 -0
- package/dist/generated/i18n/i18n-defaults.d.ts +18 -0
- package/dist/generated/i18n/i18n-defaults.js +18 -0
- package/dist/generated/i18n/i18n-defaults.js.map +1 -0
- package/dist/generated/json-imports/Themes-fetch.d.ts +1 -0
- package/dist/generated/json-imports/Themes-fetch.js +21 -0
- package/dist/generated/json-imports/Themes-fetch.js.map +1 -0
- package/dist/generated/json-imports/Themes-node.d.ts +1 -0
- package/dist/generated/json-imports/Themes-node.js +21 -0
- package/dist/generated/json-imports/Themes-node.js.map +1 -0
- package/dist/generated/json-imports/Themes.d.ts +1 -0
- package/dist/generated/json-imports/Themes.js +21 -0
- package/dist/generated/json-imports/Themes.js.map +1 -0
- package/dist/generated/json-imports/i18n-fetch.d.ts +1 -0
- package/dist/generated/json-imports/i18n-fetch.js +120 -0
- package/dist/generated/json-imports/i18n-fetch.js.map +1 -0
- package/dist/generated/json-imports/i18n-node.d.ts +1 -0
- package/dist/generated/json-imports/i18n-node.js +120 -0
- package/dist/generated/json-imports/i18n-node.js.map +1 -0
- package/dist/generated/json-imports/i18n.d.ts +1 -0
- package/dist/generated/json-imports/i18n.js +120 -0
- package/dist/generated/json-imports/i18n.js.map +1 -0
- package/dist/generated/themes/Button.css.d.ts +2 -0
- package/dist/generated/themes/Button.css.js +8 -0
- package/dist/generated/themes/Button.css.js.map +1 -0
- package/dist/generated/themes/Input.css.d.ts +2 -0
- package/dist/generated/themes/Input.css.js +8 -0
- package/dist/generated/themes/Input.css.js.map +1 -0
- package/dist/generated/themes/PromptInput.css.d.ts +2 -0
- package/dist/generated/themes/PromptInput.css.js +8 -0
- package/dist/generated/themes/PromptInput.css.js.map +1 -0
- package/dist/generated/themes/TextArea.css.d.ts +2 -0
- package/dist/generated/themes/TextArea.css.js +8 -0
- package/dist/generated/themes/TextArea.css.js.map +1 -0
- package/dist/generated/themes/Versioning.css.d.ts +2 -0
- package/dist/generated/themes/Versioning.css.js +8 -0
- package/dist/generated/themes/Versioning.css.js.map +1 -0
- package/dist/generated/themes/WritingAssistant.css.d.ts +2 -0
- package/dist/generated/themes/WritingAssistant.css.js +8 -0
- package/dist/generated/themes/WritingAssistant.css.js.map +1 -0
- package/dist/generated/themes/sap_horizon/parameters-bundle.css.d.ts +2 -0
- package/dist/generated/themes/sap_horizon/parameters-bundle.css.js +2 -0
- package/dist/generated/themes/sap_horizon/parameters-bundle.css.js.map +1 -0
- package/dist/generated/themes/sap_horizon_dark/parameters-bundle.css.d.ts +2 -0
- package/dist/generated/themes/sap_horizon_dark/parameters-bundle.css.js +2 -0
- package/dist/generated/themes/sap_horizon_dark/parameters-bundle.css.js.map +1 -0
- package/dist/generated/themes/sap_horizon_hcb/parameters-bundle.css.d.ts +2 -0
- package/dist/generated/themes/sap_horizon_hcb/parameters-bundle.css.js +2 -0
- package/dist/generated/themes/sap_horizon_hcb/parameters-bundle.css.js.map +1 -0
- package/dist/generated/themes/sap_horizon_hcw/parameters-bundle.css.d.ts +2 -0
- package/dist/generated/themes/sap_horizon_hcw/parameters-bundle.css.js +2 -0
- package/dist/generated/themes/sap_horizon_hcw/parameters-bundle.css.js.map +1 -0
- package/dist/vscode.html-custom-data.json +188 -0
- package/dist/web-types.json +488 -0
- package/jsconfig.json +11 -0
- package/package-scripts.cjs +18 -0
- package/package.json +64 -0
- package/src/ButtonTemplate.tsx +27 -0
- package/src/InputTemplate.tsx +197 -0
- package/src/PromptInputTemplate.tsx +49 -0
- package/src/TextArea.css +25 -0
- package/src/TextAreaTemplate.tsx +91 -0
- package/src/ToolbarLabelTemplate.tsx +9 -0
- package/src/VersioningTemplate.tsx +34 -0
- package/src/WritingAssistantTemplate.tsx +51 -0
- package/src/i18n/messagebundle.properties +50 -0
- package/src/i18n/messagebundle_ar.properties +32 -0
- package/src/i18n/messagebundle_bg.properties +32 -0
- package/src/i18n/messagebundle_ca.properties +32 -0
- package/src/i18n/messagebundle_cnr.properties +32 -0
- package/src/i18n/messagebundle_cs.properties +32 -0
- package/src/i18n/messagebundle_cy.properties +32 -0
- package/src/i18n/messagebundle_da.properties +32 -0
- package/src/i18n/messagebundle_de.properties +32 -0
- package/src/i18n/messagebundle_el.properties +32 -0
- package/src/i18n/messagebundle_en.properties +47 -0
- package/src/i18n/messagebundle_en_GB.properties +32 -0
- package/src/i18n/messagebundle_en_US_sappsd.properties +32 -0
- package/src/i18n/messagebundle_en_US_saprigi.properties +32 -0
- package/src/i18n/messagebundle_en_US_saptrc.properties +32 -0
- package/src/i18n/messagebundle_es.properties +32 -0
- package/src/i18n/messagebundle_es_MX.properties +32 -0
- package/src/i18n/messagebundle_et.properties +32 -0
- package/src/i18n/messagebundle_fi.properties +32 -0
- package/src/i18n/messagebundle_fr.properties +32 -0
- package/src/i18n/messagebundle_fr_CA.properties +32 -0
- package/src/i18n/messagebundle_hi.properties +32 -0
- package/src/i18n/messagebundle_hr.properties +32 -0
- package/src/i18n/messagebundle_hu.properties +32 -0
- package/src/i18n/messagebundle_id.properties +32 -0
- package/src/i18n/messagebundle_it.properties +32 -0
- package/src/i18n/messagebundle_iw.properties +32 -0
- package/src/i18n/messagebundle_ja.properties +32 -0
- package/src/i18n/messagebundle_kk.properties +32 -0
- package/src/i18n/messagebundle_ko.properties +32 -0
- package/src/i18n/messagebundle_lt.properties +32 -0
- package/src/i18n/messagebundle_lv.properties +32 -0
- package/src/i18n/messagebundle_mk.properties +32 -0
- package/src/i18n/messagebundle_ms.properties +32 -0
- package/src/i18n/messagebundle_nl.properties +32 -0
- package/src/i18n/messagebundle_no.properties +32 -0
- package/src/i18n/messagebundle_pl.properties +32 -0
- package/src/i18n/messagebundle_pt.properties +32 -0
- package/src/i18n/messagebundle_pt_PT.properties +32 -0
- package/src/i18n/messagebundle_ro.properties +32 -0
- package/src/i18n/messagebundle_ru.properties +32 -0
- package/src/i18n/messagebundle_sh.properties +32 -0
- package/src/i18n/messagebundle_sk.properties +32 -0
- package/src/i18n/messagebundle_sl.properties +32 -0
- package/src/i18n/messagebundle_sr.properties +32 -0
- package/src/i18n/messagebundle_sv.properties +32 -0
- package/src/i18n/messagebundle_th.properties +32 -0
- package/src/i18n/messagebundle_tr.properties +32 -0
- package/src/i18n/messagebundle_uk.properties +32 -0
- package/src/i18n/messagebundle_vi.properties +32 -0
- package/src/i18n/messagebundle_zh_CN.properties +32 -0
- package/src/i18n/messagebundle_zh_TW.properties +32 -0
- package/src/themes/Button.css +142 -0
- package/src/themes/Input.css +83 -0
- package/src/themes/PromptInput.css +34 -0
- package/src/themes/TextArea.css +45 -0
- package/src/themes/Versioning.css +20 -0
- package/src/themes/WritingAssistant.css +23 -0
- package/src/themes/base/Button-parameters.css +2 -0
- package/src/themes/sap_horizon/parameters-bundle.css +1 -0
- package/src/themes/sap_horizon_dark/parameters-bundle.css +1 -0
- package/src/themes/sap_horizon_hcb/parameters-bundle.css +1 -0
- package/src/themes/sap_horizon_hcw/parameters-bundle.css +1 -0
- package/tsconfig.json +63 -0
package/dist/TextArea.js
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
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
|
+
var TextArea_1;
|
|
8
|
+
import customElement from "@ui5/webcomponents-base/dist/decorators/customElement.js";
|
|
9
|
+
import property from "@ui5/webcomponents-base/dist/decorators/property.js";
|
|
10
|
+
import slot from "@ui5/webcomponents-base/dist/decorators/slot.js";
|
|
11
|
+
import event from "@ui5/webcomponents-base/dist/decorators/event-strict.js";
|
|
12
|
+
import jsxRenderer from "@ui5/webcomponents-base/dist/renderer/JsxRenderer.js";
|
|
13
|
+
import { BaseTextArea } from "@ui5/webcomponents/dist/TextArea.js";
|
|
14
|
+
import { getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js";
|
|
15
|
+
import { WRITING_ASSISTANT_LABEL, } from "./generated/i18n/i18n-defaults.js";
|
|
16
|
+
// Styles
|
|
17
|
+
import TextAreaCss from "./generated/themes/TextArea.css.js";
|
|
18
|
+
import textareaStyles from "@ui5/webcomponents/dist/generated/themes/TextArea.css.js";
|
|
19
|
+
import valueStateMessageStyles from "@ui5/webcomponents/dist/generated/themes/ValueStateMessage.css.js";
|
|
20
|
+
// Templates
|
|
21
|
+
import TextAreaTemplate from "./TextAreaTemplate.js";
|
|
22
|
+
/**
|
|
23
|
+
* @class
|
|
24
|
+
*
|
|
25
|
+
* ### Overview
|
|
26
|
+
*
|
|
27
|
+
* The `ui5-ai-textarea` component extends the standard TextArea with Writing Assistant capabilities.
|
|
28
|
+
* It provides AI-powered text generation, editing suggestions, and version management functionality.
|
|
29
|
+
*
|
|
30
|
+
* ### Structure
|
|
31
|
+
* The `ui5-ai-textarea` consists of the following elements:
|
|
32
|
+
* - TextArea: The main text input area with all standard textarea functionality
|
|
33
|
+
* - WritingAssistant: Dedicated toolbar containing:
|
|
34
|
+
* - Versioning: A component with left/right navigation buttons and a label for browsing AI-generated versions
|
|
35
|
+
* - AI Button: Opens a menu that can be extended with custom AI generation options through slotting
|
|
36
|
+
*
|
|
37
|
+
* ### ES6 Module Import
|
|
38
|
+
*
|
|
39
|
+
* `import "@ui5/webcomponents-ai/dist/TextArea.js";`
|
|
40
|
+
*
|
|
41
|
+
* @constructor
|
|
42
|
+
* @extends BaseTextArea
|
|
43
|
+
* @experimental The **@ui5/webcomponents-ai** package is under development and considered experimental - components' APIs are subject to change.
|
|
44
|
+
* Furthermore, the package supports **Horizon** themes only.
|
|
45
|
+
* @since 2.16.0
|
|
46
|
+
* @public
|
|
47
|
+
* @slot {HTMLElement} menu Defines a slot for `ui5-menu` integration. This slot allows you to pass a `ui5-menu` instance that will be associated with the assistant.
|
|
48
|
+
*/
|
|
49
|
+
let TextArea = TextArea_1 = class TextArea extends BaseTextArea {
|
|
50
|
+
constructor() {
|
|
51
|
+
super(...arguments);
|
|
52
|
+
/**
|
|
53
|
+
* Defines whether the `ui5-ai-textarea` is currently in a loading(processing) state.
|
|
54
|
+
*
|
|
55
|
+
* @default false
|
|
56
|
+
* @public
|
|
57
|
+
*/
|
|
58
|
+
this.loading = false;
|
|
59
|
+
/**
|
|
60
|
+
* Defines the prompt description of the current action.
|
|
61
|
+
*
|
|
62
|
+
* @default ""
|
|
63
|
+
* @public
|
|
64
|
+
*/
|
|
65
|
+
this.promptDescription = "";
|
|
66
|
+
/**
|
|
67
|
+
* Indicates the index of the currently displayed version.
|
|
68
|
+
*
|
|
69
|
+
*
|
|
70
|
+
* @default 0
|
|
71
|
+
* @public
|
|
72
|
+
*/
|
|
73
|
+
this.currentVersion = 0;
|
|
74
|
+
/**
|
|
75
|
+
* Indicates the total number of result versions available.
|
|
76
|
+
*
|
|
77
|
+
* Notes:
|
|
78
|
+
* Versioning is hidden if the value is `0`
|
|
79
|
+
*
|
|
80
|
+
* @default 0
|
|
81
|
+
* @public
|
|
82
|
+
*/
|
|
83
|
+
this.totalVersions = 0;
|
|
84
|
+
this.focused = false;
|
|
85
|
+
/**
|
|
86
|
+
* Handles the generate click event from the AI toolbar.
|
|
87
|
+
* Opens the AI menu and sets the opener element.
|
|
88
|
+
*
|
|
89
|
+
* @private
|
|
90
|
+
*/
|
|
91
|
+
this._handleAIButtonClick = (e) => {
|
|
92
|
+
const menuNodes = this.getSlottedNodes("menu");
|
|
93
|
+
if (menuNodes.length === 0) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (!e.detail?.clickTarget) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const menu = menuNodes[0];
|
|
100
|
+
if (menu && typeof menu.open !== "undefined") {
|
|
101
|
+
menu.opener = e.detail.clickTarget.shadowRoot?.querySelector("ui5-button");
|
|
102
|
+
menu.horizontalAlign = "End";
|
|
103
|
+
menu.open = true;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Handles the stop generation event from the AI toolbar.
|
|
108
|
+
* Fires the stop-generation event to notify listeners.
|
|
109
|
+
*
|
|
110
|
+
* @private
|
|
111
|
+
*/
|
|
112
|
+
this.handleStopGeneration = () => {
|
|
113
|
+
this.fireDecoratorEvent("stop-generation");
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
static async onDefine() {
|
|
117
|
+
TextArea_1.i18nBundle = await getI18nBundle("@ui5/webcomponents-ai");
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Handles the click event for the "Previous Version" button.
|
|
121
|
+
* Updates the current version index and syncs content.
|
|
122
|
+
*/
|
|
123
|
+
_handlePreviousVersionClick() {
|
|
124
|
+
this.fireDecoratorEvent("version-change", { backwards: true });
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Handles the click event for the "Next Version" button.
|
|
128
|
+
* Updates the current version index and syncs content.
|
|
129
|
+
*/
|
|
130
|
+
_handleNextVersionClick() {
|
|
131
|
+
this.fireDecoratorEvent("version-change", { backwards: false });
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Handles the version change event from the writing assistant.
|
|
135
|
+
*/
|
|
136
|
+
_handleVersionChange(e) {
|
|
137
|
+
if (e.detail.backwards) {
|
|
138
|
+
this._handlePreviousVersionClick();
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
this._handleNextVersionClick();
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Handles keydown events for keyboard shortcuts.
|
|
146
|
+
* @private
|
|
147
|
+
*/
|
|
148
|
+
_handleKeydown(keyboardEvent) {
|
|
149
|
+
const isCtrlOrCmd = keyboardEvent.ctrlKey || keyboardEvent.metaKey;
|
|
150
|
+
const isShift = keyboardEvent.shiftKey;
|
|
151
|
+
if (isShift && keyboardEvent.key.toLowerCase() === "f4") {
|
|
152
|
+
const toolbar = this.shadowRoot?.querySelector("[ui5-ai-writing-assistant]");
|
|
153
|
+
const aiButton = toolbar?.shadowRoot?.querySelector("#ai-menu-btn");
|
|
154
|
+
if (aiButton) {
|
|
155
|
+
aiButton.focus();
|
|
156
|
+
}
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
if (this.totalVersions > 1) {
|
|
160
|
+
if (isCtrlOrCmd && isShift && keyboardEvent.key.toLowerCase() === "z") {
|
|
161
|
+
keyboardEvent.preventDefault();
|
|
162
|
+
this._handlePreviousVersionClick();
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
if (isCtrlOrCmd && isShift && keyboardEvent.key.toLowerCase() === "y") {
|
|
166
|
+
keyboardEvent.preventDefault();
|
|
167
|
+
this._handleNextVersionClick();
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Overrides the parent's onAfterRendering to add keydown handler.
|
|
173
|
+
* @private
|
|
174
|
+
*/
|
|
175
|
+
onAfterRendering() {
|
|
176
|
+
super.onAfterRendering();
|
|
177
|
+
const textarea = this.shadowRoot?.querySelector("textarea");
|
|
178
|
+
if (textarea && !this._keydownHandler) {
|
|
179
|
+
this._keydownHandler = this._handleKeydown.bind(this);
|
|
180
|
+
textarea.addEventListener("keydown", this._keydownHandler);
|
|
181
|
+
}
|
|
182
|
+
const menuNodes = this.getSlottedNodes("menu");
|
|
183
|
+
if (menuNodes.length > 0) {
|
|
184
|
+
const menu = menuNodes[0];
|
|
185
|
+
if (!this._menuFocusinHandler) {
|
|
186
|
+
this._menuFocusinHandler = () => {
|
|
187
|
+
this.focused = true;
|
|
188
|
+
};
|
|
189
|
+
menu.addEventListener("focusin", this._menuFocusinHandler);
|
|
190
|
+
}
|
|
191
|
+
if (!this._menuFocusoutHandler) {
|
|
192
|
+
this._menuFocusoutHandler = (evt) => {
|
|
193
|
+
const e = evt;
|
|
194
|
+
const relatedTarget = e.relatedTarget;
|
|
195
|
+
const focusMovingWithinComponent = relatedTarget && this.shadowRoot?.contains(relatedTarget);
|
|
196
|
+
const focusStayingInMenu = relatedTarget && menu.contains(relatedTarget);
|
|
197
|
+
if (!focusMovingWithinComponent && !focusStayingInMenu) {
|
|
198
|
+
this.focused = false;
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
menu.addEventListener("focusout", this._menuFocusoutHandler);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
_onfocusin() {
|
|
206
|
+
super._onfocusin();
|
|
207
|
+
this.focused = true;
|
|
208
|
+
}
|
|
209
|
+
_onfocusout(e) {
|
|
210
|
+
super._onfocusout(e);
|
|
211
|
+
const relatedTarget = e.relatedTarget;
|
|
212
|
+
const focusMovingWithinShadowDOM = relatedTarget && this.shadowRoot?.contains(relatedTarget);
|
|
213
|
+
const menuNodes = this.getSlottedNodes("menu");
|
|
214
|
+
const focusMovingToMenu = menuNodes.length > 0 && relatedTarget && (menuNodes[0].contains(relatedTarget)
|
|
215
|
+
|| relatedTarget === menuNodes[0]);
|
|
216
|
+
if (!focusMovingWithinShadowDOM && !focusMovingToMenu) {
|
|
217
|
+
this.focused = false;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
get _ariaLabel() {
|
|
221
|
+
return this.accessibleName || TextArea_1.i18nBundle.getText(WRITING_ASSISTANT_LABEL);
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
__decorate([
|
|
225
|
+
property({ type: Boolean })
|
|
226
|
+
], TextArea.prototype, "loading", void 0);
|
|
227
|
+
__decorate([
|
|
228
|
+
property()
|
|
229
|
+
], TextArea.prototype, "promptDescription", void 0);
|
|
230
|
+
__decorate([
|
|
231
|
+
property({ type: Number })
|
|
232
|
+
], TextArea.prototype, "currentVersion", void 0);
|
|
233
|
+
__decorate([
|
|
234
|
+
property({ type: Number })
|
|
235
|
+
], TextArea.prototype, "totalVersions", void 0);
|
|
236
|
+
__decorate([
|
|
237
|
+
property({ type: Boolean })
|
|
238
|
+
], TextArea.prototype, "focused", void 0);
|
|
239
|
+
__decorate([
|
|
240
|
+
slot({ type: HTMLElement })
|
|
241
|
+
], TextArea.prototype, "menu", void 0);
|
|
242
|
+
TextArea = TextArea_1 = __decorate([
|
|
243
|
+
customElement({
|
|
244
|
+
tag: "ui5-ai-textarea",
|
|
245
|
+
languageAware: true,
|
|
246
|
+
renderer: jsxRenderer,
|
|
247
|
+
template: TextAreaTemplate,
|
|
248
|
+
styles: [
|
|
249
|
+
textareaStyles,
|
|
250
|
+
valueStateMessageStyles,
|
|
251
|
+
TextAreaCss,
|
|
252
|
+
],
|
|
253
|
+
})
|
|
254
|
+
/**
|
|
255
|
+
* Fired when the user clicks on version navigation buttons.
|
|
256
|
+
*
|
|
257
|
+
* @param {boolean} backwards - Indicates if navigation is backwards (true) or forwards (false, default).
|
|
258
|
+
* @public
|
|
259
|
+
*/
|
|
260
|
+
,
|
|
261
|
+
event("version-change")
|
|
262
|
+
/**
|
|
263
|
+
* Fired when the user requests to stop AI text generation.
|
|
264
|
+
*
|
|
265
|
+
* @public
|
|
266
|
+
*/
|
|
267
|
+
,
|
|
268
|
+
event("stop-generation")
|
|
269
|
+
], TextArea);
|
|
270
|
+
TextArea.define();
|
|
271
|
+
export default TextArea;
|
|
272
|
+
//# sourceMappingURL=TextArea.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextArea.js","sourceRoot":"","sources":["../src/TextArea.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,aAAa,MAAM,0DAA0D,CAAC;AACrF,OAAO,QAAQ,MAAM,qDAAqD,CAAC;AAC3E,OAAO,IAAI,MAAM,iDAAiD,CAAC;AACnE,OAAO,KAAK,MAAM,yDAAyD,CAAC;AAC5E,OAAO,WAAW,MAAM,sDAAsD,CAAC;AAE/E,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,4CAA4C,CAAC;AAE3E,OAAO,EACN,uBAAuB,GACvB,MAAM,mCAAmC,CAAC;AAC3C,SAAS;AACT,OAAO,WAAW,MAAM,oCAAoC,CAAC;AAC7D,OAAO,cAAc,MAAM,0DAA0D,CAAC;AACtF,OAAO,uBAAuB,MAAM,mEAAmE,CAAC;AAExG,YAAY;AACZ,OAAO,gBAAgB,MAAM,uBAAuB,CAAC;AAMrD;;;;;;;;;;;;;;;;;;;;;;;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C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;yCACZ;AAShB;IADC,QAAQ,EAAE;mDACY;AAUvB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDACR;AAYnB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+CACT;AAGlB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;yCACZ;AAGhB;IADC,IAAI,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;sCACF;AAvDrB,QAAQ;IA3Bb,aAAa,CAAC;QACd,GAAG,EAAE,iBAAiB;QACtB,aAAa,EAAE,IAAI;QACnB,QAAQ,EAAE,WAAW;QACrB,QAAQ,EAAE,gBAAgB;QAC1B,MAAM,EAAE;YACP,cAAc;YACd,uBAAuB;YACvB,WAAW;SACX;KACD,CAAC;IAEF;;;;;OAKG;;IACF,KAAK,CAAC,gBAAgB,CAAC;IAExB;;;;OAIG;;IACF,KAAK,CAAC,iBAAiB,CAAC;GAEnB,QAAQ,CAqNb;AAED,QAAQ,CAAC,MAAM,EAAE,CAAC;AAGlB,eAAe,QAAQ,CAAC","sourcesContent":["import customElement from \"@ui5/webcomponents-base/dist/decorators/customElement.js\";\nimport property from \"@ui5/webcomponents-base/dist/decorators/property.js\";\nimport slot from \"@ui5/webcomponents-base/dist/decorators/slot.js\";\nimport event from \"@ui5/webcomponents-base/dist/decorators/event-strict.js\";\nimport jsxRenderer from \"@ui5/webcomponents-base/dist/renderer/JsxRenderer.js\";\n\nimport { BaseTextArea } from \"@ui5/webcomponents/dist/TextArea.js\";\nimport { getI18nBundle } from \"@ui5/webcomponents-base/dist/i18nBundle.js\";\nimport type I18nBundle from \"@ui5/webcomponents-base/dist/i18nBundle.js\";\nimport {\n\tWRITING_ASSISTANT_LABEL,\n} from \"./generated/i18n/i18n-defaults.js\";\n// Styles\nimport TextAreaCss from \"./generated/themes/TextArea.css.js\";\nimport textareaStyles from \"@ui5/webcomponents/dist/generated/themes/TextArea.css.js\";\nimport valueStateMessageStyles from \"@ui5/webcomponents/dist/generated/themes/ValueStateMessage.css.js\";\n\n// Templates\nimport TextAreaTemplate from \"./TextAreaTemplate.js\";\n\ntype TextAreaVersionChangeEventDetail = {\n\tbackwards: boolean,\n};\n\n/**\n * @class\n *\n * ### Overview\n *\n * The `ui5-ai-textarea` component extends the standard TextArea with Writing Assistant capabilities.\n * It provides AI-powered text generation, editing suggestions, and version management functionality.\n *\n * ### Structure\n * The `ui5-ai-textarea` consists of the following elements:\n * - TextArea: The main text input area with all standard textarea functionality\n * - WritingAssistant: Dedicated toolbar containing:\n * - Versioning: A component with left/right navigation buttons and a label for browsing AI-generated versions\n * - AI Button: Opens a menu that can be extended with custom AI generation options through slotting\n *\n * ### ES6 Module Import\n *\n * `import \"@ui5/webcomponents-ai/dist/TextArea.js\";`\n *\n * @constructor\n * @extends BaseTextArea\n * @experimental The **@ui5/webcomponents-ai** package is under development and considered experimental - components' APIs are subject to change.\n * Furthermore, the package supports **Horizon** themes only.\n * @since 2.16.0\n * @public\n * @slot {HTMLElement} menu Defines a slot for `ui5-menu` integration. This slot allows you to pass a `ui5-menu` instance that will be associated with the assistant.\n */\n@customElement({\n\ttag: \"ui5-ai-textarea\",\n\tlanguageAware: true,\n\trenderer: jsxRenderer,\n\ttemplate: TextAreaTemplate,\n\tstyles: [\n\t\ttextareaStyles,\n\t\tvalueStateMessageStyles,\n\t\tTextAreaCss,\n\t],\n})\n\n/**\n * Fired when the user clicks on version navigation buttons.\n *\n * @param {boolean} backwards - Indicates if navigation is backwards (true) or forwards (false, default).\n * @public\n */\n@event(\"version-change\")\n\n/**\n * Fired when the user requests to stop AI text generation.\n *\n * @public\n */\n@event(\"stop-generation\")\n\nclass TextArea extends BaseTextArea {\n\teventDetails!: BaseTextArea[\"eventDetails\"] & {\n\t\t\"version-change\": TextAreaVersionChangeEventDetail;\n\t\t\"stop-generation\": void;\n\t};\n\n\t// Store bound handler for proper cleanup\n\tprivate _keydownHandler?: (event: KeyboardEvent) => void;\n\tprivate _menuFocusinHandler?: () => void;\n\tprivate _menuFocusoutHandler?: (event: Event) => void;\n\n\t/**\n\t * Defines whether the `ui5-ai-textarea` is currently in a loading(processing) state.\n\t *\n\t * @default false\n\t * @public\n\t */\n\t@property({ type: Boolean })\n\tloading = false;\n\n\t/**\n\t * Defines the prompt description of the current action.\n\t *\n\t * @default \"\"\n\t * @public\n\t */\n\t@property()\n\tpromptDescription = \"\";\n\n\t/**\n\t * Indicates the index of the currently displayed version.\n\t *\n\t *\n\t * @default 0\n\t * @public\n\t */\n\t@property({ type: Number })\n\tcurrentVersion = 0;\n\n\t/**\n\t * Indicates the total number of result versions available.\n\t *\n\t * Notes:\n\t * Versioning is hidden if the value is `0`\n\t *\n\t * @default 0\n\t * @public\n\t */\n\t@property({ type: Number })\n\ttotalVersions = 0;\n\n\t@property({ type: Boolean })\n\tfocused = false;\n\n\t@slot({ type: HTMLElement })\n\tmenu!: Array<HTMLElement>;\n\n\tstatic i18nBundle: I18nBundle;\n\n\tstatic async onDefine() {\n\t\tTextArea.i18nBundle = await getI18nBundle(\"@ui5/webcomponents-ai\");\n\t}\n\n\t/**\n\t * Handles the click event for the \"Previous Version\" button.\n\t * Updates the current version index and syncs content.\n\t */\n\t_handlePreviousVersionClick(): void {\n\t\tthis.fireDecoratorEvent(\"version-change\", { backwards: true });\n\t}\n\n\t/**\n\t * Handles the click event for the \"Next Version\" button.\n\t * Updates the current version index and syncs content.\n\t */\n\t_handleNextVersionClick(): void {\n\t\tthis.fireDecoratorEvent(\"version-change\", { backwards: false });\n\t}\n\n\t/**\n\t * Handles the version change event from the writing assistant.\n\t */\n\t_handleVersionChange(e: CustomEvent<{ backwards: boolean }>): void {\n\t\tif (e.detail.backwards) {\n\t\t\tthis._handlePreviousVersionClick();\n\t\t} else {\n\t\t\tthis._handleNextVersionClick();\n\t\t}\n\t}\n\n\t/**\n\t * Handles keydown events for keyboard shortcuts.\n\t * @private\n\t */\n\t_handleKeydown(keyboardEvent: KeyboardEvent) {\n\t\tconst isCtrlOrCmd = keyboardEvent.ctrlKey || keyboardEvent.metaKey;\n\t\tconst isShift = keyboardEvent.shiftKey;\n\n\t\tif (isShift && keyboardEvent.key.toLowerCase() === \"f4\") {\n\t\t\tconst toolbar = this.shadowRoot?.querySelector(\"[ui5-ai-writing-assistant]\") as HTMLElement;\n\t\t\tconst aiButton = toolbar?.shadowRoot?.querySelector(\"#ai-menu-btn\") as HTMLElement;\n\n\t\t\tif (aiButton) {\n\t\t\t\taiButton.focus();\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.totalVersions > 1) {\n\t\t\tif (isCtrlOrCmd && isShift && keyboardEvent.key.toLowerCase() === \"z\") {\n\t\t\t\tkeyboardEvent.preventDefault();\n\t\t\t\tthis._handlePreviousVersionClick();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (isCtrlOrCmd && isShift && keyboardEvent.key.toLowerCase() === \"y\") {\n\t\t\t\tkeyboardEvent.preventDefault();\n\t\t\t\tthis._handleNextVersionClick();\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Overrides the parent's onAfterRendering to add keydown handler.\n\t * @private\n\t */\n\tonAfterRendering() {\n\t\tsuper.onAfterRendering();\n\n\t\tconst textarea = this.shadowRoot?.querySelector(\"textarea\");\n\t\tif (textarea && !this._keydownHandler) {\n\t\t\tthis._keydownHandler = this._handleKeydown.bind(this);\n\t\t\ttextarea.addEventListener(\"keydown\", this._keydownHandler);\n\t\t}\n\n\t\tconst menuNodes = this.getSlottedNodes(\"menu\");\n\t\tif (menuNodes.length > 0) {\n\t\t\tconst menu = menuNodes[0];\n\t\t\tif (!this._menuFocusinHandler) {\n\t\t\t\tthis._menuFocusinHandler = () => {\n\t\t\t\t\tthis.focused = true;\n\t\t\t\t};\n\t\t\t\tmenu.addEventListener(\"focusin\", this._menuFocusinHandler);\n\t\t\t}\n\t\t\tif (!this._menuFocusoutHandler) {\n\t\t\t\tthis._menuFocusoutHandler = (evt: Event) => {\n\t\t\t\t\tconst e = evt as FocusEvent;\n\t\t\t\t\tconst relatedTarget = e.relatedTarget as HTMLElement;\n\t\t\t\t\tconst focusMovingWithinComponent = relatedTarget && this.shadowRoot?.contains(relatedTarget);\n\t\t\t\t\tconst focusStayingInMenu = relatedTarget && menu.contains(relatedTarget);\n\t\t\t\t\tif (!focusMovingWithinComponent && !focusStayingInMenu) {\n\t\t\t\t\t\tthis.focused = false;\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tmenu.addEventListener(\"focusout\", this._menuFocusoutHandler);\n\t\t\t}\n\t\t}\n\t}\n\n\t_onfocusin() {\n\t\tsuper._onfocusin();\n\t\tthis.focused = true;\n\t}\n\n\t_onfocusout(e: FocusEvent) {\n\t\tsuper._onfocusout(e);\n\t\tconst relatedTarget = e.relatedTarget as HTMLElement;\n\t\tconst focusMovingWithinShadowDOM = relatedTarget && this.shadowRoot?.contains(relatedTarget);\n\t\tconst menuNodes = this.getSlottedNodes(\"menu\");\n\t\tconst focusMovingToMenu = menuNodes.length > 0 && relatedTarget && (\n\t\t\tmenuNodes[0].contains(relatedTarget)\n\t\t\t|| relatedTarget === menuNodes[0]\n\t\t);\n\t\tif (!focusMovingWithinShadowDOM && !focusMovingToMenu) {\n\t\t\tthis.focused = false;\n\t\t}\n\t}\n\n\t/**\n\t * Handles the generate click event from the AI toolbar.\n\t * Opens the AI menu and sets the opener element.\n\t *\n\t * @private\n\t */\n\t_handleAIButtonClick = (e: CustomEvent<{ clickTarget?: HTMLElement }>) => {\n\t\tconst menuNodes = this.getSlottedNodes(\"menu\");\n\t\tif (menuNodes.length === 0) {\n\t\t\treturn;\n\t\t}\n\t\tif (!e.detail?.clickTarget) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst menu = menuNodes[0] as HTMLElement & { opener?: HTMLElement; open?: boolean, horizontalAlign?: string };\n\t\tif (menu && typeof menu.open !== \"undefined\") {\n\t\t\tmenu.opener = e.detail.clickTarget.shadowRoot?.querySelector(\"ui5-button\") as HTMLElement;\n\t\t\tmenu.horizontalAlign = \"End\";\n\t\t\tmenu.open = true;\n\t\t}\n\t}\n\tget _ariaLabel() {\n\t\treturn this.accessibleName || TextArea.i18nBundle.getText(WRITING_ASSISTANT_LABEL);\n\t}\n\n\t/**\n\t * Handles the stop generation event from the AI toolbar.\n\t * Fires the stop-generation event to notify listeners.\n\t *\n\t * @private\n\t */\n\thandleStopGeneration = () => {\n\t\tthis.fireDecoratorEvent(\"stop-generation\");\n\t}\n}\n\nTextArea.define();\n\nexport type { TextAreaVersionChangeEventDetail };\nexport default TextArea;\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@ui5/webcomponents-base/jsx-runtime";
|
|
2
|
+
import WritingAssistant from "./WritingAssistant.js";
|
|
3
|
+
import BusyIndicator from "@ui5/webcomponents/dist/BusyIndicator.js";
|
|
4
|
+
import TextAreaPopoverTemplate from "@ui5/webcomponents/dist/TextAreaPopoverTemplate.js";
|
|
5
|
+
export default function TextAreaTemplate() {
|
|
6
|
+
return (_jsxs("div", { class: "ui5-ai-textarea-root", children: [_jsxs("div", { class: this.classes.root, onFocusIn: this._onfocusin, onFocusOut: this._onfocusout, children: [_jsxs("div", { class: "ui5-textarea-wrapper", children: [this.growing &&
|
|
7
|
+
_jsx("div", { id: `${this._id}-mirror`, class: "ui5-textarea-mirror", "aria-hidden": "true", children: this._mirrorText.map(mirrorText => {
|
|
8
|
+
return (_jsxs(_Fragment, { children: [mirrorText.text, _jsx("br", {})] }));
|
|
9
|
+
}) }), _jsx(BusyIndicator, { id: `${this._id}-busyIndicator`, active: this.loading, class: "ui5-textarea-busy-indicator", children: _jsx("textarea", { id: `${this._id}-inner`, class: "ui5-textarea-inner", part: "textarea", placeholder: this.placeholder, disabled: this.disabled, readonly: this.readonly, "aria-label": this._ariaLabel, "aria-describedby": this.ariaDescribedBy, "aria-invalid": this._ariaInvalid, "aria-required": this.required, maxlength: this._exceededTextProps.calcedMaxLength, value: this.value, "data-sap-focus-ref": true, onInput: this._oninput, onChange: this._onchange, onKeyUp: this._onkeyup, onKeyDown: this._onkeydown, onSelect: this._onselect, onScroll: this._onscroll }) }), _jsx("div", { part: "footer", children: _jsx("slot", { name: "footer", children: _jsx(WritingAssistant, { loading: this.loading, currentVersion: this.currentVersion, totalVersions: this.totalVersions, promptDescription: this.promptDescription, focused: this.focused, onButtonClick: this._handleAIButtonClick, onStopGeneration: this.handleStopGeneration, onVersionChange: this._handleVersionChange }) }) })] }), this.showExceededText &&
|
|
10
|
+
_jsx("span", { class: "ui5-textarea-exceeded-text", children: this._exceededTextProps.exceededText }), this.hasValueState &&
|
|
11
|
+
_jsx("span", { id: `${this._id}-valueStateDesc`, class: "ui5-hidden-text", children: this.ariaValueStateHiddenText })] }), TextAreaPopoverTemplate.call(this), _jsx("div", { "aria-live": "polite", "aria-atomic": "true", class: "ui5-hidden-text", children: this.loading ? this.promptDescription : "" }), _jsx("div", { id: "ai-menu-wrapper", children: _jsx("slot", { name: "menu" }) })] }));
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=TextAreaTemplate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextAreaTemplate.js","sourceRoot":"","sources":["../src/TextAreaTemplate.tsx"],"names":[],"mappings":";AACA,OAAO,gBAAgB,MAAM,uBAAuB,CAAC;AACrD,OAAO,aAAa,MAAM,0CAA0C,CAAC;AACrE,OAAO,uBAAuB,MAAM,oDAAoD,CAAC;AAEzF,MAAM,CAAC,OAAO,UAAU,gBAAgB;IACvC,OAAO,CACN,eAAK,KAAK,EAAC,sBAAsB,aAChC,eACC,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,EACxB,SAAS,EAAE,IAAI,CAAC,UAAU,EAC1B,UAAU,EAAE,IAAI,CAAC,WAAW,aAE5B,eAAK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,aAAa,EAAE,IAAI,CAAC,aAAa,EACjC,iBAAiB,EAAE,IAAI,CAAC,iBAAiB,EACzC,OAAO,EAAE,IAAI,CAAC,OAAO,EACrB,aAAa,EAAE,IAAI,CAAC,oBAAoB,EACxC,gBAAgB,EAAE,IAAI,CAAC,oBAAoB,EAC3C,eAAe,EAAE,IAAI,CAAC,oBAAoB,GACzC,GACI,GACF,IACD,EAEL,IAAI,CAAC,gBAAgB;wBACtB,eAAM,KAAK,EAAC,4BAA4B,YAAE,IAAI,CAAC,kBAAkB,CAAC,YAAY,GAAQ,EAGrF,IAAI,CAAC,aAAa;wBACnB,eAAM,EAAE,EAAE,GAAG,IAAI,CAAC,GAAG,iBAAiB,EAAE,KAAK,EAAC,iBAAiB,YAAE,IAAI,CAAC,wBAAwB,GAAQ,IAEjG,EAEL,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,EAGnC,2BAAe,QAAQ,iBAAa,MAAM,EAAC,KAAK,EAAC,iBAAiB,YAChE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,GACtC,EAEN,cAAK,EAAE,EAAC,iBAAiB,YACxB,eAAM,IAAI,EAAC,MAAM,GAAQ,GACpB,IACD,CACN,CAAC;AACH,CAAC","sourcesContent":["import type TextArea from \"./TextArea.js\";\nimport WritingAssistant from \"./WritingAssistant.js\";\nimport BusyIndicator from \"@ui5/webcomponents/dist/BusyIndicator.js\";\nimport TextAreaPopoverTemplate from \"@ui5/webcomponents/dist/TextAreaPopoverTemplate.js\";\n\nexport default function TextAreaTemplate(this: TextArea) {\n\treturn (\n\t\t<div class=\"ui5-ai-textarea-root\">\n\t\t\t<div\n\t\t\t\tclass={this.classes.root}\n\t\t\t\tonFocusIn={this._onfocusin}\n\t\t\t\tonFocusOut={this._onfocusout}\n\t\t\t>\n\t\t\t\t<div class=\"ui5-textarea-wrapper\">\n\t\t\t\t\t{this.growing &&\n\t\t\t\t\t<div id={`${this._id}-mirror`} class=\"ui5-textarea-mirror\" aria-hidden=\"true\">\n\t\t\t\t\t\t{this._mirrorText.map(mirrorText => {\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t{mirrorText.text}\n\t\t\t\t\t\t\t\t\t<br />\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t})}\n\t\t\t\t\t</div>\n\t\t\t\t\t}\n\t\t\t\t\t<BusyIndicator\n\t\t\t\t\t\tid={`${this._id}-busyIndicator`}\n\t\t\t\t\t\tactive={this.loading}\n\t\t\t\t\t\tclass=\"ui5-textarea-busy-indicator\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<textarea\n\t\t\t\t\t\t\tid={`${this._id}-inner`}\n\t\t\t\t\t\t\tclass=\"ui5-textarea-inner\"\n\t\t\t\t\t\t\tpart=\"textarea\"\n\t\t\t\t\t\t\tplaceholder={this.placeholder}\n\t\t\t\t\t\t\tdisabled={this.disabled}\n\t\t\t\t\t\t\treadonly={this.readonly}\n\t\t\t\t\t\t\taria-label={this._ariaLabel}\n\t\t\t\t\t\t\taria-describedby={this.ariaDescribedBy}\n\t\t\t\t\t\t\taria-invalid={this._ariaInvalid}\n\t\t\t\t\t\t\taria-required={this.required}\n\t\t\t\t\t\t\tmaxlength={this._exceededTextProps.calcedMaxLength}\n\t\t\t\t\t\t\tvalue={this.value}\n\t\t\t\t\t\t\tdata-sap-focus-ref\n\t\t\t\t\t\t\tonInput={this._oninput}\n\t\t\t\t\t\t\tonChange={this._onchange}\n\t\t\t\t\t\t\tonKeyUp={this._onkeyup}\n\t\t\t\t\t\t\tonKeyDown={this._onkeydown}\n\t\t\t\t\t\t\tonSelect={this._onselect}\n\t\t\t\t\t\t\tonScroll={this._onscroll}>\n\t\t\t\t\t\t</textarea>\n\t\t\t\t\t</BusyIndicator>\n\t\t\t\t\t<div part=\"footer\">\n\t\t\t\t\t\t<slot name=\"footer\">\n\t\t\t\t\t\t\t<WritingAssistant\n\t\t\t\t\t\t\t\tloading={this.loading}\n\t\t\t\t\t\t\t\tcurrentVersion={this.currentVersion}\n\t\t\t\t\t\t\t\ttotalVersions={this.totalVersions}\n\t\t\t\t\t\t\t\tpromptDescription={this.promptDescription}\n\t\t\t\t\t\t\t\tfocused={this.focused}\n\t\t\t\t\t\t\t\tonButtonClick={this._handleAIButtonClick}\n\t\t\t\t\t\t\t\tonStopGeneration={this.handleStopGeneration}\n\t\t\t\t\t\t\t\tonVersionChange={this._handleVersionChange}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</slot>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\n\t\t\t\t{this.showExceededText &&\n\t\t\t\t<span class=\"ui5-textarea-exceeded-text\">{this._exceededTextProps.exceededText}</span>\n\t\t\t\t}\n\n\t\t\t\t{this.hasValueState &&\n\t\t\t\t<span id={`${this._id}-valueStateDesc`} class=\"ui5-hidden-text\">{this.ariaValueStateHiddenText}</span>\n\t\t\t\t}\n\t\t\t</div>\n\n\t\t\t{TextAreaPopoverTemplate.call(this)}\n\n\t\t\t{/* ARIA live region for screen readers */}\n\t\t\t<div aria-live=\"polite\" aria-atomic=\"true\" class=\"ui5-hidden-text\">\n\t\t\t\t{this.loading ? this.promptDescription : \"\"}\n\t\t\t</div>\n\n\t\t\t<div id=\"ai-menu-wrapper\">\n\t\t\t\t<slot name=\"menu\"></slot>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import ToolbarItem from "@ui5/webcomponents/dist/ToolbarItem.js";
|
|
2
|
+
/**
|
|
3
|
+
* @class
|
|
4
|
+
*
|
|
5
|
+
* ### Overview
|
|
6
|
+
* The `ui5-ai-toolbar-label` represents a text label,
|
|
7
|
+
* used in the `ui5-toolbar`.
|
|
8
|
+
*
|
|
9
|
+
* ### ES6 Module Import
|
|
10
|
+
* `import "@ui5/webcomponents-ai/dist/ToolbarLabel.js";`
|
|
11
|
+
* @constructor
|
|
12
|
+
* @extends ToolbarItem
|
|
13
|
+
* @private
|
|
14
|
+
* @since 1.0.0-rc.1
|
|
15
|
+
*/
|
|
16
|
+
declare class ToolbarLabel extends ToolbarItem {
|
|
17
|
+
/**
|
|
18
|
+
* Defines the text of the label.
|
|
19
|
+
* @default ""
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
text: string;
|
|
23
|
+
/**
|
|
24
|
+
* @override
|
|
25
|
+
* ToolbarLabel is not interactive.
|
|
26
|
+
*/
|
|
27
|
+
get isInteractive(): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* @override
|
|
30
|
+
*/
|
|
31
|
+
get classes(): {
|
|
32
|
+
root: {
|
|
33
|
+
"ui5-ai-tb-label": boolean;
|
|
34
|
+
"ui5-tb-popover-item": boolean;
|
|
35
|
+
"ui5-tb-item": boolean;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export default ToolbarLabel;
|
|
@@ -0,0 +1,67 @@
|
|
|
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 jsxRenderer from "@ui5/webcomponents-base/dist/renderer/JsxRenderer.js";
|
|
8
|
+
import customElement from "@ui5/webcomponents-base/dist/decorators/customElement.js";
|
|
9
|
+
import property from "@ui5/webcomponents-base/dist/decorators/property.js";
|
|
10
|
+
import ToolbarItem from "@ui5/webcomponents/dist/ToolbarItem.js";
|
|
11
|
+
import ToolbarLabelTemplate from "./ToolbarLabelTemplate.js";
|
|
12
|
+
/**
|
|
13
|
+
* @class
|
|
14
|
+
*
|
|
15
|
+
* ### Overview
|
|
16
|
+
* The `ui5-ai-toolbar-label` represents a text label,
|
|
17
|
+
* used in the `ui5-toolbar`.
|
|
18
|
+
*
|
|
19
|
+
* ### ES6 Module Import
|
|
20
|
+
* `import "@ui5/webcomponents-ai/dist/ToolbarLabel.js";`
|
|
21
|
+
* @constructor
|
|
22
|
+
* @extends ToolbarItem
|
|
23
|
+
* @private
|
|
24
|
+
* @since 1.0.0-rc.1
|
|
25
|
+
*/
|
|
26
|
+
let ToolbarLabel = class ToolbarLabel extends ToolbarItem {
|
|
27
|
+
constructor() {
|
|
28
|
+
super(...arguments);
|
|
29
|
+
/**
|
|
30
|
+
* Defines the text of the label.
|
|
31
|
+
* @default ""
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
this.text = "";
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* @override
|
|
38
|
+
* ToolbarLabel is not interactive.
|
|
39
|
+
*/
|
|
40
|
+
get isInteractive() {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* @override
|
|
45
|
+
*/
|
|
46
|
+
get classes() {
|
|
47
|
+
return {
|
|
48
|
+
root: {
|
|
49
|
+
...super.classes.root,
|
|
50
|
+
"ui5-ai-tb-label": true,
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
__decorate([
|
|
56
|
+
property()
|
|
57
|
+
], ToolbarLabel.prototype, "text", void 0);
|
|
58
|
+
ToolbarLabel = __decorate([
|
|
59
|
+
customElement({
|
|
60
|
+
tag: "ui5-ai-toolbar-label",
|
|
61
|
+
template: ToolbarLabelTemplate,
|
|
62
|
+
renderer: jsxRenderer,
|
|
63
|
+
})
|
|
64
|
+
], ToolbarLabel);
|
|
65
|
+
ToolbarLabel.define();
|
|
66
|
+
export default ToolbarLabel;
|
|
67
|
+
//# sourceMappingURL=ToolbarLabel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolbarLabel.js","sourceRoot":"","sources":["../src/ToolbarLabel.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,WAAW,MAAM,sDAAsD,CAAC;AAC/E,OAAO,aAAa,MAAM,0DAA0D,CAAC;AACrF,OAAO,QAAQ,MAAM,qDAAqD,CAAC;AAE3E,OAAO,WAAW,MAAM,wCAAwC,CAAC;AACjE,OAAO,oBAAoB,MAAM,2BAA2B,CAAC;AAE7D;;;;;;;;;;;;;GAaG;AAMH,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,WAAW;IAAtC;;QACC;;;;WAIG;QAEH,SAAI,GAAG,EAAE,CAAC;IAqBX,CAAC;IAnBA;;;OAGG;IACH,IAAI,aAAa;QAChB,OAAO,KAAK,CAAC;IACd,CAAC;IAED;;OAEG;IACH,IAAI,OAAO;QACV,OAAO;YACN,IAAI,EAAE;gBACL,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI;gBACrB,iBAAiB,EAAE,IAAI;aACvB;SACD,CAAC;IACH,CAAC;CACD,CAAA;AArBA;IADC,QAAQ,EAAE;0CACD;AAPL,YAAY;IALjB,aAAa,CAAC;QACd,GAAG,EAAE,sBAAsB;QAC3B,QAAQ,EAAE,oBAAoB;QAC9B,QAAQ,EAAE,WAAW;KACrB,CAAC;GACI,YAAY,CA4BjB;AAED,YAAY,CAAC,MAAM,EAAE,CAAC;AAEtB,eAAe,YAAY,CAAC","sourcesContent":["import jsxRenderer from \"@ui5/webcomponents-base/dist/renderer/JsxRenderer.js\";\nimport customElement from \"@ui5/webcomponents-base/dist/decorators/customElement.js\";\nimport property from \"@ui5/webcomponents-base/dist/decorators/property.js\";\n\nimport ToolbarItem from \"@ui5/webcomponents/dist/ToolbarItem.js\";\nimport ToolbarLabelTemplate from \"./ToolbarLabelTemplate.js\";\n\n/**\n * @class\n *\n * ### Overview\n * The `ui5-ai-toolbar-label` represents a text label,\n * used in the `ui5-toolbar`.\n *\n * ### ES6 Module Import\n * `import \"@ui5/webcomponents-ai/dist/ToolbarLabel.js\";`\n * @constructor\n * @extends ToolbarItem\n * @private\n * @since 1.0.0-rc.1\n */\n@customElement({\n\ttag: \"ui5-ai-toolbar-label\",\n\ttemplate: ToolbarLabelTemplate,\n\trenderer: jsxRenderer,\n})\nclass ToolbarLabel extends ToolbarItem {\n\t/**\n\t * Defines the text of the label.\n\t * @default \"\"\n\t * @public\n\t */\n\t@property()\n\ttext = \"\";\n\n\t/**\n\t * @override\n\t * ToolbarLabel is not interactive.\n\t */\n\tget isInteractive(): boolean {\n\t\treturn false;\n\t}\n\n\t/**\n\t * @override\n\t */\n\tget classes() {\n\t\treturn {\n\t\t\troot: {\n\t\t\t\t...super.classes.root,\n\t\t\t\t\"ui5-ai-tb-label\": true,\n\t\t\t},\n\t\t};\n\t}\n}\n\nToolbarLabel.define();\n\nexport default ToolbarLabel;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolbarLabelTemplate.js","sourceRoot":"","sources":["../src/ToolbarLabelTemplate.tsx"],"names":[],"mappings":";AAEA,MAAM,CAAC,OAAO,UAAU,oBAAoB;IAC3C,OAAO,CACN,eAAM,KAAK,EAAC,sBAAsB,YAChC,IAAI,CAAC,IAAI,GACJ,CACP,CAAC;AACH,CAAC","sourcesContent":["import type ToolbarLabel from \"./ToolbarLabel.js\";\n\nexport default function ToolbarLabelTemplate(this: ToolbarLabel) {\n\treturn (\n\t\t<span class=\"ui5-ai-toolbar-label\">\n\t\t\t{this.text}\n\t\t</span>\n\t);\n}\n"]}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import ToolbarItem from "@ui5/webcomponents/dist/ToolbarItem.js";
|
|
2
|
+
import type I18nBundle from "@ui5/webcomponents-base/dist/i18nBundle.js";
|
|
3
|
+
import "@ui5/webcomponents-icons/dist/navigation-left-arrow.js";
|
|
4
|
+
import "@ui5/webcomponents-icons/dist/navigation-right-arrow.js";
|
|
5
|
+
declare enum LastClickedButton {
|
|
6
|
+
None = "",
|
|
7
|
+
Previous = "previous",
|
|
8
|
+
Next = "next"
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* @class
|
|
12
|
+
*
|
|
13
|
+
* ### Overview
|
|
14
|
+
*
|
|
15
|
+
* The `ui5-ai-versioning` component provides navigation controls for AI-generated content versions.
|
|
16
|
+
* It displays the current version index and total versions, with previous/next navigation buttons.
|
|
17
|
+
* This component extends ToolbarItem to participate in toolbar overflow behavior as a single unit.
|
|
18
|
+
*
|
|
19
|
+
* ### Structure
|
|
20
|
+
* The `ui5-ai-versioning` consists of the following elements:
|
|
21
|
+
* - Previous Button: Navigates to the previous version (disabled when at first version)
|
|
22
|
+
* - Version Counter: Shows current version / total versions (e.g., "2 / 5")
|
|
23
|
+
* - Next Button: Navigates to the nex
|
|
24
|
+
* t version (disabled when at last version)
|
|
25
|
+
*
|
|
26
|
+
* ### Focus Management
|
|
27
|
+
* The component automatically manages focus when users reach version boundaries,
|
|
28
|
+
* moving focus to the available navigation button when one becomes disabled.
|
|
29
|
+
*
|
|
30
|
+
* ### Responsive Behavior
|
|
31
|
+
* When used in a toolbar, the entire versioning component (buttons + label) will overflow
|
|
32
|
+
* together as a single unit when there is insufficient space.
|
|
33
|
+
*
|
|
34
|
+
* ### ES6 Module Import
|
|
35
|
+
*
|
|
36
|
+
* `import "@ui5/webcomponents-ai/dist/Versioning.js";`
|
|
37
|
+
*
|
|
38
|
+
* @constructor
|
|
39
|
+
* @extends ToolbarItem
|
|
40
|
+
* @since 2.16.0
|
|
41
|
+
* @private
|
|
42
|
+
*/
|
|
43
|
+
declare class Versioning extends ToolbarItem {
|
|
44
|
+
eventDetails: ToolbarItem["eventDetails"] & {
|
|
45
|
+
"version-change": {
|
|
46
|
+
backwards: boolean;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Indicates the index of the currently displayed result version.
|
|
51
|
+
*
|
|
52
|
+
* This property represents the current position in the version history.
|
|
53
|
+
* @default 0
|
|
54
|
+
* @public
|
|
55
|
+
*/
|
|
56
|
+
currentStep: number;
|
|
57
|
+
/**
|
|
58
|
+
* The total number of available result versions.
|
|
59
|
+
*
|
|
60
|
+
* Note: Versioning is hidden if the value is `0`.
|
|
61
|
+
*
|
|
62
|
+
* @default 0
|
|
63
|
+
* @public
|
|
64
|
+
*/
|
|
65
|
+
totalSteps: number;
|
|
66
|
+
_previousCurrentStep: number;
|
|
67
|
+
_previousTotalSteps: number;
|
|
68
|
+
_lastClickedButton: LastClickedButton;
|
|
69
|
+
static i18nBundle: I18nBundle;
|
|
70
|
+
static onDefine(): Promise<void>;
|
|
71
|
+
onAfterRendering(): void;
|
|
72
|
+
/**
|
|
73
|
+
* Manages focus when navigation buttons become disabled/enabled.
|
|
74
|
+
* Automatically moves focus to available button when user reaches boundaries.
|
|
75
|
+
* @private
|
|
76
|
+
*/
|
|
77
|
+
_manageFocus(): void;
|
|
78
|
+
handlePreviousVersionClick(): void;
|
|
79
|
+
handleNextVersionClick(): void;
|
|
80
|
+
get _previousButtonAccessibleName(): string;
|
|
81
|
+
get _nextButtonAccessibleName(): string;
|
|
82
|
+
get _previousButtonTooltip(): string;
|
|
83
|
+
get _nextButtonTooltip(): string;
|
|
84
|
+
/**
|
|
85
|
+
* @override
|
|
86
|
+
*/
|
|
87
|
+
get classes(): {
|
|
88
|
+
root: {
|
|
89
|
+
"ui5-ai-versioning": boolean;
|
|
90
|
+
"ui5-tb-popover-item": boolean;
|
|
91
|
+
"ui5-tb-item": boolean;
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
export default Versioning;
|