@api-client/ui 0.5.15 → 0.5.16

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.
@@ -17,4 +17,4 @@ export declare class ChipWidget extends WidgetType {
17
17
  toDOM(view: EditorView): HTMLElement;
18
18
  ignoreEvent(): boolean;
19
19
  }
20
- //# sourceMappingURL=PlaceholderWidget.d.ts.map
20
+ //# sourceMappingURL=ChipWidget.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChipWidget.d.ts","sourceRoot":"","sources":["../../../../../src/elements/code-editor/internals/ChipWidget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,6BAA6B,CAAA;AAEpC;;;;;;;;GAQG;AACH,qBAAa,UAAW,SAAQ,UAAU;IACrB,UAAU,EAAE,UAAU;gBAAtB,UAAU,EAAE,UAAU;IAIhC,EAAE,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO;IAIvC,KAAK,CAAC,IAAI,EAAE,UAAU,GAAG,WAAW;IAwB3B,WAAW,IAAI,OAAO;CAGhC"}
@@ -30,7 +30,7 @@ export class ChipWidget extends WidgetType {
30
30
  const pos = view.posAtDOM(wrapper);
31
31
  if (pos === null)
32
32
  return;
33
- const originalText = `{{${this.suggestion.label}}}`;
33
+ const originalText = `{{${this.suggestion.id}}}`;
34
34
  view.dispatch({
35
35
  changes: { from: pos, to: pos + originalText.length, insert: '' },
36
36
  });
@@ -43,4 +43,4 @@ export class ChipWidget extends WidgetType {
43
43
  return false;
44
44
  }
45
45
  }
46
- //# sourceMappingURL=PlaceholderWidget.js.map
46
+ //# sourceMappingURL=ChipWidget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChipWidget.js","sourceRoot":"","sources":["../../../../../src/elements/code-editor/internals/ChipWidget.ts"],"names":[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E;aAClE,CAAC,CAAA;YACF,IAAI,CAAC,KAAK,EAAE,CAAA;QACd,CAAC,CAAC,CAAA;QAEF,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;QACzB,OAAO,OAAO,CAAA;IAChB,CAAC;IAEQ,WAAW;QAClB,OAAO,KAAK,CAAA;IACd,CAAC;CACF","sourcesContent":["import { EditorView, WidgetType } from '@codemirror/view'\nimport type { Suggestion } from './types.js'\nimport '../../../md/chip/ui-chip.js'\n\n/**\n * A widget that represents a placeholder in the code editor,\n * specifically for suggestions that are replaced with chips.\n *\n * This widget is used to create a visual representation of a suggestion\n * in the code editor, allowing users to see and interact with suggestions\n * as chips. When a chip is removed, the corresponding text in the editor\n * is also removed.\n */\nexport class ChipWidget extends WidgetType {\n constructor(public suggestion: Suggestion) {\n super()\n }\n\n override eq(other: WidgetType): boolean {\n return this.suggestion.id == (other as ChipWidget).suggestion.id\n }\n\n toDOM(view: EditorView): HTMLElement {\n const wrapper = document.createElement('span')\n wrapper.className = 'mention-chip'\n wrapper.setAttribute('data-mention-id', this.suggestion.id)\n\n const chip = document.createElement('ui-chip')\n chip.setAttribute('type', 'input')\n chip.setAttribute('removable', 'true')\n chip.textContent = this.suggestion.label\n chip.addEventListener('remove', () => {\n const pos = view.posAtDOM(wrapper)\n if (pos === null) return\n\n const originalText = `{{${this.suggestion.id}}}`\n view.dispatch({\n changes: { from: pos, to: pos + originalText.length, insert: '' },\n })\n view.focus()\n })\n\n wrapper.appendChild(chip)\n return wrapper\n }\n\n override ignoreEvent(): boolean {\n return false\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"CodeEditor.d.ts","sourceRoot":"","sources":["../../../../../src/elements/code-editor/internals/CodeEditor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,UAAU,EAAE,cAAc,EAAE,cAAc,EAAW,MAAM,KAAK,CAAA;AA0B/E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAA;AAGrE,OAAO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AoB;IAqD5B;;;OAGG;IACH,OAAO,CAAC,uBAAuB;IAoB/B;;OAEG;IACH,OAAO,CAAC,sBAAsB;IA0C9B,OAAO,CAAC,wBAAwB;IAmBhC,OAAO,CAAC,0BAA0B;IAmBlC;;;OAGG;IACH,OAAO,CAAC,wBAAwB,CAmB/B;IAED;;;OAGG;IACH,OAAO,CAAC,yBAAyB;IAgEjC;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAiB1B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAe3B;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAU1B;;OAEG;IACH,OAAO,CAAC,iBAAiB;IASzB;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAQ9B;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAQhC;;OAEG;IACM,KAAK,IAAI,IAAI;IAItB;;OAEG;IACH,YAAY,IAAI;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAMnD;;OAEG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAUrB,MAAM,IAAI,cAAc;CAgBlC"}
@@ -251,12 +251,12 @@ let CodeEditor = (() => {
251
251
  */
252
252
  get activeSuggestions() {
253
253
  const suggestions = [];
254
- const placeholderPattern = /\{\{(\w+)\}\}/g;
254
+ const placeholderPattern = /\{\{([^}]+)\}\}/g;
255
255
  let match;
256
256
  while ((match = placeholderPattern.exec(this.value)) !== null) {
257
257
  const placeholderText = match[1];
258
- // Find suggestion by label
259
- const suggestion = this.suggestions.find((s) => s.label.toLowerCase() === placeholderText.toLowerCase());
258
+ // Find suggestion by id
259
+ const suggestion = this.suggestions.find((s) => s.id === placeholderText);
260
260
  if (suggestion) {
261
261
  suggestions.push(suggestion);
262
262
  }
@@ -341,7 +341,7 @@ let CodeEditor = (() => {
341
341
  * This is created as a method to get access to the component's `suggestions`.
342
342
  */
343
343
  createPlaceholderPlugin() {
344
- const placeholderMatcher = new SuggestionMatchDecorator(/\{\{(\w+)\}\}/g, this.suggestions);
344
+ const placeholderMatcher = new SuggestionMatchDecorator(/\{\{([^}]+)\}\}/g, this.suggestions);
345
345
  this.placeholderMatcher = placeholderMatcher;
346
346
  // This class needs to be defined here to have access to the `placeholderMatcher`
347
347
  class AtomicDecorationRange {
@@ -381,7 +381,7 @@ let CodeEditor = (() => {
381
381
  }
382
382
  }
383
383
  // Check if we're typing a suggestion trigger (e.g., {{)
384
- const suggestionMatch = textBefore.match(/\{\{(\w*)$/);
384
+ const suggestionMatch = textBefore.match(/\{\{([^}]*)$/);
385
385
  if (suggestionMatch) {
386
386
  const prefix = suggestionMatch[1];
387
387
  const suggestions = this.suggestions
@@ -401,6 +401,7 @@ let CodeEditor = (() => {
401
401
  const result = {
402
402
  label: schema.name,
403
403
  detail: schema.description || '',
404
+ type: 'function',
404
405
  info: () => this.createFunctionInfoElement(schema),
405
406
  apply: (view, completion, from, to) => {
406
407
  const functionCall = this.formatFunctionCall(schema);
@@ -418,8 +419,9 @@ let CodeEditor = (() => {
418
419
  label: suggestion.label,
419
420
  detail: suggestion.description || '',
420
421
  info: suggestion.suffix || '',
422
+ type: 'variable',
421
423
  apply: (view, completion, from, to) => {
422
- const placeholderText = `{{${suggestion.label}}}`;
424
+ const placeholderText = `{{${suggestion.id}}}`;
423
425
  view.dispatch({
424
426
  changes: { from: from - 2, to, insert: placeholderText }, // -2 to include the {{
425
427
  selection: { anchor: from - 2 + placeholderText.length },
@@ -1 +1 @@
1
- {"version":3,"file":"CodeEditor.js","sourceRoot":"","sources":["../../../../../src/elements/code-editor/internals/CodeEditor.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAkC,OAAO,EAAE,MAAM,KAAK,CAAA;AAC/E,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AACtD,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,OAAO;;;;;UAKnE,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAA,gCAAgC,IAAI,CAAC,cAAc,QAAQ,CAAC,CAAC,CAAC,OAAO;;KAElG,CAAA;QACH,CAAC;;;AAtjBH;;;;;;;;;;;;;;GAcG;AACH","sourcesContent":["import { html, LitElement, PropertyValues, TemplateResult, nothing } from 'lit'\nimport { property, query, state } from 'lit/decorators.js'\nimport { classMap } from 'lit/directives/class-map.js'\nimport { linter } from '@codemirror/lint'\nimport { Compartment, EditorState, Extension } from '@codemirror/state'\nimport {\n autocompletion,\n CompletionContext,\n type CompletionResult,\n type CompletionSource,\n type Completion,\n} from '@codemirror/autocomplete'\nimport { javascript } from '@codemirror/lang-javascript'\nimport { syntaxHighlighting, defaultHighlightStyle } from '@codemirror/language'\nimport { oneDark } from '@codemirror/theme-one-dark'\nimport { keymap } from '@codemirror/view'\nimport { defaultKeymap } from '@codemirror/commands'\nimport {\n EditorView,\n Decoration,\n DecorationSet,\n ViewPlugin,\n ViewUpdate,\n hoverTooltip,\n type Tooltip,\n} from '@codemirror/view'\nimport type { FunctionSchema } from '@pawel-up/jexl/schemas/types.js'\nimport { getTypeStringFromSchema } from '@pawel-up/jexl/schemas/utils.js'\nimport { functionLinter } from './Linter.js'\nimport type { FunctionInsertEvent, Suggestion, SuggestionInsertEvent } from './types.js'\nimport { SuggestionMatchDecorator } from './SuggestionMatchDecorator.js'\n\n/**\n * A CodeMirror 6 based editor component that supports function autocomplete and suggestion placeholders.\n *\n * Features:\n * - Dynamic function schema loading\n * - Autocomplete for functions and suggestions\n * - Suggestion placeholders with double curly braces ({{suggestion}})\n * - Keyboard navigation\n * - Accessibility support\n *\n * @fires function-insert - When a function is inserted\n * @fires suggestion-insert - When a suggestion is inserted\n * @fires input - When the editor content changes\n * @fires change - When the editor loses focus and content has changed\n */\nexport default class CodeEditor extends LitElement {\n /**\n * Shadow root configuration for the component.\n * Uses 'open' mode for accessibility and delegates focus to enable proper focus management.\n */\n static override shadowRootOptions: ShadowRootInit = {\n mode: 'open',\n delegatesFocus: true,\n }\n\n /**\n * The label text displayed as placeholder/floating label\n */\n @property({ type: String })\n accessor label = ''\n\n /**\n * Supporting text displayed below the editor\n */\n @property({ type: String, attribute: 'supporting-text' })\n accessor supportingText = ''\n\n /**\n * Whether the component is disabled\n */\n @property({ type: Boolean, reflect: true })\n accessor disabled = false\n\n /**\n * Whether the component is in an invalid state\n */\n @property({ type: Boolean, reflect: true })\n accessor invalid = false\n\n /**\n * The name attribute for form integration\n */\n @property({ type: String })\n accessor name = ''\n\n /**\n * Whether the input is required\n */\n @property({ type: Boolean })\n accessor required = false\n\n /**\n * Placeholder text shown when editor is empty\n */\n @property({ type: String })\n accessor placeholder = ''\n\n /**\n * This property is used internally to set value without triggering updates.\n */\n #value = ''\n\n /**\n * The editor content value\n */\n get value(): string {\n return this.#value\n }\n\n @property({ type: String })\n set value(newValue: string) {\n const oldValue = this.#value\n if (newValue !== oldValue) {\n this.#value = newValue\n this._previousValue = newValue\n this.requestUpdate('value', oldValue)\n }\n }\n\n /**\n * Available function schemas for autocomplete\n */\n @property({ type: Array, attribute: false })\n accessor functionSchemas: FunctionSchema[] = []\n\n /**\n * Available suggestions for autocomplete\n */\n @property({ type: Array, attribute: false })\n accessor suggestions: Suggestion[] = []\n\n /**\n * Whether to use dark theme\n */\n @property({ type: Boolean, attribute: 'dark-theme' })\n accessor darkTheme = false\n\n /**\n * Programming language for syntax highlighting\n */\n @property({ type: String })\n accessor language = 'javascript'\n\n @query('.editor-container')\n private accessor editorContainer!: HTMLDivElement\n\n @state()\n private accessor hasContent = false\n\n @state()\n private accessor isEditorFocus = false\n\n private editorView?: EditorView\n /**\n * A control value to track previous value of the editor.\n * This is used to detect when change event should be dispatched.\n */\n private _previousValue = ''\n /**\n * Matcher for suggestion placeholders in the editor.\n */\n placeholderMatcher?: SuggestionMatchDecorator\n\n /**\n * Get all suggestions (placeholders) currently in the editor\n */\n get activeSuggestions(): Suggestion[] {\n const suggestions: Suggestion[] = []\n const placeholderPattern = /\\{\\{(\\w+)\\}\\}/g\n let match: RegExpExecArray | null\n while ((match = placeholderPattern.exec(this.value)) !== null) {\n const placeholderText = match[1]\n // Find suggestion by label\n const suggestion = this.suggestions.find((s) => s.label.toLowerCase() === placeholderText.toLowerCase())\n if (suggestion) {\n suggestions.push(suggestion)\n }\n }\n return suggestions\n }\n\n private readonlyState = new Compartment()\n\n override disconnectedCallback(): void {\n super.disconnectedCallback()\n this.editorView?.destroy()\n }\n\n override firstUpdated(): void {\n this.initializeCodeMirror()\n this.updateEditorContent()\n }\n\n override willUpdate(changedProperties: PropertyValues): void {\n super.willUpdate(changedProperties)\n\n if (changedProperties.has('suggestions')) {\n if (this.placeholderMatcher) {\n this.placeholderMatcher.suggestions = this.suggestions || []\n }\n }\n\n if (changedProperties.has('value') && this.editorView) {\n this.updateEditorContent()\n }\n\n if (changedProperties.has('disabled')) {\n this.editorView?.dispatch({\n effects: this.readonlyState.reconfigure(EditorState.readOnly.of(this.disabled)),\n })\n }\n }\n\n /**\n * Initialize CodeMirror editor with extensions\n */\n private initializeCodeMirror(): void {\n const extensions: Extension[] = [\n keymap.of(defaultKeymap),\n syntaxHighlighting(defaultHighlightStyle),\n autocompletion({\n override: [this.createCompletionSource()],\n activateOnTyping: true,\n maxRenderedOptions: 10,\n }),\n EditorView.updateListener.of((update: ViewUpdate) => {\n if (update.docChanged) {\n this.handleEditorChange()\n }\n if (update.focusChanged) {\n this.handleFocusChange(update.view.hasFocus)\n }\n }),\n this.createPlaceholderPlugin(),\n hoverTooltip(this.createHoverTooltipSource),\n linter((view) => functionLinter(view, this.functionSchemas, (e) => this.dispatchEvent(e))),\n this.readonlyState.of(EditorState.readOnly.of(this.disabled)),\n ]\n\n // Add language support\n if (this.language === 'javascript') {\n extensions.push(javascript())\n }\n\n // Add theme\n if (this.darkTheme) {\n extensions.push(oneDark)\n }\n\n // Add placeholder\n if (this.placeholder) {\n extensions.push(\n EditorView.contentAttributes.of({\n 'aria-placeholder': this.placeholder,\n })\n )\n }\n\n const state = EditorState.create({\n doc: this.value,\n extensions,\n })\n\n this.editorView = new EditorView({\n state,\n parent: this.editorContainer,\n })\n }\n\n /**\n * Creates the ViewPlugin for rendering suggestion placeholders.\n * This is created as a method to get access to the component's `suggestions`.\n */\n private createPlaceholderPlugin(): Extension {\n const placeholderMatcher = new SuggestionMatchDecorator(/\\{\\{(\\w+)\\}\\}/g, this.suggestions)\n this.placeholderMatcher = placeholderMatcher\n // This class needs to be defined here to have access to the `placeholderMatcher`\n class AtomicDecorationRange {\n placeholders: DecorationSet\n constructor(view: EditorView) {\n this.placeholders = placeholderMatcher.createDeco(view)\n }\n update(update: ViewUpdate) {\n this.placeholders = placeholderMatcher.updateDeco(update, this.placeholders)\n }\n }\n\n return ViewPlugin.fromClass(AtomicDecorationRange, {\n decorations: (instance) => instance.placeholders,\n provide: (plugin) => EditorView.atomicRanges.of((view) => view.plugin(plugin)?.placeholders || Decoration.none),\n })\n }\n\n /**\n * Create completion source for functions and suggestions\n */\n private createCompletionSource(): CompletionSource {\n return (context: CompletionContext): CompletionResult | null => {\n const { pos } = context\n const line = context.state.doc.lineAt(pos)\n const textBefore = line.text.slice(0, pos - line.from)\n\n // Check if we're typing a function name\n const functionMatch = textBefore.match(/(\\w+)$/)\n if (functionMatch) {\n const prefix = functionMatch[1]\n const functions = this.functionSchemas\n .filter((fn) => fn.name.toLowerCase().startsWith(prefix.toLowerCase()))\n .map((fn) => this.createFunctionCompletion(fn))\n\n if (functions.length > 0) {\n return {\n from: pos - prefix.length,\n options: functions,\n }\n }\n }\n\n // Check if we're typing a suggestion trigger (e.g., {{)\n const suggestionMatch = textBefore.match(/\\{\\{(\\w*)$/)\n if (suggestionMatch) {\n const prefix = suggestionMatch[1]\n const suggestions = this.suggestions\n .filter((suggestion) => suggestion.label.toLowerCase().startsWith(prefix.toLowerCase()))\n .map((suggestion) => this.createSuggestionCompletion(suggestion))\n\n if (suggestions.length > 0) {\n return {\n from: pos - prefix.length,\n options: suggestions,\n }\n }\n }\n\n return null\n }\n }\n\n private createFunctionCompletion(schema: FunctionSchema): Completion {\n const result: Completion = {\n label: schema.name,\n detail: schema.description || '',\n info: () => this.createFunctionInfoElement(schema),\n apply: (view: EditorView, completion: unknown, from: number, to: number) => {\n const functionCall = this.formatFunctionCall(schema)\n view.dispatch({\n changes: { from, to, insert: functionCall },\n selection: { anchor: from + functionCall.length },\n })\n this.dispatchFunctionInsert(schema, from)\n },\n }\n\n return result\n }\n\n private createSuggestionCompletion(suggestion: Suggestion): Completion {\n const result: Completion = {\n label: suggestion.label,\n detail: suggestion.description || '',\n info: suggestion.suffix || '',\n apply: (view: EditorView, completion: unknown, from: number, to: number) => {\n const placeholderText = `{{${suggestion.label}}}`\n view.dispatch({\n changes: { from: from - 2, to, insert: placeholderText }, // -2 to include the {{\n selection: { anchor: from - 2 + placeholderText.length },\n })\n this.dispatchSuggestionInsert(suggestion, from - 2)\n },\n }\n\n return result\n }\n\n /**\n * Creates the source for the hover tooltips.\n * This is an arrow function to automatically bind `this`.\n */\n private createHoverTooltipSource = (view: EditorView, pos: number): Tooltip | null => {\n const word = view.state.wordAt(pos)\n if (!word) {\n return null\n }\n\n const functionName = view.state.doc.sliceString(word.from, word.to)\n const fnSchema = this.functionSchemas.find((schema) => schema.name === functionName)\n\n if (!fnSchema) {\n return null\n }\n\n return {\n pos: word.from,\n end: word.to,\n above: true,\n create: () => ({ dom: this.createFunctionInfoElement(fnSchema) }),\n }\n }\n\n /**\n * Creates a styled HTML element to display function documentation.\n * This is used for both hover tooltips and autocomplete info panels.\n */\n private createFunctionInfoElement(fn: FunctionSchema): HTMLElement {\n const container = document.createElement('div')\n container.className = 'function-info' // for styling\n\n if (fn.description) {\n const description = document.createElement('p')\n description.className = 'description'\n description.textContent = fn.description\n container.appendChild(description)\n }\n\n if (fn.parameters && fn.parameters.length > 0) {\n const paramsContainer = document.createElement('div')\n paramsContainer.className = 'parameters'\n\n const paramsHeader = document.createElement('h4')\n paramsHeader.textContent = 'Parameters'\n paramsContainer.appendChild(paramsHeader)\n\n const paramsList = document.createElement('ul')\n fn.parameters.forEach((param) => {\n const listItem = document.createElement('li')\n\n const name = document.createElement('span')\n name.className = 'param-name'\n name.textContent = param.name\n\n const type = document.createElement('span')\n type.className = 'param-type'\n type.textContent = `: ${getTypeStringFromSchema(param.schema)}`\n\n listItem.appendChild(name)\n listItem.appendChild(type)\n\n if (param.schema.description) {\n const paramDesc = document.createElement('p')\n paramDesc.className = 'param-description'\n paramDesc.textContent = param.schema.description\n listItem.appendChild(paramDesc)\n }\n paramsList.appendChild(listItem)\n })\n paramsContainer.appendChild(paramsList)\n container.appendChild(paramsContainer)\n }\n\n if (fn.returns) {\n const returnsContainer = document.createElement('div')\n returnsContainer.className = 'returns'\n\n const returnsHeader = document.createElement('h4')\n returnsHeader.textContent = 'Returns'\n returnsContainer.appendChild(returnsHeader)\n\n const returnsDesc = document.createElement('p')\n const returnType = getTypeStringFromSchema(fn.returns)\n returnsDesc.textContent = fn.returns.description ? `${returnType}: ${fn.returns.description}` : returnType\n returnsContainer.appendChild(returnsDesc)\n container.appendChild(returnsContainer)\n }\n\n return container\n }\n\n /**\n * Format function call with parameters\n */\n private formatFunctionCall(fn: FunctionSchema): string {\n if (!fn.parameters || fn.parameters.length === 0) {\n return `${fn.name}()`\n }\n\n const params = fn.parameters\n .map((param) => {\n if (param.required) {\n return param.name\n }\n return `${param.name}?`\n })\n .join(', ')\n\n return `${fn.name}(${params})`\n }\n\n /**\n * Update editor content when value changes\n */\n private updateEditorContent(): void {\n if (!this.editorView) return\n\n const currentValue = this.editorView.state.doc.toString()\n if (currentValue !== this.value) {\n this.editorView.dispatch({\n changes: {\n from: 0,\n to: this.editorView.state.doc.length,\n insert: this.value,\n },\n })\n }\n }\n\n /**\n * Handle editor content change\n */\n private handleEditorChange(): void {\n if (!this.editorView) return\n\n const newValue = this.editorView.state.doc.toString()\n this.#value = newValue\n this.hasContent = newValue.length > 0\n\n this.dispatchEvent(new Event('input', { bubbles: true }))\n }\n\n /**\n * Handle focus change\n */\n private handleFocusChange(hasFocus: boolean): void {\n this.isEditorFocus = hasFocus\n\n if (!hasFocus && this.#value !== this._previousValue) {\n this._previousValue = this.#value\n this.dispatchEvent(new Event('change'))\n }\n }\n\n /**\n * Dispatch function insert event\n */\n private dispatchFunctionInsert(functionSchema: FunctionSchema, position: number): void {\n const event = new CustomEvent<FunctionInsertEvent>('function-insert', {\n detail: { functionSchema, position },\n bubbles: true,\n })\n this.dispatchEvent(event)\n }\n\n /**\n * Dispatch suggestion insert event\n */\n private dispatchSuggestionInsert(suggestion: Suggestion, position: number): void {\n const event = new CustomEvent<SuggestionInsertEvent>('suggestion-insert', {\n detail: { suggestion, position },\n bubbles: true,\n })\n this.dispatchEvent(event)\n }\n\n /**\n * Focus the editor\n */\n override focus(): void {\n this.editorView?.focus()\n }\n\n /**\n * Get the editor's current selection\n */\n getSelection(): { from: number; to: number } | null {\n if (!this.editorView) return null\n const { from, to } = this.editorView.state.selection.main\n return { from, to }\n }\n\n /**\n * Insert text at the current cursor position\n */\n insertText(text: string): void {\n if (!this.editorView) return\n\n const { from, to } = this.editorView.state.selection.main\n this.editorView.dispatch({\n changes: { from, to, insert: text },\n selection: { anchor: from + text.length },\n })\n }\n\n override render(): TemplateResult {\n const hasLabel = !!this.label\n const hasSupportingText = !!this.supportingText\n\n return html`\n <div class=\"surface ${classMap({ 'has-focus': this.isEditorFocus, 'invalid': this.invalid })}\">\n <div class=\"content\">\n ${hasLabel ? html`<div class=\"label\">${this.label}</div>` : nothing}\n\n <div class=\"editor-container\" part=\"editor\"></div>\n </div>\n\n ${hasSupportingText ? html`<div class=\"supporting-text\">${this.supportingText}</div>` : nothing}\n </div>\n `\n }\n}\n"]}
1
+ {"version":3,"file":"CodeEditor.js","sourceRoot":"","sources":["../../../../../src/elements/code-editor/internals/CodeEditor.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAkC,O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AAE,WAAW,EAAE,IAAI,CAAC,aAAa,EAAE,SAAS,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC;;YAEtF,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAA,sBAAsB,IAAI,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO;;;;;UAKnE,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAA,gCAAgC,IAAI,CAAC,cAAc,QAAQ,CAAC,CAAC,CAAC,OAAO;;KAElG,CAAA;QACH,CAAC;;;AAxjBH;;;;;;;;;;;;;;GAcG;AACH","sourcesContent":["import { html, LitElement, PropertyValues, TemplateResult, nothing } from 'lit'\nimport { property, query, state } from 'lit/decorators.js'\nimport { classMap } from 'lit/directives/class-map.js'\nimport { linter } from '@codemirror/lint'\nimport { Compartment, EditorState, Extension } from '@codemirror/state'\nimport {\n autocompletion,\n CompletionContext,\n type CompletionResult,\n type CompletionSource,\n type Completion,\n} from '@codemirror/autocomplete'\nimport { javascript } from '@codemirror/lang-javascript'\nimport { syntaxHighlighting, defaultHighlightStyle } from '@codemirror/language'\nimport { oneDark } from '@codemirror/theme-one-dark'\nimport { keymap } from '@codemirror/view'\nimport { defaultKeymap } from '@codemirror/commands'\nimport {\n EditorView,\n Decoration,\n DecorationSet,\n ViewPlugin,\n ViewUpdate,\n hoverTooltip,\n type Tooltip,\n} from '@codemirror/view'\nimport type { FunctionSchema } from '@pawel-up/jexl/schemas/types.js'\nimport { getTypeStringFromSchema } from '@pawel-up/jexl/schemas/utils.js'\nimport { functionLinter } from './Linter.js'\nimport type { FunctionInsertEvent, Suggestion, SuggestionInsertEvent } from './types.js'\nimport { SuggestionMatchDecorator } from './SuggestionMatchDecorator.js'\n\n/**\n * A CodeMirror 6 based editor component that supports function autocomplete and suggestion placeholders.\n *\n * Features:\n * - Dynamic function schema loading\n * - Autocomplete for functions and suggestions\n * - Suggestion placeholders with double curly braces ({{suggestion}})\n * - Keyboard navigation\n * - Accessibility support\n *\n * @fires function-insert - When a function is inserted\n * @fires suggestion-insert - When a suggestion is inserted\n * @fires input - When the editor content changes\n * @fires change - When the editor loses focus and content has changed\n */\nexport default class CodeEditor extends LitElement {\n /**\n * Shadow root configuration for the component.\n * Uses 'open' mode for accessibility and delegates focus to enable proper focus management.\n */\n static override shadowRootOptions: ShadowRootInit = {\n mode: 'open',\n delegatesFocus: true,\n }\n\n /**\n * The label text displayed as placeholder/floating label\n */\n @property({ type: String })\n accessor label = ''\n\n /**\n * Supporting text displayed below the editor\n */\n @property({ type: String, attribute: 'supporting-text' })\n accessor supportingText = ''\n\n /**\n * Whether the component is disabled\n */\n @property({ type: Boolean, reflect: true })\n accessor disabled = false\n\n /**\n * Whether the component is in an invalid state\n */\n @property({ type: Boolean, reflect: true })\n accessor invalid = false\n\n /**\n * The name attribute for form integration\n */\n @property({ type: String })\n accessor name = ''\n\n /**\n * Whether the input is required\n */\n @property({ type: Boolean })\n accessor required = false\n\n /**\n * Placeholder text shown when editor is empty\n */\n @property({ type: String })\n accessor placeholder = ''\n\n /**\n * This property is used internally to set value without triggering updates.\n */\n #value = ''\n\n /**\n * The editor content value\n */\n get value(): string {\n return this.#value\n }\n\n @property({ type: String })\n set value(newValue: string) {\n const oldValue = this.#value\n if (newValue !== oldValue) {\n this.#value = newValue\n this._previousValue = newValue\n this.requestUpdate('value', oldValue)\n }\n }\n\n /**\n * Available function schemas for autocomplete\n */\n @property({ type: Array, attribute: false })\n accessor functionSchemas: FunctionSchema[] = []\n\n /**\n * Available suggestions for autocomplete\n */\n @property({ type: Array, attribute: false })\n accessor suggestions: Suggestion[] = []\n\n /**\n * Whether to use dark theme\n */\n @property({ type: Boolean, attribute: 'dark-theme' })\n accessor darkTheme = false\n\n /**\n * Programming language for syntax highlighting\n */\n @property({ type: String })\n accessor language = 'javascript'\n\n @query('.editor-container')\n private accessor editorContainer!: HTMLDivElement\n\n @state()\n private accessor hasContent = false\n\n @state()\n private accessor isEditorFocus = false\n\n private editorView?: EditorView\n /**\n * A control value to track previous value of the editor.\n * This is used to detect when change event should be dispatched.\n */\n private _previousValue = ''\n /**\n * Matcher for suggestion placeholders in the editor.\n */\n placeholderMatcher?: SuggestionMatchDecorator\n\n /**\n * Get all suggestions (placeholders) currently in the editor\n */\n get activeSuggestions(): Suggestion[] {\n const suggestions: Suggestion[] = []\n const placeholderPattern = /\\{\\{([^}]+)\\}\\}/g\n let match: RegExpExecArray | null\n while ((match = placeholderPattern.exec(this.value)) !== null) {\n const placeholderText = match[1]\n // Find suggestion by id\n const suggestion = this.suggestions.find((s) => s.id === placeholderText)\n if (suggestion) {\n suggestions.push(suggestion)\n }\n }\n return suggestions\n }\n\n private readonlyState = new Compartment()\n\n override disconnectedCallback(): void {\n super.disconnectedCallback()\n this.editorView?.destroy()\n }\n\n override firstUpdated(): void {\n this.initializeCodeMirror()\n this.updateEditorContent()\n }\n\n override willUpdate(changedProperties: PropertyValues): void {\n super.willUpdate(changedProperties)\n\n if (changedProperties.has('suggestions')) {\n if (this.placeholderMatcher) {\n this.placeholderMatcher.suggestions = this.suggestions || []\n }\n }\n\n if (changedProperties.has('value') && this.editorView) {\n this.updateEditorContent()\n }\n\n if (changedProperties.has('disabled')) {\n this.editorView?.dispatch({\n effects: this.readonlyState.reconfigure(EditorState.readOnly.of(this.disabled)),\n })\n }\n }\n\n /**\n * Initialize CodeMirror editor with extensions\n */\n private initializeCodeMirror(): void {\n const extensions: Extension[] = [\n keymap.of(defaultKeymap),\n syntaxHighlighting(defaultHighlightStyle),\n autocompletion({\n override: [this.createCompletionSource()],\n activateOnTyping: true,\n maxRenderedOptions: 10,\n }),\n EditorView.updateListener.of((update: ViewUpdate) => {\n if (update.docChanged) {\n this.handleEditorChange()\n }\n if (update.focusChanged) {\n this.handleFocusChange(update.view.hasFocus)\n }\n }),\n this.createPlaceholderPlugin(),\n hoverTooltip(this.createHoverTooltipSource),\n linter((view) => functionLinter(view, this.functionSchemas, (e) => this.dispatchEvent(e))),\n this.readonlyState.of(EditorState.readOnly.of(this.disabled)),\n ]\n\n // Add language support\n if (this.language === 'javascript') {\n extensions.push(javascript())\n }\n\n // Add theme\n if (this.darkTheme) {\n extensions.push(oneDark)\n }\n\n // Add placeholder\n if (this.placeholder) {\n extensions.push(\n EditorView.contentAttributes.of({\n 'aria-placeholder': this.placeholder,\n })\n )\n }\n\n const state = EditorState.create({\n doc: this.value,\n extensions,\n })\n\n this.editorView = new EditorView({\n state,\n parent: this.editorContainer,\n })\n }\n\n /**\n * Creates the ViewPlugin for rendering suggestion placeholders.\n * This is created as a method to get access to the component's `suggestions`.\n */\n private createPlaceholderPlugin(): Extension {\n const placeholderMatcher = new SuggestionMatchDecorator(/\\{\\{([^}]+)\\}\\}/g, this.suggestions)\n this.placeholderMatcher = placeholderMatcher\n // This class needs to be defined here to have access to the `placeholderMatcher`\n class AtomicDecorationRange {\n placeholders: DecorationSet\n constructor(view: EditorView) {\n this.placeholders = placeholderMatcher.createDeco(view)\n }\n update(update: ViewUpdate) {\n this.placeholders = placeholderMatcher.updateDeco(update, this.placeholders)\n }\n }\n\n return ViewPlugin.fromClass(AtomicDecorationRange, {\n decorations: (instance) => instance.placeholders,\n provide: (plugin) => EditorView.atomicRanges.of((view) => view.plugin(plugin)?.placeholders || Decoration.none),\n })\n }\n\n /**\n * Create completion source for functions and suggestions\n */\n private createCompletionSource(): CompletionSource {\n return (context: CompletionContext): CompletionResult | null => {\n const { pos } = context\n const line = context.state.doc.lineAt(pos)\n const textBefore = line.text.slice(0, pos - line.from)\n\n // Check if we're typing a function name\n const functionMatch = textBefore.match(/(\\w+)$/)\n if (functionMatch) {\n const prefix = functionMatch[1]\n const functions = this.functionSchemas\n .filter((fn) => fn.name.toLowerCase().startsWith(prefix.toLowerCase()))\n .map((fn) => this.createFunctionCompletion(fn))\n\n if (functions.length > 0) {\n return {\n from: pos - prefix.length,\n options: functions,\n }\n }\n }\n\n // Check if we're typing a suggestion trigger (e.g., {{)\n const suggestionMatch = textBefore.match(/\\{\\{([^}]*)$/)\n if (suggestionMatch) {\n const prefix = suggestionMatch[1]\n const suggestions = this.suggestions\n .filter((suggestion) => suggestion.label.toLowerCase().startsWith(prefix.toLowerCase()))\n .map((suggestion) => this.createSuggestionCompletion(suggestion))\n\n if (suggestions.length > 0) {\n return {\n from: pos - prefix.length,\n options: suggestions,\n }\n }\n }\n\n return null\n }\n }\n\n private createFunctionCompletion(schema: FunctionSchema): Completion {\n const result: Completion = {\n label: schema.name,\n detail: schema.description || '',\n type: 'function',\n info: () => this.createFunctionInfoElement(schema),\n apply: (view: EditorView, completion: unknown, from: number, to: number) => {\n const functionCall = this.formatFunctionCall(schema)\n view.dispatch({\n changes: { from, to, insert: functionCall },\n selection: { anchor: from + functionCall.length },\n })\n this.dispatchFunctionInsert(schema, from)\n },\n }\n\n return result\n }\n\n private createSuggestionCompletion(suggestion: Suggestion): Completion {\n const result: Completion = {\n label: suggestion.label,\n detail: suggestion.description || '',\n info: suggestion.suffix || '',\n type: 'variable',\n apply: (view: EditorView, completion: unknown, from: number, to: number) => {\n const placeholderText = `{{${suggestion.id}}}`\n view.dispatch({\n changes: { from: from - 2, to, insert: placeholderText }, // -2 to include the {{\n selection: { anchor: from - 2 + placeholderText.length },\n })\n this.dispatchSuggestionInsert(suggestion, from - 2)\n },\n }\n\n return result\n }\n\n /**\n * Creates the source for the hover tooltips.\n * This is an arrow function to automatically bind `this`.\n */\n private createHoverTooltipSource = (view: EditorView, pos: number): Tooltip | null => {\n const word = view.state.wordAt(pos)\n if (!word) {\n return null\n }\n\n const functionName = view.state.doc.sliceString(word.from, word.to)\n const fnSchema = this.functionSchemas.find((schema) => schema.name === functionName)\n\n if (!fnSchema) {\n return null\n }\n\n return {\n pos: word.from,\n end: word.to,\n above: true,\n create: () => ({ dom: this.createFunctionInfoElement(fnSchema) }),\n }\n }\n\n /**\n * Creates a styled HTML element to display function documentation.\n * This is used for both hover tooltips and autocomplete info panels.\n */\n private createFunctionInfoElement(fn: FunctionSchema): HTMLElement {\n const container = document.createElement('div')\n container.className = 'function-info' // for styling\n\n if (fn.description) {\n const description = document.createElement('p')\n description.className = 'description'\n description.textContent = fn.description\n container.appendChild(description)\n }\n\n if (fn.parameters && fn.parameters.length > 0) {\n const paramsContainer = document.createElement('div')\n paramsContainer.className = 'parameters'\n\n const paramsHeader = document.createElement('h4')\n paramsHeader.textContent = 'Parameters'\n paramsContainer.appendChild(paramsHeader)\n\n const paramsList = document.createElement('ul')\n fn.parameters.forEach((param) => {\n const listItem = document.createElement('li')\n\n const name = document.createElement('span')\n name.className = 'param-name'\n name.textContent = param.name\n\n const type = document.createElement('span')\n type.className = 'param-type'\n type.textContent = `: ${getTypeStringFromSchema(param.schema)}`\n\n listItem.appendChild(name)\n listItem.appendChild(type)\n\n if (param.schema.description) {\n const paramDesc = document.createElement('p')\n paramDesc.className = 'param-description'\n paramDesc.textContent = param.schema.description\n listItem.appendChild(paramDesc)\n }\n paramsList.appendChild(listItem)\n })\n paramsContainer.appendChild(paramsList)\n container.appendChild(paramsContainer)\n }\n\n if (fn.returns) {\n const returnsContainer = document.createElement('div')\n returnsContainer.className = 'returns'\n\n const returnsHeader = document.createElement('h4')\n returnsHeader.textContent = 'Returns'\n returnsContainer.appendChild(returnsHeader)\n\n const returnsDesc = document.createElement('p')\n const returnType = getTypeStringFromSchema(fn.returns)\n returnsDesc.textContent = fn.returns.description ? `${returnType}: ${fn.returns.description}` : returnType\n returnsContainer.appendChild(returnsDesc)\n container.appendChild(returnsContainer)\n }\n\n return container\n }\n\n /**\n * Format function call with parameters\n */\n private formatFunctionCall(fn: FunctionSchema): string {\n if (!fn.parameters || fn.parameters.length === 0) {\n return `${fn.name}()`\n }\n\n const params = fn.parameters\n .map((param) => {\n if (param.required) {\n return param.name\n }\n return `${param.name}?`\n })\n .join(', ')\n\n return `${fn.name}(${params})`\n }\n\n /**\n * Update editor content when value changes\n */\n private updateEditorContent(): void {\n if (!this.editorView) return\n\n const currentValue = this.editorView.state.doc.toString()\n if (currentValue !== this.value) {\n this.editorView.dispatch({\n changes: {\n from: 0,\n to: this.editorView.state.doc.length,\n insert: this.value,\n },\n })\n }\n }\n\n /**\n * Handle editor content change\n */\n private handleEditorChange(): void {\n if (!this.editorView) return\n\n const newValue = this.editorView.state.doc.toString()\n this.#value = newValue\n this.hasContent = newValue.length > 0\n\n this.dispatchEvent(new Event('input', { bubbles: true }))\n }\n\n /**\n * Handle focus change\n */\n private handleFocusChange(hasFocus: boolean): void {\n this.isEditorFocus = hasFocus\n\n if (!hasFocus && this.#value !== this._previousValue) {\n this._previousValue = this.#value\n this.dispatchEvent(new Event('change'))\n }\n }\n\n /**\n * Dispatch function insert event\n */\n private dispatchFunctionInsert(functionSchema: FunctionSchema, position: number): void {\n const event = new CustomEvent<FunctionInsertEvent>('function-insert', {\n detail: { functionSchema, position },\n bubbles: true,\n })\n this.dispatchEvent(event)\n }\n\n /**\n * Dispatch suggestion insert event\n */\n private dispatchSuggestionInsert(suggestion: Suggestion, position: number): void {\n const event = new CustomEvent<SuggestionInsertEvent>('suggestion-insert', {\n detail: { suggestion, position },\n bubbles: true,\n })\n this.dispatchEvent(event)\n }\n\n /**\n * Focus the editor\n */\n override focus(): void {\n this.editorView?.focus()\n }\n\n /**\n * Get the editor's current selection\n */\n getSelection(): { from: number; to: number } | null {\n if (!this.editorView) return null\n const { from, to } = this.editorView.state.selection.main\n return { from, to }\n }\n\n /**\n * Insert text at the current cursor position\n */\n insertText(text: string): void {\n if (!this.editorView) return\n\n const { from, to } = this.editorView.state.selection.main\n this.editorView.dispatch({\n changes: { from, to, insert: text },\n selection: { anchor: from + text.length },\n })\n }\n\n override render(): TemplateResult {\n const hasLabel = !!this.label\n const hasSupportingText = !!this.supportingText\n\n return html`\n <div class=\"surface ${classMap({ 'has-focus': this.isEditorFocus, 'invalid': this.invalid })}\">\n <div class=\"content\">\n ${hasLabel ? html`<div class=\"label\">${this.label}</div>` : nothing}\n\n <div class=\"editor-container\" part=\"editor\"></div>\n </div>\n\n ${hasSupportingText ? html`<div class=\"supporting-text\">${this.supportingText}</div>` : nothing}\n </div>\n `\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SuggestionMatchDecorator.d.ts","sourceRoot":"","sources":["../../../../../src/elements/code-editor/internals/SuggestionMatchDecorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAc,MAAM,kBAAkB,CAAA;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAG5C;;GAEG;AACH,qBAAa,wBAAyB,SAAQ,cAAc;;IASjD,WAAW,EAAE,UAAU,EAAE;IARlC;;;;;OAKG;gBAED,MAAM,EAAE,MAAM,EACP,WAAW,EAAE,UAAU,EAAE;CAmBnC"}
1
+ {"version":3,"file":"SuggestionMatchDecorator.d.ts","sourceRoot":"","sources":["../../../../../src/elements/code-editor/internals/SuggestionMatchDecorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAc,MAAM,kBAAkB,CAAA;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAG5C;;GAEG;AACH,qBAAa,wBAAyB,SAAQ,cAAc;;IASjD,WAAW,EAAE,UAAU,EAAE;IARlC;;;;;OAKG;gBAED,MAAM,EAAE,MAAM,EACP,WAAW,EAAE,UAAU,EAAE;CAkBnC"}
@@ -1,5 +1,5 @@
1
1
  import { MatchDecorator, Decoration } from '@codemirror/view';
2
- import { ChipWidget } from './PlaceholderWidget.js';
2
+ import { ChipWidget } from './ChipWidget.js';
3
3
  /**
4
4
  * A class that specializes in creating and managing decorations for suggestion matches in a code editor.
5
5
  */
@@ -19,10 +19,10 @@ export class SuggestionMatchDecorator extends MatchDecorator {
19
19
  this.suggestions = suggestions;
20
20
  }
21
21
  #decoration(match) {
22
- const label = match[1];
23
- const suggestion = this.suggestions.find((s) => s.label === label);
22
+ const id = match[1];
23
+ const suggestion = this.suggestions.find((s) => s.id === id);
24
24
  // If no suggestion is found, create a default one
25
- const suggestionData = suggestion || { id: label, label };
25
+ const suggestionData = suggestion || { id, label: id };
26
26
  return Decoration.replace({
27
27
  widget: new ChipWidget(suggestionData),
28
28
  });
@@ -1 +1 @@
1
- {"version":3,"file":"SuggestionMatchDecorator.js","sourceRoot":"","sources":["../../../../../src/elements/code-editor/internals/SuggestionMatchDecorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE7D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAEnD;;GAEG;AACH,MAAM,OAAO,wBAAyB,SAAQ,cAAc;IASjD;IART;;;;;OAKG;IACH,YACE,MAAc,EACP,WAAyB;QAEhC,KAAK,CAAC;YACJ,MAAM;YACN,UAAU,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC;SAC/C,CAAC,CAAA;QALK,gBAAW,GAAX,WAAW,CAAc;IAMlC,CAAC;IAED,WAAW,CAAC,KAAsB;QAChC,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;QACtB,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,CAAA;QAElE,kDAAkD;QAClD,MAAM,cAAc,GAAe,UAAU,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAA;QAErE,OAAO,UAAU,CAAC,OAAO,CAAC;YACxB,MAAM,EAAE,IAAI,UAAU,CAAC,cAAc,CAAC;SACvC,CAAC,CAAA;IACJ,CAAC;CACF","sourcesContent":["import { MatchDecorator, Decoration } from '@codemirror/view'\nimport type { Suggestion } from './types.js'\nimport { ChipWidget } from './PlaceholderWidget.js'\n\n/**\n * A class that specializes in creating and managing decorations for suggestion matches in a code editor.\n */\nexport class SuggestionMatchDecorator extends MatchDecorator {\n /**\n * Creates a new instance of SuggestionMatchDecorator.\n * @param regexp - The regular expression used to match suggestions in the code.\n * @param suggestions - An array of suggestions that will be used to create decorations.\n * Each suggestion should have a unique `id` and a `label` that will be displayed in the editor.\n */\n constructor(\n regexp: RegExp,\n public suggestions: Suggestion[]\n ) {\n super({\n regexp,\n decoration: (match) => this.#decoration(match),\n })\n }\n\n #decoration(match: RegExpExecArray): Decoration {\n const label = match[1]\n const suggestion = this.suggestions.find((s) => s.label === label)\n\n // If no suggestion is found, create a default one\n const suggestionData: Suggestion = suggestion || { id: label, label }\n\n return Decoration.replace({\n widget: new ChipWidget(suggestionData),\n })\n }\n}\n"]}
1
+ {"version":3,"file":"SuggestionMatchDecorator.js","sourceRoot":"","sources":["../../../../../src/elements/code-editor/internals/SuggestionMatchDecorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE7D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C;;GAEG;AACH,MAAM,OAAO,wBAAyB,SAAQ,cAAc;IASjD;IART;;;;;OAKG;IACH,YACE,MAAc,EACP,WAAyB;QAEhC,KAAK,CAAC;YACJ,MAAM;YACN,UAAU,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC;SAC/C,CAAC,CAAA;QALK,gBAAW,GAAX,WAAW,CAAc;IAMlC,CAAC;IAED,WAAW,CAAC,KAAsB;QAChC,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;QACnB,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;QAE5D,kDAAkD;QAClD,MAAM,cAAc,GAAe,UAAU,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAA;QAClE,OAAO,UAAU,CAAC,OAAO,CAAC;YACxB,MAAM,EAAE,IAAI,UAAU,CAAC,cAAc,CAAC;SACvC,CAAC,CAAA;IACJ,CAAC;CACF","sourcesContent":["import { MatchDecorator, Decoration } from '@codemirror/view'\nimport type { Suggestion } from './types.js'\nimport { ChipWidget } from './ChipWidget.js'\n\n/**\n * A class that specializes in creating and managing decorations for suggestion matches in a code editor.\n */\nexport class SuggestionMatchDecorator extends MatchDecorator {\n /**\n * Creates a new instance of SuggestionMatchDecorator.\n * @param regexp - The regular expression used to match suggestions in the code.\n * @param suggestions - An array of suggestions that will be used to create decorations.\n * Each suggestion should have a unique `id` and a `label` that will be displayed in the editor.\n */\n constructor(\n regexp: RegExp,\n public suggestions: Suggestion[]\n ) {\n super({\n regexp,\n decoration: (match) => this.#decoration(match),\n })\n }\n\n #decoration(match: RegExpExecArray): Decoration {\n const id = match[1]\n const suggestion = this.suggestions.find((s) => s.id === id)\n\n // If no suggestion is found, create a default one\n const suggestionData: Suggestion = suggestion || { id, label: id }\n return Decoration.replace({\n widget: new ChipWidget(suggestionData),\n })\n }\n}\n"]}
@@ -8,6 +8,10 @@ import type {
8
8
  SuggestionInsertEvent,
9
9
  } from '../../../src/elements/code-editor/code-editor.js'
10
10
  import '../../../src/elements/code-editor/code-editor.js'
11
+ import { stringLibrarySchema } from '@pawel-up/jexl/schemas/string.schema.js'
12
+ import { arrayLibrarySchema } from '@pawel-up/jexl/schemas/array.schema.js'
13
+ import { dateLibrarySchema } from '@pawel-up/jexl/schemas/date.schema.js'
14
+ import { mathLibrarySchema } from '@pawel-up/jexl/schemas/math.schema.js'
11
15
 
12
16
  class CodeEditorDemo extends DemoPage {
13
17
  override accessor componentName = 'Code Editor'
@@ -18,75 +22,10 @@ class CodeEditorDemo extends DemoPage {
18
22
  @reactive()
19
23
  private accessor editorValue = [
20
24
  '// Start typing function names or {{ mentions }}',
21
- 'console.log("Hello, world!")',
22
25
  '',
23
- '// Try: getData, processData, or @John, @Jane',
24
- '// Example: Ask {{John}} about the API design',
25
- '// Example: {{Jane}} can review the implementation',
26
- '',
27
- '"Hello {{John}}! Can you help with the " + getData() + " function?"',
26
+ '"Hello {{John}}! Can you help with the " + upper() + " function?"',
28
27
  ].join('\n')
29
28
 
30
- private functionSchemas: FunctionSchema[] = [
31
- {
32
- name: 'getData',
33
- description: 'Fetches data from the server',
34
- parameters: [
35
- {
36
- name: 'url',
37
- schema: { type: 'string', description: 'The URL to fetch data from' },
38
- required: true,
39
- },
40
- {
41
- name: 'options',
42
- schema: { type: 'object', description: 'Fetch options' },
43
- required: false,
44
- },
45
- ],
46
- returns: {
47
- type: 'object',
48
- description: 'The fetched data as an object',
49
- },
50
- category: 'network',
51
- },
52
- {
53
- name: 'processData',
54
- description: 'Processes raw data into a usable format',
55
- parameters: [
56
- {
57
- name: 'data',
58
- schema: { description: 'Raw data to process' },
59
- required: true,
60
- },
61
- {
62
- name: 'transformer',
63
- schema: { description: 'Optional transformer function' },
64
- required: false,
65
- },
66
- ],
67
- returns: {},
68
- category: 'data',
69
- },
70
- {
71
- category: 'validation',
72
- name: 'validateInput',
73
- description: 'Validates user input against a schema',
74
- parameters: [
75
- {
76
- name: 'input',
77
- schema: { type: 'object', description: 'The input to validate' },
78
- required: true,
79
- },
80
- {
81
- name: 'schema',
82
- schema: { type: 'object', description: 'Validation schema' },
83
- required: true,
84
- },
85
- ],
86
- returns: { type: 'object', description: 'Validation result' },
87
- },
88
- ]
89
-
90
29
  private suggestions: Suggestion[] = [
91
30
  {
92
31
  id: 'user-john',
@@ -111,6 +50,42 @@ class CodeEditorDemo extends DemoPage {
111
50
  },
112
51
  ]
113
52
 
53
+ functions: FunctionSchema[] = []
54
+
55
+ constructor() {
56
+ super()
57
+
58
+ // Initialize function schemas
59
+ this.functions = this.createFunctionSchema()
60
+ }
61
+
62
+ /**
63
+ * Creates a schema for the code-editor functions.
64
+ * This method is responsible for defining the functions that can be used in the formula,
65
+ * given the current data type.
66
+ */
67
+ createFunctionSchema(): FunctionSchema[] {
68
+ const result: FunctionSchema[] = []
69
+
70
+ for (const func of Object.values(stringLibrarySchema.functions)) {
71
+ result.push(func)
72
+ }
73
+
74
+ for (const func of Object.values(arrayLibrarySchema.functions)) {
75
+ result.push(func)
76
+ }
77
+
78
+ for (const func of Object.values(dateLibrarySchema.functions)) {
79
+ result.push(func)
80
+ }
81
+
82
+ for (const func of Object.values(mathLibrarySchema.functions)) {
83
+ result.push(func)
84
+ }
85
+
86
+ return result
87
+ }
88
+
114
89
  private handleFunctionInsert(event: CustomEvent<FunctionInsertEvent>): void {
115
90
  const { functionSchema, position } = event.detail
116
91
  this.output = `Function inserted: ${functionSchema.name} at position ${position}`
@@ -124,7 +99,6 @@ class CodeEditorDemo extends DemoPage {
124
99
  private handleInput(event: Event): void {
125
100
  const target = event.target as HTMLElement & { value: string }
126
101
  this.editorValue = target.value
127
- console.log('Editor input:', new Error().stack)
128
102
  }
129
103
 
130
104
  private handleChange(event: Event): void {
@@ -145,7 +119,7 @@ class CodeEditorDemo extends DemoPage {
145
119
  label="Code Editor"
146
120
  supporting-text="Type function names or {{fnName}} to see autocomplete"
147
121
  .value=${this.editorValue}
148
- .functionSchemas=${this.functionSchemas}
122
+ .functionSchemas=${this.functions}
149
123
  .suggestions=${this.suggestions}
150
124
  @function-insert=${this.handleFunctionInsert}
151
125
  @suggestion-insert=${this.handleSuggestionInsert}
@@ -164,7 +138,7 @@ class CodeEditorDemo extends DemoPage {
164
138
  label="Dark Theme Editor"
165
139
  supporting-text="Dark theme variant"
166
140
  .value=${'// Dark theme example\nconst theme = "dark"'}
167
- .functionSchemas=${this.functionSchemas}
141
+ .functionSchemas=${this.functions}
168
142
  .suggestions=${this.suggestions}
169
143
  dark-theme
170
144
  ></code-editor>
@@ -178,7 +152,7 @@ class CodeEditorDemo extends DemoPage {
178
152
  label="Disabled Editor"
179
153
  supporting-text="This editor is disabled"
180
154
  .value=${'// This editor is disabled\nconst readOnly = true'}
181
- .functionSchemas=${this.functionSchemas}
155
+ .functionSchemas=${this.functions}
182
156
  .suggestions=${this.suggestions}
183
157
  disabled
184
158
  ></code-editor>
@@ -192,23 +166,11 @@ class CodeEditorDemo extends DemoPage {
192
166
  label="Error Editor"
193
167
  supporting-text="This editor has an error"
194
168
  .value=${'// This editor has an error\nconst invalid = true'}
195
- .functionSchemas=${this.functionSchemas}
169
+ .functionSchemas=${this.functions}
196
170
  .suggestions=${this.suggestions}
197
171
  invalid
198
172
  ></code-editor>
199
173
  </section>
200
-
201
- <section class="demo-section">
202
- <h2 class="display-large">Function Schemas</h2>
203
- <p>Available function schemas for autocomplete:</p>
204
- <pre>${JSON.stringify(this.functionSchemas, null, 2)}</pre>
205
- </section>
206
-
207
- <section class="demo-section">
208
- <h2 class="display-large">Suggestions</h2>
209
- <p>Available suggestions (use @mention syntax):</p>
210
- <pre>${JSON.stringify(this.suggestions, null, 2)}</pre>
211
- </section>
212
174
  `
213
175
  }
214
176
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@api-client/ui",
3
- "version": "0.5.15",
3
+ "version": "0.5.16",
4
4
  "description": "Internal UI component library for the API Client ecosystem.",
5
5
  "license": "UNLICENSED",
6
6
  "main": "build/src/index.js",
@@ -33,7 +33,7 @@ export class ChipWidget extends WidgetType {
33
33
  const pos = view.posAtDOM(wrapper)
34
34
  if (pos === null) return
35
35
 
36
- const originalText = `{{${this.suggestion.label}}}`
36
+ const originalText = `{{${this.suggestion.id}}}`
37
37
  view.dispatch({
38
38
  changes: { from: pos, to: pos + originalText.length, insert: '' },
39
39
  })
@@ -168,12 +168,12 @@ export default class CodeEditor extends LitElement {
168
168
  */
169
169
  get activeSuggestions(): Suggestion[] {
170
170
  const suggestions: Suggestion[] = []
171
- const placeholderPattern = /\{\{(\w+)\}\}/g
171
+ const placeholderPattern = /\{\{([^}]+)\}\}/g
172
172
  let match: RegExpExecArray | null
173
173
  while ((match = placeholderPattern.exec(this.value)) !== null) {
174
174
  const placeholderText = match[1]
175
- // Find suggestion by label
176
- const suggestion = this.suggestions.find((s) => s.label.toLowerCase() === placeholderText.toLowerCase())
175
+ // Find suggestion by id
176
+ const suggestion = this.suggestions.find((s) => s.id === placeholderText)
177
177
  if (suggestion) {
178
178
  suggestions.push(suggestion)
179
179
  }
@@ -274,7 +274,7 @@ export default class CodeEditor extends LitElement {
274
274
  * This is created as a method to get access to the component's `suggestions`.
275
275
  */
276
276
  private createPlaceholderPlugin(): Extension {
277
- const placeholderMatcher = new SuggestionMatchDecorator(/\{\{(\w+)\}\}/g, this.suggestions)
277
+ const placeholderMatcher = new SuggestionMatchDecorator(/\{\{([^}]+)\}\}/g, this.suggestions)
278
278
  this.placeholderMatcher = placeholderMatcher
279
279
  // This class needs to be defined here to have access to the `placeholderMatcher`
280
280
  class AtomicDecorationRange {
@@ -319,7 +319,7 @@ export default class CodeEditor extends LitElement {
319
319
  }
320
320
 
321
321
  // Check if we're typing a suggestion trigger (e.g., {{)
322
- const suggestionMatch = textBefore.match(/\{\{(\w*)$/)
322
+ const suggestionMatch = textBefore.match(/\{\{([^}]*)$/)
323
323
  if (suggestionMatch) {
324
324
  const prefix = suggestionMatch[1]
325
325
  const suggestions = this.suggestions
@@ -342,6 +342,7 @@ export default class CodeEditor extends LitElement {
342
342
  const result: Completion = {
343
343
  label: schema.name,
344
344
  detail: schema.description || '',
345
+ type: 'function',
345
346
  info: () => this.createFunctionInfoElement(schema),
346
347
  apply: (view: EditorView, completion: unknown, from: number, to: number) => {
347
348
  const functionCall = this.formatFunctionCall(schema)
@@ -361,8 +362,9 @@ export default class CodeEditor extends LitElement {
361
362
  label: suggestion.label,
362
363
  detail: suggestion.description || '',
363
364
  info: suggestion.suffix || '',
365
+ type: 'variable',
364
366
  apply: (view: EditorView, completion: unknown, from: number, to: number) => {
365
- const placeholderText = `{{${suggestion.label}}}`
367
+ const placeholderText = `{{${suggestion.id}}}`
366
368
  view.dispatch({
367
369
  changes: { from: from - 2, to, insert: placeholderText }, // -2 to include the {{
368
370
  selection: { anchor: from - 2 + placeholderText.length },
@@ -1,6 +1,6 @@
1
1
  import { MatchDecorator, Decoration } from '@codemirror/view'
2
2
  import type { Suggestion } from './types.js'
3
- import { ChipWidget } from './PlaceholderWidget.js'
3
+ import { ChipWidget } from './ChipWidget.js'
4
4
 
5
5
  /**
6
6
  * A class that specializes in creating and managing decorations for suggestion matches in a code editor.
@@ -23,12 +23,11 @@ export class SuggestionMatchDecorator extends MatchDecorator {
23
23
  }
24
24
 
25
25
  #decoration(match: RegExpExecArray): Decoration {
26
- const label = match[1]
27
- const suggestion = this.suggestions.find((s) => s.label === label)
26
+ const id = match[1]
27
+ const suggestion = this.suggestions.find((s) => s.id === id)
28
28
 
29
29
  // If no suggestion is found, create a default one
30
- const suggestionData: Suggestion = suggestion || { id: label, label }
31
-
30
+ const suggestionData: Suggestion = suggestion || { id, label: id }
32
31
  return Decoration.replace({
33
32
  widget: new ChipWidget(suggestionData),
34
33
  })
@@ -1 +0,0 @@
1
- {"version":3,"file":"PlaceholderWidget.d.ts","sourceRoot":"","sources":["../../../../../src/elements/code-editor/internals/PlaceholderWidget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,6BAA6B,CAAA;AAEpC;;;;;;;;GAQG;AACH,qBAAa,UAAW,SAAQ,UAAU;IACrB,UAAU,EAAE,UAAU;gBAAtB,UAAU,EAAE,UAAU;IAIhC,EAAE,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO;IAIvC,KAAK,CAAC,IAAI,EAAE,UAAU,GAAG,WAAW;IAwB3B,WAAW,IAAI,OAAO;CAGhC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"PlaceholderWidget.js","sourceRoot":"","sources":["../../../../../src/elements/code-editor/internals/PlaceholderWidget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAEzD,OAAO,6BAA6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QAEF,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;QACzB,OAAO,OAAO,CAAA;IAChB,CAAC;IAEQ,WAAW;QAClB,OAAO,KAAK,CAAA;IACd,CAAC;CACF","sourcesContent":["import { EditorView, WidgetType } from '@codemirror/view'\nimport type { Suggestion } from './types.js'\nimport '../../../md/chip/ui-chip.js'\n\n/**\n * A widget that represents a placeholder in the code editor,\n * specifically for suggestions that are replaced with chips.\n *\n * This widget is used to create a visual representation of a suggestion\n * in the code editor, allowing users to see and interact with suggestions\n * as chips. When a chip is removed, the corresponding text in the editor\n * is also removed.\n */\nexport class ChipWidget extends WidgetType {\n constructor(public suggestion: Suggestion) {\n super()\n }\n\n override eq(other: WidgetType): boolean {\n return this.suggestion.id == (other as ChipWidget).suggestion.id\n }\n\n toDOM(view: EditorView): HTMLElement {\n const wrapper = document.createElement('span')\n wrapper.className = 'mention-chip'\n wrapper.setAttribute('data-mention-id', this.suggestion.id)\n\n const chip = document.createElement('ui-chip')\n chip.setAttribute('type', 'input')\n chip.setAttribute('removable', 'true')\n chip.textContent = this.suggestion.label\n chip.addEventListener('remove', () => {\n const pos = view.posAtDOM(wrapper)\n if (pos === null) return\n\n const originalText = `{{${this.suggestion.label}}}`\n view.dispatch({\n changes: { from: pos, to: pos + originalText.length, insert: '' },\n })\n view.focus()\n })\n\n wrapper.appendChild(chip)\n return wrapper\n }\n\n override ignoreEvent(): boolean {\n return false\n }\n}\n"]}