@libs-ui/components-inputs-mention 0.2.306 → 0.2.307-0
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/defines/template.define.d.ts +1 -1
- package/esm2022/defines/caret-coords.define.mjs +9 -9
- package/esm2022/defines/keyboard.define.mjs +1 -1
- package/esm2022/defines/template.define.mjs +4 -4
- package/esm2022/defines/utils.define.mjs +8 -9
- package/esm2022/index.mjs +1 -1
- package/esm2022/interfaces/mention.interface.mjs +1 -1
- package/esm2022/list/list.component.mjs +25 -26
- package/esm2022/mention.directive.mjs +31 -29
- package/fesm2022/libs-ui-components-inputs-mention.mjs +51 -51
- package/fesm2022/libs-ui-components-inputs-mention.mjs.map +1 -1
- package/interfaces/mention.interface.d.ts +2 -2
- package/list/list.component.d.ts +1 -1
- package/mention.directive.d.ts +2 -2
- package/package.json +6 -6
|
@@ -33,12 +33,12 @@ const DEFAULT_CONFIG = {
|
|
|
33
33
|
mentionSelect: (item) => `@${get(item, 'email')}`,
|
|
34
34
|
mentionFilter: (search, items) => {
|
|
35
35
|
const searchString = deleteUnicode(search.toLowerCase());
|
|
36
|
-
return items?.filter(item => {
|
|
36
|
+
return items?.filter((item) => {
|
|
37
37
|
const name = deleteUnicode(get(item, 'name').toLowerCase());
|
|
38
38
|
const userName = deleteUnicode(get(item, 'username').toLowerCase());
|
|
39
39
|
return name.includes(searchString) || userName.includes(searchString);
|
|
40
40
|
});
|
|
41
|
-
}
|
|
41
|
+
},
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
const setValue = (el, value) => {
|
|
@@ -81,7 +81,7 @@ const insertValueToContentEditable = (start, end, text) => {
|
|
|
81
81
|
// Range.createContextualFragment() would be useful here but is
|
|
82
82
|
// only relatively recently standardized and is not supported in
|
|
83
83
|
// some browsers (IE9, for one)
|
|
84
|
-
const el = document.createElement(
|
|
84
|
+
const el = document.createElement('SPAN');
|
|
85
85
|
el.innerHTML = text;
|
|
86
86
|
const frag = document.createDocumentFragment();
|
|
87
87
|
let node, lastNode, nodeHandlerEvent;
|
|
@@ -113,7 +113,7 @@ const getTextBeforeCursor = () => {
|
|
|
113
113
|
rangeNew.selectNodeContents(anchorNode);
|
|
114
114
|
rangeNew.setEnd(range.startContainer, range.startOffset);
|
|
115
115
|
const fragNew = rangeNew.cloneContents();
|
|
116
|
-
const elmPrev = document.createElement(
|
|
116
|
+
const elmPrev = document.createElement('SPAN');
|
|
117
117
|
elmPrev.appendChild(fragNew);
|
|
118
118
|
return elmPrev.innerText;
|
|
119
119
|
};
|
|
@@ -140,7 +140,6 @@ const setCaretPosition = (el, pos, iframe) => {
|
|
|
140
140
|
if (range) {
|
|
141
141
|
sel.addRange(range);
|
|
142
142
|
}
|
|
143
|
-
;
|
|
144
143
|
};
|
|
145
144
|
const getCaretPosition = (el, iframe) => {
|
|
146
145
|
if (isInputOrTextAreaElement(el)) {
|
|
@@ -181,7 +180,7 @@ const getContentEditableCaretCoords = (ctx) => {
|
|
|
181
180
|
return {
|
|
182
181
|
left: 0,
|
|
183
182
|
top: 0,
|
|
184
|
-
bottom: 0
|
|
183
|
+
bottom: 0,
|
|
185
184
|
};
|
|
186
185
|
}
|
|
187
186
|
const prevRange = sel.getRangeAt(0);
|
|
@@ -202,7 +201,7 @@ const getContentEditableCaretCoords = (ctx) => {
|
|
|
202
201
|
const coordinates = {
|
|
203
202
|
left: 0,
|
|
204
203
|
top: markerEl.offsetHeight,
|
|
205
|
-
bottom: -1
|
|
204
|
+
bottom: -1,
|
|
206
205
|
};
|
|
207
206
|
localToRelativeCoordinates(ctx, markerEl, coordinates);
|
|
208
207
|
markerEl.parentNode?.removeChild(markerEl);
|
|
@@ -272,7 +271,7 @@ const insertTextAtCaret = (element, text) => {
|
|
|
272
271
|
const sel = window.getSelection();
|
|
273
272
|
if (sel?.getRangeAt && sel.rangeCount) {
|
|
274
273
|
let range = sel.getRangeAt(0);
|
|
275
|
-
const el = document.createElement(
|
|
274
|
+
const el = document.createElement('SPAN');
|
|
276
275
|
range.deleteContents();
|
|
277
276
|
el.innerHTML = text;
|
|
278
277
|
const frag = document.createDocumentFragment();
|
|
@@ -356,10 +355,10 @@ const properties = [
|
|
|
356
355
|
'letterSpacing',
|
|
357
356
|
'wordSpacing',
|
|
358
357
|
'tabSize',
|
|
359
|
-
'MozTabSize'
|
|
358
|
+
'MozTabSize',
|
|
360
359
|
];
|
|
361
|
-
const isBrowser =
|
|
362
|
-
const isFirefox =
|
|
360
|
+
const isBrowser = typeof window !== 'undefined';
|
|
361
|
+
const isFirefox = isBrowser && get(window, 'mozInnerScreenX') !== null;
|
|
363
362
|
const getCaretCoordinates = (element, position) => {
|
|
364
363
|
if (!isBrowser) {
|
|
365
364
|
throw new Error('textarea-caret-position#getCaretCoordinates should only be called in a browser');
|
|
@@ -379,10 +378,10 @@ const getCaretCoordinates = (element, position) => {
|
|
|
379
378
|
// Position off-screen
|
|
380
379
|
style.position = 'absolute'; // required to return coordinates properly
|
|
381
380
|
// Transfer the element's properties to the div
|
|
382
|
-
properties.forEach(prop => {
|
|
381
|
+
properties.forEach((prop) => {
|
|
383
382
|
if (isInput && prop === 'lineHeight') {
|
|
384
383
|
// Special case for <input>s because text is rendered centered and line height may be != height
|
|
385
|
-
if (computed.boxSizing !==
|
|
384
|
+
if (computed.boxSizing !== 'border-box') {
|
|
386
385
|
style.lineHeight = computed.height;
|
|
387
386
|
return;
|
|
388
387
|
}
|
|
@@ -390,7 +389,7 @@ const getCaretCoordinates = (element, position) => {
|
|
|
390
389
|
const outerHeight = parseInt(computed.paddingTop) + parseInt(computed.paddingBottom) + parseInt(computed.borderTopWidth) + parseInt(computed.borderBottomWidth);
|
|
391
390
|
const targetHeight = outerHeight + parseInt(computed.lineHeight);
|
|
392
391
|
if (height > targetHeight) {
|
|
393
|
-
style.lineHeight = height - outerHeight +
|
|
392
|
+
style.lineHeight = height - outerHeight + 'px';
|
|
394
393
|
return;
|
|
395
394
|
}
|
|
396
395
|
if (height === targetHeight) {
|
|
@@ -427,7 +426,7 @@ const getCaretCoordinates = (element, position) => {
|
|
|
427
426
|
const coordinates = {
|
|
428
427
|
top: span.offsetTop + parseInt(computed['borderTopWidth']),
|
|
429
428
|
left: span.offsetLeft + parseInt(computed['borderLeftWidth']),
|
|
430
|
-
height: parseInt(computed['lineHeight'])
|
|
429
|
+
height: parseInt(computed['lineHeight']),
|
|
431
430
|
};
|
|
432
431
|
document.body.removeChild(div);
|
|
433
432
|
return coordinates;
|
|
@@ -464,7 +463,9 @@ class LibsUiComponentsInputsMentionListComponent {
|
|
|
464
463
|
}
|
|
465
464
|
/* FUNCTIONS */
|
|
466
465
|
initEvent(element, eventName) {
|
|
467
|
-
fromEvent(element, eventName)
|
|
466
|
+
fromEvent(element, eventName)
|
|
467
|
+
.pipe(takeUntil(this.onDestroy))
|
|
468
|
+
.subscribe((event) => {
|
|
468
469
|
if (eventName === 'resize' || !this.elementEl()?.nativeElement.contains(event.target)) {
|
|
469
470
|
this.handlerListenClose(event);
|
|
470
471
|
}
|
|
@@ -481,10 +482,10 @@ class LibsUiComponentsInputsMentionListComponent {
|
|
|
481
482
|
if (isInputOrTextAreaElement(nativeParentElement)) {
|
|
482
483
|
// parent elements need to have postition:relative for this to work correctly?
|
|
483
484
|
this.coords.set(getCaretCoordinates(nativeParentElement, nativeParentElement.selectionStart));
|
|
484
|
-
this.coords.update(item => ({
|
|
485
|
+
this.coords.update((item) => ({
|
|
485
486
|
...item,
|
|
486
487
|
top: nativeParentElement.offsetTop + item.top - nativeParentElement.scrollTop,
|
|
487
|
-
left: nativeParentElement.offsetLeft + item.left - nativeParentElement.scrollLeft + nativeParentElement.getBoundingClientRect().left
|
|
488
|
+
left: nativeParentElement.offsetLeft + item.left - nativeParentElement.scrollLeft + nativeParentElement.getBoundingClientRect().left,
|
|
488
489
|
}));
|
|
489
490
|
// getCretCoordinates() for text/input elements needs an additional offset to position the list correctly
|
|
490
491
|
this.offset.set(this.getBlockCursorDimensions(nativeParentElement).height);
|
|
@@ -497,15 +498,15 @@ class LibsUiComponentsInputsMentionListComponent {
|
|
|
497
498
|
const caretRelativeToView = getContentEditableCaretCoords(context);
|
|
498
499
|
const doc = document.documentElement;
|
|
499
500
|
const scrollLeft = (window.scrollX || doc.scrollLeft) - (doc.clientLeft || 0);
|
|
500
|
-
this.coords.update(item => ({
|
|
501
|
+
this.coords.update((item) => ({
|
|
501
502
|
...item,
|
|
502
503
|
left: caretRelativeToView.left - scrollLeft - (leftDiv || 0),
|
|
503
|
-
bottom: window.parent.innerHeight - caretRelativeToView.top + 18
|
|
504
|
+
bottom: window.parent.innerHeight - caretRelativeToView.top + 18,
|
|
504
505
|
}));
|
|
505
506
|
if (caretRelativeToView.bottom && caretRelativeToView.bottom !== -1) {
|
|
506
|
-
this.coords.update(item => ({
|
|
507
|
+
this.coords.update((item) => ({
|
|
507
508
|
...item,
|
|
508
|
-
bottom: caretRelativeToView.bottom
|
|
509
|
+
bottom: caretRelativeToView.bottom,
|
|
509
510
|
}));
|
|
510
511
|
}
|
|
511
512
|
this.positionElement();
|
|
@@ -516,11 +517,11 @@ class LibsUiComponentsInputsMentionListComponent {
|
|
|
516
517
|
const scrollTop = (window.scrollX || doc.scrollTop) - (doc.clientTop || 0);
|
|
517
518
|
// bounding rectangles are relative to view, offsets are relative to container?
|
|
518
519
|
const caretRelativeToView = getContentEditableCaretCoords({ iframe, parent: null });
|
|
519
|
-
this.coords.update(item => ({
|
|
520
|
+
this.coords.update((item) => ({
|
|
520
521
|
...item,
|
|
521
522
|
top: caretRelativeToView.top - scrollTop + 10,
|
|
522
523
|
left: caretRelativeToView.left - scrollLeft - (leftDiv || 0),
|
|
523
|
-
bottom: caretRelativeToView.bottom
|
|
524
|
+
bottom: caretRelativeToView.bottom,
|
|
524
525
|
}));
|
|
525
526
|
this.positionElement();
|
|
526
527
|
}
|
|
@@ -544,7 +545,7 @@ class LibsUiComponentsInputsMentionListComponent {
|
|
|
544
545
|
positionElement(left = this.coords().left, top = this.coords().top, dropUp = this.dropUp(), bottom = this.coords().bottom || 0) {
|
|
545
546
|
const el = this.elementEl()?.nativeElement;
|
|
546
547
|
top += dropUp ? 0 : this.offset(); // top of list is next line
|
|
547
|
-
el.style.position =
|
|
548
|
+
el.style.position = 'absolute';
|
|
548
549
|
el.style.left = left + 'px';
|
|
549
550
|
el.style.top = bottom !== -1 ? 'auto' : top + 'px';
|
|
550
551
|
el.style.bottom = bottom === -1 ? 'auto' : bottom + 'px';
|
|
@@ -554,7 +555,7 @@ class LibsUiComponentsInputsMentionListComponent {
|
|
|
554
555
|
const parentStyles = window.getComputedStyle(nativeParentElement);
|
|
555
556
|
return {
|
|
556
557
|
height: parseFloat(parentStyles.lineHeight),
|
|
557
|
-
width: parseFloat(parentStyles.fontSize)
|
|
558
|
+
width: parseFloat(parentStyles.fontSize),
|
|
558
559
|
};
|
|
559
560
|
}
|
|
560
561
|
handleActiveItem(event, index) {
|
|
@@ -562,7 +563,7 @@ class LibsUiComponentsInputsMentionListComponent {
|
|
|
562
563
|
this.activeIndex.set(index);
|
|
563
564
|
}
|
|
564
565
|
scrollToActive() {
|
|
565
|
-
if (!this.itemsEl() ||
|
|
566
|
+
if (!this.itemsEl() || this.itemsEl().length <= this.activeIndex()) {
|
|
566
567
|
return;
|
|
567
568
|
}
|
|
568
569
|
this.itemsEl()[this.activeIndex()].nativeElement.scrollIntoView();
|
|
@@ -580,14 +581,11 @@ class LibsUiComponentsInputsMentionListComponent {
|
|
|
580
581
|
this.onDestroy.complete();
|
|
581
582
|
}
|
|
582
583
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: LibsUiComponentsInputsMentionListComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
583
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.13", type: LibsUiComponentsInputsMentionListComponent, isStandalone: true, selector: "libs_ui-components-inputs-mention-list", inputs: { labelKey: { classPropertyName: "labelKey", publicName: "labelKey", isSignal: true, isRequired: false, transformFunction: null }, zIndex: { classPropertyName: "zIndex", publicName: "zIndex", isSignal: true, isRequired: false, transformFunction: null }, isIframe: { classPropertyName: "isIframe", publicName: "isIframe", isSignal: true, isRequired: true, transformFunction: null }, defaultAvatar: { classPropertyName: "defaultAvatar", publicName: "defaultAvatar", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { labelKey: "labelKeyChange", zIndex: "zIndexChange", isIframe: "isIframeChange", defaultAvatar: "defaultAvatarChange" }, viewQueries: [{ propertyName: "elementEl", first: true, predicate: ["element"], descendants: true, isSignal: true }, { propertyName: "itemsEl", predicate: ["item"], descendants: true, isSignal: true }], ngImport: i0, template: "<div
|
|
584
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.13", type: LibsUiComponentsInputsMentionListComponent, isStandalone: true, selector: "libs_ui-components-inputs-mention-list", inputs: { labelKey: { classPropertyName: "labelKey", publicName: "labelKey", isSignal: true, isRequired: false, transformFunction: null }, zIndex: { classPropertyName: "zIndex", publicName: "zIndex", isSignal: true, isRequired: false, transformFunction: null }, isIframe: { classPropertyName: "isIframe", publicName: "isIframe", isSignal: true, isRequired: true, transformFunction: null }, defaultAvatar: { classPropertyName: "defaultAvatar", publicName: "defaultAvatar", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { labelKey: "labelKeyChange", zIndex: "zIndexChange", isIframe: "isIframeChange", defaultAvatar: "defaultAvatarChange" }, viewQueries: [{ propertyName: "elementEl", first: true, predicate: ["element"], descendants: true, isSignal: true }, { propertyName: "itemsEl", predicate: ["item"], descendants: true, isSignal: true }], ngImport: i0, template: "<div\n #element\n class=\"libs-ui-mention-list\"\n [style.zIndex]=\"zIndex()\"\n [class.hidden]=\"hidden()\">\n @for (item of items(); track item) {\n <div\n #item\n class=\"libs-ui-mention-list-item\"\n [class.libs-ui-mention-list-item-active]=\"$index === activeIndex()\"\n (mousedown)=\"handlerClick($event, $index)\"\n (mouseenter)=\"handleActiveItem($event, $index)\">\n <div class=\"px-[12px] py-[6px] flex items-center\">\n <libs_ui-components-avatar\n [size]=\"24\"\n [linkAvatar]=\"item.avatar\"\n [linkAvatarError]=\"defaultAvatar()\"\n [getLastTextAfterSpace]=\"true\"\n [textAvatar]=\"item.name\"\n [idGenColor]=\"item.id\" />\n <libs_ui-components-popover\n [classInclude]=\"'libs-ui-font-h5r'\"\n [type]=\"'text'\"\n [ignoreShowPopover]=\"true\"\n [config]=\"{ width: 250 }\">\n <!-- // ta.m \u1EA9n show tooltip v\u00EC ch\u01B0a x\u1EED l\u00FD \u0111c v\u1ECB tr\u00ED -->\n {{ item.name + ' (' + item.username + ')' }}\n </libs_ui-components-popover>\n </div>\n </div>\n }\n</div>\n", styles: [".libs-ui-mention-list{position:absolute;top:-999px;left:-9999px;z-index:1202;float:left;width:315px;padding:4px 0;background-color:#fff;border:solid 1px #e6e8ed;border-radius:5px;max-height:190px;overflow:auto;box-shadow:0 2px 10px 1px #3333331a}.libs-ui-mention-list .libs-ui-mention-list-item{background:#fff;cursor:pointer}.libs-ui-mention-list .libs-ui-mention-list-item:hover,.libs-ui-mention-list .libs-ui-mention-list-item-active{background-color:var(--libs-ui-color-light-3, #f4f8ff)}\n"], dependencies: [{ kind: "component", type: LibsUiComponentsAvatarComponent, selector: "libs_ui-components-avatar", inputs: ["typeShape", "classInclude", "size", "linkAvatar", "linkAvatarError", "classImageInclude", "zIndexPreviewImage", "clickPreviewImage", "idGenColor", "getLastTextAfterSpace", "textAvatar", "textAvatarClassInclude", "containertextAvatarClassInclude"], outputs: ["outAvatarError", "outEventPreviewImage"] }, { kind: "component", type: LibsUiComponentsPopoverComponent, selector: "libs_ui-components-popover,[LibsUiComponentsPopoverDirective]", inputs: ["debugId", "flagMouse", "type", "mode", "config", "ignoreShowPopover", "elementRefCustom", "initEventInElementRefCustom", "classInclude", "ignoreHiddenPopoverContentWhenMouseLeave", "ignoreStopPropagationEvent", "ignoreCursorPointerModeLikeClick", "isAddContentToParentDocument", "ignoreClickOutside"], outputs: ["outEvent", "outChangStageFlagMouse", "outEventPopoverContent", "outFunctionsControl"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
584
585
|
}
|
|
585
586
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: LibsUiComponentsInputsMentionListComponent, decorators: [{
|
|
586
587
|
type: Component,
|
|
587
|
-
args: [{ selector: 'libs_ui-components-inputs-mention-list', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, imports: [
|
|
588
|
-
LibsUiComponentsAvatarComponent,
|
|
589
|
-
LibsUiComponentsPopoverComponent
|
|
590
|
-
], template: "<div #element\n class=\"libs-ui-mention-list\"\n [style.zIndex]=\"zIndex()\"\n [class.hidden]=\"hidden()\">\n @for (item of items(); track item) {\n <div #item\n class=\"libs-ui-mention-list-item\"\n [class.libs-ui-mention-list-item-active]=\"$index === activeIndex()\"\n (mousedown)=\"handlerClick($event, $index)\"\n (mouseenter)=\"handleActiveItem($event, $index)\">\n <div class=\"px-[12px] py-[6px] flex items-center\">\n <libs_ui-components-avatar [size]=\"24\"\n [linkAvatar]=\"item.avatar\"\n [linkAvatarError]=\"defaultAvatar()\"\n [getLastTextAfterSpace]=\"true\"\n [textAvatar]=\"item.name\"\n [idGenColor]=\"item.id\" />\n <libs_ui-components-popover [classInclude]=\"'libs-ui-font-h5r'\"\n [type]=\"'text'\"\n [ignoreShowPopover]=\"true\"\n [config]=\"{width: 250}\">\n <!-- // ta.m \u1EA9n show tooltip v\u00EC ch\u01B0a x\u1EED l\u00FD \u0111c v\u1ECB tr\u00ED -->\n {{ item.name + ' (' + item.username + ')' }}\n </libs_ui-components-popover>\n </div>\n </div>\n }\n</div>\n", styles: [".libs-ui-mention-list{position:absolute;top:-999px;left:-9999px;z-index:1202;float:left;width:315px;padding:4px 0;background-color:#fff;border:solid 1px #e6e8ed;border-radius:5px;max-height:190px;overflow:auto;box-shadow:0 2px 10px 1px #3333331a}.libs-ui-mention-list .libs-ui-mention-list-item{background:#fff;cursor:pointer}.libs-ui-mention-list .libs-ui-mention-list-item:hover,.libs-ui-mention-list .libs-ui-mention-list-item-active{background-color:var(--libs-ui-color-light-3, #f4f8ff)}\n"] }]
|
|
588
|
+
args: [{ selector: 'libs_ui-components-inputs-mention-list', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, imports: [LibsUiComponentsAvatarComponent, LibsUiComponentsPopoverComponent], template: "<div\n #element\n class=\"libs-ui-mention-list\"\n [style.zIndex]=\"zIndex()\"\n [class.hidden]=\"hidden()\">\n @for (item of items(); track item) {\n <div\n #item\n class=\"libs-ui-mention-list-item\"\n [class.libs-ui-mention-list-item-active]=\"$index === activeIndex()\"\n (mousedown)=\"handlerClick($event, $index)\"\n (mouseenter)=\"handleActiveItem($event, $index)\">\n <div class=\"px-[12px] py-[6px] flex items-center\">\n <libs_ui-components-avatar\n [size]=\"24\"\n [linkAvatar]=\"item.avatar\"\n [linkAvatarError]=\"defaultAvatar()\"\n [getLastTextAfterSpace]=\"true\"\n [textAvatar]=\"item.name\"\n [idGenColor]=\"item.id\" />\n <libs_ui-components-popover\n [classInclude]=\"'libs-ui-font-h5r'\"\n [type]=\"'text'\"\n [ignoreShowPopover]=\"true\"\n [config]=\"{ width: 250 }\">\n <!-- // ta.m \u1EA9n show tooltip v\u00EC ch\u01B0a x\u1EED l\u00FD \u0111c v\u1ECB tr\u00ED -->\n {{ item.name + ' (' + item.username + ')' }}\n </libs_ui-components-popover>\n </div>\n </div>\n }\n</div>\n", styles: [".libs-ui-mention-list{position:absolute;top:-999px;left:-9999px;z-index:1202;float:left;width:315px;padding:4px 0;background-color:#fff;border:solid 1px #e6e8ed;border-radius:5px;max-height:190px;overflow:auto;box-shadow:0 2px 10px 1px #3333331a}.libs-ui-mention-list .libs-ui-mention-list-item{background:#fff;cursor:pointer}.libs-ui-mention-list .libs-ui-mention-list-item:hover,.libs-ui-mention-list .libs-ui-mention-list-item-active{background-color:var(--libs-ui-color-light-3, #f4f8ff)}\n"] }]
|
|
591
589
|
}] });
|
|
592
590
|
|
|
593
591
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
@@ -610,7 +608,7 @@ class LibsUiComponentsInputsMentionDirective {
|
|
|
610
608
|
dynamicComponentService = inject(LibsUiDynamicComponentService);
|
|
611
609
|
onDestroy = new Subject();
|
|
612
610
|
// #region INPUT
|
|
613
|
-
timeDelayInit = input(0, { transform: val => val ?? 0 });
|
|
611
|
+
timeDelayInit = input(0, { transform: (val) => val ?? 0 });
|
|
614
612
|
mentionConfig = input();
|
|
615
613
|
mentionListTemplate = input();
|
|
616
614
|
// #region OUTPUT
|
|
@@ -653,7 +651,7 @@ class LibsUiComponentsInputsMentionDirective {
|
|
|
653
651
|
setTimeout(() => {
|
|
654
652
|
this.handlerKeydown({ key: this.mentionConfig()?.triggerChar, keyCode: KEY_BACKSPACE, shiftKey: true, inputEvent: true }, element);
|
|
655
653
|
}, 500);
|
|
656
|
-
}
|
|
654
|
+
},
|
|
657
655
|
});
|
|
658
656
|
}, this.timeDelayInit());
|
|
659
657
|
}
|
|
@@ -666,7 +664,7 @@ class LibsUiComponentsInputsMentionDirective {
|
|
|
666
664
|
this.triggerChars.set({});
|
|
667
665
|
this.addConfig(mentionConfig);
|
|
668
666
|
if (mentionConfig.mention) {
|
|
669
|
-
mentionConfig.mention.forEach(config => this.addConfig(config));
|
|
667
|
+
mentionConfig.mention.forEach((config) => this.addConfig(config));
|
|
670
668
|
}
|
|
671
669
|
}
|
|
672
670
|
addConfig(config) {
|
|
@@ -683,15 +681,15 @@ class LibsUiComponentsInputsMentionDirective {
|
|
|
683
681
|
}
|
|
684
682
|
if (labelKey) {
|
|
685
683
|
// remove items without an labelKey (as it's required to filter the list)
|
|
686
|
-
config.items = config.items.filter(e => e[labelKey]);
|
|
684
|
+
config.items = config.items.filter((e) => e[labelKey]);
|
|
687
685
|
if (!config.disableSort) {
|
|
688
|
-
config.items.sort((a, b) => (a[labelKey] || '').localeCompare(
|
|
686
|
+
config.items.sort((a, b) => (a[labelKey] || '').localeCompare(b[labelKey] || ''));
|
|
689
687
|
}
|
|
690
688
|
}
|
|
691
689
|
}
|
|
692
|
-
this.triggerChars.update(item => ({
|
|
690
|
+
this.triggerChars.update((item) => ({
|
|
693
691
|
...item,
|
|
694
|
-
[config.triggerChar || '@']: config
|
|
692
|
+
[config.triggerChar || '@']: config,
|
|
695
693
|
}));
|
|
696
694
|
if (this.activeConfig() && this.activeConfig()?.triggerChar === config.triggerChar) {
|
|
697
695
|
this.activeConfig.set(config);
|
|
@@ -739,7 +737,7 @@ class LibsUiComponentsInputsMentionDirective {
|
|
|
739
737
|
if (!charPressed) {
|
|
740
738
|
const charCode = event.which || event.keyCode;
|
|
741
739
|
charPressed = String.fromCharCode(event.which || event.keyCode);
|
|
742
|
-
if (!event.shiftKey &&
|
|
740
|
+
if (!event.shiftKey && charCode >= 65 && charCode <= 90) {
|
|
743
741
|
charPressed = String.fromCharCode(charCode + 32);
|
|
744
742
|
}
|
|
745
743
|
}
|
|
@@ -806,13 +804,13 @@ class LibsUiComponentsInputsMentionDirective {
|
|
|
806
804
|
// optional function to format the selected item before inserting the text
|
|
807
805
|
this.insertMention(nativeElement, pos);
|
|
808
806
|
// fire input event so angular bindings are updated
|
|
809
|
-
if (
|
|
807
|
+
if ('Event' in window) {
|
|
810
808
|
// this seems backwards, but fire the event from this elements nativeElement (not the
|
|
811
809
|
// one provided that may be in an iframe, as it won't be propogate)
|
|
812
810
|
// Create the event using the modern Event constructor
|
|
813
|
-
const evt = new Event(this.iframe() ?
|
|
811
|
+
const evt = new Event(this.iframe() ? 'change' : 'input', {
|
|
814
812
|
bubbles: true,
|
|
815
|
-
cancelable: false
|
|
813
|
+
cancelable: false,
|
|
816
814
|
});
|
|
817
815
|
// Dispatch the event on the native element
|
|
818
816
|
nativeElement.dispatchEvent(evt);
|
|
@@ -851,11 +849,11 @@ class LibsUiComponentsInputsMentionDirective {
|
|
|
851
849
|
const searchString = mention.replace(String.fromCharCode(160), ' ').replace(String.fromCharCode(0), '');
|
|
852
850
|
this.searchString.set(searchString.trim());
|
|
853
851
|
const limitSpaceSearchQuery = this.activeConfig()?.limitSpaceSearchQuery;
|
|
854
|
-
if (limitSpaceSearchQuery &&
|
|
852
|
+
if (limitSpaceSearchQuery && searchString.split(' ').length - 1 > limitSpaceSearchQuery) {
|
|
855
853
|
this.searchString.set('');
|
|
856
854
|
}
|
|
857
855
|
if (this.activeConfig()?.returnTrigger) {
|
|
858
|
-
const triggerChar =
|
|
856
|
+
const triggerChar = this.searchString() || event.keyCode === KEY_BACKSPACE ? val.substring(this.startPos(), (this.startPos() || 0) + 1) : '';
|
|
859
857
|
this.outSearchTerm.emit(triggerChar + this.searchString());
|
|
860
858
|
this.updateSearchList();
|
|
861
859
|
return;
|
|
@@ -876,10 +874,10 @@ class LibsUiComponentsInputsMentionDirective {
|
|
|
876
874
|
return {
|
|
877
875
|
key: key,
|
|
878
876
|
config: this.triggerChars()[key],
|
|
879
|
-
index: textBeforeCursor.lastIndexOf(key)
|
|
877
|
+
index: textBeforeCursor.lastIndexOf(key),
|
|
880
878
|
};
|
|
881
879
|
});
|
|
882
|
-
const matchingCharacters = triggerChars.reduce((pre, current) => pre && current && current.index > pre.index ? current : pre);
|
|
880
|
+
const matchingCharacters = triggerChars.reduce((pre, current) => (pre && current && current.index > pre.index ? current : pre));
|
|
883
881
|
if (matchingCharacters.index < 0) {
|
|
884
882
|
this.stopSearch();
|
|
885
883
|
return;
|
|
@@ -895,7 +893,7 @@ class LibsUiComponentsInputsMentionDirective {
|
|
|
895
893
|
this.searchString.set(search.replace(matchingCharacters.key, ''));
|
|
896
894
|
this.searching.set(true);
|
|
897
895
|
this.handlerKeydown({ keyCode: ''.charCodeAt(0), inputEvent: false }, nativeElement);
|
|
898
|
-
const divElement = document.createElement(
|
|
896
|
+
const divElement = document.createElement('div');
|
|
899
897
|
divElement.style.width = 'max-content';
|
|
900
898
|
divElement.style.position = 'absolute';
|
|
901
899
|
divElement.innerText = search;
|
|
@@ -1052,11 +1050,13 @@ class LibsUiComponentsInputsMentionDirective {
|
|
|
1052
1050
|
subscription: undefined,
|
|
1053
1051
|
item: itemActive,
|
|
1054
1052
|
triggerChar: triggerChar,
|
|
1055
|
-
manualAdd: true
|
|
1053
|
+
manualAdd: true,
|
|
1056
1054
|
};
|
|
1057
1055
|
this.nodesInsert().add(data);
|
|
1058
1056
|
if (mentionEventName) {
|
|
1059
|
-
data.subscription = fromEvent(span, mentionEventName)
|
|
1057
|
+
data.subscription = fromEvent(span, mentionEventName)
|
|
1058
|
+
.pipe(tap((e) => e.stopPropagation()), takeUntil$1(this.onDestroy))
|
|
1059
|
+
.subscribe(() => {
|
|
1060
1060
|
if (mentionActionByEvent) {
|
|
1061
1061
|
mentionActionByEvent(itemActive, triggerChar);
|
|
1062
1062
|
}
|
|
@@ -1081,7 +1081,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
|
|
|
1081
1081
|
args: [{
|
|
1082
1082
|
// eslint-disable-next-line @angular-eslint/directive-selector
|
|
1083
1083
|
selector: '[LibsUiComponentsInputsMentionDirective]',
|
|
1084
|
-
standalone: true
|
|
1084
|
+
standalone: true,
|
|
1085
1085
|
}]
|
|
1086
1086
|
}], ctorParameters: () => [] });
|
|
1087
1087
|
|