@api-client/ui 0.5.38 → 0.5.40

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.
Files changed (299) hide show
  1. package/build/src/md/list/internals/ListItem.d.ts +24 -15
  2. package/build/src/md/list/internals/ListItem.d.ts.map +1 -1
  3. package/build/src/md/list/internals/ListItem.js +85 -59
  4. package/build/src/md/list/internals/ListItem.js.map +1 -1
  5. package/build/src/md/list/internals/ListItem.styles.js +11 -11
  6. package/build/src/md/list/internals/ListItem.styles.js.map +1 -1
  7. package/build/src/md/select/internals/Option.d.ts +4 -14
  8. package/build/src/md/select/internals/Option.d.ts.map +1 -1
  9. package/build/src/md/select/internals/Option.js +13 -28
  10. package/build/src/md/select/internals/Option.js.map +1 -1
  11. package/build/src/md/select/internals/Select.d.ts +1 -1
  12. package/build/src/md/select/internals/Select.d.ts.map +1 -1
  13. package/build/src/md/select/internals/Select.js +15 -5
  14. package/build/src/md/select/internals/Select.js.map +1 -1
  15. package/build/tsconfig.tsbuildinfo +1 -0
  16. package/package.json +1 -1
  17. package/src/md/list/internals/ListItem.styles.ts +11 -11
  18. package/src/md/list/internals/ListItem.ts +68 -43
  19. package/src/md/select/internals/Option.ts +14 -26
  20. package/src/md/select/internals/Select.ts +15 -5
  21. package/.aiexclude +0 -3
  22. package/.cursor/rules/html-and-css-best-practices.mdc +0 -63
  23. package/.cursor/rules/lit-best-practices.mdc +0 -89
  24. package/.editorconfig +0 -29
  25. package/.github/CONTRIBUTING.md +0 -24
  26. package/.github/instructions/html-and-css-best-practices.instructions.md +0 -70
  27. package/.github/instructions/lit-best-practices.instructions.md +0 -90
  28. package/.github/release.yml +0 -14
  29. package/.github/stale.yml +0 -23
  30. package/.github/workflows/auto-release.yml +0 -182
  31. package/.github/workflows/release.yml +0 -82
  32. package/.prettierrc.js +0 -14
  33. package/.vscode/settings.json +0 -18
  34. package/RELEASE.md +0 -163
  35. package/RELEASE_SETUP.md +0 -235
  36. package/build/src/demo/DemoPage.d.ts +0 -81
  37. package/build/src/demo/DemoPage.d.ts.map +0 -1
  38. package/build/src/demo/DemoPage.js +0 -175
  39. package/build/src/demo/DemoPage.js.map +0 -1
  40. package/build/src/demo/DemoStyles.d.ts +0 -3
  41. package/build/src/demo/DemoStyles.d.ts.map +0 -1
  42. package/build/src/demo/DemoStyles.js +0 -60
  43. package/build/src/demo/DemoStyles.js.map +0 -1
  44. package/build/test/elements/navigation/Navigation.test.d.ts +0 -3
  45. package/build/test/elements/navigation/Navigation.test.d.ts.map +0 -1
  46. package/build/test/elements/navigation/Navigation.test.js +0 -113
  47. package/build/test/elements/navigation/Navigation.test.js.map +0 -1
  48. package/commitlint.config.cjs +0 -2
  49. package/demo/elements/authorization/AuthPlugin.js +0 -57
  50. package/demo/elements/authorization/AuthProxy.js +0 -215
  51. package/demo/elements/authorization/api-key.html +0 -27
  52. package/demo/elements/authorization/api-key.ts +0 -44
  53. package/demo/elements/authorization/basic.html +0 -27
  54. package/demo/elements/authorization/basic.ts +0 -43
  55. package/demo/elements/authorization/bearer.html +0 -27
  56. package/demo/elements/authorization/bearer.ts +0 -43
  57. package/demo/elements/authorization/env.js +0 -8
  58. package/demo/elements/authorization/index.html +0 -44
  59. package/demo/elements/authorization/ntlm.html +0 -27
  60. package/demo/elements/authorization/ntlm.ts +0 -43
  61. package/demo/elements/authorization/oauth-authorize.html +0 -75
  62. package/demo/elements/authorization/oauth-authorize.ts +0 -40
  63. package/demo/elements/authorization/oauth-error.html +0 -18
  64. package/demo/elements/authorization/oauth-error.ts +0 -10
  65. package/demo/elements/authorization/oauth-popup.html +0 -36
  66. package/demo/elements/authorization/oauth2.html +0 -27
  67. package/demo/elements/authorization/oauth2.ts +0 -100
  68. package/demo/elements/authorization/oidc.html +0 -27
  69. package/demo/elements/authorization/oidc.ts +0 -139
  70. package/demo/elements/authorization/private.crt +0 -31
  71. package/demo/elements/authorization/private.csr +0 -28
  72. package/demo/elements/authorization/private.key +0 -51
  73. package/demo/elements/authorization/private.pem +0 -31
  74. package/demo/elements/authorization/redirect.html +0 -20
  75. package/demo/elements/authorization/ssl-commands.sh +0 -30
  76. package/demo/elements/authorization/ssl.conf +0 -24
  77. package/demo/elements/autocomplete/index.html +0 -64
  78. package/demo/elements/autocomplete/index.ts +0 -171
  79. package/demo/elements/code-editor/CodeEditorDemo.ts +0 -173
  80. package/demo/elements/code-editor/index.html +0 -19
  81. package/demo/elements/context-menu/DemoIcons.ts +0 -21
  82. package/demo/elements/context-menu/basic.html +0 -25
  83. package/demo/elements/context-menu/basic.ts +0 -119
  84. package/demo/elements/context-menu/custom-data.html +0 -25
  85. package/demo/elements/context-menu/custom-data.ts +0 -62
  86. package/demo/elements/context-menu/demo.css +0 -28
  87. package/demo/elements/context-menu/enabled-state.html +0 -25
  88. package/demo/elements/context-menu/enabled-state.ts +0 -73
  89. package/demo/elements/context-menu/icons.html +0 -25
  90. package/demo/elements/context-menu/icons.ts +0 -64
  91. package/demo/elements/context-menu/index.html +0 -43
  92. package/demo/elements/context-menu/nested.html +0 -25
  93. package/demo/elements/context-menu/nestedt.ts +0 -152
  94. package/demo/elements/context-menu/no-execute.html +0 -25
  95. package/demo/elements/context-menu/no-execute.ts +0 -134
  96. package/demo/elements/context-menu/radio-menu.html +0 -25
  97. package/demo/elements/context-menu/radio-menu.ts +0 -83
  98. package/demo/elements/context-menu/separators.html +0 -25
  99. package/demo/elements/context-menu/separators.ts +0 -172
  100. package/demo/elements/currency/index.html +0 -91
  101. package/demo/elements/currency/index.ts +0 -352
  102. package/demo/elements/environment/environment-editor.html +0 -20
  103. package/demo/elements/environment/environment-editor.ts +0 -49
  104. package/demo/elements/environment/index.html +0 -33
  105. package/demo/elements/environment/server-editor.html +0 -20
  106. package/demo/elements/environment/server-editor.ts +0 -67
  107. package/demo/elements/environment/variables-editor.html +0 -20
  108. package/demo/elements/environment/variables-editor.ts +0 -94
  109. package/demo/elements/har/har-viewer.html +0 -20
  110. package/demo/elements/har/har-viewer.ts +0 -76
  111. package/demo/elements/har/har1.har +0 -3044
  112. package/demo/elements/har/har2.json +0 -439
  113. package/demo/elements/har/index.html +0 -26
  114. package/demo/elements/highlight/example.md +0 -27
  115. package/demo/elements/highlight/index.html +0 -31
  116. package/demo/elements/highlight/marked-highlight.html +0 -132
  117. package/demo/elements/highlight/marked-highlight.ts +0 -22
  118. package/demo/elements/highlight/prism-highlight.html +0 -62
  119. package/demo/elements/highlight/prism-highlight.ts +0 -17
  120. package/demo/elements/http/body-editor.html +0 -17
  121. package/demo/elements/http/body-editor.ts +0 -115
  122. package/demo/elements/http/headers.html +0 -17
  123. package/demo/elements/http/headers.ts +0 -59
  124. package/demo/elements/http/http-assertions.html +0 -20
  125. package/demo/elements/http/http-assertions.ts +0 -89
  126. package/demo/elements/http/http-flows.html +0 -23
  127. package/demo/elements/http/http-flows.ts +0 -89
  128. package/demo/elements/http/index.html +0 -45
  129. package/demo/elements/http/request-editor.html +0 -26
  130. package/demo/elements/http/request-editor.ts +0 -197
  131. package/demo/elements/http/request-log.html +0 -16
  132. package/demo/elements/http/request-log.ts +0 -136
  133. package/demo/elements/http/url-editing.html +0 -17
  134. package/demo/elements/http/url-editing.ts +0 -112
  135. package/demo/elements/icons/index.html +0 -81
  136. package/demo/elements/icons/index.ts +0 -52
  137. package/demo/elements/index.html +0 -72
  138. package/demo/elements/mention-textarea/index.html +0 -19
  139. package/demo/elements/mention-textarea/index.ts +0 -205
  140. package/demo/elements/navigation/navigation-item.html +0 -49
  141. package/demo/elements/navigation/navigation-item.ts +0 -131
  142. package/demo/elements/navigation/navigation.html +0 -20
  143. package/demo/elements/navigation/navigation.ts +0 -45
  144. package/demo/elements/project/index.html +0 -29
  145. package/demo/elements/project/project-run-report.html +0 -20
  146. package/demo/elements/project/project-run-report.ts +0 -132
  147. package/demo/elements/project/request-editor.html +0 -23
  148. package/demo/elements/project/request-editor.ts +0 -232
  149. package/demo/elements/user/user-avatar.html +0 -17
  150. package/demo/elements/user/user-avatar.ts +0 -60
  151. package/demo/env.js +0 -4
  152. package/demo/index.html +0 -34
  153. package/demo/layout/index.html +0 -94
  154. package/demo/layout/index.ts +0 -190
  155. package/demo/md/DemoStyles.ts +0 -61
  156. package/demo/md/UiDemoPage.ts +0 -6
  157. package/demo/md/buttons/button.html +0 -121
  158. package/demo/md/buttons/button.ts +0 -246
  159. package/demo/md/buttons/group.html +0 -36
  160. package/demo/md/buttons/group.ts +0 -171
  161. package/demo/md/checkbox/index.html +0 -39
  162. package/demo/md/checkbox/index.ts +0 -220
  163. package/demo/md/chip/chip.html +0 -70
  164. package/demo/md/chip/chip.ts +0 -219
  165. package/demo/md/chip/pawel6c9a.jpg +0 -0
  166. package/demo/md/collapse/CustomDetail.ts +0 -89
  167. package/demo/md/collapse/collapse.html +0 -21
  168. package/demo/md/collapse/collapse.ts +0 -78
  169. package/demo/md/date-picker/date-picker.ts +0 -336
  170. package/demo/md/date-picker/index.html +0 -171
  171. package/demo/md/dialog/confirm-dialog.html +0 -49
  172. package/demo/md/dialog/confirm-dialog.ts +0 -121
  173. package/demo/md/dialog/dialog.html +0 -25
  174. package/demo/md/dialog/dialog.ts +0 -468
  175. package/demo/md/dropdown-list/index.html +0 -31
  176. package/demo/md/dropdown-list/index.ts +0 -158
  177. package/demo/md/icon-button/index.html +0 -122
  178. package/demo/md/icon-button/index.ts +0 -132
  179. package/demo/md/index.html +0 -73
  180. package/demo/md/inputs/input.html +0 -73
  181. package/demo/md/inputs/input.ts +0 -278
  182. package/demo/md/inputs/radio.html +0 -39
  183. package/demo/md/inputs/radio.ts +0 -156
  184. package/demo/md/inputs/switch.html +0 -45
  185. package/demo/md/inputs/switch.ts +0 -144
  186. package/demo/md/list/list.html +0 -65
  187. package/demo/md/list/list.ts +0 -204
  188. package/demo/md/listbox/listbox.html +0 -31
  189. package/demo/md/listbox/listbox.ts +0 -27
  190. package/demo/md/menu/index.html +0 -19
  191. package/demo/md/menu/index.ts +0 -514
  192. package/demo/md/notification/snack.html +0 -21
  193. package/demo/md/notification/snack.ts +0 -70
  194. package/demo/md/progress/progress.html +0 -46
  195. package/demo/md/progress/progress.ts +0 -161
  196. package/demo/md/segmented-button/index.html +0 -21
  197. package/demo/md/segmented-button/index.ts +0 -55
  198. package/demo/md/select/index.html +0 -16
  199. package/demo/md/select/index.ts +0 -207
  200. package/demo/md/tabs/tabs.html +0 -40
  201. package/demo/md/tabs/tabs.ts +0 -214
  202. package/demo/oauth-popup.html +0 -36
  203. package/demo/page.css +0 -8
  204. package/demo/resources/calendar-month.png +0 -0
  205. package/demo/resources/favorite.png +0 -0
  206. package/demo/resources/fingerprint.png +0 -0
  207. package/demo/resources/home-work.png +0 -0
  208. package/demo/resources/mood.png +0 -0
  209. package/demo/resources/print.png +0 -0
  210. package/demo/resources/stars.png +0 -0
  211. package/demo/resources/theaters.png +0 -0
  212. package/demo/tsconfig.json +0 -4
  213. package/eslint.config.js +0 -97
  214. package/scripts/copy-assets.js +0 -21
  215. package/scripts/release.js +0 -66
  216. package/src/demo/DemoPage.ts +0 -169
  217. package/src/demo/DemoStyles.ts +0 -60
  218. package/test/README.md +0 -375
  219. package/test/contextual-menu/ContextMenu.test.ts +0 -760
  220. package/test/contextual-menu/ContextMenuElement.test.ts +0 -569
  221. package/test/core/activity.spec.ts +0 -413
  222. package/test/core/activity_manager.spec.ts +0 -544
  223. package/test/core/application.spec.ts +0 -218
  224. package/test/core/fragment.spec.ts +0 -565
  225. package/test/core/fragment_manager.spec.ts +0 -404
  226. package/test/core/live_data.spec.ts +0 -558
  227. package/test/core/renderer.spec.ts +0 -113
  228. package/test/dom-assertions.test.ts +0 -182
  229. package/test/elements/MonacoSetup.ts +0 -65
  230. package/test/elements/authorization/basic-method.test.ts +0 -177
  231. package/test/elements/authorization/bearer-method.test.ts +0 -143
  232. package/test/elements/authorization/ntlm-method.test.ts +0 -219
  233. package/test/elements/authorization/oauth2-client-credentials-method.test.ts +0 -334
  234. package/test/elements/authorization/oauth2-code-method.test.ts +0 -320
  235. package/test/elements/authorization/oauth2-custom-grant-method.test.ts +0 -255
  236. package/test/elements/authorization/oauth2-device-code-method.test.ts +0 -371
  237. package/test/elements/authorization/oauth2-implicit-method.test.ts +0 -407
  238. package/test/elements/authorization/oauth2-jwt-method.test.ts +0 -217
  239. package/test/elements/authorization/oauth2-password-method.test.ts +0 -275
  240. package/test/elements/authorization/openid-method.test.ts +0 -591
  241. package/test/elements/autocomplete/autocomplete-input.spec.ts +0 -646
  242. package/test/elements/code-editor/code-editor.accessibility.test.ts +0 -298
  243. package/test/elements/code-editor/code-editor.test.ts +0 -574
  244. package/test/elements/currency/CurrencyPicker.accessibility.test.ts +0 -328
  245. package/test/elements/currency/CurrencyPicker.core.test.ts +0 -318
  246. package/test/elements/currency/CurrencyPicker.integration.test.ts +0 -482
  247. package/test/elements/currency/CurrencyPicker.test.ts +0 -486
  248. package/test/elements/data-table/DataTable.browser.test.ts +0 -649
  249. package/test/elements/har/HarUtils.test.ts +0 -45
  250. package/test/elements/har/HarViewerElement.test.ts +0 -687
  251. package/test/elements/har/test-data/har1.har +0 -3044
  252. package/test/elements/highlight/MarkedHighlightElement.test.ts +0 -452
  253. package/test/elements/highlight/PrismHighlightElement.test.ts +0 -79
  254. package/test/elements/highlight/PrismHighlighter.test.ts +0 -94
  255. package/test/elements/highlight/remoteSanitization.md +0 -1
  256. package/test/elements/highlight/test.md +0 -3
  257. package/test/elements/highlight/test1.md +0 -3
  258. package/test/elements/highlight/test2.md +0 -1
  259. package/test/elements/http/BodyFormdataEditorElement.test.ts +0 -482
  260. package/test/elements/http/BodyMultipartEditorElement.test.ts +0 -658
  261. package/test/elements/http/BodyRawEditorElement.test.ts +0 -90
  262. package/test/elements/http/CertificateAdd.test.ts +0 -457
  263. package/test/elements/http/HttpAssertions.test.ts +0 -994
  264. package/test/elements/http/HttpFlows.test.ts +0 -502
  265. package/test/elements/http/UrlEncodeUtils.test.ts +0 -202
  266. package/test/elements/layout/SplitItem.test.ts +0 -440
  267. package/test/elements/layout/SplitLayoutManager.test.ts +0 -1501
  268. package/test/elements/layout/SplitPanel.test.ts +0 -1109
  269. package/test/elements/mention-textarea/MentionTextArea.basic.test.ts +0 -114
  270. package/test/elements/mention-textarea/MentionTextArea.test.ts +0 -613
  271. package/test/elements/navigation/Navigation.test.ts +0 -120
  272. package/test/env.ts +0 -15
  273. package/test/events/EventTypes.test.ts +0 -363
  274. package/test/events/EventsTestHelpers.ts +0 -16
  275. package/test/helpers/TestUtils.ts +0 -243
  276. package/test/helpers/UiMock.ts +0 -185
  277. package/test/lib/Dom.test.ts +0 -231
  278. package/test/md/button/UiButton.test.ts +0 -347
  279. package/test/md/button/UiIconButton.test.ts +0 -155
  280. package/test/md/chip/UiChip.test.ts +0 -219
  281. package/test/md/collapse/UiCollapse.test.ts +0 -250
  282. package/test/md/collapse/flex-layout.test.ts +0 -105
  283. package/test/md/date-time/DateTime.test.ts +0 -348
  284. package/test/md/dialog/UiConfirmDialog.test.ts +0 -131
  285. package/test/md/dialog/UiDialog.test.ts +0 -759
  286. package/test/md/menu/Menu.test.ts +0 -855
  287. package/test/md/menu/MenuIntegration.test.ts +0 -426
  288. package/test/md/menu/MenuItem.test.ts +0 -652
  289. package/test/md/menu/SubMenu.test.ts +0 -410
  290. package/test/md/progress/UiCircularProgressElement.test.ts +0 -481
  291. package/test/md/progress/UiProgressElement.test.ts +0 -117
  292. package/test/md/progress/UiRangeElement.test.ts +0 -156
  293. package/test/md/select/Select.test.ts +0 -925
  294. package/test/plugins/takeScreenshotPlugin.js +0 -35
  295. package/test/setup.test.ts +0 -217
  296. package/test/setup.ts +0 -117
  297. package/test/tsconfig.json +0 -7
  298. package/web-dev-server.config.js +0 -21
  299. package/web-test-runner.config.js +0 -90
@@ -1,613 +0,0 @@
1
- import { assert, fixture, html, nextFrame } from '@open-wc/testing'
2
- import type { MentionSuggestion } from '../../../src/elements/mention-textarea/ui-mention-textarea.js'
3
- import '../../../src/elements/mention-textarea/ui-mention-textarea.js'
4
-
5
- type MentionTextAreaElement =
6
- import('../../../src/elements/mention-textarea/ui-mention-textarea.js').MentionTextAreaElement
7
-
8
- describe('MentionTextArea', () => {
9
- const mockSuggestions: MentionSuggestion[] = [
10
- { id: 'user1', label: 'John Doe', description: 'Software Engineer' },
11
- { id: 'user2', label: 'Jane Smith', description: 'Product Manager' },
12
- { id: 'user3', label: 'Bob Johnson', description: 'Designer', suffix: 'Design Team' },
13
- ]
14
-
15
- async function basicFixture(): Promise<MentionTextAreaElement> {
16
- return fixture(html`<mention-textarea></mention-textarea>`)
17
- }
18
-
19
- async function withSuggestionsFixture(): Promise<MentionTextAreaElement> {
20
- return fixture(html`<mention-textarea .suggestions="${mockSuggestions}"></mention-textarea>`)
21
- }
22
-
23
- async function labeledFixture(): Promise<MentionTextAreaElement> {
24
- return fixture(html`
25
- <mention-textarea
26
- label="Message"
27
- placeholder="Type your message..."
28
- .suggestions="${mockSuggestions}"
29
- ></mention-textarea>
30
- `)
31
- }
32
-
33
- function getEditor(element: MentionTextAreaElement): HTMLElement {
34
- return element.shadowRoot!.querySelector('.editor')!
35
- }
36
-
37
- function getSuggestionsPopover(element: MentionTextAreaElement): HTMLElement {
38
- return element.shadowRoot!.querySelector('.suggestions-popover')!
39
- }
40
-
41
- function getSuggestionItems(element: MentionTextAreaElement): NodeListOf<Element> {
42
- return element.shadowRoot!.querySelectorAll('.suggestion-item')
43
- }
44
-
45
- function simulateInput(element: MentionTextAreaElement, text: string): void {
46
- const editor = getEditor(element)
47
- editor.textContent = text
48
- editor.dispatchEvent(new Event('input', { bubbles: true }))
49
- }
50
-
51
- function simulatePaste(element: MentionTextAreaElement, text: string): void {
52
- const editor = getEditor(element)
53
- const clipboardData = new DataTransfer()
54
- clipboardData.setData('text/plain', text)
55
-
56
- const pasteEvent = new ClipboardEvent('paste', {
57
- bubbles: true,
58
- clipboardData,
59
- })
60
-
61
- editor.dispatchEvent(pasteEvent)
62
- }
63
-
64
- describe('basic functionality', () => {
65
- it('should render with default properties', async () => {
66
- const element = await basicFixture()
67
-
68
- assert.isNotNull(element)
69
- assert.equal(element.label, '')
70
- assert.equal(element.value, '')
71
- assert.equal(element.mentionTrigger, '@')
72
- assert.equal(element.minQueryLength, 0)
73
- assert.isFalse(element.disabled)
74
- assert.isFalse(element.required)
75
- })
76
-
77
- it('should have proper shadow DOM structure', async () => {
78
- const element = await labeledFixture()
79
-
80
- const container = element.shadowRoot!.querySelector('.container')
81
- const editor = getEditor(element)
82
- const label = element.shadowRoot!.querySelector('.label')
83
-
84
- assert.isNotNull(container)
85
- assert.isNotNull(editor)
86
- assert.isNotNull(label)
87
- assert.equal(editor.getAttribute('contenteditable'), 'true')
88
- assert.equal(editor.getAttribute('role'), 'textbox')
89
- })
90
-
91
- it('should display label and placeholder', async () => {
92
- const element = await labeledFixture()
93
-
94
- const label = element.shadowRoot!.querySelector('.label')
95
- const editor = getEditor(element)
96
-
97
- assert.equal(label!.textContent!.trim(), 'Message')
98
- assert.equal(editor.getAttribute('data-placeholder'), 'Type your message...')
99
- })
100
- })
101
-
102
- describe('value property', () => {
103
- it('should update value when set programmatically', async () => {
104
- const element = await basicFixture()
105
-
106
- element.value = 'Programmatic value'
107
- await nextFrame()
108
-
109
- assert.equal(element.value, 'Programmatic value')
110
- const editor = getEditor(element)
111
- assert.equal(editor.textContent, 'Programmatic value')
112
- })
113
-
114
- it('should sync value when editor content changes', async () => {
115
- const element = await basicFixture()
116
-
117
- simulateInput(element, 'Hello world')
118
- await nextFrame()
119
-
120
- assert.equal(element.value, 'Hello world')
121
- })
122
-
123
- it('should handle mentions in value', async () => {
124
- const element = await withSuggestionsFixture()
125
-
126
- element.value = 'Hello @{user1} how are you?'
127
- await nextFrame()
128
-
129
- const editor = getEditor(element)
130
- const mentionChip = editor.querySelector('.mention-chip')
131
- assert.isNotNull(mentionChip)
132
- assert.equal(mentionChip!.getAttribute('data-mention-id'), 'user1')
133
- })
134
- })
135
-
136
- describe('disabled state', () => {
137
- it('should disable editor when disabled', async () => {
138
- const element = await basicFixture()
139
- element.disabled = true
140
- await nextFrame()
141
-
142
- const editor = getEditor(element)
143
- assert.equal(editor.getAttribute('contenteditable'), 'false')
144
- assert.equal(editor.getAttribute('tabindex'), '-1')
145
- })
146
- })
147
-
148
- describe('mention suggestions', () => {
149
- it('should show suggestions container when created', async () => {
150
- const element = await withSuggestionsFixture()
151
-
152
- // Check if suggestions container exists
153
- const popover = getSuggestionsPopover(element)
154
- assert.isNotNull(popover)
155
- })
156
-
157
- it('should create mention chip in value format', async () => {
158
- const element = await withSuggestionsFixture()
159
-
160
- element.value = 'Hello @{user1}'
161
- await nextFrame()
162
-
163
- const editor = getEditor(element)
164
- const mentionChip = editor.querySelector('.mention-chip')
165
-
166
- assert.isNotNull(mentionChip)
167
- assert.equal(mentionChip!.getAttribute('data-mention-id'), 'user1')
168
- assert.equal(mentionChip!.getAttribute('contenteditable'), 'false')
169
- })
170
- })
171
-
172
- describe('paste functionality', () => {
173
- it('should handle pasting plain text', async () => {
174
- const element = await basicFixture()
175
-
176
- // Focus editor and set up selection
177
- const editor = getEditor(element)
178
- editor.focus()
179
-
180
- // Create a range at the beginning
181
- const range = document.createRange()
182
- const selection = window.getSelection()!
183
- range.setStart(editor, 0)
184
- range.setEnd(editor, 0)
185
- selection.removeAllRanges()
186
- selection.addRange(range)
187
-
188
- simulatePaste(element, 'Pasted content')
189
- await nextFrame()
190
-
191
- assert.equal(element.value, 'Pasted content')
192
- })
193
-
194
- it('should insert pasted text in editor', async () => {
195
- const element = await basicFixture()
196
-
197
- // Focus editor and set up selection
198
- const editor = getEditor(element)
199
- editor.focus()
200
-
201
- // Create a range at the beginning
202
- const range = document.createRange()
203
- const selection = window.getSelection()!
204
- range.setStart(editor, 0)
205
- range.setEnd(editor, 0)
206
- selection.removeAllRanges()
207
- selection.addRange(range)
208
-
209
- simulatePaste(element, 'Test paste')
210
- await nextFrame()
211
-
212
- const editorAfter = getEditor(element)
213
- assert.equal(editorAfter.textContent, 'Test paste')
214
- })
215
- })
216
-
217
- describe('accessibility', () => {
218
- it('should have proper ARIA attributes', async () => {
219
- const element = await labeledFixture()
220
-
221
- const editor = getEditor(element)
222
-
223
- assert.equal(editor.getAttribute('role'), 'textbox')
224
- assert.equal(editor.getAttribute('aria-multiline'), 'true')
225
- assert.equal(editor.getAttribute('aria-label'), 'Message')
226
- })
227
-
228
- it('should set aria-required when required', async () => {
229
- const element = await basicFixture()
230
- element.required = true
231
- await nextFrame()
232
-
233
- const editor = getEditor(element)
234
- assert.equal(editor.getAttribute('aria-required'), 'true')
235
- })
236
-
237
- it('should set aria-invalid when invalid', async () => {
238
- const element = await basicFixture()
239
- element.invalid = true
240
- await nextFrame()
241
-
242
- const editor = getEditor(element)
243
- assert.equal(editor.getAttribute('aria-invalid'), 'true')
244
- })
245
-
246
- it('should be focusable with proper tabindex', async () => {
247
- const element = await basicFixture()
248
-
249
- const editor = getEditor(element)
250
- assert.equal(editor.getAttribute('tabindex'), '0')
251
- })
252
-
253
- it('should not be focusable when disabled', async () => {
254
- const element = await basicFixture()
255
- element.disabled = true
256
- await nextFrame()
257
-
258
- const editor = getEditor(element)
259
- assert.equal(editor.getAttribute('tabindex'), '-1')
260
- })
261
- })
262
-
263
- describe('form integration', () => {
264
- it('should have proper name attribute', async () => {
265
- const element = (await fixture(
266
- html`<mention-textarea name="message"></mention-textarea>`
267
- )) as MentionTextAreaElement
268
-
269
- assert.equal(element.name, 'message')
270
- })
271
-
272
- it('should integrate with form validation', async () => {
273
- const element = await basicFixture()
274
- element.required = true
275
- await nextFrame()
276
-
277
- // Element should be invalid when empty and required
278
- assert.isTrue(element.required)
279
- assert.equal(element.value, '')
280
- })
281
- })
282
-
283
- describe('edge cases', () => {
284
- it('should handle empty suggestions array', async () => {
285
- const element = (await fixture(
286
- html`<mention-textarea .suggestions="${[]}"></mention-textarea>`
287
- )) as MentionTextAreaElement
288
-
289
- simulateInput(element, '@test')
290
- await nextFrame()
291
-
292
- const suggestions = getSuggestionItems(element)
293
- assert.equal(suggestions.length, 0)
294
- })
295
-
296
- it('should handle malformed mention in value', async () => {
297
- const element = await withSuggestionsFixture()
298
-
299
- element.value = 'Hello @{nonexistent} user'
300
- await nextFrame()
301
-
302
- const editor = getEditor(element)
303
- // Should fallback to text when mention is not found
304
- assert.include(editor.textContent!, '@{nonexistent}')
305
- })
306
-
307
- it('should handle multiple mentions in one text', async () => {
308
- const element = await withSuggestionsFixture()
309
-
310
- element.value = 'Hello @{user1} and @{user2}!'
311
- await nextFrame()
312
-
313
- const editor = getEditor(element)
314
- const mentionChips = editor.querySelectorAll('.mention-chip')
315
-
316
- assert.equal(mentionChips.length, 2)
317
- assert.equal(mentionChips[0].getAttribute('data-mention-id'), 'user1')
318
- assert.equal(mentionChips[1].getAttribute('data-mention-id'), 'user2')
319
- })
320
- })
321
-
322
- describe('mentions getter', () => {
323
- it('should return empty array when no mentions exist', async () => {
324
- const element = await basicFixture()
325
-
326
- element.value = 'Hello world without mentions'
327
- await nextFrame()
328
-
329
- assert.deepEqual(element.mentions, [])
330
- })
331
-
332
- it('should return single mention ID', async () => {
333
- const element = await withSuggestionsFixture()
334
-
335
- element.value = 'Hello @{user1} how are you?'
336
- await nextFrame()
337
-
338
- assert.deepEqual(element.mentions, ['user1'])
339
- })
340
-
341
- it('should return multiple unique mention IDs', async () => {
342
- const element = await withSuggestionsFixture()
343
-
344
- element.value = 'Hello @{user1} and @{user2}!'
345
- await nextFrame()
346
-
347
- assert.deepEqual(element.mentions.sort(), ['user1', 'user2'])
348
- })
349
-
350
- it('should deduplicate repeated mentions', async () => {
351
- const element = await withSuggestionsFixture()
352
-
353
- element.value = 'Hello @{user1}, @{user1} said @{user2} and @{user1} again'
354
- await nextFrame()
355
-
356
- const mentions = element.mentions.sort()
357
- assert.deepEqual(mentions, ['user1', 'user2'])
358
- assert.equal(mentions.length, 2)
359
- })
360
-
361
- it('should handle empty value', async () => {
362
- const element = await withSuggestionsFixture()
363
-
364
- element.value = ''
365
- await nextFrame()
366
-
367
- assert.deepEqual(element.mentions, [])
368
- })
369
-
370
- it('should handle malformed mentions', async () => {
371
- const element = await withSuggestionsFixture()
372
-
373
- element.value = 'Hello @{user1} and @{ } and @{valid_user}'
374
- await nextFrame()
375
-
376
- const mentions = element.mentions.sort()
377
- assert.include(mentions, 'user1')
378
- assert.include(mentions, ' ') // empty space is still captured
379
- assert.include(mentions, 'valid_user')
380
- assert.equal(mentions.length, 3)
381
- })
382
-
383
- it('should handle special characters in mention IDs', async () => {
384
- const element = await withSuggestionsFixture()
385
-
386
- element.value = 'Hello @{user-1} and @{user_2} and @{user.3}'
387
- await nextFrame()
388
-
389
- const mentions = element.mentions.sort()
390
- assert.deepEqual(mentions, ['user-1', 'user.3', 'user_2'])
391
- })
392
-
393
- it('should handle unicode characters in mention IDs', async () => {
394
- const element = await withSuggestionsFixture()
395
-
396
- element.value = 'Hello @{user-🎉} and @{user_ñ} and @{用户1}'
397
- await nextFrame()
398
-
399
- const mentions = element.mentions.sort()
400
- assert.deepEqual(mentions, ['user-🎉', 'user_ñ', '用户1'])
401
- })
402
-
403
- it('should handle nested curly braces gracefully', async () => {
404
- const element = await withSuggestionsFixture()
405
-
406
- element.value = 'Hello @{user{nested}} and @{user1}'
407
- await nextFrame()
408
-
409
- const mentions = element.mentions.sort()
410
- // The regex matches @{user{nested}} as 'user{nested' and @{user1} as 'user1'
411
- assert.include(mentions, 'user1')
412
- assert.include(mentions, 'user{nested')
413
- assert.equal(mentions.length, 2)
414
- })
415
-
416
- it('should handle very long mention IDs', async () => {
417
- const element = await withSuggestionsFixture()
418
- const longId = 'a'.repeat(1000)
419
-
420
- element.value = `Hello @{${longId}} world`
421
- await nextFrame()
422
-
423
- const mentions = element.mentions
424
- assert.include(mentions, longId)
425
- assert.equal(mentions.length, 1)
426
- })
427
-
428
- it('should handle mentions at the beginning and end of text', async () => {
429
- const element = await withSuggestionsFixture()
430
-
431
- element.value = '@{user1} said hello to @{user2}'
432
- await nextFrame()
433
-
434
- const mentions = element.mentions.sort()
435
- assert.deepEqual(mentions, ['user1', 'user2'])
436
- })
437
- })
438
-
439
- describe('getPlainText method', () => {
440
- it('should return plain text without mentions when no mentions exist', async () => {
441
- const element = await basicFixture()
442
-
443
- element.value = 'Hello world without mentions'
444
- await nextFrame()
445
-
446
- assert.equal(element.getPlainText(), 'Hello world without mentions')
447
- })
448
-
449
- it('should replace mention with field label when field exists in suggestions', async () => {
450
- const element = await withSuggestionsFixture()
451
-
452
- element.value = 'Hello @{user1} how are you?'
453
- await nextFrame()
454
-
455
- // user1 should be replaced with "John Doe" from suggestions
456
- assert.equal(element.getPlainText(), 'Hello John Doe how are you?')
457
- })
458
-
459
- it('should replace multiple mentions with their labels', async () => {
460
- const element = await withSuggestionsFixture()
461
-
462
- element.value = 'Hello @{user1} and @{user2}!'
463
- await nextFrame()
464
-
465
- assert.equal(element.getPlainText(), 'Hello John Doe and Jane Smith!')
466
- })
467
-
468
- it('should keep original field name when field not found in suggestions', async () => {
469
- const element = await withSuggestionsFixture()
470
-
471
- element.value = 'Hello @{nonexistent} user'
472
- await nextFrame()
473
-
474
- assert.equal(element.getPlainText(), 'Hello nonexistent user')
475
- })
476
-
477
- it('should handle mixed existing and non-existing mentions', async () => {
478
- const element = await withSuggestionsFixture()
479
-
480
- element.value = 'Hello @{user1} and @{nonexistent} and @{user2}'
481
- await nextFrame()
482
-
483
- assert.equal(element.getPlainText(), 'Hello John Doe and nonexistent and Jane Smith')
484
- })
485
-
486
- it('should handle duplicate mentions correctly', async () => {
487
- const element = await withSuggestionsFixture()
488
-
489
- element.value = '@{user1} said hello to @{user1}'
490
- await nextFrame()
491
-
492
- assert.equal(element.getPlainText(), 'John Doe said hello to John Doe')
493
- })
494
-
495
- it('should handle empty value', async () => {
496
- const element = await withSuggestionsFixture()
497
-
498
- element.value = ''
499
- await nextFrame()
500
-
501
- assert.equal(element.getPlainText(), '')
502
- })
503
-
504
- it('should preserve text formatting and whitespace', async () => {
505
- const element = await withSuggestionsFixture()
506
-
507
- element.value = ' Hello @{user1},\n\nHow are you @{user2}? \n'
508
- await nextFrame()
509
-
510
- assert.equal(element.getPlainText(), ' Hello John Doe,\n\nHow are you Jane Smith? \n')
511
- })
512
-
513
- it('should handle mention-like text that is not a mention', async () => {
514
- const element = await withSuggestionsFixture()
515
-
516
- element.value = 'Use at{symbol} and @{user1}'
517
- await nextFrame()
518
-
519
- // Only @{user1} should be replaced, at{symbol} should remain as is
520
- assert.equal(element.getPlainText(), 'Use at{symbol} and John Doe')
521
- })
522
-
523
- it('should find field by ID not label', async () => {
524
- const element = await withSuggestionsFixture()
525
-
526
- // Use the ID 'user1' which should match and return label 'John Doe'
527
- element.value = 'Hello @{user1}'
528
- await nextFrame()
529
-
530
- assert.equal(element.getPlainText(), 'Hello John Doe')
531
- })
532
-
533
- it('should handle mention IDs with special characters', async () => {
534
- const element = await withSuggestionsFixture()
535
- // Add a suggestion with special characters in ID
536
- element.suggestions = [
537
- ...element.suggestions,
538
- { id: 'user-special_123', label: 'Special User', description: 'Test user' },
539
- ]
540
-
541
- element.value = 'Hello @{user-special_123}'
542
- await nextFrame()
543
-
544
- assert.equal(element.getPlainText(), 'Hello Special User')
545
- })
546
-
547
- it('should handle unicode characters in mention IDs', async () => {
548
- const element = await withSuggestionsFixture()
549
- element.suggestions = [
550
- ...element.suggestions,
551
- { id: 'user-🎉', label: 'Party User', description: 'Celebration' },
552
- { id: '用户1', label: 'Chinese User', description: 'Test' },
553
- ]
554
-
555
- element.value = 'Hello @{user-🎉} and @{用户1}'
556
- await nextFrame()
557
-
558
- assert.equal(element.getPlainText(), 'Hello Party User and Chinese User')
559
- })
560
-
561
- it('should handle complex text with multiple lines and mentions', async () => {
562
- const element = await withSuggestionsFixture()
563
-
564
- element.value = `Line 1 with @{user1}
565
- Line 2 with @{user2}
566
- Line 3 with @{user1} again`
567
- await nextFrame()
568
-
569
- const expected = `Line 1 with John Doe
570
- Line 2 with Jane Smith
571
- Line 3 with John Doe again`
572
-
573
- assert.equal(element.getPlainText(), expected)
574
- })
575
-
576
- it('should handle malformed mentions gracefully', async () => {
577
- const element = await withSuggestionsFixture()
578
-
579
- element.value = 'Hello @{user1} and @{invalid and @{user2}'
580
- await nextFrame()
581
-
582
- // The regex matches @{user1} and @{invalid and @{user2} as one mention
583
- // @{user1} gets replaced with "John Doe"
584
- // @{invalid and @{user2} doesn't match any suggestion, so falls back to the field ID
585
- assert.equal(element.getPlainText(), 'Hello John Doe and invalid and @{user2')
586
- })
587
-
588
- it('should handle empty suggestion array', async () => {
589
- const element = await basicFixture()
590
- element.suggestions = []
591
-
592
- element.value = 'Hello @{user1} world'
593
- await nextFrame()
594
-
595
- // Should fallback to the mention ID since no suggestions available
596
- assert.equal(element.getPlainText(), 'Hello user1 world')
597
- })
598
-
599
- it('should handle null and undefined values in suggestions', async () => {
600
- const element = await withSuggestionsFixture()
601
- element.suggestions = [
602
- { id: 'user1', label: 'John Doe', description: 'Engineer' },
603
- { id: 'user2', label: '', description: 'Empty label' }, // Empty label
604
- { id: 'user3', label: 'Jane Smith' }, // No description
605
- ]
606
-
607
- element.value = 'Hello @{user1} and @{user2} and @{user3}'
608
- await nextFrame()
609
-
610
- assert.equal(element.getPlainText(), 'Hello John Doe and and Jane Smith')
611
- })
612
- })
613
- })