@api-client/ui 0.5.7 → 0.5.9
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/build/src/elements/mention-textarea/internals/MentionTextArea.d.ts +225 -0
- package/build/src/elements/mention-textarea/internals/MentionTextArea.d.ts.map +1 -0
- package/build/src/elements/mention-textarea/internals/MentionTextArea.js +1065 -0
- package/build/src/elements/mention-textarea/internals/MentionTextArea.js.map +1 -0
- package/build/src/elements/mention-textarea/internals/MentionTextArea.styles.d.ts +3 -0
- package/build/src/elements/mention-textarea/internals/MentionTextArea.styles.d.ts.map +1 -0
- package/build/src/elements/mention-textarea/internals/MentionTextArea.styles.js +274 -0
- package/build/src/elements/mention-textarea/internals/MentionTextArea.styles.js.map +1 -0
- package/build/src/elements/mention-textarea/ui-mention-textarea.d.ts +13 -0
- package/build/src/elements/mention-textarea/ui-mention-textarea.d.ts.map +1 -0
- package/build/src/elements/mention-textarea/ui-mention-textarea.js +28 -0
- package/build/src/elements/mention-textarea/ui-mention-textarea.js.map +1 -0
- package/build/src/md/chip/internals/Chip.styles.d.ts.map +1 -1
- package/build/src/md/chip/internals/Chip.styles.js +2 -0
- package/build/src/md/chip/internals/Chip.styles.js.map +1 -1
- package/demo/elements/index.html +3 -0
- package/demo/elements/mention-textarea/index.html +19 -0
- package/demo/elements/mention-textarea/index.ts +205 -0
- package/package.json +2 -2
- package/src/elements/mention-textarea/internals/MentionTextArea.styles.ts +274 -0
- package/src/elements/mention-textarea/internals/MentionTextArea.ts +1068 -0
- package/src/elements/mention-textarea/ui-mention-textarea.ts +18 -0
- package/src/md/chip/internals/Chip.styles.ts +2 -0
- package/test/elements/http/CertificateAdd.test.ts +0 -3
- package/test/elements/mention-textarea/MentionTextArea.basic.test.ts +114 -0
- package/test/elements/mention-textarea/MentionTextArea.test.ts +613 -0
- package/tsconfig.json +1 -1
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { LitElement, PropertyValues, TemplateResult } from 'lit';
|
|
2
|
+
import '../../../md/chip/ui-chip.js';
|
|
3
|
+
export interface MentionSuggestion {
|
|
4
|
+
/** Unique identifier for the suggestion */
|
|
5
|
+
id: string;
|
|
6
|
+
/** Main label/headline displayed */
|
|
7
|
+
label: string;
|
|
8
|
+
/** Supporting description text */
|
|
9
|
+
description?: string;
|
|
10
|
+
/** Suffix text (e.g., role, department) */
|
|
11
|
+
suffix?: string;
|
|
12
|
+
/** Additional data associated with the suggestion */
|
|
13
|
+
data?: Record<string, unknown>;
|
|
14
|
+
}
|
|
15
|
+
export interface MentionInsertEvent {
|
|
16
|
+
/** The inserted mention suggestion */
|
|
17
|
+
suggestion: MentionSuggestion;
|
|
18
|
+
/** The text that triggered the mention (e.g., "@john") */
|
|
19
|
+
trigger: string;
|
|
20
|
+
/** The position where the mention was inserted */
|
|
21
|
+
position: number;
|
|
22
|
+
}
|
|
23
|
+
export interface MentionRemoveEvent {
|
|
24
|
+
/** The removed mention suggestion */
|
|
25
|
+
suggestion: MentionSuggestion;
|
|
26
|
+
/** The position where the mention was removed from */
|
|
27
|
+
position: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* A material design textarea component that supports @mentions with suggestions.
|
|
31
|
+
*
|
|
32
|
+
* Features:
|
|
33
|
+
* - Material Design styling
|
|
34
|
+
* - @mention triggers with customizable suggestions
|
|
35
|
+
* - Inline pill/chip rendering for mentions
|
|
36
|
+
* - Proper caret management
|
|
37
|
+
* - Keyboard navigation for suggestions
|
|
38
|
+
* - Overflow container support
|
|
39
|
+
* - Generic design for extensibility
|
|
40
|
+
* - Accessibility support
|
|
41
|
+
*
|
|
42
|
+
* @fires mention-insert - When a mention is inserted
|
|
43
|
+
* @fires mention-remove - When a mention is removed
|
|
44
|
+
* @fires input - When the input value changes
|
|
45
|
+
* @fires change - When the input loses focus and value has changed
|
|
46
|
+
*/
|
|
47
|
+
export default class MentionTextArea extends LitElement {
|
|
48
|
+
/**
|
|
49
|
+
* Shadow root configuration for the component.
|
|
50
|
+
* Uses 'open' mode for accessibility and delegates focus to enable proper focus management.
|
|
51
|
+
*/
|
|
52
|
+
static shadowRootOptions: ShadowRootInit;
|
|
53
|
+
/**
|
|
54
|
+
* The label text displayed as placeholder/floating label
|
|
55
|
+
*/
|
|
56
|
+
accessor label: string;
|
|
57
|
+
/**
|
|
58
|
+
* Supporting text displayed below the input
|
|
59
|
+
*/
|
|
60
|
+
accessor supportingText: string;
|
|
61
|
+
/**
|
|
62
|
+
* Whether the component is disabled
|
|
63
|
+
*/
|
|
64
|
+
accessor disabled: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Whether the component is in an invalid state
|
|
67
|
+
*/
|
|
68
|
+
accessor invalid: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* The name attribute for form integration
|
|
71
|
+
*/
|
|
72
|
+
accessor name: string;
|
|
73
|
+
/**
|
|
74
|
+
* Whether the input is required
|
|
75
|
+
*/
|
|
76
|
+
accessor required: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Placeholder text shown when input is empty
|
|
79
|
+
*/
|
|
80
|
+
accessor placeholder: string;
|
|
81
|
+
get value(): string;
|
|
82
|
+
set value(newValue: string);
|
|
83
|
+
/**
|
|
84
|
+
* Available suggestions for mentions
|
|
85
|
+
*/
|
|
86
|
+
accessor suggestions: MentionSuggestion[];
|
|
87
|
+
/**
|
|
88
|
+
* Character that triggers mention suggestions (default: '@')
|
|
89
|
+
*/
|
|
90
|
+
accessor mentionTrigger: string;
|
|
91
|
+
/**
|
|
92
|
+
* Minimum characters after trigger to show suggestions
|
|
93
|
+
*/
|
|
94
|
+
accessor minQueryLength: number;
|
|
95
|
+
private accessor editorElement;
|
|
96
|
+
private accessor suggestionsPopover;
|
|
97
|
+
private accessor isShowingSuggestions;
|
|
98
|
+
private accessor filteredSuggestions;
|
|
99
|
+
private accessor selectedSuggestionIndex;
|
|
100
|
+
private accessor hasContent;
|
|
101
|
+
private accessor isLabelFloating;
|
|
102
|
+
private accessor isEditorFocus;
|
|
103
|
+
private currentMentionQuery;
|
|
104
|
+
private currentMentionStart;
|
|
105
|
+
private mentionMap;
|
|
106
|
+
private mutationObserver?;
|
|
107
|
+
private _value;
|
|
108
|
+
/**
|
|
109
|
+
* A read-only list of the names of the fields currently mentioned in the textarea.
|
|
110
|
+
*/
|
|
111
|
+
get mentions(): string[];
|
|
112
|
+
connectedCallback(): void;
|
|
113
|
+
disconnectedCallback(): void;
|
|
114
|
+
firstUpdated(): void;
|
|
115
|
+
willUpdate(changedProperties: PropertyValues): void;
|
|
116
|
+
/**
|
|
117
|
+
* Get the plain text content without field references
|
|
118
|
+
* @returns The plain text content with field names instead of references
|
|
119
|
+
*/
|
|
120
|
+
getPlainText(): string;
|
|
121
|
+
/**
|
|
122
|
+
* Sets the caret position at the beginning of a specific text node
|
|
123
|
+
*/
|
|
124
|
+
private setCaretPositionAtTextNode;
|
|
125
|
+
/**
|
|
126
|
+
* Synchronizes the value property from the editor content
|
|
127
|
+
*/
|
|
128
|
+
private syncValueFromEditor;
|
|
129
|
+
/**
|
|
130
|
+
* Gets the value from editor content, converting chips to @{mention} format
|
|
131
|
+
*/
|
|
132
|
+
private getValueFromEditor;
|
|
133
|
+
/**
|
|
134
|
+
* Synchronizes the editor content from the value property
|
|
135
|
+
*/
|
|
136
|
+
private syncEditorFromValue;
|
|
137
|
+
/**
|
|
138
|
+
* Parses value string into text and mention fragments
|
|
139
|
+
*/
|
|
140
|
+
private parseValueToFragments;
|
|
141
|
+
/**
|
|
142
|
+
* Creates a mention chip element
|
|
143
|
+
*/
|
|
144
|
+
private createMentionChip;
|
|
145
|
+
/**
|
|
146
|
+
* Updates content state flags
|
|
147
|
+
*/
|
|
148
|
+
private updateContentState;
|
|
149
|
+
/**
|
|
150
|
+
* Handles input events in the editor
|
|
151
|
+
*/
|
|
152
|
+
private handleEditorInput;
|
|
153
|
+
/**
|
|
154
|
+
* Handles keydown events in the editor
|
|
155
|
+
*/
|
|
156
|
+
private handleEditorKeyDown;
|
|
157
|
+
/**
|
|
158
|
+
* Handles keydown events when suggestions are visible
|
|
159
|
+
*/
|
|
160
|
+
private handleSuggestionKeyDown;
|
|
161
|
+
/**
|
|
162
|
+
* Handles focus events
|
|
163
|
+
*/
|
|
164
|
+
private handleEditorFocus;
|
|
165
|
+
/**
|
|
166
|
+
* Handles blur events
|
|
167
|
+
*/
|
|
168
|
+
private handleEditorBlur;
|
|
169
|
+
private handleEditorPaste;
|
|
170
|
+
/**
|
|
171
|
+
* Checks if the current caret position indicates a mention trigger
|
|
172
|
+
*/
|
|
173
|
+
private checkForMentionTrigger;
|
|
174
|
+
private walkerNodeFilter;
|
|
175
|
+
/**
|
|
176
|
+
* Gets the global text position within the editor for a position within a text node
|
|
177
|
+
*/
|
|
178
|
+
private getGlobalTextPosition;
|
|
179
|
+
/**
|
|
180
|
+
* Finds the DOM node and offset that corresponds to a global text position
|
|
181
|
+
*/
|
|
182
|
+
private findNodeAtGlobalPosition;
|
|
183
|
+
/**
|
|
184
|
+
* Shows the suggestions popover
|
|
185
|
+
*/
|
|
186
|
+
private showSuggestions;
|
|
187
|
+
/**
|
|
188
|
+
* Hides the suggestions popover
|
|
189
|
+
*/
|
|
190
|
+
private hideSuggestions;
|
|
191
|
+
/**
|
|
192
|
+
* Updates filtered suggestions based on current query
|
|
193
|
+
*/
|
|
194
|
+
private updateFilteredSuggestions;
|
|
195
|
+
/**
|
|
196
|
+
* Positions the suggestions popover using the Popover API anchor positioning
|
|
197
|
+
*/
|
|
198
|
+
private positionSuggestions;
|
|
199
|
+
/**
|
|
200
|
+
* Selects a suggestion and inserts it as a mention
|
|
201
|
+
*/
|
|
202
|
+
private selectSuggestion;
|
|
203
|
+
/**
|
|
204
|
+
* Removes a mention chip
|
|
205
|
+
*/
|
|
206
|
+
private removeMention;
|
|
207
|
+
/**
|
|
208
|
+
* Gets the text position of an element
|
|
209
|
+
*/
|
|
210
|
+
private getElementPosition;
|
|
211
|
+
/**
|
|
212
|
+
* Handles clicking on a suggestion
|
|
213
|
+
*/
|
|
214
|
+
private handleSuggestionClick;
|
|
215
|
+
/**
|
|
216
|
+
* Renders a suggestion item
|
|
217
|
+
*/
|
|
218
|
+
private renderSuggestion;
|
|
219
|
+
/**
|
|
220
|
+
* Renders the suggestions popover
|
|
221
|
+
*/
|
|
222
|
+
private renderSuggestions;
|
|
223
|
+
render(): TemplateResult;
|
|
224
|
+
}
|
|
225
|
+
//# sourceMappingURL=MentionTextArea.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MentionTextArea.d.ts","sourceRoot":"","sources":["../../../../../src/elements/mention-textarea/internals/MentionTextArea.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,UAAU,EAAE,cAAc,EAAE,cAAc,EAAW,MAAM,KAAK,CAAA;AAK/E,OAAO,6BAA6B,CAAA;AAEpC,MAAM,WAAW,iBAAiB;IAChC,2CAA2C;IAC3C,EAAE,EAAE,MAAM,CAAA;IACV,oCAAoC;IACpC,KAAK,EAAE,MAAM,CAAA;IACb,kCAAkC;IAClC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,2CAA2C;IAC3C,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,qDAAqD;IACrD,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC/B;AAED,MAAM,WAAW,kBAAkB;IACjC,sCAAsC;IACtC,UAAU,EAAE,iBAAiB,CAAA;IAC7B,0DAA0D;IAC1D,OAAO,EAAE,MAAM,CAAA;IACf,kDAAkD;IAClD,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,kBAAkB;IACjC,qCAAqC;IACrC,UAAU,EAAE,iBAAiB,CAAA;IAC7B,sDAAsD;IACtD,QAAQ,EAAE,MAAM,CAAA;CACjB;AAcD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,UAAU;IACrD;;;OAGG;IACH,OAAgB,iBAA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