Skip to content

Commit 0b0b516

Browse files
chore(ui5-ai-input): update samples and tooltips (#12600)
1 parent 0d36c6a commit 0b0b516

File tree

12 files changed

+30
-223
lines changed

12 files changed

+30
-223
lines changed

packages/ai/cypress/specs/Input.cy.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Input from "../../src/Input.js";
22
import MenuItem from "@ui5/webcomponents/dist/MenuItem.js";
33
import "@ui5/webcomponents-icons/dist/ai.js";
44
import "@ui5/webcomponents-icons/dist/stop.js";
5-
import { VERSIONING_NEXT_BUTTON_TOOLTIP, VERSIONING_PREVIOUS_BUTTON_TOOLTIP, INPUT_WRITING_ASSISTANT_LABEL } from "../../src/generated/i18n/i18n-defaults.js";
5+
import { INPUT_VERSIONING_NEXT_BUTTON_TOOLTIP, INPUT_VERSIONING_PREVIOUS_BUTTON_TOOLTIP, INPUT_WRITING_ASSISTANT_BUTTON_TOOLTIP } from "../../src/generated/i18n/i18n-defaults.js";
66

77
describe("Basic", () => {
88
describe("Initialization", () => {
@@ -690,7 +690,7 @@ describe("Versioning Menu Item", () => {
690690
cy.get("[ui5-ai-input]")
691691
.shadow()
692692
.find('[data-ui5-versioning-button="previous"]')
693-
.should("have.attr", "tooltip", VERSIONING_PREVIOUS_BUTTON_TOOLTIP.defaultText);
693+
.should("have.attr", "tooltip", INPUT_VERSIONING_PREVIOUS_BUTTON_TOOLTIP.defaultText);
694694
});
695695

696696
it("should have translatable next button tooltip", () => {
@@ -699,7 +699,7 @@ describe("Versioning Menu Item", () => {
699699
cy.get("[ui5-ai-input]")
700700
.shadow()
701701
.find('[data-ui5-versioning-button="next"]')
702-
.should("have.attr", "tooltip", VERSIONING_NEXT_BUTTON_TOOLTIP.defaultText);
702+
.should("have.attr", "tooltip", INPUT_VERSIONING_NEXT_BUTTON_TOOLTIP.defaultText);
703703
});
704704
});
705705
});
@@ -807,7 +807,7 @@ describe("Writing Assistant Input Icon", () => {
807807
cy.get("[ui5-ai-input]")
808808
.shadow()
809809
.find("input")
810-
.should("have.attr", "aria-label", INPUT_WRITING_ASSISTANT_LABEL.defaultText);
810+
.should("have.attr", "aria-label", INPUT_WRITING_ASSISTANT_BUTTON_TOOLTIP.defaultText);
811811
});
812812
})
813813

packages/ai/src/Input.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ import ValueStateMessageCss from "@ui5/webcomponents/dist/generated/themes/Value
2020
// templates
2121
import InputTemplate from "./InputTemplate.js";
2222
import {
23-
VERSIONING_NEXT_BUTTON_TEXT,
24-
VERSIONING_PREVIOUS_BUTTON_TEXT,
25-
INPUT_WRITING_ASSISTANT_LABEL,
23+
INPUT_VERSIONING_NEXT_BUTTON_TOOLTIP,
24+
INPUT_VERSIONING_PREVIOUS_BUTTON_TOOLTIP,
25+
INPUT_WRITING_ASSISTANT_BUTTON_TOOLTIP,
2626
WRITING_ASSISTANT_GENERATING_ANNOUNCEMENT,
2727
} from "./generated/i18n/i18n-defaults.js";
2828

@@ -293,19 +293,19 @@ class Input extends BaseInput {
293293
}
294294

295295
get ariaLabel() {
296-
return this.accessibleName || !this.loading ? Input.i18nBundle.getText(INPUT_WRITING_ASSISTANT_LABEL) : Input.i18nBundle.getText(WRITING_ASSISTANT_GENERATING_ANNOUNCEMENT);
296+
return this.accessibleName || !this.loading ? Input.i18nBundle.getText(INPUT_WRITING_ASSISTANT_BUTTON_TOOLTIP) : Input.i18nBundle.getText(WRITING_ASSISTANT_GENERATING_ANNOUNCEMENT);
297297
}
298298

299299
get stopGeneratingTooltip() {
300300
return Input.i18nBundle.getText(WRITING_ASSISTANT_GENERATING_ANNOUNCEMENT);
301301
}
302302

303303
get nextButtonAccessibleName() {
304-
return Input.i18nBundle.getText(VERSIONING_NEXT_BUTTON_TEXT);
304+
return Input.i18nBundle.getText(INPUT_VERSIONING_NEXT_BUTTON_TOOLTIP);
305305
}
306306

307307
get previousButtonAccessibleName() {
308-
return Input.i18nBundle.getText(VERSIONING_PREVIOUS_BUTTON_TEXT);
308+
return Input.i18nBundle.getText(INPUT_VERSIONING_PREVIOUS_BUTTON_TOOLTIP);
309309
}
310310

311311
get menu() {

packages/ai/src/InputTemplate.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type Input from "./Input.js";
22
import Icon from "@ui5/webcomponents/dist/Icon.js";
33
import BusyIndicator from "@ui5/webcomponents/dist/BusyIndicator.js";
44
import MenuItem from "@ui5/webcomponents/dist/MenuItem.js";
5+
import MenuSeparator from "@ui5/webcomponents/dist/MenuSeparator.js";
56
import Button from "@ui5/webcomponents/dist/Button.js";
67
import Menu from "@ui5/webcomponents/dist/Menu.js";
78
import "@ui5/webcomponents-icons/dist/navigation-left-arrow.js";
@@ -153,6 +154,7 @@ export default function InputTemplate(this: Input, hooks?: { preContent: Templat
153154
function Versioning(this: Input) {
154155
return (
155156
<>
157+
<MenuSeparator />
156158
<MenuItem
157159
type="Inactive"
158160
class="ui5-ai-versioning-menu-footer"

packages/ai/src/i18n/messagebundle.properties

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,14 @@ BUTTON_TOOLTIP_TEXT={0} with Artificial Intelligence
1313
#XFLD: Text for the aria-label attribute of the Writing Assistant toolbar
1414
WRITING_ASSISTANT_LABEL=Writing Assistant Toolbar Shift + F4
1515

16-
#XFLD: Text for the aria-label attribute of the Input with Writing Assistant
17-
INPUT_WRITING_ASSISTANT_LABEL= Input with AI Writing Assistant Shift + F4
16+
#XFLD: Next version button accessible name in Input
17+
INPUT_VERSIONING_NEXT_BUTTON_TOOLTIP=Next Version (Ctrl + Shift + Y)
18+
19+
#XFLD: Next version button accessible name in Input
20+
INPUT_VERSIONING_PREVIOUS_BUTTON_TOOLTIP=Previous Version (Ctrl + Shift + Z)
21+
22+
#XFLD: Tooltip for the Writing Assistant button in Input
23+
INPUT_WRITING_ASSISTANT_BUTTON_TOOLTIP=AI Writing Assistant (Shift + F4)
1824

1925
#XFLD: Previous version button accessible name
2026
VERSIONING_PREVIOUS_BUTTON_TEXT=Previous Version

packages/ai/test/pages/Input.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ <h1 class="sr-only">AI Input Demo</h1>
3131

3232
<ui5-ai-input
3333
id="ai-input"
34-
placeholder="Ask me something..."
34+
placeholder="Write your title"
3535
>
36-
<ui5-menu-item text="Generate text" slot="actions" data-menu-action="generate"></ui5-menu-item>
36+
<ui5-menu-item text="Generate" slot="actions" data-menu-action="generate"></ui5-menu-item>
3737
</ui5-ai-input>
3838

3939
<script>
@@ -42,7 +42,6 @@ <h1 class="sr-only">AI Input Demo</h1>
4242
bg: "Мениджърите по иновации водят с креативност.",
4343
de: "Innovationsmanager führen mit Kreativität.",
4444
expanded: "They combine creative ideas with strategic action.",
45-
rephrased: "Managers use creativity to guide innovation.",
4645
simplified: "They lead using creativity.",
4746
summarized: "Driving innovation creatively."
4847
};
@@ -70,7 +69,6 @@ <h1 class="sr-only">AI Input Demo</h1>
7069
children: [
7170
{ text: "Simplify", action: "simplify", processingLabel: "Simplifying text", completedLabel: "Simplified text", textKey: "simplified", isChild: true },
7271
{ text: "Expand", action: "expand", processingLabel: "Expanding text", completedLabel: "Expanded text", textKey: "expanded", isChild: true },
73-
{ text: "Rephrase", action: "rephrase", processingLabel: "Rephrasing text", completedLabel: "Rephrased text", textKey: "rephrased", isChild: true },
7472
{ text: "Summarize", action: "summarize", processingLabel: "Summarizing text", completedLabel: "Summarized text", textKey: "summarized", isChild: true }
7573
]
7674
},
@@ -196,6 +194,7 @@ <h1 class="sr-only">AI Input Demo</h1>
196194

197195
updateComponentState();
198196
aiInput.loading = false;
197+
aiInput.placeholder = "Write your title";
199198
aiInput.focus();
200199
}
201200

@@ -221,6 +220,7 @@ <h1 class="sr-only">AI Input Demo</h1>
221220
function setLoadingState(promptDescription) {
222221
aiInput.value = ""
223222
aiInput.loading = true;
223+
aiInput.placeholder = "";
224224
aiInput.promptDescription = promptDescription || '';
225225
}
226226

@@ -289,6 +289,7 @@ <h1 class="sr-only">AI Input Demo</h1>
289289
}
290290
currentActionInProgress = null;
291291
aiInput.loading = false;
292+
aiInput.placeholder = "Write your title";
292293
aiInput.focus();
293294
}
294295

packages/website/docs/_samples/ai/Input/Basic/main.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ const SAMPLE_TEXTS = {
88
bg: "Мениджърите по иновации водят с креативност.",
99
de: "Innovationsmanager führen mit Kreativität.",
1010
expanded: "They combine creative ideas with strategic action.",
11-
rephrased: "Managers use creativity to guide innovation.",
1211
simplified: "They lead using creativity.",
1312
summarized: "Driving innovation creatively."
1413
};
@@ -36,7 +35,6 @@ const MENU_CONFIG = [
3635
children: [
3736
{ text: "Simplify", action: "simplify", processingLabel: "Simplifying text", completedLabel: "Simplified text", textKey: "simplified", isChild: true },
3837
{ text: "Expand", action: "expand", processingLabel: "Expanding text", completedLabel: "Expanded text", textKey: "expanded", isChild: true },
39-
{ text: "Rephrase", action: "rephrase", processingLabel: "Rephrasing text", completedLabel: "Rephrased text", textKey: "rephrased", isChild: true },
4038
{ text: "Summarize", action: "summarize", processingLabel: "Summarizing text", completedLabel: "Summarized text", textKey: "summarized", isChild: true }
4139
]
4240
},
@@ -162,6 +160,7 @@ function completeGeneration(action, menuItem) {
162160

163161
updateComponentState();
164162
aiInput.loading = false;
163+
aiInput.placeholder = "Write your title";
165164
aiInput.focus();
166165
}
167166

@@ -187,6 +186,7 @@ function animateTextGeneration(text, action, menuItem) {
187186
function setLoadingState(promptDescription) {
188187
aiInput.value = ""
189188
aiInput.loading = true;
189+
aiInput.placeholder = "";
190190
aiInput.promptDescription = promptDescription || '';
191191
}
192192

@@ -255,6 +255,7 @@ function stopGeneration() {
255255
}
256256
currentActionInProgress = null;
257257
aiInput.loading = false;
258+
aiInput.placeholder = "Write your title";
258259
aiInput.focus();
259260
}
260261

packages/website/docs/_samples/ai/Input/Basic/sample.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
<body style="background-color: var(--sapBackgroundColor)">
1212
<!-- playground-fold-end -->
1313
<div style="height: 200px;">
14-
<ui5-ai-input id="ai-input" placeholder="Ask me something..." style="width: 400px">
15-
<ui5-menu-item text="Generate text" slot="actions" data-menu-action="generate"></ui5-menu-item>
14+
<ui5-ai-input id="ai-input" placeholder="Write your title" style="width: 400px">
15+
<ui5-menu-item text="Generate" slot="actions" data-menu-action="generate"></ui5-menu-item>
1616
</ui5-ai-input>
1717
</div>
1818
<!-- playground-fold -->

packages/website/docs/components/patterns/AI Writing Assistant/AI Writing Assistant.mdx

Lines changed: 0 additions & 20 deletions
This file was deleted.

packages/website/docs/components/patterns/AI Writing Assistant/Input.md

Lines changed: 0 additions & 6 deletions
This file was deleted.

packages/website/docs/components/patterns/AI Writing Assistant/main.css

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)