@ui5/webcomponents-ai 2.15.0 → 2.16.0-rc.1
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 +25 -0
- package/README.md +1 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/Button.d.ts +1 -1
- package/dist/Button.js +4 -4
- package/dist/Button.js.map +1 -1
- package/dist/TextArea.d.ts +115 -0
- package/dist/TextArea.js +234 -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 +98 -0
- package/dist/WritingAssistant.js +190 -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.js +1 -0
- package/dist/bundle.esm.js.map +1 -1
- package/dist/css/themes/AITextArea.css +1 -0
- package/dist/css/themes/Button.css +1 -1
- package/dist/css/themes/PromptInput.css +1 -1
- package/dist/css/themes/Versioning.css +1 -0
- package/dist/css/themes/WritingAssistant.css +1 -0
- package/dist/custom-elements-internal.json +197 -0
- package/dist/custom-elements.json +183 -0
- package/dist/generated/assets/i18n/messagebundle_en.json +1 -1
- package/dist/generated/i18n/i18n-defaults.d.ts +10 -1
- package/dist/generated/i18n/i18n-defaults.js +10 -1
- package/dist/generated/i18n/i18n-defaults.js.map +1 -1
- package/dist/generated/themes/AITextArea.css.d.ts +2 -0
- package/dist/generated/themes/AITextArea.css.js +8 -0
- package/dist/generated/themes/AITextArea.css.js.map +1 -0
- package/dist/generated/themes/Button.css.d.ts +1 -1
- package/dist/generated/themes/Button.css.js +1 -1
- package/dist/generated/themes/Button.css.js.map +1 -1
- package/dist/generated/themes/PromptInput.css.d.ts +1 -1
- package/dist/generated/themes/PromptInput.css.js +1 -1
- package/dist/generated/themes/PromptInput.css.js.map +1 -1
- 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/vscode.html-custom-data.json +27 -0
- package/dist/web-types.json +78 -1
- package/package-scripts.cjs +0 -1
- package/package.json +8 -8
- package/src/TextArea.css +45 -0
- package/src/TextAreaTemplate.tsx +90 -0
- package/src/ToolbarLabelTemplate.tsx +9 -0
- package/src/VersioningTemplate.tsx +34 -0
- package/src/WritingAssistantTemplate.tsx +49 -0
- package/src/i18n/messagebundle.properties +26 -0
- package/src/i18n/messagebundle_en.properties +1 -0
- package/src/themes/AITextArea.css +45 -0
- package/src/themes/PromptInput.css +5 -1
- package/src/themes/Versioning.css +20 -0
- package/src/themes/WritingAssistant.css +45 -0
package/dist/Button.d.ts
CHANGED
|
@@ -124,7 +124,7 @@ declare class Button extends UI5Element {
|
|
|
124
124
|
states: Array<ButtonState>;
|
|
125
125
|
_splitButton?: SplitButton;
|
|
126
126
|
_hiddenSplitButton?: SplitButton;
|
|
127
|
-
static
|
|
127
|
+
static i18nBundleAi: I18nBundle;
|
|
128
128
|
get _hideArrowButton(): boolean;
|
|
129
129
|
get _effectiveState(): string;
|
|
130
130
|
get _effectiveStateObject(): ButtonState | undefined;
|
package/dist/Button.js
CHANGED
|
@@ -9,6 +9,7 @@ import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
|
|
|
9
9
|
import { renderFinished } from "@ui5/webcomponents-base/dist/Render.js";
|
|
10
10
|
import customElement from "@ui5/webcomponents-base/dist/decorators/customElement.js";
|
|
11
11
|
import property from "@ui5/webcomponents-base/dist/decorators/property.js";
|
|
12
|
+
import { i18n } from "@ui5/webcomponents-base/dist/decorators.js";
|
|
12
13
|
import event from "@ui5/webcomponents-base/dist/decorators/event-strict.js";
|
|
13
14
|
import slot from "@ui5/webcomponents-base/dist/decorators/slot.js";
|
|
14
15
|
import query from "@ui5/webcomponents-base/dist/decorators/query.js";
|
|
@@ -19,7 +20,6 @@ import ButtonTemplate from "./ButtonTemplate.js";
|
|
|
19
20
|
import { getEffectiveAriaLabelText, getAssociatedLabelForTexts, getAllAccessibleNameRefTexts, } from "@ui5/webcomponents-base/dist/util/AccessibilityTextsHelper.js";
|
|
20
21
|
// Styles
|
|
21
22
|
import ButtonCss from "./generated/themes/Button.css.js";
|
|
22
|
-
import { i18n } from "@ui5/webcomponents-base/dist/decorators.js";
|
|
23
23
|
/**
|
|
24
24
|
* @class
|
|
25
25
|
*
|
|
@@ -240,7 +240,7 @@ let Button = Button_1 = class Button extends UI5Element {
|
|
|
240
240
|
}
|
|
241
241
|
get _computedAccessibilityAttributes() {
|
|
242
242
|
const labelRefTexts = getAllAccessibleNameRefTexts(this) || getEffectiveAriaLabelText(this) || getAssociatedLabelForTexts(this) || "";
|
|
243
|
-
const mainTitle = this._hasText ? Button_1.
|
|
243
|
+
const mainTitle = this._hasText ? Button_1.i18nBundleAi.getText(BUTTON_TOOLTIP_TEXT, this._stateText) : "";
|
|
244
244
|
const title = `${mainTitle} ${labelRefTexts}`.trim();
|
|
245
245
|
return {
|
|
246
246
|
root: {
|
|
@@ -288,8 +288,8 @@ __decorate([
|
|
|
288
288
|
query(".ui5-ai-button-hidden[ui5-split-button]")
|
|
289
289
|
], Button.prototype, "_hiddenSplitButton", void 0);
|
|
290
290
|
__decorate([
|
|
291
|
-
i18n("@ui5/webcomponents")
|
|
292
|
-
], Button, "
|
|
291
|
+
i18n("@ui5/webcomponents-ai")
|
|
292
|
+
], Button, "i18nBundleAi", void 0);
|
|
293
293
|
Button = Button_1 = __decorate([
|
|
294
294
|
customElement({
|
|
295
295
|
tag: "ui5-ai-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,yDAAyD,CAAC;AAC5E,OAAO,IAAI,MAAM,iDAAiD,CAAC;AACnE,OAAO,KAAK,MAAM,kDAAkD,CAAC;AACrE,OAAO,WAAW,MAAM,sDAAsD,CAAC;AAI/E,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,kBAAkB,CAAC;AAC1B,OAAO,cAAc,MAAM,qBAAqB,CAAC;AACjD,OAAO,EACN,yBAAyB,EACzB,0BAA0B,EAC1B,4BAA4B,GAC5B,MAAM,+DAA+D,CAAC;AAEvE,SAAS;AACT,OAAO,SAAS,MAAM,kCAAkC,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,4CAA4C,CAAC;AAQlE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AA8BH,IAAM,MAAM,cAAZ,MAAM,MAAO,SAAQ,UAAU;IAA/B;;QAKC;;;;WAIG;QAEH,WAAM,GAAuB,SAAS,CAAA;QAEtC;;;;;;WAMG;QAEH,aAAQ,GA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CACV;AASlB;IADC,IAAI,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;sCACjB;AAG5B;IADC,KAAK,CAAC,oBAAoB,CAAC;4CACD;AAG3B;IADC,KAAK,CAAC,yCAAyC,CAAC;kDAChB;AAG1B;IADN,IAAI,CAAC,oBAAoB,CAAC;gCACG;AAvGzB,MAAM;IA5BX,aAAa,CAAC;QACd,GAAG,EAAE,eAAe;QACpB,aAAa,EAAE,IAAI;QACnB,QAAQ,EAAE,WAAW;QACrB,QAAQ,EAAE,cAAc;QACxB,MAAM,EAAE,SAAS;QACjB,iBAAiB,EAAE,EAAE,cAAc,EAAE,IAAI,EAAE;KAC3C,CAAC;IAEF;;;;OAIG;;IACF,KAAK,CAAC,OAAO,EAAE;QACf,OAAO,EAAE,IAAI;KACb,CAAC;IAEF;;;;;OAKG;;IACF,KAAK,CAAC,oBAAoB,EAAE;QAC5B,OAAO,EAAE,IAAI;KACb,CAAC;GAEI,MAAM,CAyRX;AAED,MAAM,CAAC,MAAM,EAAE,CAAC;AAChB,eAAe,MAAM,CAAC","sourcesContent":["import UI5Element from \"@ui5/webcomponents-base/dist/UI5Element.js\";\nimport { renderFinished } from \"@ui5/webcomponents-base/dist/Render.js\";\nimport customElement from \"@ui5/webcomponents-base/dist/decorators/customElement.js\";\nimport property from \"@ui5/webcomponents-base/dist/decorators/property.js\";\nimport event from \"@ui5/webcomponents-base/dist/decorators/event-strict.js\";\nimport slot from \"@ui5/webcomponents-base/dist/decorators/slot.js\";\nimport query from \"@ui5/webcomponents-base/dist/decorators/query.js\";\nimport jsxRenderer from \"@ui5/webcomponents-base/dist/renderer/JsxRenderer.js\";\nimport type SplitButton from \"@ui5/webcomponents/dist/SplitButton.js\";\nimport type ButtonDesign from \"@ui5/webcomponents/dist/types/ButtonDesign.js\";\nimport type ButtonState from \"./ButtonState.js\";\nimport { BUTTON_TOOLTIP_TEXT } from \"./generated/i18n/i18n-defaults.js\";\nimport \"./ButtonState.js\";\nimport ButtonTemplate from \"./ButtonTemplate.js\";\nimport {\n\tgetEffectiveAriaLabelText,\n\tgetAssociatedLabelForTexts,\n\tgetAllAccessibleNameRefTexts,\n} from \"@ui5/webcomponents-base/dist/util/AccessibilityTextsHelper.js\";\n\n// Styles\nimport ButtonCss from \"./generated/themes/Button.css.js\";\nimport { i18n } from \"@ui5/webcomponents-base/dist/decorators.js\";\nimport type I18nBundle from \"@ui5/webcomponents-base/dist/i18nBundle.js\";\nimport type { AccessibilityAttributes } from \"@ui5/webcomponents-base/dist/types.js\";\n\ntype AIButtonRootAccessibilityAttributes = Pick<AccessibilityAttributes, \"hasPopup\" | \"roleDescription\" | \"title\" | \"ariaKeyShortcuts\">;\ntype AIButtonArrowButtonAccessibilityAttributes = Pick<AccessibilityAttributes, \"hasPopup\" | \"expanded\" | \"title\">;\ntype AIButtonAccessibilityAttributes = { root?: AIButtonRootAccessibilityAttributes, arrowButton?: AIButtonArrowButtonAccessibilityAttributes}\n\n/**\n * @class\n *\n * ### Overview\n *\n * The `ui5-ai-button` component serves as a button for AI-related scenarios. Users can trigger actions by clicking or tapping the `ui5-ai-button`\n * or by pressing keyboard keys like [Enter] or [Space].\n *\n * ### Usage\n *\n * For the `ui5-ai-button` user interface, you can define one or more button states by placing `ui5-ai-button-state` components in their default slot.\n * Each state has a name for identification and can include text, an icon, and an end icon, as needed for its purpose.\n * You can define a split mode for the `ui5-ai-button`, which will results in displaying an arrow button for additional actions.\n *\n * You can choose from a set of predefined designs for `ui5-ai-button` (as in `ui5-button`) to match the desired styling.\n *\n * The `ui5-ai-button` can be activated by clicking or tapping it. You can change the button state in the click event handler. When the button is\n * in split mode, you can activate the default button action by clicking or tapping it, or by pressing keyboard keys like [Enter] or [Space].\n * You can activate the arrow button by clicking or tapping it, or by pressing keyboard keys like [Arrow Up], [Arrow Down], or [F4].\n * To display additional actions, you can attach a menu to the arrow button.\n *\n * ### ES6 Module Import\n *\n * `import \"@ui5/webcomponents-ai/dist/Button.js\";`\n *\n * @constructor\n * @extends UI5Element\n * @since 2.0.0\n * @public\n * @experimental The Button and ButtonState web components are availabe since 2.0 under an experimental flag and their API and behaviour are subject to change.\n */\n\n@customElement({\n\ttag: \"ui5-ai-button\",\n\tlanguageAware: true,\n\trenderer: jsxRenderer,\n\ttemplate: ButtonTemplate,\n\tstyles: ButtonCss,\n\tshadowRootOptions: { delegatesFocus: true },\n})\n\n/**\n * Fired when the component is activated either with a\n * mouse/tap or by using the Enter or Space key.\n * @public\n */\n@event(\"click\", {\n\tbubbles: true,\n})\n\n/**\n * Fired when the component is in split mode and after the arrow button\n * is activated either by clicking or tapping it or by using the [Arrow Up] / [Arrow Down],\n * [Alt] + [Arrow Up]/ [Arrow Down], or [F4] keyboard keys.\n * @public\n */\n@event(\"arrow-button-click\", {\n\tbubbles: true,\n})\n\nclass Button extends UI5Element {\n\teventDetails!: {\n\t\t\"click\": void;\n\t\t\"arrow-button-click\": void;\n\t}\n\t/**\n\t * Defines the component design.\n\t * @default \"Default\"\n\t * @public\n\t */\n\t@property()\n\tdesign?: `${ButtonDesign}` = \"Default\"\n\n\t/**\n\t * Defines whether the component is disabled.\n\t * A disabled component can't be pressed or\n\t * focused, and it is not in the tab chain.\n\t * @default false\n\t * @public\n\t */\n\t@property({ type: Boolean })\n\tdisabled = false;\n\n\t/**\n\t * Defines the current state of the component.\n\t *\n\t * @default undefined\n\t * @public\n\t */\n\t@property()\n\tstate?: string;\n\n\t/**\n\t * Defines the active state of the arrow button in split mode.\n\t * Set to true when the button is in split mode and a menu with additional options\n\t * is opened by the arrow button. Set back to false when the menu is closed.\n\t * @default false\n\t * @public\n\t * @since 2.6.0\n\t */\n\t@property({ type: Boolean, noAttribute: true })\n\tarrowButtonPressed = false;\n\n\t/**\n \t * Defines the additional accessibility attributes that will be applied to the component.\n\t *\n\t * This property allows for fine-tuned control of ARIA attributes for screen reader support.\n\t * It accepts an object with the following optional fields:\n\t *\n\t * - **root**: Accessibility attributes that will be applied to the root element.\n\t * - **hasPopup**: Indicates the availability and type of interactive popup element (such as a menu or dialog).\n\t * Accepts string values: `\"dialog\"`, `\"grid\"`, `\"listbox\"`, `\"menu\"`, or `\"tree\"`.\n\t * - **roleDescription**: Defines a human-readable description for the button's role.\n\t * Accepts any string value.\n\t * - **title**: Specifies a tooltip or description for screen readers.\n\t * Accepts any string value.\n\t * - **ariaKeyShortcuts**: Defines keyboard shortcuts that activate or focus the button.\n\t *\n\t * - **arrowButton**: Accessibility attributes that will be applied to the arrow (split) button element.\n\t * - **hasPopup**: Indicates the type of popup triggered by the arrow button.\n\t * Accepts string values: `\"dialog\"`, `\"grid\"`, `\"listbox\"`, `\"menu\"`, or `\"tree\"`.\n\t * - **expanded**: Indicates whether the popup controlled by the arrow button is currently expanded.\n\t * Accepts boolean values: `true` or `false`.\n\t *\n\t * @public\n\t * @since 2.6.0\n\t * @default {}\n \t*/\n\t@property({ type: Object })\n\taccessibilityAttributes: AIButtonAccessibilityAttributes = {};\n\n\t/**\n\t * Keeps the current state object of the component.\n\t * @private\n\t */\n\t@property({ type: Object })\n\t_currentStateObject?: ButtonState;\n\n\t/**\n\t * Determines if the button is in icon-only mode.\n\t * This property is animation related only.\n\t * @default false\n\t * @private\n\t */\n\t@property({ type: Boolean })\n\ticonOnly? = false;\n\n\t/**\n\t * Defines the available states of the component.\n\t * **Note:** Although this slot accepts HTML Elements, it is strongly recommended that\n\t * you only use `ui5-ai-button-state` components in order to preserve the intended design.\n\t * @public\n\t */\n\t@slot({ type: HTMLElement, \"default\": true })\n\tstates!: Array<ButtonState>;\n\n\t@query(\"[ui5-split-button]\")\n\t_splitButton?: SplitButton;\n\n\t@query(\".ui5-ai-button-hidden[ui5-split-button]\")\n\t_hiddenSplitButton?: SplitButton;\n\n\t@i18n(\"@ui5/webcomponents\")\n\tstatic i18nBundle: I18nBundle;\n\n\tget _hideArrowButton() {\n\t\treturn !this._effectiveStateObject?.showArrowButton;\n\t}\n\n\tget _effectiveState() {\n\t\treturn this.state || (this.states.length && this.states[0].name) || \"\";\n\t}\n\n\tget _effectiveStateObject() {\n\t\treturn this.states.find(state => state.name === this._effectiveState);\n\t}\n\n\tget _stateIconOnly() {\n\t\treturn !this._stateText && !!this._stateIcon;\n\t}\n\n\tget _stateText() {\n\t\treturn this._currentStateObject?.text;\n\t}\n\n\tget _stateIcon() {\n\t\treturn this._currentStateObject?.icon;\n\t}\n\n\tget _stateEndIcon() {\n\t\tconst endIcon = this._effectiveStateObject?.showArrowButton ? \"\" : this._effectiveStateObject?.endIcon;\n\t\treturn endIcon;\n\t}\n\n\tget _hasText() {\n\t\treturn !!this._stateText;\n\t}\n\n\tonBeforeRendering(): void {\n\t\tconst splitButton = this._splitButton;\n\n\t\tif (splitButton) {\n\t\t\tsplitButton.activeArrowButton = this.arrowButtonPressed;\n\t\t}\n\n\t\tif (!this._currentStateObject?.name) {\n\t\t\tthis._currentStateObject = this._effectiveStateObject;\n\t\t}\n\n\t\tconst currentStateName = this._currentStateObject?.name || \"\";\n\n\t\tthis.iconOnly = this._stateIconOnly;\n\t\tif (currentStateName !== \"\" && currentStateName !== this._effectiveState) {\n\t\t\tthis._fadeOut();\n\t\t}\n\t}\n\n\t/**\n\t * Starts the fade-out animation.\n\t * @private\n\t */\n\tasync _fadeOut(): Promise<void> {\n\t\tconst fadeOutDuration = 180;\n\t\tconst button = this._splitButton;\n\t\tconst hiddenButton = this._hiddenSplitButton;\n\t\tconst newStateObject = this._effectiveStateObject;\n\n\t\tif (!newStateObject) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.warn(`State with name=\"${this.state}\" doesn't exist!`);\n\t\t\treturn;\n\t\t}\n\n\t\tif (!button || !hiddenButton) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst buttonWidth = button.offsetWidth;\n\t\tconst currentState: Partial<ButtonState> = this._currentStateObject || {};\n\n\t\tif ((!currentState.showArrowButton && newStateObject.showArrowButton) || (!currentState.endIcon && !!newStateObject.endIcon)) {\n\t\t\tthis.classList.add(\"ui5-ai-button-button-to-menu\");\n\t\t}\n\t\tif ((currentState.showArrowButton && !newStateObject.showArrowButton) || (!!currentState.endIcon && !newStateObject.endIcon)) {\n\t\t\tthis.classList.add(\"ui5-ai-button-menu-to-button\");\n\t\t}\n\n\t\tthis.style.width = `${buttonWidth}px`;\n\t\thiddenButton.icon = newStateObject.icon;\n\t\thiddenButton._endIcon = newStateObject.endIcon;\n\t\thiddenButton.textContent = newStateObject.text || null;\n\t\thiddenButton._hideArrowButton = this._hideArrowButton;\n\n\t\tawait renderFinished();\n\t\tconst hiddenButtonWidth = hiddenButton.offsetWidth;\n\t\tthis.style.width = `${hiddenButtonWidth}px`;\n\t\tthis.classList.add(\"ui5-ai-button-fade-out\");\n\n\t\tsetTimeout(() => {\n\t\t\tthis.classList.add(\"ui5-ai-button-fade-mid\");\n\t\t\tbutton._hideArrowButton = this._hideArrowButton;\n\t\t\tthis._fadeIn();\n\t\t}, fadeOutDuration);\n\t}\n\n\t/**\n\t * Starts the fade-in animation.\n\t * @private\n\t */\n\t_fadeIn(): void {\n\t\tconst fadeInDuration = 160;\n\n\t\tsetTimeout(() => {\n\t\t\tconst newStateObject = this._effectiveStateObject;\n\t\t\tthis._currentStateObject = newStateObject;\n\t\t\tthis.classList.add(\"ui5-ai-button-fade-in\");\n\t\t\tthis._resetFade();\n\t\t}, fadeInDuration);\n\t}\n\n\t/**\n\t * Resets the fade phases when the animation is completed.\n\t * @private\n\t */\n\t_resetFade(): void {\n\t\tconst fadeResetDuration = 160;\n\n\t\tsetTimeout(() => {\n\t\t\tthis.classList.remove(\"ui5-ai-button-fade-out\");\n\t\t\tthis.classList.remove(\"ui5-ai-button-fade-mid\");\n\t\t\tthis.classList.remove(\"ui5-ai-button-fade-in\");\n\t\t\tthis.classList.remove(\"ui5-ai-button-button-to-menu\");\n\t\t\tthis.classList.remove(\"ui5-ai-button-menu-to-button\");\n\t\t}, fadeResetDuration);\n\n\t\t// reset the button's width after animations\n\t\tconst button = this._splitButton;\n\n\t\tif (button) {\n\t\t\tbutton.style.width = \"\";\n\t\t}\n\t}\n\n\t/**\n\t * Handles the click event.\n\t * @private\n\t */\n\t_onClick(e: CustomEvent): void {\n\t\te.stopImmediatePropagation();\n\t\tthis.fireDecoratorEvent(\"click\");\n\t}\n\n\t/**\n\t * Handles the arrow-button-click event when `ui5-ai-button` is in split mode.\n\t * @private\n\t */\n\t_onArrowClick(e: CustomEvent): void {\n\t\te.stopImmediatePropagation();\n\t\tthis.fireDecoratorEvent(\"arrow-button-click\");\n\t}\n\n\tget _computedAccessibilityAttributes(): AIButtonAccessibilityAttributes {\n\t\tconst labelRefTexts = getAllAccessibleNameRefTexts(this) || getEffectiveAriaLabelText(this) || getAssociatedLabelForTexts(this) || \"\";\n\n\t\tconst mainTitle = this._hasText ? Button.i18nBundle.getText(BUTTON_TOOLTIP_TEXT, this._stateText as string) : \"\";\n\t\tconst title = `${mainTitle} ${labelRefTexts}`.trim();\n\n\t\treturn {\n\t\t\troot: {\n\t\t\t\thasPopup: this.accessibilityAttributes?.root?.hasPopup || \"false\",\n\t\t\t\troleDescription: this.accessibilityAttributes?.root?.roleDescription,\n\t\t\t\ttitle: this.accessibilityAttributes?.root?.title || title,\n\t\t\t\tariaKeyShortcuts: this.accessibilityAttributes?.root?.ariaKeyShortcuts,\n\t\t\t},\n\t\t\tarrowButton: {\n\t\t\t\thasPopup: this.accessibilityAttributes?.arrowButton?.hasPopup,\n\t\t\t\texpanded: this.accessibilityAttributes?.arrowButton?.expanded,\n\t\t\t\ttitle: this.accessibilityAttributes?.arrowButton?.title,\n\t\t\t},\n\t\t};\n\t}\n}\n\nButton.define();\nexport default Button;\nexport type {\n\tAIButtonAccessibilityAttributes,\n};\n"]}
|
|
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,CA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,OAAO,EAAE,IAAI;KACb,CAAC;IAEF;;;;;OAKG;;IACF,KAAK,CAAC,oBAAoB,EAAE;QAC5B,OAAO,EAAE,IAAI;KACb,CAAC;GAEI,MAAM,CAyRX;AAED,MAAM,CAAC,MAAM,EAAE,CAAC;AAChB,eAAe,MAAM,CAAC","sourcesContent":["import UI5Element from \"@ui5/webcomponents-base/dist/UI5Element.js\";\nimport { renderFinished } from \"@ui5/webcomponents-base/dist/Render.js\";\nimport customElement from \"@ui5/webcomponents-base/dist/decorators/customElement.js\";\nimport property from \"@ui5/webcomponents-base/dist/decorators/property.js\";\nimport { i18n } from \"@ui5/webcomponents-base/dist/decorators.js\";\nimport event from \"@ui5/webcomponents-base/dist/decorators/event-strict.js\";\nimport slot from \"@ui5/webcomponents-base/dist/decorators/slot.js\";\nimport query from \"@ui5/webcomponents-base/dist/decorators/query.js\";\nimport jsxRenderer from \"@ui5/webcomponents-base/dist/renderer/JsxRenderer.js\";\nimport type SplitButton from \"@ui5/webcomponents/dist/SplitButton.js\";\nimport type ButtonDesign from \"@ui5/webcomponents/dist/types/ButtonDesign.js\";\nimport type ButtonState from \"./ButtonState.js\";\nimport { BUTTON_TOOLTIP_TEXT } from \"./generated/i18n/i18n-defaults.js\";\nimport \"./ButtonState.js\";\nimport ButtonTemplate from \"./ButtonTemplate.js\";\nimport {\n\tgetEffectiveAriaLabelText,\n\tgetAssociatedLabelForTexts,\n\tgetAllAccessibleNameRefTexts,\n} from \"@ui5/webcomponents-base/dist/util/AccessibilityTextsHelper.js\";\nimport type I18nBundle from \"@ui5/webcomponents-base/dist/i18nBundle.js\";\nimport type { AccessibilityAttributes } from \"@ui5/webcomponents-base/dist/types.js\";\n\n// Styles\nimport ButtonCss from \"./generated/themes/Button.css.js\";\n\ntype AIButtonRootAccessibilityAttributes = Pick<AccessibilityAttributes, \"hasPopup\" | \"roleDescription\" | \"title\" | \"ariaKeyShortcuts\">;\ntype AIButtonArrowButtonAccessibilityAttributes = Pick<AccessibilityAttributes, \"hasPopup\" | \"expanded\" | \"title\">;\ntype AIButtonAccessibilityAttributes = { root?: AIButtonRootAccessibilityAttributes, arrowButton?: AIButtonArrowButtonAccessibilityAttributes}\n\n/**\n * @class\n *\n * ### Overview\n *\n * The `ui5-ai-button` component serves as a button for AI-related scenarios. Users can trigger actions by clicking or tapping the `ui5-ai-button`\n * or by pressing keyboard keys like [Enter] or [Space].\n *\n * ### Usage\n *\n * For the `ui5-ai-button` user interface, you can define one or more button states by placing `ui5-ai-button-state` components in their default slot.\n * Each state has a name for identification and can include text, an icon, and an end icon, as needed for its purpose.\n * You can define a split mode for the `ui5-ai-button`, which will results in displaying an arrow button for additional actions.\n *\n * You can choose from a set of predefined designs for `ui5-ai-button` (as in `ui5-button`) to match the desired styling.\n *\n * The `ui5-ai-button` can be activated by clicking or tapping it. You can change the button state in the click event handler. When the button is\n * in split mode, you can activate the default button action by clicking or tapping it, or by pressing keyboard keys like [Enter] or [Space].\n * You can activate the arrow button by clicking or tapping it, or by pressing keyboard keys like [Arrow Up], [Arrow Down], or [F4].\n * To display additional actions, you can attach a menu to the arrow button.\n *\n * ### ES6 Module Import\n *\n * `import \"@ui5/webcomponents-ai/dist/Button.js\";`\n *\n * @constructor\n * @extends UI5Element\n * @since 2.0.0\n * @public\n * @experimental The Button and ButtonState web components are availabe since 2.0 under an experimental flag and their API and behaviour are subject to change.\n */\n\n@customElement({\n\ttag: \"ui5-ai-button\",\n\tlanguageAware: true,\n\trenderer: jsxRenderer,\n\ttemplate: ButtonTemplate,\n\tstyles: ButtonCss,\n\tshadowRootOptions: { delegatesFocus: true },\n})\n\n/**\n * Fired when the component is activated either with a\n * mouse/tap or by using the Enter or Space key.\n * @public\n */\n@event(\"click\", {\n\tbubbles: true,\n})\n\n/**\n * Fired when the component is in split mode and after the arrow button\n * is activated either by clicking or tapping it or by using the [Arrow Up] / [Arrow Down],\n * [Alt] + [Arrow Up]/ [Arrow Down], or [F4] keyboard keys.\n * @public\n */\n@event(\"arrow-button-click\", {\n\tbubbles: true,\n})\n\nclass Button extends UI5Element {\n\teventDetails!: {\n\t\t\"click\": void;\n\t\t\"arrow-button-click\": void;\n\t}\n\t/**\n\t * Defines the component design.\n\t * @default \"Default\"\n\t * @public\n\t */\n\t@property()\n\tdesign?: `${ButtonDesign}` = \"Default\"\n\n\t/**\n\t * Defines whether the component is disabled.\n\t * A disabled component can't be pressed or\n\t * focused, and it is not in the tab chain.\n\t * @default false\n\t * @public\n\t */\n\t@property({ type: Boolean })\n\tdisabled = false;\n\n\t/**\n\t * Defines the current state of the component.\n\t *\n\t * @default undefined\n\t * @public\n\t */\n\t@property()\n\tstate?: string;\n\n\t/**\n\t * Defines the active state of the arrow button in split mode.\n\t * Set to true when the button is in split mode and a menu with additional options\n\t * is opened by the arrow button. Set back to false when the menu is closed.\n\t * @default false\n\t * @public\n\t * @since 2.6.0\n\t */\n\t@property({ type: Boolean, noAttribute: true })\n\tarrowButtonPressed = false;\n\n\t/**\n \t * Defines the additional accessibility attributes that will be applied to the component.\n\t *\n\t * This property allows for fine-tuned control of ARIA attributes for screen reader support.\n\t * It accepts an object with the following optional fields:\n\t *\n\t * - **root**: Accessibility attributes that will be applied to the root element.\n\t * - **hasPopup**: Indicates the availability and type of interactive popup element (such as a menu or dialog).\n\t * Accepts string values: `\"dialog\"`, `\"grid\"`, `\"listbox\"`, `\"menu\"`, or `\"tree\"`.\n\t * - **roleDescription**: Defines a human-readable description for the button's role.\n\t * Accepts any string value.\n\t * - **title**: Specifies a tooltip or description for screen readers.\n\t * Accepts any string value.\n\t * - **ariaKeyShortcuts**: Defines keyboard shortcuts that activate or focus the button.\n\t *\n\t * - **arrowButton**: Accessibility attributes that will be applied to the arrow (split) button element.\n\t * - **hasPopup**: Indicates the type of popup triggered by the arrow button.\n\t * Accepts string values: `\"dialog\"`, `\"grid\"`, `\"listbox\"`, `\"menu\"`, or `\"tree\"`.\n\t * - **expanded**: Indicates whether the popup controlled by the arrow button is currently expanded.\n\t * Accepts boolean values: `true` or `false`.\n\t *\n\t * @public\n\t * @since 2.6.0\n\t * @default {}\n \t*/\n\t@property({ type: Object })\n\taccessibilityAttributes: AIButtonAccessibilityAttributes = {};\n\n\t/**\n\t * Keeps the current state object of the component.\n\t * @private\n\t */\n\t@property({ type: Object })\n\t_currentStateObject?: ButtonState;\n\n\t/**\n\t * Determines if the button is in icon-only mode.\n\t * This property is animation related only.\n\t * @default false\n\t * @private\n\t */\n\t@property({ type: Boolean })\n\ticonOnly? = false;\n\n\t/**\n\t * Defines the available states of the component.\n\t * **Note:** Although this slot accepts HTML Elements, it is strongly recommended that\n\t * you only use `ui5-ai-button-state` components in order to preserve the intended design.\n\t * @public\n\t */\n\t@slot({ type: HTMLElement, \"default\": true })\n\tstates!: Array<ButtonState>;\n\n\t@query(\"[ui5-split-button]\")\n\t_splitButton?: SplitButton;\n\n\t@query(\".ui5-ai-button-hidden[ui5-split-button]\")\n\t_hiddenSplitButton?: SplitButton;\n\n\t@i18n(\"@ui5/webcomponents-ai\")\n\tstatic i18nBundleAi: I18nBundle;\n\n\tget _hideArrowButton() {\n\t\treturn !this._effectiveStateObject?.showArrowButton;\n\t}\n\n\tget _effectiveState() {\n\t\treturn this.state || (this.states.length && this.states[0].name) || \"\";\n\t}\n\n\tget _effectiveStateObject() {\n\t\treturn this.states.find(state => state.name === this._effectiveState);\n\t}\n\n\tget _stateIconOnly() {\n\t\treturn !this._stateText && !!this._stateIcon;\n\t}\n\n\tget _stateText() {\n\t\treturn this._currentStateObject?.text;\n\t}\n\n\tget _stateIcon() {\n\t\treturn this._currentStateObject?.icon;\n\t}\n\n\tget _stateEndIcon() {\n\t\tconst endIcon = this._effectiveStateObject?.showArrowButton ? \"\" : this._effectiveStateObject?.endIcon;\n\t\treturn endIcon;\n\t}\n\n\tget _hasText() {\n\t\treturn !!this._stateText;\n\t}\n\n\tonBeforeRendering(): void {\n\t\tconst splitButton = this._splitButton;\n\n\t\tif (splitButton) {\n\t\t\tsplitButton.activeArrowButton = this.arrowButtonPressed;\n\t\t}\n\n\t\tif (!this._currentStateObject?.name) {\n\t\t\tthis._currentStateObject = this._effectiveStateObject;\n\t\t}\n\n\t\tconst currentStateName = this._currentStateObject?.name || \"\";\n\n\t\tthis.iconOnly = this._stateIconOnly;\n\t\tif (currentStateName !== \"\" && currentStateName !== this._effectiveState) {\n\t\t\tthis._fadeOut();\n\t\t}\n\t}\n\n\t/**\n\t * Starts the fade-out animation.\n\t * @private\n\t */\n\tasync _fadeOut(): Promise<void> {\n\t\tconst fadeOutDuration = 180;\n\t\tconst button = this._splitButton;\n\t\tconst hiddenButton = this._hiddenSplitButton;\n\t\tconst newStateObject = this._effectiveStateObject;\n\n\t\tif (!newStateObject) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.warn(`State with name=\"${this.state}\" doesn't exist!`);\n\t\t\treturn;\n\t\t}\n\n\t\tif (!button || !hiddenButton) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst buttonWidth = button.offsetWidth;\n\t\tconst currentState: Partial<ButtonState> = this._currentStateObject || {};\n\n\t\tif ((!currentState.showArrowButton && newStateObject.showArrowButton) || (!currentState.endIcon && !!newStateObject.endIcon)) {\n\t\t\tthis.classList.add(\"ui5-ai-button-button-to-menu\");\n\t\t}\n\t\tif ((currentState.showArrowButton && !newStateObject.showArrowButton) || (!!currentState.endIcon && !newStateObject.endIcon)) {\n\t\t\tthis.classList.add(\"ui5-ai-button-menu-to-button\");\n\t\t}\n\n\t\tthis.style.width = `${buttonWidth}px`;\n\t\thiddenButton.icon = newStateObject.icon;\n\t\thiddenButton._endIcon = newStateObject.endIcon;\n\t\thiddenButton.textContent = newStateObject.text || null;\n\t\thiddenButton._hideArrowButton = this._hideArrowButton;\n\n\t\tawait renderFinished();\n\t\tconst hiddenButtonWidth = hiddenButton.offsetWidth;\n\t\tthis.style.width = `${hiddenButtonWidth}px`;\n\t\tthis.classList.add(\"ui5-ai-button-fade-out\");\n\n\t\tsetTimeout(() => {\n\t\t\tthis.classList.add(\"ui5-ai-button-fade-mid\");\n\t\t\tbutton._hideArrowButton = this._hideArrowButton;\n\t\t\tthis._fadeIn();\n\t\t}, fadeOutDuration);\n\t}\n\n\t/**\n\t * Starts the fade-in animation.\n\t * @private\n\t */\n\t_fadeIn(): void {\n\t\tconst fadeInDuration = 160;\n\n\t\tsetTimeout(() => {\n\t\t\tconst newStateObject = this._effectiveStateObject;\n\t\t\tthis._currentStateObject = newStateObject;\n\t\t\tthis.classList.add(\"ui5-ai-button-fade-in\");\n\t\t\tthis._resetFade();\n\t\t}, fadeInDuration);\n\t}\n\n\t/**\n\t * Resets the fade phases when the animation is completed.\n\t * @private\n\t */\n\t_resetFade(): void {\n\t\tconst fadeResetDuration = 160;\n\n\t\tsetTimeout(() => {\n\t\t\tthis.classList.remove(\"ui5-ai-button-fade-out\");\n\t\t\tthis.classList.remove(\"ui5-ai-button-fade-mid\");\n\t\t\tthis.classList.remove(\"ui5-ai-button-fade-in\");\n\t\t\tthis.classList.remove(\"ui5-ai-button-button-to-menu\");\n\t\t\tthis.classList.remove(\"ui5-ai-button-menu-to-button\");\n\t\t}, fadeResetDuration);\n\n\t\t// reset the button's width after animations\n\t\tconst button = this._splitButton;\n\n\t\tif (button) {\n\t\t\tbutton.style.width = \"\";\n\t\t}\n\t}\n\n\t/**\n\t * Handles the click event.\n\t * @private\n\t */\n\t_onClick(e: CustomEvent): void {\n\t\te.stopImmediatePropagation();\n\t\tthis.fireDecoratorEvent(\"click\");\n\t}\n\n\t/**\n\t * Handles the arrow-button-click event when `ui5-ai-button` is in split mode.\n\t * @private\n\t */\n\t_onArrowClick(e: CustomEvent): void {\n\t\te.stopImmediatePropagation();\n\t\tthis.fireDecoratorEvent(\"arrow-button-click\");\n\t}\n\n\tget _computedAccessibilityAttributes(): AIButtonAccessibilityAttributes {\n\t\tconst labelRefTexts = getAllAccessibleNameRefTexts(this) || getEffectiveAriaLabelText(this) || getAssociatedLabelForTexts(this) || \"\";\n\n\t\tconst mainTitle = this._hasText ? Button.i18nBundleAi.getText(BUTTON_TOOLTIP_TEXT, this._stateText as string) : \"\";\n\t\tconst title = `${mainTitle} ${labelRefTexts}`.trim();\n\n\t\treturn {\n\t\t\troot: {\n\t\t\t\thasPopup: this.accessibilityAttributes?.root?.hasPopup || \"false\",\n\t\t\t\troleDescription: this.accessibilityAttributes?.root?.roleDescription,\n\t\t\t\ttitle: this.accessibilityAttributes?.root?.title || title,\n\t\t\t\tariaKeyShortcuts: this.accessibilityAttributes?.root?.ariaKeyShortcuts,\n\t\t\t},\n\t\t\tarrowButton: {\n\t\t\t\thasPopup: this.accessibilityAttributes?.arrowButton?.hasPopup,\n\t\t\t\texpanded: this.accessibilityAttributes?.arrowButton?.expanded,\n\t\t\t\ttitle: this.accessibilityAttributes?.arrowButton?.title,\n\t\t\t},\n\t\t};\n\t}\n}\n\nButton.define();\nexport default Button;\nexport type {\n\tAIButtonAccessibilityAttributes,\n};\n"]}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import TextArea from "@ui5/webcomponents/dist/TextArea.js";
|
|
2
|
+
import type I18nBundle from "@ui5/webcomponents-base/dist/i18nBundle.js";
|
|
3
|
+
/**
|
|
4
|
+
* @class
|
|
5
|
+
*
|
|
6
|
+
* ### Overview
|
|
7
|
+
*
|
|
8
|
+
* The `ui5-ai-textarea` component extends the standard TextArea with AI Writing Assistant capabilities.
|
|
9
|
+
* It provides AI-powered text generation, editing suggestions, and version management functionality.
|
|
10
|
+
*
|
|
11
|
+
* ### Structure
|
|
12
|
+
* The `ui5-ai-textarea` consists of the following elements:
|
|
13
|
+
* - TextArea: The main text input area with all standard textarea functionality
|
|
14
|
+
* - AI Toolbar: Specialized toolbar with AI generation controls
|
|
15
|
+
* - Version Navigation: Controls for navigating between AI-generated versions
|
|
16
|
+
* - Menu Integration: Support for AI action menu
|
|
17
|
+
*
|
|
18
|
+
* Single vs multiple result display is determined internally based on totalVersions count.
|
|
19
|
+
*
|
|
20
|
+
* ### ES6 Module Import
|
|
21
|
+
*
|
|
22
|
+
* `import "@sap-webcomponents/ai/dist/TextArea.js";`
|
|
23
|
+
*
|
|
24
|
+
* @constructor
|
|
25
|
+
* @extends TextArea
|
|
26
|
+
* @since 2.16.0
|
|
27
|
+
* @public
|
|
28
|
+
* @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.
|
|
29
|
+
*/
|
|
30
|
+
declare class AITextArea extends TextArea {
|
|
31
|
+
eventDetails: TextArea["eventDetails"] & {
|
|
32
|
+
"version-change": {
|
|
33
|
+
backwards: boolean;
|
|
34
|
+
};
|
|
35
|
+
"stop-generation": object;
|
|
36
|
+
};
|
|
37
|
+
private _keydownHandler?;
|
|
38
|
+
/**
|
|
39
|
+
* Defines whether the `ui5-ai-textarea` is currently in a loading(processing) state.
|
|
40
|
+
*
|
|
41
|
+
* @default false
|
|
42
|
+
* @public
|
|
43
|
+
*/
|
|
44
|
+
loading: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Defines the action text of the AI Writing Assistant.
|
|
47
|
+
*
|
|
48
|
+
* @default ""
|
|
49
|
+
* @public
|
|
50
|
+
*/
|
|
51
|
+
actionText: string;
|
|
52
|
+
/**
|
|
53
|
+
* Indicates the index of the currently displayed result version.
|
|
54
|
+
*
|
|
55
|
+
* The index is **1-based** (i.e. `1` represents the first result).
|
|
56
|
+
*
|
|
57
|
+
* @default 1
|
|
58
|
+
* @public
|
|
59
|
+
*/
|
|
60
|
+
currentVersionIndex: number;
|
|
61
|
+
/**
|
|
62
|
+
* Indicates the total number of result versions available.
|
|
63
|
+
*
|
|
64
|
+
* @default 1
|
|
65
|
+
* @public
|
|
66
|
+
*/
|
|
67
|
+
totalVersions: number;
|
|
68
|
+
menu: Array<HTMLElement>;
|
|
69
|
+
static i18nBundle: I18nBundle;
|
|
70
|
+
static onDefine(): Promise<void>;
|
|
71
|
+
/**
|
|
72
|
+
* Handles the click event for the "Previous Version" button.
|
|
73
|
+
* Updates the current version index and syncs content.
|
|
74
|
+
*/
|
|
75
|
+
_handlePreviousVersionClick(): void;
|
|
76
|
+
/**
|
|
77
|
+
* Handles the click event for the "Next Version" button.
|
|
78
|
+
* Updates the current version index and syncs content.
|
|
79
|
+
*/
|
|
80
|
+
_handleNextVersionClick(): void;
|
|
81
|
+
/**
|
|
82
|
+
* Handles the version change event from the writing assistant.
|
|
83
|
+
*/
|
|
84
|
+
_handleVersionChange(e: CustomEvent<{
|
|
85
|
+
backwards: boolean;
|
|
86
|
+
}>): void;
|
|
87
|
+
/**
|
|
88
|
+
* Handles keydown events for keyboard shortcuts.
|
|
89
|
+
* @private
|
|
90
|
+
*/
|
|
91
|
+
_handleKeydown(keyboardEvent: KeyboardEvent): void;
|
|
92
|
+
/**
|
|
93
|
+
* Overrides the parent's onAfterRendering to add keydown handler.
|
|
94
|
+
* @private
|
|
95
|
+
*/
|
|
96
|
+
onAfterRendering(): void;
|
|
97
|
+
/**
|
|
98
|
+
* Handles the generate click event from the AI toolbar.
|
|
99
|
+
* Opens the AI menu and sets the opener element.
|
|
100
|
+
*
|
|
101
|
+
* @private
|
|
102
|
+
*/
|
|
103
|
+
_handleAIButtonClick: (e: CustomEvent<{
|
|
104
|
+
clickTarget?: HTMLElement;
|
|
105
|
+
}>) => void;
|
|
106
|
+
get _ariaLabel(): string;
|
|
107
|
+
/**
|
|
108
|
+
* Handles the stop generation event from the AI toolbar.
|
|
109
|
+
* Fires the stop-generation event to notify listeners.
|
|
110
|
+
*
|
|
111
|
+
* @private
|
|
112
|
+
*/
|
|
113
|
+
handleStopGeneration: () => void;
|
|
114
|
+
}
|
|
115
|
+
export default AITextArea;
|
package/dist/TextArea.js
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
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 AITextArea_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 TextArea from "@ui5/webcomponents/dist/TextArea.js";
|
|
14
|
+
import BusyIndicator from "@ui5/webcomponents/dist/BusyIndicator.js";
|
|
15
|
+
import { getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js";
|
|
16
|
+
import { WRITING_ASSISTANT_LABEL, } from "./generated/i18n/i18n-defaults.js";
|
|
17
|
+
// Styles
|
|
18
|
+
import AITextAreaCss from "./generated/themes/AITextArea.css.js";
|
|
19
|
+
import textareaStyles from "@ui5/webcomponents/dist/generated/themes/TextArea.css.js";
|
|
20
|
+
import valueStateMessageStyles from "@ui5/webcomponents/dist/generated/themes/ValueStateMessage.css.js";
|
|
21
|
+
// Templates
|
|
22
|
+
import TextAreaTemplate from "./TextAreaTemplate.js";
|
|
23
|
+
import WritingAssistant from "./WritingAssistant.js";
|
|
24
|
+
/**
|
|
25
|
+
* @class
|
|
26
|
+
*
|
|
27
|
+
* ### Overview
|
|
28
|
+
*
|
|
29
|
+
* The `ui5-ai-textarea` component extends the standard TextArea with AI Writing Assistant capabilities.
|
|
30
|
+
* It provides AI-powered text generation, editing suggestions, and version management functionality.
|
|
31
|
+
*
|
|
32
|
+
* ### Structure
|
|
33
|
+
* The `ui5-ai-textarea` consists of the following elements:
|
|
34
|
+
* - TextArea: The main text input area with all standard textarea functionality
|
|
35
|
+
* - AI Toolbar: Specialized toolbar with AI generation controls
|
|
36
|
+
* - Version Navigation: Controls for navigating between AI-generated versions
|
|
37
|
+
* - Menu Integration: Support for AI action menu
|
|
38
|
+
*
|
|
39
|
+
* Single vs multiple result display is determined internally based on totalVersions count.
|
|
40
|
+
*
|
|
41
|
+
* ### ES6 Module Import
|
|
42
|
+
*
|
|
43
|
+
* `import "@sap-webcomponents/ai/dist/TextArea.js";`
|
|
44
|
+
*
|
|
45
|
+
* @constructor
|
|
46
|
+
* @extends TextArea
|
|
47
|
+
* @since 2.16.0
|
|
48
|
+
* @public
|
|
49
|
+
* @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.
|
|
50
|
+
*/
|
|
51
|
+
let AITextArea = AITextArea_1 = class AITextArea extends TextArea {
|
|
52
|
+
constructor() {
|
|
53
|
+
super(...arguments);
|
|
54
|
+
/**
|
|
55
|
+
* Defines whether the `ui5-ai-textarea` is currently in a loading(processing) state.
|
|
56
|
+
*
|
|
57
|
+
* @default false
|
|
58
|
+
* @public
|
|
59
|
+
*/
|
|
60
|
+
this.loading = false;
|
|
61
|
+
/**
|
|
62
|
+
* Defines the action text of the AI Writing Assistant.
|
|
63
|
+
*
|
|
64
|
+
* @default ""
|
|
65
|
+
* @public
|
|
66
|
+
*/
|
|
67
|
+
this.actionText = "";
|
|
68
|
+
/**
|
|
69
|
+
* Indicates the index of the currently displayed result version.
|
|
70
|
+
*
|
|
71
|
+
* The index is **1-based** (i.e. `1` represents the first result).
|
|
72
|
+
*
|
|
73
|
+
* @default 1
|
|
74
|
+
* @public
|
|
75
|
+
*/
|
|
76
|
+
this.currentVersionIndex = 1;
|
|
77
|
+
/**
|
|
78
|
+
* Indicates the total number of result versions available.
|
|
79
|
+
*
|
|
80
|
+
* @default 1
|
|
81
|
+
* @public
|
|
82
|
+
*/
|
|
83
|
+
this.totalVersions = 1;
|
|
84
|
+
/**
|
|
85
|
+
* Handles the generate click event from the AI toolbar.
|
|
86
|
+
* Opens the AI menu and sets the opener element.
|
|
87
|
+
*
|
|
88
|
+
* @private
|
|
89
|
+
*/
|
|
90
|
+
this._handleAIButtonClick = (e) => {
|
|
91
|
+
const menuNodes = this.getSlottedNodes("menu");
|
|
92
|
+
if (menuNodes.length === 0) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
if (!e.detail?.clickTarget) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const menu = menuNodes[0];
|
|
99
|
+
if (menu && typeof menu.open !== "undefined") {
|
|
100
|
+
menu.opener = e.detail.clickTarget;
|
|
101
|
+
menu.open = true;
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Handles the stop generation event from the AI toolbar.
|
|
106
|
+
* Fires the stop-generation event to notify listeners.
|
|
107
|
+
*
|
|
108
|
+
* @private
|
|
109
|
+
*/
|
|
110
|
+
this.handleStopGeneration = () => {
|
|
111
|
+
this.fireDecoratorEvent("stop-generation");
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
static async onDefine() {
|
|
115
|
+
AITextArea_1.i18nBundle = await getI18nBundle("@ui5/webcomponents-ai");
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Handles the click event for the "Previous Version" button.
|
|
119
|
+
* Updates the current version index and syncs content.
|
|
120
|
+
*/
|
|
121
|
+
_handlePreviousVersionClick() {
|
|
122
|
+
this.fireDecoratorEvent("version-change", { backwards: true });
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Handles the click event for the "Next Version" button.
|
|
126
|
+
* Updates the current version index and syncs content.
|
|
127
|
+
*/
|
|
128
|
+
_handleNextVersionClick() {
|
|
129
|
+
this.fireDecoratorEvent("version-change", { backwards: false });
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Handles the version change event from the writing assistant.
|
|
133
|
+
*/
|
|
134
|
+
_handleVersionChange(e) {
|
|
135
|
+
if (e.detail.backwards) {
|
|
136
|
+
this._handlePreviousVersionClick();
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
this._handleNextVersionClick();
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Handles keydown events for keyboard shortcuts.
|
|
144
|
+
* @private
|
|
145
|
+
*/
|
|
146
|
+
_handleKeydown(keyboardEvent) {
|
|
147
|
+
const isCtrlOrCmd = keyboardEvent.ctrlKey || keyboardEvent.metaKey;
|
|
148
|
+
const isShift = keyboardEvent.shiftKey;
|
|
149
|
+
if (isShift && keyboardEvent.key.toLowerCase() === "f4") {
|
|
150
|
+
const toolbar = this.shadowRoot?.querySelector("[ui5-ai-writing-assistant]");
|
|
151
|
+
const aiButton = toolbar?.shadowRoot?.querySelector("#ai-menu-btn");
|
|
152
|
+
if (aiButton) {
|
|
153
|
+
aiButton.focus();
|
|
154
|
+
}
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
if (this.totalVersions > 1) {
|
|
158
|
+
if (isCtrlOrCmd && isShift && keyboardEvent.key.toLowerCase() === "z") {
|
|
159
|
+
keyboardEvent.preventDefault();
|
|
160
|
+
this._handlePreviousVersionClick();
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
if (isCtrlOrCmd && isShift && keyboardEvent.key.toLowerCase() === "y") {
|
|
164
|
+
keyboardEvent.preventDefault();
|
|
165
|
+
this._handleNextVersionClick();
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Overrides the parent's onAfterRendering to add keydown handler.
|
|
171
|
+
* @private
|
|
172
|
+
*/
|
|
173
|
+
onAfterRendering() {
|
|
174
|
+
super.onAfterRendering();
|
|
175
|
+
// Add keydown event listener to the textarea
|
|
176
|
+
const textarea = this.shadowRoot?.querySelector("textarea");
|
|
177
|
+
if (textarea && !this._keydownHandler) {
|
|
178
|
+
this._keydownHandler = this._handleKeydown.bind(this);
|
|
179
|
+
textarea.addEventListener("keydown", this._keydownHandler);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
get _ariaLabel() {
|
|
183
|
+
return this.accessibleName || AITextArea_1.i18nBundle.getText(WRITING_ASSISTANT_LABEL);
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
__decorate([
|
|
187
|
+
property({ type: Boolean })
|
|
188
|
+
], AITextArea.prototype, "loading", void 0);
|
|
189
|
+
__decorate([
|
|
190
|
+
property()
|
|
191
|
+
], AITextArea.prototype, "actionText", void 0);
|
|
192
|
+
__decorate([
|
|
193
|
+
property({ type: Number })
|
|
194
|
+
], AITextArea.prototype, "currentVersionIndex", void 0);
|
|
195
|
+
__decorate([
|
|
196
|
+
property({ type: Number })
|
|
197
|
+
], AITextArea.prototype, "totalVersions", void 0);
|
|
198
|
+
__decorate([
|
|
199
|
+
slot({ type: HTMLElement })
|
|
200
|
+
], AITextArea.prototype, "menu", void 0);
|
|
201
|
+
AITextArea = AITextArea_1 = __decorate([
|
|
202
|
+
customElement({
|
|
203
|
+
tag: "ui5-ai-textarea",
|
|
204
|
+
languageAware: true,
|
|
205
|
+
renderer: jsxRenderer,
|
|
206
|
+
template: TextAreaTemplate,
|
|
207
|
+
styles: [
|
|
208
|
+
textareaStyles,
|
|
209
|
+
valueStateMessageStyles,
|
|
210
|
+
AITextAreaCss,
|
|
211
|
+
],
|
|
212
|
+
dependencies: [
|
|
213
|
+
WritingAssistant,
|
|
214
|
+
BusyIndicator,
|
|
215
|
+
],
|
|
216
|
+
})
|
|
217
|
+
/**
|
|
218
|
+
* Fired when the user clicks on version navigation buttons.
|
|
219
|
+
*
|
|
220
|
+
* @public
|
|
221
|
+
*/
|
|
222
|
+
,
|
|
223
|
+
event("version-change")
|
|
224
|
+
/**
|
|
225
|
+
* Fired when the user requests to stop AI text generation.
|
|
226
|
+
*
|
|
227
|
+
* @public
|
|
228
|
+
*/
|
|
229
|
+
,
|
|
230
|
+
event("stop-generation")
|
|
231
|
+
], AITextArea);
|
|
232
|
+
AITextArea.define();
|
|
233
|
+
export default AITextArea;
|
|
234
|
+
//# 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,QAAQ,MAAM,qCAAqC,CAAC;AAC3D,OAAO,aAAa,MAAM,0CAA0C,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,4CAA4C,CAAC;AAE3E,OAAO,EACN,uBAAuB,GACvB,MAAM,mCAAmC,CAAC;AAC3C,SAAS;AACT,OAAO,aAAa,MAAM,sCAAsC,CAAC;AACjE,OAAO,cAAc,MAAM,0DAA0D,CAAC;AACtF,OAAO,uBAAuB,MAAM,mEAAmE,CAAC;AAExG,YAAY;AACZ,OAAO,gBAAgB,MAAM,uBAAuB,CAAC;AACrD,OAAO,gBAAgB,MAAM,uBAAuB,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AA+BH,IAAM,UAAU,kBAAhB,MAAM,UAAW,SAAQ,QAAQ;IAAjC;;QAWC;;;;;WAKG;QAEH,YAAO,GAAG,KAAK,CAAC;QAEhB;;;;;WAKG;QAEH,eAAU,GAAG,EAAE,CAAC;QAEhB;;;;;;;WAOG;QAEH,wBAAmB,GAAG,CAAC,CAAC;QAExB;;;;;WAKG;QAEH,kBAAa,GAAG,CAAC,CAAC;QAqFlB;;;;;WAKG;QACH,yBAAoB,GAAG,CAAC,C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,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACtD,QAAQ,CAAC,gBAAgB,CAAC,SAAS,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;QAC5D,CAAC;IACF,CAAC;IAuBD,IAAI,UAAU;QACb,OAAO,IAAI,CAAC,cAAc,IAAI,YAAU,CAAC,UAAU,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACtF,CAAC;CAWD,CAAA;AApJA;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;2CACZ;AAShB;IADC,QAAQ,EAAE;8CACK;AAWhB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uDACH;AASxB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iDACT;AAGlB;IADC,IAAI,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;wCACF;AAlDrB,UAAU;IA9Bf,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,aAAa;SACb;QACD,YAAY,EAAE;YACb,gBAAgB;YAChB,aAAa;SACb;KACD,CAAC;IAEF;;;;OAIG;;IACF,KAAK,CAAC,gBAAgB,CAAC;IAExB;;;;OAIG;;IACF,KAAK,CAAC,iBAAiB,CAAC;GAEnB,UAAU,CAsKf;AAED,UAAU,CAAC,MAAM,EAAE,CAAC;AAEpB,eAAe,UAAU,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 TextArea from \"@ui5/webcomponents/dist/TextArea.js\";\nimport BusyIndicator from \"@ui5/webcomponents/dist/BusyIndicator.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 AITextAreaCss from \"./generated/themes/AITextArea.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\";\nimport WritingAssistant from \"./WritingAssistant.js\";\n\n/**\n * @class\n *\n * ### Overview\n *\n * The `ui5-ai-textarea` component extends the standard TextArea with AI 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 * - AI Toolbar: Specialized toolbar with AI generation controls\n * - Version Navigation: Controls for navigating between AI-generated versions\n * - Menu Integration: Support for AI action menu\n *\n * Single vs multiple result display is determined internally based on totalVersions count.\n *\n * ### ES6 Module Import\n *\n * `import \"@sap-webcomponents/ai/dist/TextArea.js\";`\n *\n * @constructor\n * @extends TextArea\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\tAITextAreaCss,\n\t],\n\tdependencies: [\n\t\tWritingAssistant,\n\t\tBusyIndicator,\n\t],\n})\n\n/**\n * Fired when the user clicks on version navigation buttons.\n *\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 AITextArea extends TextArea {\n\teventDetails!: TextArea[\"eventDetails\"] & {\n\t\t\"version-change\": {\n\t\t\tbackwards: boolean;\n\t\t};\n\t\t\"stop-generation\": object;\n\t};\n\n\t// Store bound handler for proper cleanup\n\tprivate _keydownHandler?: (event: KeyboardEvent) => 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 action text of the AI Writing Assistant.\n\t *\n\t * @default \"\"\n\t * @public\n\t */\n\t@property()\n\tactionText = \"\";\n\n\t/**\n\t * Indicates the index of the currently displayed result version.\n\t *\n\t * The index is **1-based** (i.e. `1` represents the first result).\n\t *\n\t * @default 1\n\t * @public\n\t */\n\t@property({ type: Number })\n\tcurrentVersionIndex = 1;\n\n\t/**\n\t * Indicates the total number of result versions available.\n\t *\n\t * @default 1\n\t * @public\n\t */\n\t@property({ type: Number })\n\ttotalVersions = 1;\n\n\t@slot({ type: HTMLElement })\n\tmenu!: Array<HTMLElement>;\n\n\tstatic i18nBundle: I18nBundle;\n\n\tstatic async onDefine() {\n\t\tAITextArea.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\t// Add keydown event listener to the textarea\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\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 };\n\t\tif (menu && typeof menu.open !== \"undefined\") {\n\t\t\tmenu.opener = e.detail.clickTarget;\n\t\t\tmenu.open = true;\n\t\t}\n\t}\n\tget _ariaLabel() {\n\t\treturn this.accessibleName || AITextArea.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\nAITextArea.define();\n\nexport default AITextArea;\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, currentVersionIndex: this.currentVersionIndex, totalVersions: this.totalVersions, actionText: this.actionText, 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.actionText : "" }), _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,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GACd,GACI,EAChB,cAAK,IAAI,EAAC,QAAQ,YACjB,eAAM,IAAI,EAAC,QAAQ,YAClB,KAAC,gBAAgB,IAChB,OAAO,EAAE,IAAI,CAAC,OAAO,EACrB,mBAAmB,EAAE,IAAI,CAAC,mBAAmB,EAC7C,aAAa,EAAE,IAAI,CAAC,aAAa,EACjC,UAAU,EAAE,IAAI,CAAC,UAAU,EAC3B,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,UAAU,CAAC,CAAC,CAAC,EAAE,GAC/B,EAEN,cAAK,EAAE,EAAC,iBAAiB,YACxB,eAAM,IAAI,EAAC,MAAM,GAAQ,GACpB,IACD,CACN,CAAC;AACH,CAAC","sourcesContent":["import type AITextArea 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: AITextArea) {\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\tcurrentVersionIndex={this.currentVersionIndex}\n\t\t\t\t\t\t\t\ttotalVersions={this.totalVersions}\n\t\t\t\t\t\t\t\tactionText={this.actionText}\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.actionText : \"\"}\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;
|