Skip to content

Commit 06a62fe

Browse files
author
Julia Volkova
committed
reorganied imports
1 parent 8488800 commit 06a62fe

File tree

9 files changed

+526
-107
lines changed

9 files changed

+526
-107
lines changed

apps/demos/Demos/Form/SmartPaste/Angular/app/app.component.html

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,16 @@
33
<div class="instruction">Paste text from the clipboard to populate the form. Press Ctrl+Shift+V or use the "Smart Paste" button under the form.</div>
44
<div class="textarea-container">
55
<dx-button id="copy" text="Copy Text" icon="copy" stylingMode="contained" type="default" width="fit-content" (onClick)="onCopy()"></dx-button>
6-
<dx-text-area id="textarea" [value]="text" stylingMode="filled" height="100%" (onValueChanged)="setText($event)"></dx-text-area>
6+
<dx-text-area id="textarea" [value]="text" stylingMode="filled" height="100%" (onValueChanged)="onTextareaValueChangedEvent($event)"></dx-text-area>
77
</div>
8-
<dx-form id="form" labelMode="outside" labelLocation="top" [minColWidth]="220" [aiIntegration]="aiIntegration">
8+
<dx-form
9+
id="form"
10+
labelMode="outside"
11+
labelLocation="top"
12+
[minColWidth]="220"
13+
[aiIntegration]="aiIntegration"
14+
stylingMode="filled"
15+
>
916
<dxi-form-item itemType="group" [colCountByScreen]="colCountByScreen" caption="Billing Summary">
1017
<dxi-form-item
1118
dataField="Amount Due"

apps/demos/Demos/Form/SmartPaste/Angular/app/app.component.ts

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
import { NgModule, Component, ViewChild, enableProdMode } from '@angular/core';
22
import { BrowserModule } from '@angular/platform-browser';
33
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
4-
import {
5-
DxTextAreaModule,
6-
DxFormModule,
7-
DxFormComponent,
8-
DxDateBoxModule,
9-
DxButtonModule
10-
} from 'devextreme-angular';
4+
5+
import { AzureOpenAI, type OpenAI } from 'openai';
6+
7+
import { DxButtonModule } from 'devextreme-angular';
8+
import type { ButtonStyle } from 'devextreme-angular/common';
119
import {
1210
AIIntegration,
1311
RequestParams,
1412
Response,
1513
} from 'devextreme-angular/common/ai-integration';
14+
import { DxFormModule, DxFormComponent } from 'devextreme-angular/ui/form';
15+
import { DxTextAreaModule, type DxTextAreaTypes } from 'devextreme-angular/ui/text-area';
1616
import notify from 'devextreme/ui/notify';
17-
import { AzureOpenAI, OpenAI } from 'openai';
17+
1818
import { Service } from './app.service';
19-
import { ButtonStyle } from 'devextreme-angular/common';
20-
import type { ValueChangedEvent } from 'devextreme/ui/text_area';
2119

2220
if (!/localhost/.test(document.location.host)) {
2321
enableProdMode();
@@ -34,8 +32,9 @@ const stylingMode = 'filled';
3432
type AIMessage = (OpenAI.ChatCompletionUserMessageParam | OpenAI.ChatCompletionSystemMessageParam) & {
3533
content: string;
3634
};
35+
console.log('AAA');
3736

38-
const sendNotification = (message, of, offset) => {
37+
const sendNotification = (message: string, of: string, offset?: string) => {
3938
notify({
4039
message,
4140
position: {
@@ -169,25 +168,20 @@ export class AppComponent {
169168

170169
onCopy() {
171170
navigator.clipboard.writeText(this.text);
172-
sendNotification('Text copied to clipboard', '#textarea', '0 -20');
171+
sendNotification('Text copied to clipboard', '#textarea');
173172
}
174173

175-
setText(event: ValueChangedEvent) {
174+
onTextareaValueChangedEvent(event: DxTextAreaTypes.ValueChangedEvent) {
176175
this.text = event.value;
177176
}
178-
179-
smartPaste() {
180-
form.instance().smartPaste();
181-
}
182177
}
183178

184179
@NgModule({
185180
imports: [
186181
BrowserModule,
187-
DxTextAreaModule,
188-
DxFormModule,
189-
DxDateBoxModule,
190182
DxButtonModule,
183+
DxFormModule,
184+
DxTextAreaModule,
191185
],
192186
declarations: [AppComponent],
193187
bootstrap: [AppComponent],

apps/demos/Demos/Form/SmartPaste/React/App.tsx

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,35 @@
1-
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
1+
import React, { useCallback, useEffect, useRef, useState } from 'react';
22

33
import type { ButtonStyle, ValidationRule } from 'devextreme-react/common';
4-
4+
import { Button } from 'devextreme-react/button';
55
import {
66
Form,
7-
Item, GroupItem, Label,
8-
type FormTypes,
7+
Item, GroupItem,
98
ButtonItem,
109
FormRef,
1110
} from 'devextreme-react/form';
12-
import 'devextreme-react/text-area';
13-
import Button from 'devextreme-react/button';
11+
import { TextArea, type TextAreaTypes } from 'devextreme-react/text-area';
1412

1513
import notify from 'devextreme/ui/notify';
1614

1715
import { aiIntegration, defaultText } from './data.ts';
18-
import TextArea from 'devextreme-react/text-area';
1916

2017
const stylingMode = 'filled';
2118

2219
const amountDueEditorOptions = { placeholder: '$0.00', stylingMode };
2320
const amountDueAIOptions = { instruction: 'Format as the following: $0.00' };
21+
2422
const statementDueEditorOptions = { placeholder: 'MM/DD/YYYY', stylingMode };
2523
const statementDueAIOptions = { instruction: 'Format as the following: MM/DD/YYYY' };
24+
2625
const textEditorOptions = { stylingMode };
26+
2727
const phoneEditorOptions = { placeholder: '(000) 000-0000', stylingMode };
2828
const phoneAIOptions = { instruction: 'Format as the following: (000) 000-0000' };
29+
2930
const emailValidationRules: ValidationRule[] = [{ type: 'email' }];
3031
const emailAIOptions = { instruction: 'Do not fill this field if the text contains an invalid email address. A valid email is in the following format: email@example.com' };
32+
3133
const zipEditorOptions = { stylingMode, mode: 'text', value: null };
3234
const zipAIOptions = { instruction: 'If the text does not contain a ZIP, determine the ZIP code from the provided address.' };
3335

@@ -47,7 +49,7 @@ const colCountByScreen = {
4749
lg: 2,
4850
};
4951

50-
const showNotification = (message, of, offset) => {
52+
const showNotification = (message: string, of: string, offset?: string) => {
5153
notify({
5254
message,
5355
position: {
@@ -91,13 +93,17 @@ const App = () => {
9193
formRef.current.instance().registerKeyHandler('V', shortcutHandler);
9294
}, []);
9395

96+
const onTextAreaValueChanged = useCallback((e: TextAreaTypes.ValueChangedEvent) => {
97+
setText(e.value);
98+
}, []);
99+
94100
return (
95101
<>
96102
<div className="instruction">Copy text from the editor below to the clipboard. Edit the text to see how your changes affect Smart Paste result.</div>
97103
<div className="instruction">Paste text from the clipboard to populate the form. Press Ctrl+Shift+V or use the "Smart Paste" button under the form.</div>
98104
<div className="textarea-container">
99105
<Button text="Copy Text" icon="copy" stylingMode="contained" type="default" width="fit-content" onClick={onCopy} />
100-
<TextArea id="textarea" value={text} stylingMode="filled" height="100%" onChange={setText} />
106+
<TextArea id="textarea" value={text} stylingMode="filled" height="100%" onValueChanged={onTextAreaValueChanged} />
101107
</div>
102108
<Form
103109
id="form"

apps/demos/Demos/Form/SmartPaste/React/data.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import {
2-
AIIntegration,
3-
RequestParams,
4-
Response,
2+
AIIntegration,
3+
RequestParams,
4+
Response,
55
} from 'devextreme-react/common/ai-integration';
6-
import { AzureOpenAI, OpenAI } from 'openai';
6+
7+
import { AzureOpenAI, type OpenAI } from 'openai';
78

89
type AIMessage = (OpenAI.ChatCompletionUserMessageParam | OpenAI.ChatCompletionSystemMessageParam) & {
910
content: string;

apps/demos/Demos/Form/SmartPaste/Vue/App.vue

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
</template>
3838
<script setup lang="ts">
3939
import { onMounted, ref } from 'vue';
40+
import { AzureOpenAI, type OpenAI } from 'openai';
4041
import {
4142
DxForm, DxItem, DxButtonItem, DxGroupItem
4243
} from 'devextreme-vue/form';
@@ -45,9 +46,11 @@ import DxButton from 'devextreme-vue/button';
4546
import DxTextArea from 'devextreme-vue/text-area';
4647
import { AIIntegration } from 'devextreme-vue/common/ai-integration';
4748
import notify from 'devextreme/ui/notify';
48-
import { AzureOpenAI, OpenAI } from 'openai';
4949
import { AzureOpenAIConfig, defaultText } from './data.ts';
5050
51+
const text = ref(defaultText);
52+
const formRef = ref();
53+
5154
type AIMessage = (OpenAI.ChatCompletionUserMessageParam | OpenAI.ChatCompletionSystemMessageParam) & {
5255
content: string;
5356
};
@@ -93,18 +96,20 @@ const aiIntegration = new AIIntegration({
9396
9497
const stylingMode = 'filled';
9598
96-
const text = ref(defaultText);
97-
const formRef = ref();
98-
9999
const amountDueEditorOptions = { placeholder: '$0.00', stylingMode };
100100
const amountDueAIOptions = { instruction: 'Format as the following: $0.00' };
101+
101102
const statementDueEditorOptions = { placeholder: 'MM/DD/YYYY', stylingMode };
102103
const statementDueAIOptions = { instruction: 'Format as the following: MM/DD/YYYY' };
104+
103105
const textEditorOptions = { stylingMode };
106+
104107
const phoneEditorOptions = { placeholder: '(000) 000-0000', stylingMode };
105108
const phoneAIOptions = { instruction: 'Format as the following: (000) 000-0000' };
109+
106110
const emailValidationRules: ValidationRule[] = [{ type: 'email' }];
107111
const emailAIOptions = { instruction: 'Do not fill this field if the text contains an invalid email address. A valid email is in the following format: email@example.com' };
112+
108113
const zipEditorOptions = { stylingMode, mode: 'text', value: null };
109114
const zipAIOptions = { instruction: 'If the text does not contain a ZIP, determine the ZIP code from the provided address.' };
110115
@@ -124,7 +129,7 @@ const colCountByScreen = {
124129
lg: 2,
125130
};
126131
127-
const showNotification = (message, of, offset) => {
132+
const showNotification = (message: string, of: string, offset?: string) => {
128133
notify({
129134
message,
130135
position: {

apps/demos/Demos/Form/SmartPaste/Vue/data.ts

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,35 +15,3 @@ Address:
1515
- 123 Elm St Apt 4B
1616
- New York, NY 10001
1717
`;
18-
19-
const employee = {
20-
ID: 1,
21-
FirstName: 'John',
22-
LastName: 'Heart',
23-
Position: 'CEO',
24-
BirthDate: '1964/03/16',
25-
HireDate: '1995/01/15',
26-
Notes: 'John has been in the Audio/Video industry since 1990. He has led DevAv as its CEO since 2003.\r\n\r\nWhen not working hard as the CEO, John loves to golf and bowl. He once bowled a perfect game of 300.',
27-
Address: '351 S Hill St., Los Angeles, CA',
28-
Phone: '360-684-1334',
29-
Email: 'jheart@dx-email.com',
30-
};
31-
32-
const positions = [
33-
'HR Manager',
34-
'IT Manager',
35-
'CEO',
36-
'Controller',
37-
'Sales Manager',
38-
'Support Manager',
39-
'Shipping Manager',
40-
];
41-
42-
export default {
43-
getEmployee() {
44-
return employee;
45-
},
46-
getPositions() {
47-
return positions;
48-
},
49-
};

apps/demos/Demos/Form/SmartPaste/jQuery/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<div id="copy"></div>
2727
<div id="textarea"></div>
2828
</div>
29-
<div id="form" tabindex="0"></div>
29+
<div id="form"></div>
3030
</div>
3131
</body>
3232
</html>

0 commit comments

Comments
 (0)