Skip to content

Commit 99924df

Browse files
authored
Merge branch 'master' into rkaraivanov/date-picker-autofill-fix
2 parents eff79f0 + 7ae9db2 commit 99924df

File tree

12 files changed

+225
-117
lines changed

12 files changed

+225
-117
lines changed

package-lock.json

Lines changed: 61 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@
8080
"custom-element-vs-code-integration": "^1.5.0",
8181
"globby": "^15.0.0",
8282
"husky": "^9.1.7",
83-
"ig-typedoc-theme": "^6.2.3",
83+
"ig-typedoc-theme": "^7.0.0",
8484
"igniteui-i18n-resources": "0.6.0-alpha.4",
85-
"igniteui-theming": "^21.0.2",
85+
"igniteui-theming": "^22.1.0",
8686
"keep-a-changelog": "^2.7.1",
8787
"lint-staged": "^16.2.6",
8888
"lit-analyzer": "^2.0.3",
@@ -101,8 +101,8 @@
101101
"stylelint-scss": "^6.12.1",
102102
"ts-lit-plugin": "^2.0.2",
103103
"tslib": "^2.8.1",
104-
"typedoc": "~0.27.9",
105-
"typedoc-plugin-localization": "^3.0.6",
104+
"typedoc": "~0.28.14",
105+
"typedoc-plugin-localization": "^3.1.0",
106106
"typescript": "^5.8.3",
107107
"vite": "^7.1.12"
108108
},

scripts/build-typedoc.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
import path from 'node:path';
2+
import { fileURLToPath } from 'node:url';
23
import { create } from 'browser-sync';
34
import watch from 'node-watch';
45
import { Application } from 'typedoc';
56
import report from './report.mjs';
67

8+
const __filename = fileURLToPath(import.meta.url);
9+
const __dirname = path.dirname(__filename);
10+
11+
const toPosix = (p) => p.replace(/\\/g, '/');
712
const browserSync = create();
8-
const ROOT = path.join.bind(null, path.resolve('./'));
13+
const ROOT = (...segments) =>
14+
toPosix(path.resolve(__dirname, '..', ...segments));
915

1016
const TYPEDOC = {
1117
PLUGINS: {
@@ -99,6 +105,7 @@ async function main() {
99105
entryPointStrategy,
100106
plugin: [TYPEDOC.PLUGINS.THEME, TYPEDOC.PLUGINS.LOCALIZATION],
101107
theme: 'igtheme',
108+
router: 'structure',
102109
excludePrivate: true,
103110
excludeProtected: true,
104111
excludeNotDocumented: true,

src/components/chat/chat-input.ts

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { addThemingController } from '../../theming/theming-controller.js';
88
import IgcIconButtonComponent from '../button/icon-button.js';
99
import IgcChipComponent from '../chip/chip.js';
1010
import { chatContext, chatUserInputContext } from '../common/context.js';
11-
import { enterKey } from '../common/controllers/key-bindings.js';
11+
import { enterKey, tabKey } from '../common/controllers/key-bindings.js';
1212
import { registerComponent } from '../common/definitions/register.js';
1313
import { partMap } from '../common/part-map.js';
1414
import { bindIf, hasFiles, isEmpty, trimmedHtml } from '../common/util.js';
@@ -91,6 +91,10 @@ export default class IgcChatInputComponent extends LitElement {
9191
sendButton: () => this._renderSendButton(),
9292
});
9393

94+
private _userIsTyping = false;
95+
private _userLastTypeTime = Date.now();
96+
private _typingTimeout = 0;
97+
9498
@consume({ context: chatContext, subscribe: true })
9599
private readonly _state!: ChatState;
96100

@@ -148,6 +152,11 @@ export default class IgcChatInputComponent extends LitElement {
148152
this.focusInput();
149153
}
150154

155+
private _setTypingStateAndEmit(state: boolean): void {
156+
this._userIsTyping = state;
157+
this._userInputState.emitUserTypingState(state);
158+
}
159+
151160
private _handleAttachmentRemoved(attachment: IgcChatMessageAttachment): void {
152161
const current = this._userInputState.inputAttachments;
153162

@@ -160,16 +169,38 @@ export default class IgcChatInputComponent extends LitElement {
160169
}
161170

162171
private _handleKeydown(event: KeyboardEvent): void {
163-
const isSendRequest =
164-
event.key.toLowerCase() === enterKey.toLowerCase() && !event.shiftKey;
172+
this._userLastTypeTime = Date.now();
173+
const isEnterKey = event.key.toLowerCase() === enterKey.toLowerCase();
174+
const isTab = event.key.toLocaleLowerCase() === tabKey.toLowerCase();
165175

166-
if (isSendRequest) {
176+
if (isTab && !this._userIsTyping) {
177+
return;
178+
}
179+
180+
if (isEnterKey && !event.shiftKey) {
167181
event.preventDefault();
168182
this._sendMessage();
169-
} else {
170-
// TODO:
171-
this._state.handleKeyDown(event);
183+
184+
if (this._userIsTyping) {
185+
clearTimeout(this._typingTimeout);
186+
this._setTypingStateAndEmit(false);
187+
}
188+
189+
return;
172190
}
191+
192+
clearTimeout(this._typingTimeout);
193+
const delay = this._state.stopTypingDelay;
194+
195+
if (!this._userIsTyping) {
196+
this._setTypingStateAndEmit(true);
197+
}
198+
199+
this._typingTimeout = setTimeout(() => {
200+
if (this._userIsTyping && this._userLastTypeTime + delay <= Date.now()) {
201+
this._setTypingStateAndEmit(false);
202+
}
203+
}, delay);
173204
}
174205

175206
private _handleFileInputClick(): void {
@@ -238,6 +269,7 @@ export default class IgcChatInputComponent extends LitElement {
238269
this._state.attachFilesWithEvent(Array.from(input.files!));
239270
}
240271
}
272+
241273
/**
242274
* Default attachments area template used when no custom template is provided.
243275
* Renders the list of input attachments as chips.

src/components/chat/chat-state.ts

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ export class ChatState {
4646
*/
4747
private _acceptedTypesCache: ChatAcceptedFileTypes | null = null;
4848

49-
private _isTyping = false;
50-
private _lastTyped = Date.now();
51-
5249
public resourceStrings = IgcChatResourceStringEN;
5350

5451
//#endregion
@@ -217,6 +214,11 @@ export class ChatState {
217214
return this._host.emitEvent('igcMessageReact', { detail: reaction });
218215
}
219216

217+
/** @internal */
218+
public emitUserTypingState(state: boolean): boolean {
219+
return this._host.emitEvent('igcTypingChange', { detail: state });
220+
}
221+
220222
/**
221223
* @internal
222224
*/
@@ -326,29 +328,5 @@ export class ChatState {
326328
}
327329
}
328330

329-
public handleKeyDown = (_: KeyboardEvent) => {
330-
this._lastTyped = Date.now();
331-
if (!this._isTyping) {
332-
this.emitEvent('igcTypingChange', {
333-
detail: { isTyping: true },
334-
});
335-
this._isTyping = true;
336-
337-
const stopTypingDelay = this.stopTypingDelay;
338-
setTimeout(() => {
339-
if (
340-
this._isTyping &&
341-
stopTypingDelay &&
342-
this._lastTyped + stopTypingDelay < Date.now()
343-
) {
344-
this.emitEvent('igcTypingChange', {
345-
detail: { isTyping: false },
346-
});
347-
this._isTyping = false;
348-
}
349-
}, stopTypingDelay);
350-
}
351-
};
352-
353331
//#endregion
354332
}

0 commit comments

Comments
 (0)