@api-client/ui 0.5.19 → 0.5.21
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/code-editor/internals/CodeEditor.d.ts +4 -8
- package/build/src/elements/code-editor/internals/CodeEditor.d.ts.map +1 -1
- package/build/src/elements/code-editor/internals/CodeEditor.js +13 -33
- package/build/src/elements/code-editor/internals/CodeEditor.js.map +1 -1
- package/build/src/md/dialog/internals/Dialog.d.ts +13 -35
- package/build/src/md/dialog/internals/Dialog.d.ts.map +1 -1
- package/build/src/md/dialog/internals/Dialog.js +32 -146
- package/build/src/md/dialog/internals/Dialog.js.map +1 -1
- package/demo/elements/code-editor/CodeEditorDemo.ts +7 -21
- package/package.json +1 -2
- package/src/elements/code-editor/README.md +9 -6
- package/src/elements/code-editor/internals/CodeEditor.ts +9 -21
- package/src/md/dialog/internals/Dialog.ts +20 -120
- package/test/elements/code-editor/code-editor.accessibility.test.ts +2 -29
- package/test/elements/code-editor/code-editor.test.ts +10 -13
- package/build/src/events/SyntheticSubmitEvent.d.ts +0 -9
- package/build/src/events/SyntheticSubmitEvent.d.ts.map +0 -1
- package/build/src/events/SyntheticSubmitEvent.js +0 -22
- package/build/src/events/SyntheticSubmitEvent.js.map +0 -1
- package/src/events/SyntheticSubmitEvent.ts +0 -27
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
} from '@codemirror/autocomplete'
|
|
13
13
|
import { javascript } from '@codemirror/lang-javascript'
|
|
14
14
|
import { syntaxHighlighting, defaultHighlightStyle } from '@codemirror/language'
|
|
15
|
-
import { oneDark } from '@codemirror/theme-one-dark'
|
|
16
15
|
import { keymap } from '@codemirror/view'
|
|
17
16
|
import { defaultKeymap } from '@codemirror/commands'
|
|
18
17
|
import {
|
|
@@ -42,9 +41,9 @@ import '../../../md/button/ui-button.js'
|
|
|
42
41
|
* - Keyboard navigation
|
|
43
42
|
* - Accessibility support
|
|
44
43
|
*
|
|
45
|
-
* @fires
|
|
46
|
-
* @fires
|
|
47
|
-
* @fires
|
|
44
|
+
* @fires functioninsert - When a function is inserted
|
|
45
|
+
* @fires suggestioninsert - When a suggestion is inserted
|
|
46
|
+
* @fires docsrequest - When documentation is requested for a function
|
|
48
47
|
* @fires input - When the editor content changes
|
|
49
48
|
* @fires change - When the editor loses focus and content has changed
|
|
50
49
|
*/
|
|
@@ -69,7 +68,7 @@ export default class CodeEditor extends LitElement {
|
|
|
69
68
|
* Supporting text displayed below the editor
|
|
70
69
|
* @attribute
|
|
71
70
|
*/
|
|
72
|
-
@property({ type: String
|
|
71
|
+
@property({ type: String })
|
|
73
72
|
accessor supportingText = ''
|
|
74
73
|
|
|
75
74
|
/**
|
|
@@ -141,12 +140,6 @@ export default class CodeEditor extends LitElement {
|
|
|
141
140
|
@property({ type: Array, attribute: false })
|
|
142
141
|
accessor suggestions: Suggestion[] = []
|
|
143
142
|
|
|
144
|
-
/**
|
|
145
|
-
* Whether to use dark theme
|
|
146
|
-
*/
|
|
147
|
-
@property({ type: Boolean, attribute: 'dark-theme' })
|
|
148
|
-
accessor darkTheme = false
|
|
149
|
-
|
|
150
143
|
/**
|
|
151
144
|
* Programming language for syntax highlighting
|
|
152
145
|
* @attribute
|
|
@@ -156,9 +149,9 @@ export default class CodeEditor extends LitElement {
|
|
|
156
149
|
|
|
157
150
|
/**
|
|
158
151
|
* Whether to show documentation links/buttons in function tooltips and autocomplete
|
|
159
|
-
* @attribute
|
|
152
|
+
* @attribute
|
|
160
153
|
*/
|
|
161
|
-
@property({ type: Boolean
|
|
154
|
+
@property({ type: Boolean })
|
|
162
155
|
accessor showDocumentation = false
|
|
163
156
|
|
|
164
157
|
@query('.editor-container')
|
|
@@ -265,11 +258,6 @@ export default class CodeEditor extends LitElement {
|
|
|
265
258
|
extensions.push(javascript())
|
|
266
259
|
}
|
|
267
260
|
|
|
268
|
-
// Add theme
|
|
269
|
-
if (this.darkTheme) {
|
|
270
|
-
extensions.push(oneDark)
|
|
271
|
-
}
|
|
272
|
-
|
|
273
261
|
// Add placeholder
|
|
274
262
|
if (this.placeholder) {
|
|
275
263
|
extensions.push(
|
|
@@ -578,7 +566,7 @@ export default class CodeEditor extends LitElement {
|
|
|
578
566
|
* Dispatch function insert event
|
|
579
567
|
*/
|
|
580
568
|
private dispatchFunctionInsert(functionSchema: FunctionSchema, position: number): void {
|
|
581
|
-
const event = new CustomEvent<FunctionInsertEvent>('
|
|
569
|
+
const event = new CustomEvent<FunctionInsertEvent>('functioninsert', {
|
|
582
570
|
detail: { functionSchema, position },
|
|
583
571
|
bubbles: true,
|
|
584
572
|
})
|
|
@@ -589,7 +577,7 @@ export default class CodeEditor extends LitElement {
|
|
|
589
577
|
* Dispatch suggestion insert event
|
|
590
578
|
*/
|
|
591
579
|
private dispatchSuggestionInsert(suggestion: Suggestion, position: number): void {
|
|
592
|
-
const event = new CustomEvent<SuggestionInsertEvent>('
|
|
580
|
+
const event = new CustomEvent<SuggestionInsertEvent>('suggestioninsert', {
|
|
593
581
|
detail: { suggestion, position },
|
|
594
582
|
bubbles: true,
|
|
595
583
|
})
|
|
@@ -600,7 +588,7 @@ export default class CodeEditor extends LitElement {
|
|
|
600
588
|
* Dispatch function documentation event
|
|
601
589
|
*/
|
|
602
590
|
private dispatchFunctionDocumentation(functionSchema: FunctionSchema): void {
|
|
603
|
-
const event = new CustomEvent<FunctionDocumentationEvent>('
|
|
591
|
+
const event = new CustomEvent<FunctionDocumentationEvent>('docsrequest', {
|
|
604
592
|
detail: { functionSchema },
|
|
605
593
|
bubbles: true,
|
|
606
594
|
})
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { html, nothing, type PropertyValues, type TemplateResult } from 'lit'
|
|
2
2
|
import { property, query, queryAssignedElements, queryAssignedNodes, state } from 'lit/decorators.js'
|
|
3
3
|
import { type ClassInfo, classMap } from 'lit/directives/class-map.js'
|
|
4
4
|
import { UiElement } from '../../UiElement.js'
|
|
5
5
|
import { isDisabled, setDisabled } from '../../../lib/disabled.js'
|
|
6
6
|
import type UiButton from '../../button/internals/button.js'
|
|
7
7
|
import type { TypedEvents } from '../../../core/types.js'
|
|
8
|
-
import {
|
|
9
|
-
import { SyntheticSubmitEvent } from '../../../events/SyntheticSubmitEvent.js'
|
|
8
|
+
import type { ButtonType } from '../../button/internals/button.js'
|
|
10
9
|
import '../../button/ui-button.js'
|
|
11
10
|
import { bound } from '../../../decorators/bound.js'
|
|
12
11
|
|
|
@@ -42,8 +41,8 @@ export type RenderFunction = () => TemplateResult
|
|
|
42
41
|
* closing reason detail.
|
|
43
42
|
*
|
|
44
43
|
* ```javascript
|
|
45
|
-
* <ui-button color="text" value="dismiss">Cancel</ui-button>
|
|
46
|
-
* <ui-button color="text" value="confirm">Take action</ui-button>
|
|
44
|
+
* <ui-button slot="button" color="text" value="dismiss">Cancel</ui-button>
|
|
45
|
+
* <ui-button slot="button" color="text" value="confirm">Take action</ui-button>
|
|
47
46
|
* ```
|
|
48
47
|
*
|
|
49
48
|
* ```javascript
|
|
@@ -133,26 +132,6 @@ export default class UiDialog extends UiElement implements TypedEvents<DialogEve
|
|
|
133
132
|
*/
|
|
134
133
|
@property({ type: Boolean }) accessor destructive = false
|
|
135
134
|
|
|
136
|
-
/**
|
|
137
|
-
* Part of the imperative access to the element.
|
|
138
|
-
* When set, it wraps the content in a `<form>` element.
|
|
139
|
-
* When this is enabled the following will happen:
|
|
140
|
-
* - The `confirm` button will get `type="submit"`
|
|
141
|
-
* - The form `method` attribute is set to `dialog`
|
|
142
|
-
* - The form `id` attribute is set to a random string. You can get it from the `formId` getter.
|
|
143
|
-
* - The dialog will dispatch the same `submit` event as the form.
|
|
144
|
-
* - When the `submit` event dispatched by the dialog gets cancelled, then:
|
|
145
|
-
* - The original submit event also gets cancelled.
|
|
146
|
-
* - The default confirm action is not invoked
|
|
147
|
-
* - The dialog stays opened
|
|
148
|
-
* - When the submit event is not cancelled, then:
|
|
149
|
-
* - The default confirm action is invoked.
|
|
150
|
-
* - The dialog is closed.
|
|
151
|
-
*
|
|
152
|
-
* @deprecated Wrap the content in a `<form>` element instead.
|
|
153
|
-
*/
|
|
154
|
-
@property({ type: Boolean }) accessor useForm: boolean | undefined
|
|
155
|
-
|
|
156
135
|
/**
|
|
157
136
|
* Only when `confirmLabel` is set.
|
|
158
137
|
* Defines the value associated with the button's name when it's submitted with the form data.
|
|
@@ -160,6 +139,15 @@ export default class UiDialog extends UiElement implements TypedEvents<DialogEve
|
|
|
160
139
|
* @attribute
|
|
161
140
|
*/
|
|
162
141
|
@property({ type: String }) accessor confirmValue: string | undefined
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* The type of the confirm button.
|
|
145
|
+
* This is used to set the button's `type` attribute.
|
|
146
|
+
* If not set, the default is `button`.
|
|
147
|
+
* If set to `submit`, the dialog will trigger the form submission on the parent form.
|
|
148
|
+
* @attribute
|
|
149
|
+
*/
|
|
150
|
+
@property({ type: String }) accessor confirmType: ButtonType | undefined
|
|
163
151
|
/**
|
|
164
152
|
* When the dialog is wrapped in a form, set this to `true` to close the dialog
|
|
165
153
|
* when the form is submitted.
|
|
@@ -167,6 +155,7 @@ export default class UiDialog extends UiElement implements TypedEvents<DialogEve
|
|
|
167
155
|
* Note that the dialog doesn't perform any validation of the form. It only closes
|
|
168
156
|
* when the form is submitted, regardless of the application logic. The `submit` event
|
|
169
157
|
* is dispatched by the dialog when the form is valid.
|
|
158
|
+
* @attribute
|
|
170
159
|
*/
|
|
171
160
|
@property({ type: Boolean }) accessor submitClose: boolean | undefined
|
|
172
161
|
|
|
@@ -193,25 +182,6 @@ export default class UiDialog extends UiElement implements TypedEvents<DialogEve
|
|
|
193
182
|
*/
|
|
194
183
|
dialogValue?: unknown
|
|
195
184
|
|
|
196
|
-
#formId?: string
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* @deprecated Use `useForm` instead.
|
|
200
|
-
*/
|
|
201
|
-
get formId(): string | undefined {
|
|
202
|
-
return this.#formId
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* @deprecated This will be removed in the future.
|
|
207
|
-
*/
|
|
208
|
-
@state() accessor #inject: TemplateResult | RenderFunction | undefined
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* @deprecated This will be removed in the future.
|
|
212
|
-
*/
|
|
213
|
-
#pendingStyles?: CSSResultOrNative[]
|
|
214
|
-
|
|
215
185
|
/**
|
|
216
186
|
* A reference to the parent form element.
|
|
217
187
|
* When a form is found, the dialog will hook into the form's submit event
|
|
@@ -228,29 +198,6 @@ export default class UiDialog extends UiElement implements TypedEvents<DialogEve
|
|
|
228
198
|
this.addEventListener('keydown', this.handleKeyDown)
|
|
229
199
|
}
|
|
230
200
|
|
|
231
|
-
/**
|
|
232
|
-
* Allows to inject a template into the internals of the element.
|
|
233
|
-
* This is helpful when working with imperative dialogs.
|
|
234
|
-
* @param content The content to inject into the body.
|
|
235
|
-
* @deprecated This will be removed in the future. To use forms, wrap the content in a `<form>` element.
|
|
236
|
-
*/
|
|
237
|
-
inject(content?: TemplateResult | RenderFunction, styles?: CSSResultOrNative[]): void {
|
|
238
|
-
this.#inject = content
|
|
239
|
-
if (styles) {
|
|
240
|
-
if (this.shadowRoot) {
|
|
241
|
-
adoptStyles(this.shadowRoot, styles)
|
|
242
|
-
} else {
|
|
243
|
-
if (!this.#pendingStyles) {
|
|
244
|
-
this.#pendingStyles = []
|
|
245
|
-
}
|
|
246
|
-
this.#pendingStyles.push(...styles)
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
if (this.shadowRoot && styles) {
|
|
250
|
-
adoptStyles(this.shadowRoot, styles)
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
|
|
254
201
|
override connectedCallback(): void {
|
|
255
202
|
super.connectedCallback()
|
|
256
203
|
this.#form = this.closest('form')
|
|
@@ -267,22 +214,6 @@ export default class UiDialog extends UiElement implements TypedEvents<DialogEve
|
|
|
267
214
|
}
|
|
268
215
|
}
|
|
269
216
|
|
|
270
|
-
protected override firstUpdated(): void {
|
|
271
|
-
const styles = this.#pendingStyles
|
|
272
|
-
if (styles) {
|
|
273
|
-
const root = this.shadowRoot as ShadowRoot
|
|
274
|
-
const all = [...root.adoptedStyleSheets, ...styles]
|
|
275
|
-
adoptStyles(this.shadowRoot as ShadowRoot, all)
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
override willUpdate(cp: PropertyValues<this>): void {
|
|
280
|
-
if (cp.has('useForm') && this.useForm && !this.#formId) {
|
|
281
|
-
const r = (Math.random() + 1).toString(36).substring(7)
|
|
282
|
-
this.#formId = `form-${r}`
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
|
|
286
217
|
@bound
|
|
287
218
|
protected handleFormSubmit(): void {
|
|
288
219
|
if (this.submitClose) {
|
|
@@ -425,33 +356,15 @@ export default class UiDialog extends UiElement implements TypedEvents<DialogEve
|
|
|
425
356
|
}
|
|
426
357
|
|
|
427
358
|
protected handleConfirm(): void {
|
|
428
|
-
|
|
429
|
-
this.handleInteraction('confirm')
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
#handleSubmit(event: SubmitEvent): void {
|
|
434
|
-
const form = event.target as HTMLFormElement
|
|
435
|
-
const copy = new SyntheticSubmitEvent(event.type, form, {
|
|
436
|
-
submitter: event.submitter,
|
|
437
|
-
cancelable: true,
|
|
438
|
-
bubbles: false,
|
|
439
|
-
composed: false,
|
|
440
|
-
})
|
|
441
|
-
const dispatched = this.dispatchEvent(copy)
|
|
442
|
-
if (dispatched) {
|
|
443
|
-
this.handleInteraction('confirm')
|
|
444
|
-
} else {
|
|
445
|
-
event.preventDefault()
|
|
446
|
-
}
|
|
359
|
+
this.handleInteraction('confirm')
|
|
447
360
|
}
|
|
448
361
|
|
|
449
362
|
override render(): TemplateResult {
|
|
450
|
-
const {
|
|
363
|
+
const { modal } = this
|
|
451
364
|
const dialogClass = modal ? 'modal' : 'non-modal'
|
|
452
365
|
return html`
|
|
453
366
|
<dialog @close="${this.handleDialogClose}" part="dialog" class="${dialogClass}">
|
|
454
|
-
<div class="container">${
|
|
367
|
+
<div class="container">${this.renderContent()}</div>
|
|
455
368
|
</dialog>
|
|
456
369
|
`
|
|
457
370
|
}
|
|
@@ -460,14 +373,6 @@ export default class UiDialog extends UiElement implements TypedEvents<DialogEve
|
|
|
460
373
|
return [this.renderIcon(), this.renderTitle(), this.renderBody(), this.renderButtons()]
|
|
461
374
|
}
|
|
462
375
|
|
|
463
|
-
#renderFormContent(): TemplateResult {
|
|
464
|
-
return html`
|
|
465
|
-
<form id="${ifDefined(this.formId)}" method="dialog" @submit="${this.#handleSubmit}" part="form">
|
|
466
|
-
${this.renderContent()}
|
|
467
|
-
</form>
|
|
468
|
-
`
|
|
469
|
-
}
|
|
470
|
-
|
|
471
376
|
protected renderIcon(): TemplateResult {
|
|
472
377
|
const classes: ClassInfo = {
|
|
473
378
|
'icon': true,
|
|
@@ -494,12 +399,7 @@ export default class UiDialog extends UiElement implements TypedEvents<DialogEve
|
|
|
494
399
|
}
|
|
495
400
|
|
|
496
401
|
protected renderBody(): TemplateResult {
|
|
497
|
-
|
|
498
|
-
if (typeof content === 'function') {
|
|
499
|
-
content = content()
|
|
500
|
-
}
|
|
501
|
-
const injected = content || nothing
|
|
502
|
-
return html` <div class="content" part="body"><slot></slot>${injected}</div> `
|
|
402
|
+
return html` <div class="content" part="body"><slot></slot></div> `
|
|
503
403
|
}
|
|
504
404
|
|
|
505
405
|
protected renderButtons(): TemplateResult {
|
|
@@ -533,11 +433,11 @@ export default class UiDialog extends UiElement implements TypedEvents<DialogEve
|
|
|
533
433
|
}
|
|
534
434
|
|
|
535
435
|
#renderConfirmButton(): TemplateResult | typeof nothing {
|
|
536
|
-
const { confirmLabel, confirmValue = 'confirm',
|
|
436
|
+
const { confirmLabel, confirmValue = 'confirm', destructive } = this
|
|
537
437
|
if (!confirmLabel) {
|
|
538
438
|
return nothing
|
|
539
439
|
}
|
|
540
|
-
const type =
|
|
440
|
+
const type = this.confirmType ?? 'button'
|
|
541
441
|
const buttonClass = destructive ? 'internal-button destructive' : 'internal-button'
|
|
542
442
|
return html`
|
|
543
443
|
<ui-button
|
|
@@ -42,7 +42,7 @@ describe('CodeEditor - Accessibility', () => {
|
|
|
42
42
|
return fixture(html`
|
|
43
43
|
<code-editor
|
|
44
44
|
label="Accessible Code Editor"
|
|
45
|
-
|
|
45
|
+
supportingtext="Enter your code with accessibility support"
|
|
46
46
|
placeholder="Type your code here..."
|
|
47
47
|
.functionSchemas="${sampleFunctionSchemas}"
|
|
48
48
|
.suggestions="${sampleSuggestions}"
|
|
@@ -54,7 +54,7 @@ describe('CodeEditor - Accessibility', () => {
|
|
|
54
54
|
return fixture(html`
|
|
55
55
|
<code-editor
|
|
56
56
|
label="Code Editor with Documentation"
|
|
57
|
-
|
|
57
|
+
showdocumentation
|
|
58
58
|
.functionSchemas="${sampleFunctionSchemas}"
|
|
59
59
|
></code-editor>
|
|
60
60
|
`)
|
|
@@ -245,33 +245,6 @@ describe('CodeEditor - Accessibility', () => {
|
|
|
245
245
|
})
|
|
246
246
|
})
|
|
247
247
|
|
|
248
|
-
describe('High Contrast and Theme Support', () => {
|
|
249
|
-
it('should support dark theme for accessibility', async () => {
|
|
250
|
-
const el = await accessibleFixture()
|
|
251
|
-
el.darkTheme = true
|
|
252
|
-
await nextFrame()
|
|
253
|
-
|
|
254
|
-
// Wait for CodeMirror to apply theme
|
|
255
|
-
await aTimeout(100)
|
|
256
|
-
|
|
257
|
-
assert.isTrue(el.darkTheme)
|
|
258
|
-
})
|
|
259
|
-
|
|
260
|
-
it('should maintain readability in different themes', async () => {
|
|
261
|
-
const el = await accessibleFixture()
|
|
262
|
-
await nextFrame()
|
|
263
|
-
|
|
264
|
-
// Test both light and dark themes
|
|
265
|
-
el.darkTheme = false
|
|
266
|
-
await nextFrame()
|
|
267
|
-
assert.isFalse(el.darkTheme)
|
|
268
|
-
|
|
269
|
-
el.darkTheme = true
|
|
270
|
-
await nextFrame()
|
|
271
|
-
assert.isTrue(el.darkTheme)
|
|
272
|
-
})
|
|
273
|
-
})
|
|
274
|
-
|
|
275
248
|
describe('Touch and Mobile Accessibility', () => {
|
|
276
249
|
it.skip('should be usable on touch devices', async () => {
|
|
277
250
|
const el = await accessibleFixture()
|
|
@@ -77,7 +77,7 @@ describe('CodeEditor', () => {
|
|
|
77
77
|
return fixture(html`
|
|
78
78
|
<code-editor
|
|
79
79
|
label="Test Editor"
|
|
80
|
-
|
|
80
|
+
supportingtext="Enter your code here"
|
|
81
81
|
placeholder="Type here..."
|
|
82
82
|
.functionSchemas="${sampleFunctionSchemas}"
|
|
83
83
|
.suggestions="${sampleSuggestions}"
|
|
@@ -88,7 +88,7 @@ describe('CodeEditor', () => {
|
|
|
88
88
|
async function documentationFixture(): Promise<CodeEditorElement> {
|
|
89
89
|
return fixture(html`
|
|
90
90
|
<code-editor
|
|
91
|
-
|
|
91
|
+
showdocumentation
|
|
92
92
|
.functionSchemas="${sampleFunctionSchemas}"
|
|
93
93
|
.suggestions="${sampleSuggestions}"
|
|
94
94
|
></code-editor>
|
|
@@ -106,7 +106,6 @@ describe('CodeEditor', () => {
|
|
|
106
106
|
assert.isFalse(el.required)
|
|
107
107
|
assert.equal(el.placeholder, '')
|
|
108
108
|
assert.equal(el.value, '')
|
|
109
|
-
assert.isFalse(el.darkTheme)
|
|
110
109
|
assert.equal(el.language, 'javascript')
|
|
111
110
|
assert.isFalse(el.showDocumentation)
|
|
112
111
|
assert.deepEqual(el.functionSchemas, [])
|
|
@@ -123,7 +122,6 @@ describe('CodeEditor', () => {
|
|
|
123
122
|
el.required = true
|
|
124
123
|
el.placeholder = 'Test Placeholder'
|
|
125
124
|
el.value = 'test code'
|
|
126
|
-
el.darkTheme = true
|
|
127
125
|
el.language = 'python'
|
|
128
126
|
el.showDocumentation = true
|
|
129
127
|
el.functionSchemas = sampleFunctionSchemas
|
|
@@ -138,7 +136,6 @@ describe('CodeEditor', () => {
|
|
|
138
136
|
assert.isTrue(el.required)
|
|
139
137
|
assert.equal(el.placeholder, 'Test Placeholder')
|
|
140
138
|
assert.equal(el.value, 'test code')
|
|
141
|
-
assert.isTrue(el.darkTheme)
|
|
142
139
|
assert.equal(el.language, 'python')
|
|
143
140
|
assert.isTrue(el.showDocumentation)
|
|
144
141
|
assert.deepEqual(el.functionSchemas, sampleFunctionSchemas)
|
|
@@ -342,7 +339,7 @@ describe('CodeEditor', () => {
|
|
|
342
339
|
})
|
|
343
340
|
|
|
344
341
|
describe('Function Events', () => {
|
|
345
|
-
it('should dispatch
|
|
342
|
+
it('should dispatch functioninsert event through user interaction', async () => {
|
|
346
343
|
const el = await configuredFixture()
|
|
347
344
|
await nextFrame()
|
|
348
345
|
|
|
@@ -351,33 +348,33 @@ describe('CodeEditor', () => {
|
|
|
351
348
|
|
|
352
349
|
// Create a spy to capture the event
|
|
353
350
|
const eventSpy = sinon.spy()
|
|
354
|
-
el.addEventListener('
|
|
351
|
+
el.addEventListener('functioninsert', eventSpy)
|
|
355
352
|
|
|
356
353
|
// Note: In a real test, this would be triggered by CodeMirror autocompletion
|
|
357
354
|
// For now, we test that the event listener is properly set up
|
|
358
355
|
assert.isFalse(eventSpy.called)
|
|
359
356
|
})
|
|
360
357
|
|
|
361
|
-
it('should dispatch
|
|
358
|
+
it('should dispatch suggestioninsert event through user interaction', async () => {
|
|
362
359
|
const el = await configuredFixture()
|
|
363
360
|
await nextFrame()
|
|
364
361
|
|
|
365
362
|
// Create a spy to capture the event
|
|
366
363
|
const eventSpy = sinon.spy()
|
|
367
|
-
el.addEventListener('
|
|
364
|
+
el.addEventListener('suggestioninsert', eventSpy)
|
|
368
365
|
|
|
369
366
|
// Note: In a real test, this would be triggered by CodeMirror autocompletion
|
|
370
367
|
// For now, we test that the event listener is properly set up
|
|
371
368
|
assert.isFalse(eventSpy.called)
|
|
372
369
|
})
|
|
373
370
|
|
|
374
|
-
it('should have
|
|
371
|
+
it('should have docsrequest event listener when showDocumentation is true', async () => {
|
|
375
372
|
const el = await documentationFixture()
|
|
376
373
|
await nextFrame()
|
|
377
374
|
|
|
378
375
|
// Create a spy to capture the event
|
|
379
376
|
const eventSpy = sinon.spy()
|
|
380
|
-
el.addEventListener('
|
|
377
|
+
el.addEventListener('docsrequest', eventSpy)
|
|
381
378
|
|
|
382
379
|
// Test that the element is configured to dispatch this event
|
|
383
380
|
assert.isTrue(el.showDocumentation)
|
|
@@ -487,13 +484,13 @@ describe('CodeEditor', () => {
|
|
|
487
484
|
assert.isAtLeast(el.functionSchemas.length, 1)
|
|
488
485
|
})
|
|
489
486
|
|
|
490
|
-
it('should dispatch
|
|
487
|
+
it('should dispatch docsrequest event when documentation is enabled', async () => {
|
|
491
488
|
const el = await documentationFixture()
|
|
492
489
|
await nextFrame()
|
|
493
490
|
await aTimeout(100) // Wait for CodeMirror initialization
|
|
494
491
|
|
|
495
492
|
const eventSpy = sinon.spy()
|
|
496
|
-
el.addEventListener('
|
|
493
|
+
el.addEventListener('docsrequest', eventSpy)
|
|
497
494
|
|
|
498
495
|
// Access the private method through bracket notation to avoid TypeScript errors
|
|
499
496
|
const functionSchema = sampleFunctionSchemas[0]
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare class SyntheticSubmitEvent extends Event {
|
|
2
|
-
#private;
|
|
3
|
-
constructor(type: string, form: HTMLFormElement, eventInitDict?: SubmitEventInit);
|
|
4
|
-
get form(): HTMLFormElement;
|
|
5
|
-
get submitter(): HTMLElement | null | undefined;
|
|
6
|
-
get target(): HTMLFormElement;
|
|
7
|
-
get currentTarget(): HTMLFormElement;
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=SyntheticSubmitEvent.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SyntheticSubmitEvent.d.ts","sourceRoot":"","sources":["../../../src/events/SyntheticSubmitEvent.ts"],"names":[],"mappings":"AAAA,qBAAa,oBAAqB,SAAQ,KAAK;;gBAKjC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,aAAa,CAAC,EAAE,eAAe;IAMhF,IAAI,IAAI,IAAI,eAAe,CAE1B;IAED,IAAI,SAAS,IAAI,WAAW,GAAG,IAAI,GAAG,SAAS,CAE9C;IAED,IAAa,MAAM,IAAI,eAAe,CAErC;IAED,IAAa,aAAa,IAAI,eAAe,CAE5C;CACF"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export class SyntheticSubmitEvent extends Event {
|
|
2
|
-
#form;
|
|
3
|
-
#submitter;
|
|
4
|
-
constructor(type, form, eventInitDict) {
|
|
5
|
-
super(type, eventInitDict);
|
|
6
|
-
this.#form = form;
|
|
7
|
-
this.#submitter = eventInitDict?.submitter;
|
|
8
|
-
}
|
|
9
|
-
get form() {
|
|
10
|
-
return this.#form;
|
|
11
|
-
}
|
|
12
|
-
get submitter() {
|
|
13
|
-
return this.#submitter;
|
|
14
|
-
}
|
|
15
|
-
get target() {
|
|
16
|
-
return this.#form;
|
|
17
|
-
}
|
|
18
|
-
get currentTarget() {
|
|
19
|
-
return this.#form;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=SyntheticSubmitEvent.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SyntheticSubmitEvent.js","sourceRoot":"","sources":["../../../src/events/SyntheticSubmitEvent.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAC7C,KAAK,CAAiB;IAEtB,UAAU,CAAqB;IAE/B,YAAY,IAAY,EAAE,IAAqB,EAAE,aAA+B;QAC9E,KAAK,CAAC,IAAI,EAAE,aAAa,CAAC,CAAA;QAC1B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;QACjB,IAAI,CAAC,UAAU,GAAG,aAAa,EAAE,SAAS,CAAA;IAC5C,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAA;IACnB,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,UAAU,CAAA;IACxB,CAAC;IAED,IAAa,MAAM;QACjB,OAAO,IAAI,CAAC,KAAK,CAAA;IACnB,CAAC;IAED,IAAa,aAAa;QACxB,OAAO,IAAI,CAAC,KAAK,CAAA;IACnB,CAAC;CACF","sourcesContent":["export class SyntheticSubmitEvent extends Event {\n #form: HTMLFormElement\n\n #submitter?: HTMLElement | null\n\n constructor(type: string, form: HTMLFormElement, eventInitDict?: SubmitEventInit) {\n super(type, eventInitDict)\n this.#form = form\n this.#submitter = eventInitDict?.submitter\n }\n\n get form(): HTMLFormElement {\n return this.#form\n }\n\n get submitter(): HTMLElement | null | undefined {\n return this.#submitter\n }\n\n override get target(): HTMLFormElement {\n return this.#form\n }\n\n override get currentTarget(): HTMLFormElement {\n return this.#form\n }\n}\n"]}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export class SyntheticSubmitEvent extends Event {
|
|
2
|
-
#form: HTMLFormElement
|
|
3
|
-
|
|
4
|
-
#submitter?: HTMLElement | null
|
|
5
|
-
|
|
6
|
-
constructor(type: string, form: HTMLFormElement, eventInitDict?: SubmitEventInit) {
|
|
7
|
-
super(type, eventInitDict)
|
|
8
|
-
this.#form = form
|
|
9
|
-
this.#submitter = eventInitDict?.submitter
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
get form(): HTMLFormElement {
|
|
13
|
-
return this.#form
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
get submitter(): HTMLElement | null | undefined {
|
|
17
|
-
return this.#submitter
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
override get target(): HTMLFormElement {
|
|
21
|
-
return this.#form
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
override get currentTarget(): HTMLFormElement {
|
|
25
|
-
return this.#form
|
|
26
|
-
}
|
|
27
|
-
}
|