@scalar/api-client 3.10.3 → 3.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/dist/style.css +200 -103
- package/dist/v2/blocks/operation-block/OperationBlock.vue.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/OperationBlock.vue.js.map +1 -1
- package/dist/v2/blocks/operation-block/OperationBlock.vue.script.js +9 -0
- package/dist/v2/blocks/operation-block/OperationBlock.vue.script.js.map +1 -1
- package/dist/v2/blocks/operation-block/helpers/send-request.d.ts +7 -1
- package/dist/v2/blocks/operation-block/helpers/send-request.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/helpers/send-request.js +2 -2
- package/dist/v2/blocks/operation-block/helpers/send-request.js.map +1 -1
- package/dist/v2/blocks/request-block/RequestBlock.vue.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/RequestBlock.vue.js +1 -1
- package/dist/v2/blocks/request-block/RequestBlock.vue.js.map +1 -1
- package/dist/v2/blocks/request-block/RequestBlock.vue.script.js +46 -9
- package/dist/v2/blocks/request-block/RequestBlock.vue.script.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestParams.vue.d.ts +4 -0
- package/dist/v2/blocks/request-block/components/RequestParams.vue.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestParams.vue.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestParams.vue.script.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestTable.vue.d.ts +3 -11
- package/dist/v2/blocks/request-block/components/RequestTable.vue.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestTable.vue.js +1 -1
- package/dist/v2/blocks/request-block/components/RequestTable.vue.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestTable.vue.script.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestTableRow.vue.d.ts +8 -10
- package/dist/v2/blocks/request-block/components/RequestTableRow.vue.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestTableRow.vue.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestTableRow.vue.script.js +24 -23
- package/dist/v2/blocks/request-block/components/RequestTableRow.vue.script.js.map +1 -1
- package/dist/v2/blocks/request-block/helpers/create-parameter-handlers.d.ts +9 -6
- package/dist/v2/blocks/request-block/helpers/create-parameter-handlers.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/helpers/create-parameter-handlers.js +31 -4
- package/dist/v2/blocks/request-block/helpers/create-parameter-handlers.js.map +1 -1
- package/dist/v2/blocks/request-block/helpers/create-parameter-rows.d.ts +4 -0
- package/dist/v2/blocks/request-block/helpers/create-parameter-rows.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/helpers/create-parameter-rows.js +78 -5
- package/dist/v2/blocks/request-block/helpers/create-parameter-rows.js.map +1 -1
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.js +1 -1
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.js.map +1 -1
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.script.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/AuthSelector.vue.script.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.d.ts +4 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.script.js +2 -2
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.script.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/OpenIDConnect.vue.d.ts +3 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/OpenIDConnect.vue.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/OpenIDConnect.vue.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/OpenIDConnect.vue.script.js +3 -2
- package/dist/v2/blocks/scalar-auth-selector-block/components/OpenIDConnect.vue.script.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthDataTableInput.vue.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthDataTableInput.vue.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthDataTableInput.vue.script.js +0 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthDataTableInput.vue.script.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthTab.vue.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthTab.vue.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthTab.vue.script.js +2 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthTab.vue.script.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/fetch-openid-connect-discovery.d.ts +4 -1
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/fetch-openid-connect-discovery.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/fetch-openid-connect-discovery.js +4 -3
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/fetch-openid-connect-discovery.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth.d.ts +7 -2
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth.js +11 -9
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth.js.map +1 -1
- package/dist/v2/components/code-input/CodeInput.vue.d.ts.map +1 -1
- package/dist/v2/components/code-input/CodeInput.vue.js +1 -1
- package/dist/v2/components/code-input/CodeInput.vue.js.map +1 -1
- package/dist/v2/components/code-input/CodeInput.vue.script.js +3 -2
- package/dist/v2/components/code-input/CodeInput.vue.script.js.map +1 -1
- package/dist/v2/components/code-input/CodeInputLite.vue.d.ts +124 -0
- package/dist/v2/components/code-input/CodeInputLite.vue.d.ts.map +1 -0
- package/dist/v2/components/code-input/CodeInputLite.vue.js +10 -0
- package/dist/v2/components/code-input/CodeInputLite.vue.js.map +1 -0
- package/dist/v2/components/code-input/CodeInputLite.vue.script.js +631 -0
- package/dist/v2/components/code-input/CodeInputLite.vue.script.js.map +1 -0
- package/dist/v2/components/code-input/PillTooltipHost.vue.d.ts +3 -0
- package/dist/v2/components/code-input/PillTooltipHost.vue.d.ts.map +1 -1
- package/dist/v2/components/code-input/PillTooltipHost.vue.js.map +1 -1
- package/dist/v2/components/code-input/PillTooltipHost.vue.script.js +23 -11
- package/dist/v2/components/code-input/PillTooltipHost.vue.script.js.map +1 -1
- package/dist/v2/components/code-input/code-variable-widget.d.ts.map +1 -1
- package/dist/v2/components/code-input/code-variable-widget.js +5 -2
- package/dist/v2/components/code-input/code-variable-widget.js.map +1 -1
- package/dist/v2/components/code-input/helpers/build-pill-context.d.ts +11 -0
- package/dist/v2/components/code-input/helpers/build-pill-context.d.ts.map +1 -0
- package/dist/v2/components/code-input/helpers/build-pill-context.js +28 -0
- package/dist/v2/components/code-input/helpers/build-pill-context.js.map +1 -0
- package/dist/v2/components/code-input/helpers/lookup-variable-value.d.ts +11 -0
- package/dist/v2/components/code-input/helpers/lookup-variable-value.d.ts.map +1 -0
- package/dist/v2/components/code-input/helpers/lookup-variable-value.js +18 -0
- package/dist/v2/components/code-input/helpers/lookup-variable-value.js.map +1 -0
- package/dist/v2/components/code-input/helpers/pill-signature.d.ts +13 -0
- package/dist/v2/components/code-input/helpers/pill-signature.d.ts.map +1 -0
- package/dist/v2/components/code-input/helpers/pill-signature.js +25 -0
- package/dist/v2/components/code-input/helpers/pill-signature.js.map +1 -0
- package/dist/v2/components/code-input/helpers/serialize-value.d.ts +10 -0
- package/dist/v2/components/code-input/helpers/serialize-value.d.ts.map +1 -0
- package/dist/v2/components/code-input/helpers/serialize-value.js +17 -0
- package/dist/v2/components/code-input/helpers/serialize-value.js.map +1 -0
- package/dist/v2/components/code-input/index.d.ts +1 -0
- package/dist/v2/components/code-input/index.d.ts.map +1 -1
- package/dist/v2/components/code-input/index.js +2 -1
- package/dist/v2/components/data-table/DataTableInput.vue.d.ts +0 -4
- package/dist/v2/components/data-table/DataTableInput.vue.d.ts.map +1 -1
- package/dist/v2/components/data-table/DataTableInput.vue.js +1 -1
- package/dist/v2/components/data-table/DataTableInput.vue.js.map +1 -1
- package/dist/v2/components/data-table/DataTableInput.vue.script.js +2 -19
- package/dist/v2/components/data-table/DataTableInput.vue.script.js.map +1 -1
- package/dist/v2/constants.js +1 -1
- package/dist/v2/features/environments/components/EnvironmentVariablesDropdown.vue.d.ts +9 -0
- package/dist/v2/features/environments/components/EnvironmentVariablesDropdown.vue.d.ts.map +1 -1
- package/dist/v2/features/environments/components/EnvironmentVariablesDropdown.vue.js.map +1 -1
- package/dist/v2/features/environments/components/EnvironmentVariablesDropdown.vue.script.js +59 -28
- package/dist/v2/features/environments/components/EnvironmentVariablesDropdown.vue.script.js.map +1 -1
- package/dist/v2/features/environments/components/EnvironmentVariablesTable.vue.d.ts.map +1 -1
- package/dist/v2/features/environments/components/EnvironmentVariablesTable.vue.js +1 -1
- package/dist/v2/features/environments/components/EnvironmentVariablesTable.vue.js.map +1 -1
- package/dist/v2/features/environments/components/EnvironmentVariablesTable.vue.script.js +3 -8
- package/dist/v2/features/environments/components/EnvironmentVariablesTable.vue.script.js.map +1 -1
- package/dist/v2/features/modal/Modal.vue.js.map +1 -1
- package/dist/v2/features/modal/Modal.vue.script.js +1 -1
- package/dist/v2/features/modal/Modal.vue.script.js.map +1 -1
- package/dist/vue-styles.css +147 -95
- package/package.json +11 -11
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CodeInputLite.vue.script.js","names":["$attrs","$slots"],"sources":["../../../../src/v2/components/code-input/CodeInputLite.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * CodeInputLite\n *\n * Single-line `contenteditable` editor that renders `{{varname}}` as atomic\n * pill spans (`contenteditable=\"false\"`) and offers an env-variable\n * autocomplete on `{{`. The value is still exposed as a `{{name}}`-bearing\n * string via `update:modelValue`; DOM ↔ model conversion lives in\n * `renderModel` and `serializeEditor`.\n */\nexport default {\n inheritAttrs: false,\n}\n</script>\n\n<script setup lang=\"ts\">\nimport { isDefined } from '@scalar/helpers/array/is-defined'\nimport { REGEX } from '@scalar/helpers/regex/regex-helpers'\nimport {\n CONTEXT_FUNCTION_NAMES,\n getContextFunctionComment,\n isContextFunctionName,\n type ContextFunctionName,\n} from '@scalar/workspace-store/request-example'\nimport type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments'\nimport { nanoid } from 'nanoid'\nimport {\n computed,\n createApp,\n nextTick,\n onBeforeUnmount,\n onMounted,\n ref,\n useAttrs,\n useTemplateRef,\n watch,\n type App,\n} from 'vue'\n\nimport DataTableInputSelect from '@/v2/components/data-table/DataTableInputSelect.vue'\nimport EnvironmentVariableDropdown from '@/v2/features/environments/components/EnvironmentVariablesDropdown.vue'\nimport type { ClientLayout } from '@/v2/types/layout'\n\nimport type { CodeInputModelValue } from './CodeInput.vue'\nimport { buildPillContext } from './helpers/build-pill-context'\nimport { lookupVariableValue } from './helpers/lookup-variable-value'\nimport { pillSignature } from './helpers/pill-signature'\nimport { serializeValue } from './helpers/serialize-value'\nimport PillTooltipHost from './PillTooltipHost.vue'\n\ntype Props = {\n modelValue: CodeInputModelValue\n /** Environment for variable substitution. Pass undefined to disable env vars */\n environment: XScalarEnvironment | undefined\n /** Render as a non-interactive read-only label */\n disabled?: boolean\n /** Render the input with the native `readonly` attribute (still focusable, no edits) */\n readOnly?: boolean\n /** Show error styling */\n error?: boolean\n /** Layout context affects styling and dropdown visibility */\n layout?: ClientLayout\n /** Placeholder text for an empty input */\n placeholder?: string\n /** Show required indicator */\n required?: boolean\n /** Emit submit on blur */\n emitOnBlur?: boolean\n /** Render variable pills + show the autocomplete dropdown */\n withVariables?: boolean\n /** Include `{{$guid}}` etc. in the autocomplete dropdown */\n withFakeData?: boolean\n /** Always emit change events even if the value is unchanged */\n alwaysEmitChange?: boolean\n /** Strike-through styling for the input text (e.g. overridden values) */\n linethrough?: boolean\n /** Schema type — drives boolean select mode when `boolean` is included */\n type?: string | string[]\n /** Predefined enum values; when set the input is replaced by a select */\n enum?: string[]\n /** Example values; when set (and no enum/boolean) the input is replaced by a select */\n examples?: string[]\n /** Default value to suggest in select modes */\n default?: CodeInputModelValue\n /** Whether the boolean select includes a `null` option */\n nullable?: boolean\n}\n\nconst {\n modelValue,\n environment,\n disabled = false,\n readOnly = false,\n error = false,\n layout = 'desktop',\n placeholder,\n required = false,\n emitOnBlur = true,\n alwaysEmitChange = false,\n withVariables = true,\n withFakeData = false,\n linethrough = false,\n type,\n enum: enumProp,\n examples,\n default: defaultProp,\n nullable = false,\n} = defineProps<Props>()\n\nconst emit = defineEmits<{\n 'update:modelValue': [value: string]\n 'submit': [value: string, event: KeyboardEvent | FocusEvent]\n 'blur': [value: string, event: FocusEvent]\n 'navigate': [route: { page: 'document'; path: 'environment' }]\n}>()\n\nconst attrs = useAttrs() as { 'id'?: string; 'aria-label'?: string }\n\n/**\n * The id only matters once the dropdown opens (`aria-controls` /\n * `aria-activedescendant`), so we defer `nanoid()` until first focus to\n * keep idle instances cheap. A consumer-supplied `id` attr is preserved.\n */\nconst generatedComponentId = ref<string | null>(null)\nconst componentId = computed(\n (): string | undefined => attrs.id ?? generatedComponentId.value ?? undefined,\n)\nconst ensureComponentId = (): void => {\n if (!attrs.id && generatedComponentId.value === null) {\n generatedComponentId.value = `id-${nanoid()}`\n }\n}\n\nconst editorRef = useTemplateRef<HTMLDivElement>('editorRef')\nconst dropdownRef = ref<InstanceType<\n typeof EnvironmentVariableDropdown\n> | null>(null)\n\n/** Id of the dropdown's `role=\"listbox\"` element, for the combobox wiring. */\nconst listboxId = computed((): string | undefined =>\n componentId.value ? `${componentId.value}-listbox` : undefined,\n)\n\n/**\n * Id of the option the dropdown currently highlights. Mirrors the dropdown's\n * own selection so the editor can expose it via `aria-activedescendant`.\n */\nconst activeOptionId = computed(\n (): string | undefined => dropdownRef.value?.activeOptionId,\n)\n\nconst isFocused = ref(false)\nconst isEmpty = ref(true)\n\n/**\n * True while an IME composition is in progress. Rebuilding the editor DOM\n * mid-composition (e.g. when `{{` forms a pill) cancels the composition, so we\n * defer those rebuilds until `compositionend`.\n */\nconst isComposing = ref(false)\n\n/**\n * Whether the serialized value should count as empty for placeholder display.\n *\n * `contenteditable` can leave behind invisible residue after some delete\n * sequences — most commonly a non-breaking space (` `) — which makes a\n * visually empty field report a non-zero length and silently drop its\n * placeholder. Trimming covers that case; ` ` counts as whitespace, so a\n * field that only holds editor residue is treated as empty. This affects the\n * placeholder flag only, never the value emitted via `serializeEditor`.\n */\nconst isBlankValue = (text: string): boolean => text.trim().length === 0\n\n// ───────────────────────────────────────────────────────────────────\n// Rendering-mode detection (parity with CodeInput's select dispatch)\n// ───────────────────────────────────────────────────────────────────\n\n/** True when the schema type is exactly `boolean` (or includes it in a tuple type). */\nconst isBooleanMode = computed((): boolean => {\n if (enumProp?.length) {\n return false\n }\n return type === 'boolean' || (Array.isArray(type) && type.includes('boolean'))\n})\n\nconst booleanOptions = computed((): string[] =>\n nullable ? ['true', 'false', 'null'] : ['true', 'false'],\n)\n\n/** Default type when the schema is a tuple — picks the first non-null entry. */\nconst defaultType = computed((): string | undefined => {\n if (Array.isArray(type)) {\n return type.find((t) => t !== 'null') ?? 'string'\n }\n return type\n})\n\nconst handleSelectChange = (value: string): void =>\n emit('update:modelValue', value)\n\n// ───────────────────────────────────────────────────────────────────\n// Per-pill tooltip apps\n// ───────────────────────────────────────────────────────────────────\n\nlet pillTooltipApps: App[] = []\n\n/**\n * Per-pill tooltips are the heaviest part of the render (a Vue app +\n * `useTooltip` watch + listeners each), so we defer mounting them until\n * the first interaction (focus, pointerover, or dropdown open). Once on,\n * subsequent rebuilds remount tooltips for the new pills.\n */\nlet tooltipsActive = false\n\nconst teardownPillTooltips = (): void => {\n for (const app of pillTooltipApps) {\n app.unmount()\n }\n pillTooltipApps = []\n}\n\nconst mountPillTooltips = (): void => {\n if (!editorRef.value || layout === 'modal') {\n return\n }\n const pills = editorRef.value.querySelectorAll<HTMLElement>('.scalar-pill')\n for (const pillEl of pills) {\n const variableName = pillEl.dataset.variable ?? ''\n const context = buildPillContext(variableName, environment)\n const app = createApp(PillTooltipHost, { context, target: pillEl })\n // PillTooltipHost is renderless; useTooltip attaches to `target` directly.\n app.mount(document.createElement('div'))\n pillTooltipApps.push(app)\n }\n}\n\n// ───────────────────────────────────────────────────────────────────\n// DOM ↔ model conversion\n// ───────────────────────────────────────────────────────────────────\n\n/**\n * Build a pill `<span>` for the given variable. `contentEditable = 'false'`\n * makes the browser treat it as a single atom (arrow keys jump over it,\n * Backspace deletes it whole); `{{` / `}}` only live in the model string.\n */\nconst createPillElement = (\n name: string,\n start: number,\n end: number,\n): HTMLSpanElement => {\n const isCtx = isContextFunctionName(name)\n const span = document.createElement('span')\n span.className = isCtx ? 'scalar-pill scalar-pill--context-fn' : 'scalar-pill'\n span.contentEditable = 'false'\n span.dataset.variable = name\n // Model-coordinate offsets (the pill stands in for the full `{{name}}`).\n // Used by click forwarding and tests to map a pill back to the value.\n span.dataset.pillStart = String(start)\n span.dataset.pillEnd = String(end)\n\n const color = isCtx\n ? 'var(--scalar-color-3)'\n : environment?.color || 'var(--scalar-color-1)'\n span.style.setProperty('--tw-bg-base', color)\n\n // Fade env pills with no usable value. A falsy check (not just\n // `=== undefined`) matches the tooltip path's `Boolean(value)`, so a\n // variable declared with an empty string fades here too.\n const isUndefinedEnv = !isCtx && !lookupVariableValue(environment, name)\n if (isUndefinedEnv) {\n span.style.opacity = '0.5'\n }\n\n span.textContent = name\n return span\n}\n\n/** Render a model string into the editor as a mix of text nodes + pills. */\nconst renderModel = (text: string): void => {\n const editor = editorRef.value\n if (!editor) {\n return\n }\n\n teardownPillTooltips()\n editor.replaceChildren()\n\n if (!withVariables || !text.includes('{{')) {\n if (text) {\n editor.appendChild(document.createTextNode(text))\n }\n isEmpty.value = isBlankValue(text)\n return\n }\n\n const regex = new RegExp(REGEX.VARIABLES.source, REGEX.VARIABLES.flags)\n let lastIndex = 0\n let match: RegExpExecArray | null\n\n while ((match = regex.exec(text)) !== null) {\n const start = match.index\n const end = start + match[0].length\n if (start > lastIndex) {\n editor.appendChild(document.createTextNode(text.slice(lastIndex, start)))\n }\n editor.appendChild(createPillElement(match[1] ?? '', start, end))\n lastIndex = end\n }\n\n if (lastIndex < text.length) {\n editor.appendChild(document.createTextNode(text.slice(lastIndex)))\n }\n\n isEmpty.value = false\n if (tooltipsActive) {\n mountPillTooltips()\n }\n}\n\n/** Length the given child contributes to the serialized model string. */\nconst modelLengthOf = (node: Node): number => {\n if (node.nodeType === Node.TEXT_NODE) {\n return (node.textContent ?? '').length\n }\n if (node instanceof HTMLElement && node.classList.contains('scalar-pill')) {\n return `{{${node.dataset.variable ?? ''}}}`.length\n }\n // Defensive: a stray element (e.g. browser-inserted <br>) — use its text.\n return (node.textContent ?? '').length\n}\n\n/** Read the editor DOM back into a `{{name}}`-bearing model string. */\nconst serializeEditor = (): string => {\n const editor = editorRef.value\n if (!editor) {\n return ''\n }\n let out = ''\n for (const node of Array.from(editor.childNodes)) {\n if (node.nodeType === Node.TEXT_NODE) {\n out += node.textContent ?? ''\n } else if (\n node instanceof HTMLElement &&\n node.classList.contains('scalar-pill')\n ) {\n out += `{{${node.dataset.variable ?? ''}}}`\n } else if (node instanceof HTMLElement) {\n // Flatten any stray <br> / <div> the browser may inject on paste/Enter.\n out += node.textContent ?? ''\n }\n }\n return out\n}\n\nlet lastPillSignature: string | null = null\nlet lastEnvKey = ''\n\n/**\n * Cache key for the env + `withVariables` state. Includes variable\n * name/value pairs so the watcher notices adds/removes/edits even when\n * `environment.color` is unchanged — without that, pills keep stale\n * `isDefined` opacity and tooltip values until the input itself changes.\n */\nconst computeEnvKey = (): string => {\n const color = environment?.color ?? ''\n const flag = withVariables ? '1' : '0'\n const variables = environment?.variables ?? []\n let vars = ''\n for (const v of variables) {\n const value =\n typeof v.value === 'string' ? v.value : (v.value?.default ?? '')\n // Unit separators (\\x1f / \\x1e) so values can safely contain `|` or `=`.\n vars += `\\x1f${v.name}\\x1e${value}`\n }\n return `${color}|${flag}|${vars}`\n}\n\n/** Idempotent: first call flips `tooltipsActive` and mounts pill tooltips. */\nconst ensureTooltipsActive = (): void => {\n if (tooltipsActive) {\n return\n }\n tooltipsActive = true\n mountPillTooltips()\n}\n\n// ───────────────────────────────────────────────────────────────────\n// Caret ↔ model offset\n// ───────────────────────────────────────────────────────────────────\n\n/** Selection start as a model-string offset, or `null` if not inside the editor. */\nconst getModelCaret = (): number | null => {\n const editor = editorRef.value\n if (!editor) {\n return null\n }\n const selection = window.getSelection()\n if (!selection || selection.rangeCount === 0) {\n return null\n }\n const range = selection.getRangeAt(0)\n if (\n range.startContainer !== editor &&\n !editor.contains(range.startContainer)\n ) {\n return null\n }\n\n // Anchored on the editor itself: `startOffset` is a child index.\n if (range.startContainer === editor) {\n let pos = 0\n for (\n let i = 0;\n i < range.startOffset && i < editor.childNodes.length;\n i++\n ) {\n pos += modelLengthOf(editor.childNodes[i] as Node)\n }\n return pos\n }\n\n let pos = 0\n for (const child of Array.from(editor.childNodes)) {\n if (child === range.startContainer) {\n return pos + range.startOffset\n }\n // Pills are non-editable; if a browser quirk still lands a selection\n // inside one, snap to the nearest boundary instead of getting stuck.\n if (child.contains(range.startContainer)) {\n return range.startOffset === 0 ? pos : pos + modelLengthOf(child)\n }\n pos += modelLengthOf(child)\n }\n return pos\n}\n\n/** Place the caret at the given model offset, walking the DOM to find it. */\nconst setModelCaret = (target: number): void => {\n const editor = editorRef.value\n if (!editor) {\n return\n }\n const range = document.createRange()\n let pos = 0\n let placed = false\n\n for (const child of Array.from(editor.childNodes)) {\n const len = modelLengthOf(child)\n if (pos + len >= target) {\n if (child.nodeType === Node.TEXT_NODE) {\n const into = Math.max(\n 0,\n Math.min(target - pos, (child.textContent ?? '').length),\n )\n range.setStart(child, into)\n } else if (target - pos <= 0) {\n range.setStartBefore(child)\n } else {\n range.setStartAfter(child)\n }\n placed = true\n break\n }\n pos += len\n }\n\n if (!placed) {\n range.selectNodeContents(editor)\n range.collapse(false)\n } else {\n range.collapse(true)\n }\n\n const selection = window.getSelection()\n if (!selection) {\n return\n }\n selection.removeAllRanges()\n selection.addRange(range)\n}\n\n// ───────────────────────────────────────────────────────────────────\n// Environment variable dropdown\n// ───────────────────────────────────────────────────────────────────\n\nconst showDropdown = ref(false)\nconst dropdownQuery = ref('')\nconst dropdownPosition = ref({ left: 0, top: 0 })\n\nconst contextFunctionDropdownItems = computed(() =>\n withFakeData\n ? CONTEXT_FUNCTION_NAMES.map((key) => ({\n key,\n description: getContextFunctionComment(key as ContextFunctionName),\n }))\n : [],\n)\n\nconst displayVariablesDropdown = computed(\n (): boolean =>\n showDropdown.value &&\n withVariables &&\n layout !== 'modal' &&\n (Boolean(environment) || withFakeData),\n)\n\nconst updateDropdownVisibility = (): void => {\n const editor = editorRef.value\n if (!editor) {\n return\n }\n const caret = getModelCaret()\n if (caret === null) {\n showDropdown.value = false\n return\n }\n const text = serializeEditor().slice(0, caret)\n const lastOpen = text.lastIndexOf('{{')\n const lastClose = text.lastIndexOf('}}')\n\n if (lastOpen <= lastClose) {\n showDropdown.value = false\n return\n }\n\n dropdownQuery.value = text.slice(lastOpen + 2)\n // Make sure the combobox has an id before it advertises `aria-expanded`, so\n // `aria-controls` always resolves to the listbox we are about to render.\n ensureComponentId()\n showDropdown.value = true\n\n // Anchor under the caret; `getBoundingClientRect` gives the caret rect in one read.\n nextTick(() => {\n const selection = window.getSelection()\n if (!selection || selection.rangeCount === 0 || !editorRef.value) {\n return\n }\n const r = selection.getRangeAt(0).cloneRange()\n r.collapse(true)\n const rect = r.getBoundingClientRect()\n const editorRect = editorRef.value.getBoundingClientRect()\n // Some browsers collapse empty ranges to a zero rect — fall back to the editor edge.\n dropdownPosition.value = {\n left: rect.left || editorRect.left,\n top: rect.bottom || editorRect.bottom,\n }\n })\n}\n\nconst handleDropdownSelect = (item: string): void => {\n if (readOnly) {\n return\n }\n const caret = getModelCaret() ?? 0\n const value = serializeEditor()\n const from = Math.max(0, caret - dropdownQuery.value.length - 2)\n const to = caret\n const next = `${value.slice(0, from)}{{${item}}}${value.slice(to)}`\n const nextCursor = from + `{{${item}}}`.length\n\n // Pill set changed — force a re-render and reposition the caret.\n lastPillSignature = pillSignature(next, withVariables)\n renderModel(next)\n setModelCaret(nextCursor)\n\n showDropdown.value = false\n emitChange(next, { skipDropdownCheck: true })\n}\n\n// ───────────────────────────────────────────────────────────────────\n// Change / focus / blur\n// ───────────────────────────────────────────────────────────────────\n\nconst emitChange = (\n value: string,\n opts: { skipDropdownCheck?: boolean } = {},\n): void => {\n const same = value === serializeValue(modelValue)\n if (alwaysEmitChange || !same) {\n emit('update:modelValue', value)\n }\n if (!opts.skipDropdownCheck) {\n updateDropdownVisibility()\n }\n}\n\nconst handleInput = (): void => {\n const text = serializeEditor()\n isEmpty.value = isBlankValue(text)\n\n // Only rebuild when the pill set changes (e.g. `}}` closed a pattern, or\n // a value was pasted). Skipping it for plain-text edits preserves the\n // live selection — important for IME composition and double-click select.\n // Also defer while composing; `handleCompositionEnd` re-runs this path so the\n // rebuild happens once the IME has committed its text.\n const sig = pillSignature(text, withVariables)\n if (!isComposing.value && sig !== lastPillSignature) {\n const caret = getModelCaret()\n lastPillSignature = sig\n renderModel(text)\n if (caret !== null) {\n setModelCaret(caret)\n }\n }\n\n emitChange(text)\n}\n\nconst handleCompositionStart = (): void => {\n isComposing.value = true\n}\n\nconst handleCompositionEnd = (): void => {\n isComposing.value = false\n // Run the deferred input path now that the composition has committed, so any\n // pill that formed during composition is rendered.\n handleInput()\n}\n\nconst handleFocus = (): void => {\n isFocused.value = true\n ensureComponentId()\n ensureTooltipsActive()\n}\n\nconst handleBlur = (event: FocusEvent): void => {\n isFocused.value = false\n showDropdown.value = false\n const value = serializeEditor()\n // Check the serialized `value`, not `modelValue` — a `0` or `false` model is\n // a valid non-empty entry that should still submit on blur.\n if (emitOnBlur && value) {\n emit('submit', value, event)\n }\n emit('blur', value, event)\n}\n\n/**\n * Strip rich content on paste; `contenteditable=\"plaintext-only\"` is not\n * reliable cross-browser, so we intercept and use `insertText` to keep undo.\n */\nconst handlePaste = (event: ClipboardEvent): void => {\n event.preventDefault()\n const text = event.clipboardData?.getData('text/plain') ?? ''\n if (!text) {\n return\n }\n document.execCommand('insertText', false, text.replace(/\\r?\\n/g, ' '))\n // `insertText` normally fires an `input` event, but that is not guaranteed\n // across browsers. Run the same path explicitly so pill rendering, emptiness,\n // `update:modelValue`, and the dropdown never lag behind the pasted DOM.\n handleInput()\n}\n\n// ───────────────────────────────────────────────────────────────────\n// Keyboard handling\n// ───────────────────────────────────────────────────────────────────\n\nconst handleKeyDown = (event: KeyboardEvent): void => {\n if (showDropdown.value) {\n if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n event.preventDefault()\n event.stopPropagation()\n dropdownRef.value?.handleArrowKey(\n event.key === 'ArrowDown' ? 'down' : 'up',\n )\n return\n }\n if (event.key === 'Enter') {\n event.preventDefault()\n event.stopPropagation()\n dropdownRef.value?.handleSelect()\n return\n }\n if (event.key === 'Escape') {\n event.preventDefault()\n event.stopPropagation()\n showDropdown.value = false\n return\n }\n }\n\n if (event.key === 'Enter') {\n // Block the browser default so a contenteditable div does not insert\n // <br> / <div> and break single-line semantics, then emit submit\n // (used by the table editors).\n event.preventDefault()\n emit('submit', serializeEditor(), event)\n return\n }\n\n // Backspace / Delete: pill atomicity is handled by the browser via\n // `contenteditable=\"false\"` on pills — no manual `}}`-pair handling needed.\n}\n\n// ───────────────────────────────────────────────────────────────────\n// Click forwarding & lifecycle\n// ───────────────────────────────────────────────────────────────────\n\n/**\n * Clicking a pill selects it whole, so a subsequent Backspace deletes it\n * in one keystroke and typing replaces it — the usual chip/mention model.\n */\nconst handleEditorClick = (event: MouseEvent): void => {\n const target = (event.target as HTMLElement | null)?.closest<HTMLElement>(\n '.scalar-pill',\n )\n if (!target) {\n return\n }\n const editor = editorRef.value\n if (!editor) {\n return\n }\n editor.focus()\n const range = document.createRange()\n range.selectNode(target)\n const selection = window.getSelection()\n selection?.removeAllRanges()\n selection?.addRange(range)\n updateDropdownVisibility()\n}\n\nonMounted(() => {\n const initial = serializeValue(modelValue)\n lastPillSignature = pillSignature(initial, withVariables)\n lastEnvKey = computeEnvKey()\n renderModel(initial)\n isEmpty.value = isBlankValue(initial)\n\n // `autofocus` on a contenteditable div is not honoured natively, so focus\n // the editor ourselves when the consumer passes the attribute.\n if (Object.hasOwn(attrs, 'autofocus')) {\n editorRef.value?.focus()\n }\n})\n\nwatch(\n () => modelValue,\n (next) => {\n const serialized = serializeValue(next)\n // Always sync the placeholder flag, even when the DOM already matches and we\n // skip the rebuild below. Otherwise a value cell that switches from select\n // mode (no editor element) into the empty editor keeps a stale `isEmpty`,\n // and the placeholder silently disappears.\n isEmpty.value = isBlankValue(serialized)\n if (serializeEditor() === serialized) {\n return\n }\n lastPillSignature = pillSignature(serialized, withVariables)\n renderModel(serialized)\n },\n)\n\nwatch(\n [() => environment, () => withVariables],\n () => {\n // Env changes affect pill colour and `isDefined` opacity — rebuild.\n const envKey = computeEnvKey()\n if (envKey === lastEnvKey) {\n return\n }\n lastEnvKey = envKey\n // Most rows are plain text; skip the DOM walk when there are no pills.\n // Pills introduced later flow through `handleInput` / the modelValue\n // watcher, which update `lastPillSignature`.\n if (lastPillSignature === '') {\n return\n }\n lastPillSignature = pillSignature(serializeEditor(), withVariables)\n // Preserve the caret across the rebuild so editing does not jump to the\n // start when the environment changes mid-edit (mirrors `handleInput`).\n const caret = getModelCaret()\n renderModel(serializeEditor())\n if (caret !== null) {\n setModelCaret(caret)\n }\n },\n // Variables are often mutated in place (e.g. editing a value in the env\n // editor) without the object reference changing — deep watch catches it.\n { deep: true },\n)\n\nonBeforeUnmount(() => {\n teardownPillTooltips()\n})\n\n// ───────────────────────────────────────────────────────────────────\n// Public API\n// ───────────────────────────────────────────────────────────────────\n\ndefineExpose({\n /** Focus the editor. `position` controls caret placement. */\n focus: (position?: 'start' | 'end' | number): void => {\n const editor = editorRef.value\n if (!editor) {\n return\n }\n editor.focus()\n if (!isDefined(position)) {\n return\n }\n const length = serializeEditor().length\n const pos =\n position === 'start' ? 0 : position === 'end' ? length : position\n setModelCaret(pos)\n },\n /** Replace the current value programmatically and re-render the pills. */\n setContent: (next = ''): void => {\n if (serializeEditor() === next) {\n return\n }\n lastPillSignature = pillSignature(next, withVariables)\n renderModel(next)\n isEmpty.value = isBlankValue(next)\n },\n /** Read the current value as a `{{name}}`-bearing string. */\n getValue: (): string => serializeEditor(),\n /** Caret offset in the model string. */\n cursorPosition: (): number | undefined => {\n const c = getModelCaret()\n return c === null ? undefined : c\n },\n isFocused,\n editorRef,\n})\n</script>\n\n<template>\n <!-- Disabled mode: read-only label -->\n <div\n v-if=\"disabled\"\n class=\"text-c-2 flex cursor-default items-center justify-center\"\n :class=\"{\n 'font-code pr-2 pl-1 text-base': layout === 'modal',\n 'px-2': layout !== 'modal',\n 'line-through': linethrough,\n }\"\n data-testid=\"code-input-lite-disabled\">\n <span class=\"whitespace-nowrap\">{{ modelValue }}</span>\n </div>\n\n <!-- Enum mode: select dropdown with predefined values -->\n <DataTableInputSelect\n v-else-if=\"enumProp?.length\"\n :default=\"defaultProp\"\n :modelValue=\"modelValue\"\n :type=\"defaultType\"\n :value=\"enumProp\"\n @update:modelValue=\"handleSelectChange\" />\n\n <!-- Boolean mode: select dropdown with true/false (and optionally null) -->\n <DataTableInputSelect\n v-else-if=\"isBooleanMode\"\n :default=\"defaultProp\"\n :modelValue=\"modelValue\"\n :value=\"booleanOptions\"\n @update:modelValue=\"handleSelectChange\" />\n\n <!-- Examples mode: select dropdown with example values -->\n <DataTableInputSelect\n v-else-if=\"examples?.length\"\n :default=\"defaultProp\"\n :modelValue=\"modelValue\"\n :value=\"examples\"\n @update:modelValue=\"handleSelectChange\" />\n\n <!-- Editor mode -->\n <div\n v-else\n :id=\"componentId\"\n v-bind=\"$attrs\"\n class=\"code-input-lite group/code-input-lite peer relative w-full leading-[1.44] -outline-offset-1 has-[:focus-visible]:rounded-[4px] has-[:focus-visible]:outline\"\n :class=\"{\n 'code-input-lite--error': error,\n 'code-input-lite--empty': isEmpty,\n 'line-through': linethrough,\n }\">\n <!-- The single editable surface; see the file header for how pills work. -->\n <div\n ref=\"editorRef\"\n :aria-activedescendant=\"\n displayVariablesDropdown ? activeOptionId : undefined\n \"\n :aria-autocomplete=\"withVariables ? 'list' : undefined\"\n :aria-controls=\"displayVariablesDropdown ? listboxId : undefined\"\n :aria-expanded=\"displayVariablesDropdown ? 'true' : undefined\"\n :aria-invalid=\"error ? 'true' : undefined\"\n :aria-label=\"attrs['aria-label']\"\n :aria-readonly=\"readOnly ? 'true' : undefined\"\n :aria-required=\"required ? 'true' : undefined\"\n class=\"code-input-lite__editor\"\n :contenteditable=\"readOnly ? 'false' : 'true'\"\n :data-placeholder=\"placeholder\"\n :role=\"withVariables ? 'combobox' : 'textbox'\"\n spellcheck=\"false\"\n @blur=\"handleBlur\"\n @click=\"handleEditorClick\"\n @compositionend=\"handleCompositionEnd\"\n @compositionstart=\"handleCompositionStart\"\n @focus=\"handleFocus\"\n @input=\"handleInput\"\n @keydown=\"handleKeyDown\"\n @paste=\"handlePaste\"\n @pointerover=\"ensureTooltipsActive\" />\n </div>\n\n <!--\n Slots and the required indicator are siblings of the mode templates so\n they render in every mode and so `absolute right-0` anchors to the\n surrounding (relative) cell rather than the shrink-wrapped mode wrapper.\n -->\n <div\n v-if=\"$slots.warning\"\n class=\"centered-y text-orange absolute right-7 text-xs\">\n <slot name=\"warning\" />\n </div>\n <div\n v-if=\"$slots.icon\"\n class=\"centered-y absolute right-0 flex h-full items-center p-1.5 group-has-[.code-input-lite__editor:focus]:z-1\">\n <slot name=\"icon\" />\n </div>\n <div\n v-if=\"required\"\n class=\"required centered-y text-xxs text-c-3 group-[.error]:text-red bg-b-1 pointer-events-none absolute right-0 mr-0.5 pt-px pr-2 opacity-100 shadow-[-8px_0_4px_var(--scalar-background-1)] transition-opacity duration-150 peer-has-[.code-input-lite__editor:focus]:opacity-0\">\n Required\n </div>\n\n <EnvironmentVariableDropdown\n v-if=\"displayVariablesDropdown\"\n ref=\"dropdownRef\"\n :contextFunctionItems=\"contextFunctionDropdownItems\"\n :dropdownPosition=\"dropdownPosition\"\n :environment=\"environment\"\n :listboxId=\"listboxId\"\n :query=\"dropdownQuery\"\n @close=\"showDropdown = false\"\n @redirect=\"emit('navigate', { page: 'document', path: 'environment' })\"\n @select=\"handleDropdownSelect\" />\n</template>\n\n<style scoped>\n.code-input-lite {\n /* Flex so the editor centres vertically in whatever height the cell gives us.\n Font properties inherit so we adopt the surrounding typography. */\n display: flex;\n align-items: center;\n}\n\n.code-input-lite__editor {\n /* Everything font-related inherits from the surrounding context. */\n font: inherit;\n letter-spacing: inherit;\n flex: 1;\n min-width: 0;\n background: transparent;\n outline: none;\n color: var(--scalar-color-1);\n caret-color: var(--scalar-color-1);\n /* Single-line: horizontal scroll keeps the caret visible for long values;\n the scrollbar itself is hidden (would be noisy inside a table cell). */\n white-space: pre;\n overflow-x: auto;\n overflow-y: hidden;\n scrollbar-width: none;\n padding: 0 0.5em;\n box-sizing: border-box;\n line-height: 1.44;\n /* Positioning context for the absolutely positioned placeholder. */\n position: relative;\n}\n\n.code-input-lite__editor::-webkit-scrollbar {\n display: none;\n}\n\n/* Absolute so the placeholder does not occupy flow space inside the\n contenteditable; otherwise the caret would land after it on focus.\n `pointer-events: none` lets clicks fall through to focus the editor.\n Hidden on focus so it never renders on top of the text caret. */\n.code-input-lite--empty .code-input-lite__editor:not(:focus)::before {\n content: attr(data-placeholder);\n color: var(--scalar-color-3);\n pointer-events: none;\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0.5em;\n display: flex;\n align-items: center;\n}\n\n.code-input-lite--error .code-input-lite__editor {\n outline: 1px solid var(--scalar-color-red);\n}\n</style>\n\n<style>\n/* Pill styling. Each pill is `<span contenteditable=\"false\">name</span>` —\n an atomic widget; the caret lands before or after it, never inside. */\n.scalar-pill {\n color: var(--scalar-color-2);\n border-radius: 30px;\n display: inline-block;\n font-family: var(--scalar-font-code);\n font-size: 0.9em;\n line-height: 1.4;\n vertical-align: baseline;\n background: var(--scalar-background-3);\n padding: 0.125em 0.6em;\n margin-right: 0.35em;\n cursor: text;\n /* Single click selects the whole pill — chip/mention model, deletes in one go. */\n user-select: all;\n -webkit-user-select: all;\n}\n\n.dark-mode .scalar-pill {\n background: color-mix(\n in srgb,\n var(--tw-bg-base, var(--scalar-color-1)),\n transparent 90%\n );\n}\n\n.light-mode .scalar-pill {\n background: var(--scalar-background-3);\n}\n\n.scalar-pill--context-fn {\n /* Inset box-shadow as a border so the layout box stays identical to plain pills. */\n box-shadow: 0 0 0 1px\n color-mix(in srgb, var(--scalar-color-3), transparent 35%) inset;\n}\n\n.dark-mode .scalar-pill--context-fn {\n background: color-mix(in srgb, var(--scalar-background-3), transparent 55%);\n}\n\n.light-mode .scalar-pill--context-fn {\n background: color-mix(in srgb, var(--scalar-background-3), transparent 40%);\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAWE,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkGhB,MAAM,OAAO;EAOb,MAAM,QAAQ,UAAU;;;;;;EAOxB,MAAM,uBAAuB,IAAmB,KAAI;EACpD,MAAM,cAAc,eACQ,MAAM,MAAM,qBAAqB,SAAS,KAAA,EACtE;EACA,MAAM,0BAAgC;AACpC,OAAI,CAAC,MAAM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AA,CAAA,CAAA,IAAA,mBAAA,IAAA,KAAA;IAGjBA,KAAAA,OAAO,QAAA,WAAA,EADf,mBAIM,OAJN,YAIM,CADJ,WAAoB,KAAA,QAAA,QAAA,EAAA,EAAA,KAAA,GAAA,KAAA,CAAA,CAAA,IAAA,mBAAA,IAAA,KAAA;IAGd,QAAA,YAAA,WAAA,EADR,mBAIM,OAJN,YAEqR,aAErR,IAAA,mBAAA,IAAA,KAAA;IAGQ,yBAAA,SAAA,WAAA,EADR,YAUmC,sCAAA;;cAR7B;KAAJ,KAAI;KACH,sBAAsB,6BAAA;KACtB,kBAAkB,iBAAA;KAClB,aAAa,QAAA;KACb,WAAW,UAAA;KACX,OAAO,cAAA;KACP,SAAK,OAAA,OAAA,OAAA,MAAA,WAAE,aAAA,QAAY;KACnB,YAAQ,OAAA,OAAA,OAAA,MAAA,WAAE,KAAI,YAAA;MAAA,MAAA;MAAA,MAAA;MAAA,CAAA;KACd,UAAQ"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { PillContext } from './pill-context';
|
|
2
2
|
type __VLS_Props = {
|
|
3
|
+
/** Tooltip data — environment value or context-function description */
|
|
3
4
|
context: PillContext;
|
|
5
|
+
/** The pill element to attach the tooltip to */
|
|
6
|
+
target: HTMLElement;
|
|
4
7
|
};
|
|
5
8
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
6
9
|
declare const _default: typeof __VLS_export;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PillTooltipHost.vue.d.ts","sourceRoot":"","sources":["../../../../src/v2/components/code-input/PillTooltipHost.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PillTooltipHost.vue.d.ts","sourceRoot":"","sources":["../../../../src/v2/components/code-input/PillTooltipHost.vue"],"names":[],"mappings":"AA4FA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAEjD,KAAK,WAAW,GAAG;IACjB,uEAAuE;IACvE,OAAO,EAAE,WAAW,CAAA;IACpB,gDAAgD;IAChD,MAAM,EAAE,WAAW,CAAA;CACpB,CAAC;AA2DF,QAAA,MAAM,YAAY,kSAEhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PillTooltipHost.vue.js","names":[],"sources":["../../../../src/v2/components/code-input/PillTooltipHost.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { useTooltip } from '@scalar/components/tooltip'\nimport { computed, h, ref, render } from 'vue'\n\nimport type { PillContext } from './pill-context'\n\nconst props = defineProps<{\n context: PillContext\n}>()\n\ndefineOptions({ name: 'PillTooltipHost' })\n\nconst
|
|
1
|
+
{"version":3,"file":"PillTooltipHost.vue.js","names":[],"sources":["../../../../src/v2/components/code-input/PillTooltipHost.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/**\n * PillTooltipHost\n *\n * Renderless adapter that attaches a tooltip to an existing DOM element.\n * Both the legacy CodeMirror widget pipeline and the new `CodeInputLite`\n * overlay mount one of these per pill via `createApp` — they keep ownership\n * of the pill DOM (text, classes, styles) and we only attach hover/focus\n * behaviour through `useTooltip`.\n *\n * The component renders nothing of its own; pass the pill element via the\n * `target` prop and `useTooltip` will wire mouseenter/mouseleave/focus/blur\n * listeners onto it directly.\n */\nimport { useTooltip } from '@scalar/components/tooltip'\nimport { computed, h, ref, render } from 'vue'\n\nimport type { PillContext } from './pill-context'\n\nconst props = defineProps<{\n /** Tooltip data — environment value or context-function description */\n context: PillContext\n /** The pill element to attach the tooltip to */\n target: HTMLElement\n}>()\n\ndefineOptions({ name: 'PillTooltipHost' })\n\nconst isContextFn = props.context.type === 'contextFunction'\n\n/** Two-line HTML body for context-function tooltips. */\nconst contextTooltipHtml = computed(() => {\n if (\n !isContextFn ||\n typeof document === 'undefined' ||\n props.context.type !== 'contextFunction'\n ) {\n return ''\n }\n const el = document.createElement('div')\n render(\n h('div', { class: 'flex flex-col gap-1.5 text-left' }, [\n h('span', {}, props.context.details),\n h(\n 'div',\n { class: 'text-[color:var(--scalar-color-3)] text-[10px] font-normal' },\n 'Computed at request execution',\n ),\n ]),\n el,\n )\n return el.innerHTML\n})\n\nconst environmentTooltipText = computed(() =>\n props.context.type === 'environment' ? props.context.value : '',\n)\n\nconst targetRef = ref<HTMLElement>(props.target)\n\nuseTooltip({\n content: isContextFn ? contextTooltipHtml : environmentTooltipText,\n contentTarget: isContextFn ? 'innerHTML' : 'textContent',\n delay: 0,\n placement: 'bottom-start',\n offset: 6,\n targetRef,\n})\n</script>\n\n<template>\n <!-- Renderless: behaviour attaches to props.target via useTooltip -->\n</template>\n"],"mappings":""}
|
|
@@ -1,36 +1,48 @@
|
|
|
1
|
-
import { computed,
|
|
1
|
+
import { computed, defineComponent, h, ref, render } from "vue";
|
|
2
2
|
import { useTooltip } from "@scalar/components/tooltip";
|
|
3
3
|
//#region src/v2/components/code-input/PillTooltipHost.vue?vue&type=script&setup=true&lang.ts
|
|
4
|
-
var _hoisted_1 = { class: "flex items-center gap-1 whitespace-nowrap" };
|
|
5
4
|
var PillTooltipHost_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
6
5
|
name: "PillTooltipHost",
|
|
7
6
|
__name: "PillTooltipHost",
|
|
8
|
-
props: {
|
|
7
|
+
props: {
|
|
8
|
+
context: {},
|
|
9
|
+
target: {}
|
|
10
|
+
},
|
|
9
11
|
setup(__props) {
|
|
12
|
+
/**
|
|
13
|
+
* PillTooltipHost
|
|
14
|
+
*
|
|
15
|
+
* Renderless adapter that attaches a tooltip to an existing DOM element.
|
|
16
|
+
* Both the legacy CodeMirror widget pipeline and the new `CodeInputLite`
|
|
17
|
+
* overlay mount one of these per pill via `createApp` — they keep ownership
|
|
18
|
+
* of the pill DOM (text, classes, styles) and we only attach hover/focus
|
|
19
|
+
* behaviour through `useTooltip`.
|
|
20
|
+
*
|
|
21
|
+
* The component renders nothing of its own; pass the pill element via the
|
|
22
|
+
* `target` prop and `useTooltip` will wire mouseenter/mouseleave/focus/blur
|
|
23
|
+
* listeners onto it directly.
|
|
24
|
+
*/
|
|
10
25
|
const props = __props;
|
|
11
|
-
const wrapperRef = ref(null);
|
|
12
26
|
const isContextFn = props.context.type === "contextFunction";
|
|
27
|
+
/** Two-line HTML body for context-function tooltips. */
|
|
13
28
|
const contextTooltipHtml = computed(() => {
|
|
14
|
-
if (!isContextFn || typeof document === "undefined") return "";
|
|
29
|
+
if (!isContextFn || typeof document === "undefined" || props.context.type !== "contextFunction") return "";
|
|
15
30
|
const el = document.createElement("div");
|
|
16
31
|
render(h("div", { class: "flex flex-col gap-1.5 text-left" }, [h("span", {}, props.context.details), h("div", { class: "text-[color:var(--scalar-color-3)] text-[10px] font-normal" }, "Computed at request execution")]), el);
|
|
17
32
|
return el.innerHTML;
|
|
18
33
|
});
|
|
19
34
|
const environmentTooltipText = computed(() => props.context.type === "environment" ? props.context.value : "");
|
|
35
|
+
const targetRef = ref(props.target);
|
|
20
36
|
useTooltip({
|
|
21
37
|
content: isContextFn ? contextTooltipHtml : environmentTooltipText,
|
|
22
38
|
contentTarget: isContextFn ? "innerHTML" : "textContent",
|
|
23
39
|
delay: 0,
|
|
24
40
|
placement: "bottom-start",
|
|
25
41
|
offset: 6,
|
|
26
|
-
targetRef
|
|
42
|
+
targetRef
|
|
27
43
|
});
|
|
28
44
|
return (_ctx, _cache) => {
|
|
29
|
-
return
|
|
30
|
-
ref_key: "wrapperRef",
|
|
31
|
-
ref: wrapperRef,
|
|
32
|
-
class: "contents"
|
|
33
|
-
}, [createElementVNode("div", _hoisted_1, [createElementVNode("span", null, toDisplayString(props.context.type === "environment" ? props.context.name : props.context.identifier), 1)])], 512);
|
|
45
|
+
return null;
|
|
34
46
|
};
|
|
35
47
|
}
|
|
36
48
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PillTooltipHost.vue.script.js","names":[],"sources":["../../../../src/v2/components/code-input/PillTooltipHost.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { useTooltip } from '@scalar/components/tooltip'\nimport { computed, h, ref, render } from 'vue'\n\nimport type { PillContext } from './pill-context'\n\nconst props = defineProps<{\n context: PillContext\n}>()\n\ndefineOptions({ name: 'PillTooltipHost' })\n\nconst
|
|
1
|
+
{"version":3,"file":"PillTooltipHost.vue.script.js","names":[],"sources":["../../../../src/v2/components/code-input/PillTooltipHost.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/**\n * PillTooltipHost\n *\n * Renderless adapter that attaches a tooltip to an existing DOM element.\n * Both the legacy CodeMirror widget pipeline and the new `CodeInputLite`\n * overlay mount one of these per pill via `createApp` — they keep ownership\n * of the pill DOM (text, classes, styles) and we only attach hover/focus\n * behaviour through `useTooltip`.\n *\n * The component renders nothing of its own; pass the pill element via the\n * `target` prop and `useTooltip` will wire mouseenter/mouseleave/focus/blur\n * listeners onto it directly.\n */\nimport { useTooltip } from '@scalar/components/tooltip'\nimport { computed, h, ref, render } from 'vue'\n\nimport type { PillContext } from './pill-context'\n\nconst props = defineProps<{\n /** Tooltip data — environment value or context-function description */\n context: PillContext\n /** The pill element to attach the tooltip to */\n target: HTMLElement\n}>()\n\ndefineOptions({ name: 'PillTooltipHost' })\n\nconst isContextFn = props.context.type === 'contextFunction'\n\n/** Two-line HTML body for context-function tooltips. */\nconst contextTooltipHtml = computed(() => {\n if (\n !isContextFn ||\n typeof document === 'undefined' ||\n props.context.type !== 'contextFunction'\n ) {\n return ''\n }\n const el = document.createElement('div')\n render(\n h('div', { class: 'flex flex-col gap-1.5 text-left' }, [\n h('span', {}, props.context.details),\n h(\n 'div',\n { class: 'text-[color:var(--scalar-color-3)] text-[10px] font-normal' },\n 'Computed at request execution',\n ),\n ]),\n el,\n )\n return el.innerHTML\n})\n\nconst environmentTooltipText = computed(() =>\n props.context.type === 'environment' ? props.context.value : '',\n)\n\nconst targetRef = ref<HTMLElement>(props.target)\n\nuseTooltip({\n content: isContextFn ? contextTooltipHtml : environmentTooltipText,\n contentTarget: isContextFn ? 'innerHTML' : 'textContent',\n delay: 0,\n placement: 'bottom-start',\n offset: 6,\n targetRef,\n})\n</script>\n\n<template>\n <!-- Renderless: behaviour attaches to props.target via useTooltip -->\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;EAmBA,MAAM,QAAQ;EASd,MAAM,cAAc,MAAM,QAAQ,SAAS;;EAG3C,MAAM,qBAAqB,eAAe;AACxC,OACE,CAAC,eACD,OAAO,aAAa,eACpB,MAAM,QAAQ,SAAS,kBAEvB,QAAO;GAET,MAAM,KAAK,SAAS,cAAc,MAAK;AACvC,UACE,EAAE,OAAO,EAAE,OAAO,mCAAmC,EAAE,CACrD,EAAE,QAAQ,EAAE,EAAE,MAAM,QAAQ,QAAQ,EACpC,EACE,OACA,EAAE,OAAO,8DAA8D,EACvE,gCACD,CACF,CAAC,EACF,GACF;AACA,UAAO,GAAG;IACX;EAED,MAAM,yBAAyB,eAC7B,MAAM,QAAQ,SAAS,gBAAgB,MAAM,QAAQ,QAAQ,GAC/D;EAEA,MAAM,YAAY,IAAiB,MAAM,OAAM;AAE/C,aAAW;GACT,SAAS,cAAc,qBAAqB;GAC5C,eAAe,cAAc,cAAc;GAC3C,OAAO;GACP,WAAW;GACX,QAAQ;GACR;GACD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-variable-widget.d.ts","sourceRoot":"","sources":["../../../../src/v2/components/code-input/code-variable-widget.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,aAAa,EAClB,UAAU,EAEV,UAAU,EACV,KAAK,UAAU,EAEhB,MAAM,wBAAwB,CAAA;AAE/B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAA;
|
|
1
|
+
{"version":3,"file":"code-variable-widget.d.ts","sourceRoot":"","sources":["../../../../src/v2/components/code-input/code-variable-widget.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,aAAa,EAClB,UAAU,EAEV,UAAU,EACV,KAAK,UAAU,EAEhB,MAAM,wBAAwB,CAAA;AAE/B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAA;AAuGnH;;;GAGG;AACH,eAAO,MAAM,UAAU,GAAI,OAAO;IAChC,WAAW,EAAE,kBAAkB,GAAG,SAAS,CAAA;IAC3C,UAAU,EAAE,OAAO,GAAG,SAAS,CAAA;IAC/B,qBAAqB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAA;CAClD;iBAGkB,aAAa;qBACT,kBAAkB,GAAG,SAAS;mBAOhC,UAAU,GAAG,IAAI;2BAcT,UAAU,GAAG,aAAa;EAyCpD,CAAA;AAEH;;;GAGG;AACH,eAAO,MAAM,gBAAgB,uCAoC3B,CAAA"}
|
|
@@ -40,8 +40,11 @@ var PillWidget = class PillWidget extends WidgetType {
|
|
|
40
40
|
span.textContent = this.variableName;
|
|
41
41
|
span.style.setProperty("--tw-bg-base", this.pillColor);
|
|
42
42
|
if (this.variableInfo.type === "environment") span.style.opacity = this.variableInfo.isDefined ? "1" : "0.5";
|
|
43
|
-
this.app = createApp(PillTooltipHost_default, {
|
|
44
|
-
|
|
43
|
+
this.app = createApp(PillTooltipHost_default, {
|
|
44
|
+
context: this.variableInfo,
|
|
45
|
+
target: span
|
|
46
|
+
});
|
|
47
|
+
this.app.mount(document.createElement("div"));
|
|
45
48
|
return span;
|
|
46
49
|
}
|
|
47
50
|
destroy() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-variable-widget.js","names":[],"sources":["../../../../src/v2/components/code-input/code-variable-widget.ts"],"sourcesContent":["import { REGEX } from '@scalar/helpers/regex/regex-helpers'\nimport {\n Decoration,\n type DecorationSet,\n EditorView,\n RangeSetBuilder,\n ViewPlugin,\n type ViewUpdate,\n WidgetType,\n} from '@scalar/use-codemirror'\nimport { type ContextFunctionName, getContextFunctionComment } from '@scalar/workspace-store/request-example'\nimport type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments'\nimport { createApp } from 'vue'\n\nimport PillTooltipHost from './PillTooltipHost.vue'\nimport type { PillContext } from './pill-context'\n\n/**\n * Displays `{{name}}` as a pill: environment variables show the resolved value;\n * context functions (e.g. `{{$guid}}`) show that the value is generated at send time.\n */\nclass PillWidget extends WidgetType {\n private app: any\n private readonly pillColor: string\n private readonly variableInfo: PillContext\n\n constructor(\n private readonly variableName: string,\n environment: XScalarEnvironment | undefined,\n variant: PillContext['type'],\n ) {\n super()\n if (variant === 'contextFunction') {\n this.pillColor = 'var(--scalar-color-3)'\n this.variableInfo = {\n type: 'contextFunction',\n identifier: variableName,\n details: getContextFunctionComment(variableName as ContextFunctionName),\n }\n return\n }\n\n this.pillColor = environment?.color || 'var(--scalar-color-1)'\n\n const variable = environment?.variables?.find((v) => v.name === variableName)\n const value = variable ? (typeof variable.value === 'string' ? variable.value : variable.value?.default) : undefined\n this.variableInfo = {\n type: 'environment',\n name: variableName,\n value: value || 'No value',\n isDefined: Boolean(value),\n }\n }\n\n toDOM(): HTMLElement {\n const span = document.createElement('span')\n span.className = this.variableInfo.type === 'contextFunction' ? 'cm-pill cm-pill--context-fn' : 'cm-pill'\n span.textContent = this.variableName\n\n span.style.setProperty('--tw-bg-base', this.pillColor)\n\n if (this.variableInfo.type === 'environment') {\n span.style.opacity = this.variableInfo.isDefined ? '1' : '0.5'\n }\n\n this.app = createApp(PillTooltipHost, {\n context: this.variableInfo,\n })\n this.app.mount(span)\n\n return span\n }\n\n override destroy(): void {\n if (this.app) {\n this.app.unmount()\n this.app = null\n }\n }\n\n override eq(other: WidgetType): boolean {\n if (!(other instanceof PillWidget)) {\n return false\n }\n if (\n other.variableName !== this.variableName ||\n other.pillColor !== this.pillColor ||\n other.variableInfo.type !== this.variableInfo.type\n ) {\n return false\n }\n const a = other.variableInfo\n const b = this.variableInfo\n if (a.type !== b.type) {\n return false\n }\n if (a.type === 'environment' && b.type === 'environment') {\n return a.name === b.name && a.value === b.value && a.isDefined === b.isDefined\n }\n if (a.type === 'contextFunction' && b.type === 'contextFunction') {\n return a.identifier === b.identifier && a.details === b.details\n }\n return false\n }\n\n override ignoreEvent(): boolean {\n return false\n }\n}\n\n/**\n * Styles the active environment variable pill.\n * This plugin creates decorations for environment variables in the editor.\n */\nexport const pillPlugin = (props: {\n environment: XScalarEnvironment | undefined\n isReadOnly: boolean | undefined\n isContextFunctionName?: (name: string) => boolean\n}) =>\n ViewPlugin.fromClass(\n class {\n decorations: DecorationSet\n lastEnvironment: XScalarEnvironment | undefined\n\n constructor(view: EditorView) {\n this.lastEnvironment = props.environment\n this.decorations = this.buildDecorations(view)\n }\n\n update(update: ViewUpdate): void {\n // Rebuild decorations if environment changed\n if (props.environment !== this.lastEnvironment) {\n this.lastEnvironment = props.environment\n this.decorations = this.buildDecorations(update.view)\n return\n }\n\n // Only rebuild decorations if document or viewport changed\n if (update.docChanged || update.viewportChanged) {\n this.decorations = this.buildDecorations(update.view)\n }\n }\n\n buildDecorations(view: EditorView): DecorationSet {\n const builder = new RangeSetBuilder<Decoration>()\n const isContextFn = props.isContextFunctionName ?? (() => false)\n\n for (const { from, to } of view.visibleRanges) {\n const text = view.state.doc.sliceString(from, to)\n\n // Create a new regex instance to ensure lastIndex is reset\n const regex = new RegExp(REGEX.VARIABLES.source, REGEX.VARIABLES.flags)\n let match: RegExpExecArray | null\n\n while ((match = regex.exec(text)) !== null) {\n const start = from + match.index\n const end = start + match[0].length\n const variableName = match[1] ?? ''\n\n // Skip decorations that span line breaks as CodeMirror does not allow them\n const matchedText = view.state.doc.sliceString(start, end)\n if (matchedText.includes('\\n')) {\n continue\n }\n\n const variant: PillContext['type'] = isContextFn(variableName) ? 'contextFunction' : 'environment'\n\n builder.add(\n start,\n end,\n Decoration.widget({\n widget: new PillWidget(variableName, props.environment, variant),\n side: 1,\n }),\n )\n }\n }\n\n return builder.finish()\n }\n },\n {\n decorations: (v) => v.decorations,\n },\n )\n\n/**\n * Custom backspace handler for the editor.\n * Handles special cases like removing entire variable syntax and clearing all content.\n */\nexport const backspaceCommand = EditorView.domEventHandlers({\n keydown(event, view): boolean {\n if (event.key !== 'Backspace') {\n return false\n }\n\n const { state } = view\n const { from, to } = state.selection.main\n\n // When selecting all content and pressing backspace,\n // prevent breaking line content addition on pill removal\n if (from === 0 && to === state.doc.length) {\n view.dispatch({\n changes: { from: 0, to: state.doc.length },\n selection: { anchor: 0 },\n })\n event.preventDefault()\n return true\n }\n\n // When cursor is after a variable closing bracket (}}),\n // remove the entire closing syntax at once\n if (from === to && from >= 2) {\n const before = state.doc.sliceString(from - 2, from)\n if (before === '}}') {\n view.dispatch({\n changes: { from: from - 2, to: from },\n selection: { anchor: from - 2 },\n })\n event.preventDefault()\n return true\n }\n }\n\n return false\n },\n})\n"],"mappings":";;;;;;;;;;AAqBA,IAAM,aAAN,MAAM,mBAAmB,WAAW;CAClC;CACA;CACA;CAEA,YACE,cACA,aACA,SACA;AACA,SAAO;AAJU,OAAA,eAAA;AAKjB,MAAI,YAAY,mBAAmB;AACjC,QAAK,YAAY;AACjB,QAAK,eAAe;IAClB,MAAM;IACN,YAAY;IACZ,SAAS,0BAA0B,aAAoC;IACxE;AACD;;AAGF,OAAK,YAAY,aAAa,SAAS;EAEvC,MAAM,WAAW,aAAa,WAAW,MAAM,MAAM,EAAE,SAAS,aAAa;EAC7E,MAAM,QAAQ,WAAY,OAAO,SAAS,UAAU,WAAW,SAAS,QAAQ,SAAS,OAAO,UAAW,KAAA;AAC3G,OAAK,eAAe;GAClB,MAAM;GACN,MAAM;GACN,OAAO,SAAS;GAChB,WAAW,QAAQ,MAAM;GAC1B;;CAGH,QAAqB;EACnB,MAAM,OAAO,SAAS,cAAc,OAAO;AAC3C,O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AACnB,QAAK,SAAS;IACZ,SAAS;KAAE,MAAM,OAAO;KAAG,IAAI;KAAM;IACrC,WAAW,EAAE,QAAQ,OAAO,GAAG;IAChC,CAAC;AACF,SAAM,gBAAgB;AACtB,UAAO;;;AAIX,QAAO;GAEV,CAAC"}
|
|
1
|
+
{"version":3,"file":"code-variable-widget.js","names":[],"sources":["../../../../src/v2/components/code-input/code-variable-widget.ts"],"sourcesContent":["import { REGEX } from '@scalar/helpers/regex/regex-helpers'\nimport {\n Decoration,\n type DecorationSet,\n EditorView,\n RangeSetBuilder,\n ViewPlugin,\n type ViewUpdate,\n WidgetType,\n} from '@scalar/use-codemirror'\nimport { type ContextFunctionName, getContextFunctionComment } from '@scalar/workspace-store/request-example'\nimport type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments'\nimport { createApp } from 'vue'\n\nimport PillTooltipHost from './PillTooltipHost.vue'\nimport type { PillContext } from './pill-context'\n\n/**\n * Displays `{{name}}` as a pill: environment variables show the resolved value;\n * context functions (e.g. `{{$guid}}`) show that the value is generated at send time.\n */\nclass PillWidget extends WidgetType {\n private app: any\n private readonly pillColor: string\n private readonly variableInfo: PillContext\n\n constructor(\n private readonly variableName: string,\n environment: XScalarEnvironment | undefined,\n variant: PillContext['type'],\n ) {\n super()\n if (variant === 'contextFunction') {\n this.pillColor = 'var(--scalar-color-3)'\n this.variableInfo = {\n type: 'contextFunction',\n identifier: variableName,\n details: getContextFunctionComment(variableName as ContextFunctionName),\n }\n return\n }\n\n this.pillColor = environment?.color || 'var(--scalar-color-1)'\n\n const variable = environment?.variables?.find((v) => v.name === variableName)\n const value = variable ? (typeof variable.value === 'string' ? variable.value : variable.value?.default) : undefined\n this.variableInfo = {\n type: 'environment',\n name: variableName,\n value: value || 'No value',\n isDefined: Boolean(value),\n }\n }\n\n toDOM(): HTMLElement {\n const span = document.createElement('span')\n span.className = this.variableInfo.type === 'contextFunction' ? 'cm-pill cm-pill--context-fn' : 'cm-pill'\n span.textContent = this.variableName\n\n span.style.setProperty('--tw-bg-base', this.pillColor)\n\n if (this.variableInfo.type === 'environment') {\n span.style.opacity = this.variableInfo.isDefined ? '1' : '0.5'\n }\n\n // PillTooltipHost is renderless and attaches `useTooltip` listeners to\n // `target` directly — mount onto a throwaway container so the pill DOM\n // we just built is preserved.\n this.app = createApp(PillTooltipHost, {\n context: this.variableInfo,\n target: span,\n })\n this.app.mount(document.createElement('div'))\n\n return span\n }\n\n override destroy(): void {\n if (this.app) {\n this.app.unmount()\n this.app = null\n }\n }\n\n override eq(other: WidgetType): boolean {\n if (!(other instanceof PillWidget)) {\n return false\n }\n if (\n other.variableName !== this.variableName ||\n other.pillColor !== this.pillColor ||\n other.variableInfo.type !== this.variableInfo.type\n ) {\n return false\n }\n const a = other.variableInfo\n const b = this.variableInfo\n if (a.type !== b.type) {\n return false\n }\n if (a.type === 'environment' && b.type === 'environment') {\n return a.name === b.name && a.value === b.value && a.isDefined === b.isDefined\n }\n if (a.type === 'contextFunction' && b.type === 'contextFunction') {\n return a.identifier === b.identifier && a.details === b.details\n }\n return false\n }\n\n override ignoreEvent(): boolean {\n return false\n }\n}\n\n/**\n * Styles the active environment variable pill.\n * This plugin creates decorations for environment variables in the editor.\n */\nexport const pillPlugin = (props: {\n environment: XScalarEnvironment | undefined\n isReadOnly: boolean | undefined\n isContextFunctionName?: (name: string) => boolean\n}) =>\n ViewPlugin.fromClass(\n class {\n decorations: DecorationSet\n lastEnvironment: XScalarEnvironment | undefined\n\n constructor(view: EditorView) {\n this.lastEnvironment = props.environment\n this.decorations = this.buildDecorations(view)\n }\n\n update(update: ViewUpdate): void {\n // Rebuild decorations if environment changed\n if (props.environment !== this.lastEnvironment) {\n this.lastEnvironment = props.environment\n this.decorations = this.buildDecorations(update.view)\n return\n }\n\n // Only rebuild decorations if document or viewport changed\n if (update.docChanged || update.viewportChanged) {\n this.decorations = this.buildDecorations(update.view)\n }\n }\n\n buildDecorations(view: EditorView): DecorationSet {\n const builder = new RangeSetBuilder<Decoration>()\n const isContextFn = props.isContextFunctionName ?? (() => false)\n\n for (const { from, to } of view.visibleRanges) {\n const text = view.state.doc.sliceString(from, to)\n\n // Create a new regex instance to ensure lastIndex is reset\n const regex = new RegExp(REGEX.VARIABLES.source, REGEX.VARIABLES.flags)\n let match: RegExpExecArray | null\n\n while ((match = regex.exec(text)) !== null) {\n const start = from + match.index\n const end = start + match[0].length\n const variableName = match[1] ?? ''\n\n // Skip decorations that span line breaks as CodeMirror does not allow them\n const matchedText = view.state.doc.sliceString(start, end)\n if (matchedText.includes('\\n')) {\n continue\n }\n\n const variant: PillContext['type'] = isContextFn(variableName) ? 'contextFunction' : 'environment'\n\n builder.add(\n start,\n end,\n Decoration.widget({\n widget: new PillWidget(variableName, props.environment, variant),\n side: 1,\n }),\n )\n }\n }\n\n return builder.finish()\n }\n },\n {\n decorations: (v) => v.decorations,\n },\n )\n\n/**\n * Custom backspace handler for the editor.\n * Handles special cases like removing entire variable syntax and clearing all content.\n */\nexport const backspaceCommand = EditorView.domEventHandlers({\n keydown(event, view): boolean {\n if (event.key !== 'Backspace') {\n return false\n }\n\n const { state } = view\n const { from, to } = state.selection.main\n\n // When selecting all content and pressing backspace,\n // prevent breaking line content addition on pill removal\n if (from === 0 && to === state.doc.length) {\n view.dispatch({\n changes: { from: 0, to: state.doc.length },\n selection: { anchor: 0 },\n })\n event.preventDefault()\n return true\n }\n\n // When cursor is after a variable closing bracket (}}),\n // remove the entire closing syntax at once\n if (from === to && from >= 2) {\n const before = state.doc.sliceString(from - 2, from)\n if (before === '}}') {\n view.dispatch({\n changes: { from: from - 2, to: from },\n selection: { anchor: from - 2 },\n })\n event.preventDefault()\n return true\n }\n }\n\n return false\n },\n})\n"],"mappings":";;;;;;;;;;AAqBA,IAAM,aAAN,MAAM,mBAAmB,WAAW;CAClC;CACA;CACA;CAEA,YACE,cACA,aACA,SACA;AACA,SAAO;AAJU,OAAA,eAAA;AAKjB,MAAI,YAAY,mBAAmB;AACjC,QAAK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H,IAAa,mBAAmB,WAAW,iBAAiB,EAC1D,QAAQ,OAAO,MAAe;AAC5B,KAAI,MAAM,QAAQ,YAChB,QAAO;CAGT,MAAM,EAAE,UAAU;CAClB,MAAM,EAAE,MAAM,OAAO,MAAM,UAAU;AAIrC,KAAI,SAAS,KAAK,OAAO,MAAM,IAAI,QAAQ;AACzC,OAAK,SAAS;GACZ,SAAS;IAAE,MAAM;IAAG,IAAI,MAAM,IAAI;IAAQ;GAC1C,WAAW,EAAE,QAAQ,GAAG;GACzB,CAAC;AACF,QAAM,gBAAgB;AACtB,SAAO;;AAKT,KAAI,SAAS,MAAM,QAAQ;MACV,MAAM,IAAI,YAAY,OAAO,GAAG,KAAK,KACrC,MAAM;AACnB,QAAK,SAAS;IACZ,SAAS;KAAE,MAAM,OAAO;KAAG,IAAI;KAAM;IACrC,WAAW,EAAE,QAAQ,OAAO,GAAG;IAChC,CAAC;AACF,SAAM,gBAAgB;AACtB,UAAO;;;AAIX,QAAO;GAEV,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments';
|
|
2
|
+
import type { PillContext } from '../pill-context';
|
|
3
|
+
/**
|
|
4
|
+
* Build the tooltip context shown when hovering a pill.
|
|
5
|
+
*
|
|
6
|
+
* `{{$contextFunctions}}` describe what they generate at send time, while
|
|
7
|
+
* regular environment variables show the resolved value (or a "not defined"
|
|
8
|
+
* fallback when the environment does not declare them).
|
|
9
|
+
*/
|
|
10
|
+
export declare const buildPillContext: (variableName: string, environment: XScalarEnvironment | undefined) => PillContext;
|
|
11
|
+
//# sourceMappingURL=build-pill-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-pill-context.d.ts","sourceRoot":"","sources":["../../../../../src/v2/components/code-input/helpers/build-pill-context.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAA;AAEnH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAGlD;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAAI,cAAc,MAAM,EAAE,aAAa,kBAAkB,GAAG,SAAS,KAAG,WAepG,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { lookupVariableValue } from "./lookup-variable-value.js";
|
|
2
|
+
import { getContextFunctionComment, isContextFunctionName } from "@scalar/workspace-store/request-example";
|
|
3
|
+
//#region src/v2/components/code-input/helpers/build-pill-context.ts
|
|
4
|
+
/**
|
|
5
|
+
* Build the tooltip context shown when hovering a pill.
|
|
6
|
+
*
|
|
7
|
+
* `{{$contextFunctions}}` describe what they generate at send time, while
|
|
8
|
+
* regular environment variables show the resolved value (or a "not defined"
|
|
9
|
+
* fallback when the environment does not declare them).
|
|
10
|
+
*/
|
|
11
|
+
var buildPillContext = (variableName, environment) => {
|
|
12
|
+
if (isContextFunctionName(variableName)) return {
|
|
13
|
+
type: "contextFunction",
|
|
14
|
+
identifier: variableName,
|
|
15
|
+
details: getContextFunctionComment(variableName)
|
|
16
|
+
};
|
|
17
|
+
const value = lookupVariableValue(environment, variableName);
|
|
18
|
+
return {
|
|
19
|
+
type: "environment",
|
|
20
|
+
name: variableName,
|
|
21
|
+
value: value || "No value",
|
|
22
|
+
isDefined: Boolean(value)
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
//#endregion
|
|
26
|
+
export { buildPillContext };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=build-pill-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-pill-context.js","names":[],"sources":["../../../../../src/v2/components/code-input/helpers/build-pill-context.ts"],"sourcesContent":["import {\n type ContextFunctionName,\n getContextFunctionComment,\n isContextFunctionName,\n} from '@scalar/workspace-store/request-example'\nimport type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments'\n\nimport type { PillContext } from '../pill-context'\nimport { lookupVariableValue } from './lookup-variable-value'\n\n/**\n * Build the tooltip context shown when hovering a pill.\n *\n * `{{$contextFunctions}}` describe what they generate at send time, while\n * regular environment variables show the resolved value (or a \"not defined\"\n * fallback when the environment does not declare them).\n */\nexport const buildPillContext = (variableName: string, environment: XScalarEnvironment | undefined): PillContext => {\n if (isContextFunctionName(variableName)) {\n return {\n type: 'contextFunction',\n identifier: variableName,\n details: getContextFunctionComment(variableName as ContextFunctionName),\n }\n }\n const value = lookupVariableValue(environment, variableName)\n return {\n type: 'environment',\n name: variableName,\n value: value || 'No value',\n isDefined: Boolean(value),\n }\n}\n"],"mappings":";;;;;;;;;;AAiBA,IAAa,oBAAoB,cAAsB,gBAA6D;AAClH,KAAI,sBAAsB,aAAa,CACrC,QAAO;EACL,MAAM;EACN,YAAY;EACZ,SAAS,0BAA0B,aAAoC;EACxE;CAEH,MAAM,QAAQ,oBAAoB,aAAa,aAAa;AAC5D,QAAO;EACL,MAAM;EACN,MAAM;EACN,OAAO,SAAS;EAChB,WAAW,QAAQ,MAAM;EAC1B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments';
|
|
2
|
+
/**
|
|
3
|
+
* Resolve a variable name to its value in the given environment, if any.
|
|
4
|
+
*
|
|
5
|
+
* Variable values can be a plain string or a structured object with a
|
|
6
|
+
* `default` field (and optional metadata such as `description`); both shapes
|
|
7
|
+
* are flattened to a single string here. Returns `undefined` when the
|
|
8
|
+
* environment is missing or does not declare the variable.
|
|
9
|
+
*/
|
|
10
|
+
export declare const lookupVariableValue: (environment: XScalarEnvironment | undefined, name: string) => string | undefined;
|
|
11
|
+
//# sourceMappingURL=lookup-variable-value.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lookup-variable-value.d.ts","sourceRoot":"","sources":["../../../../../src/v2/components/code-input/helpers/lookup-variable-value.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAA;AAEnH;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,GAAI,aAAa,kBAAkB,GAAG,SAAS,EAAE,MAAM,MAAM,KAAG,MAAM,GAAG,SAMxG,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/v2/components/code-input/helpers/lookup-variable-value.ts
|
|
2
|
+
/**
|
|
3
|
+
* Resolve a variable name to its value in the given environment, if any.
|
|
4
|
+
*
|
|
5
|
+
* Variable values can be a plain string or a structured object with a
|
|
6
|
+
* `default` field (and optional metadata such as `description`); both shapes
|
|
7
|
+
* are flattened to a single string here. Returns `undefined` when the
|
|
8
|
+
* environment is missing or does not declare the variable.
|
|
9
|
+
*/
|
|
10
|
+
var lookupVariableValue = (environment, name) => {
|
|
11
|
+
const variable = environment?.variables?.find((entry) => entry.name === name);
|
|
12
|
+
if (!variable) return;
|
|
13
|
+
return typeof variable.value === "string" ? variable.value : variable.value?.default;
|
|
14
|
+
};
|
|
15
|
+
//#endregion
|
|
16
|
+
export { lookupVariableValue };
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=lookup-variable-value.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lookup-variable-value.js","names":[],"sources":["../../../../../src/v2/components/code-input/helpers/lookup-variable-value.ts"],"sourcesContent":["import type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments'\n\n/**\n * Resolve a variable name to its value in the given environment, if any.\n *\n * Variable values can be a plain string or a structured object with a\n * `default` field (and optional metadata such as `description`); both shapes\n * are flattened to a single string here. Returns `undefined` when the\n * environment is missing or does not declare the variable.\n */\nexport const lookupVariableValue = (environment: XScalarEnvironment | undefined, name: string): string | undefined => {\n const variable = environment?.variables?.find((entry) => entry.name === name)\n if (!variable) {\n return undefined\n }\n return typeof variable.value === 'string' ? variable.value : variable.value?.default\n}\n"],"mappings":";;;;;;;;;AAUA,IAAa,uBAAuB,aAA6C,SAAqC;CACpH,MAAM,WAAW,aAAa,WAAW,MAAM,UAAU,MAAM,SAAS,KAAK;AAC7E,KAAI,CAAC,SACH;AAEF,QAAO,OAAO,SAAS,UAAU,WAAW,SAAS,QAAQ,SAAS,OAAO"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build a structural signature for a model string.
|
|
3
|
+
*
|
|
4
|
+
* Two values produce the same signature iff their sequence of `{{name}}`
|
|
5
|
+
* pills is identical. The editor uses this to skip a DOM rebuild for
|
|
6
|
+
* plain-text edits that do not change the pill set, which preserves the
|
|
7
|
+
* live caret and avoids any flicker.
|
|
8
|
+
*
|
|
9
|
+
* Returns an empty signature when pill rendering is disabled or the text
|
|
10
|
+
* contains no pill markers — both cases share a single "no pills" bucket.
|
|
11
|
+
*/
|
|
12
|
+
export declare const pillSignature: (text: string, withVariables: boolean) => string;
|
|
13
|
+
//# sourceMappingURL=pill-signature.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pill-signature.d.ts","sourceRoot":"","sources":["../../../../../src/v2/components/code-input/helpers/pill-signature.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,aAAa,GAAI,MAAM,MAAM,EAAE,eAAe,OAAO,KAAG,MAWpE,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { REGEX } from "@scalar/helpers/regex/regex-helpers";
|
|
2
|
+
//#region src/v2/components/code-input/helpers/pill-signature.ts
|
|
3
|
+
/**
|
|
4
|
+
* Build a structural signature for a model string.
|
|
5
|
+
*
|
|
6
|
+
* Two values produce the same signature iff their sequence of `{{name}}`
|
|
7
|
+
* pills is identical. The editor uses this to skip a DOM rebuild for
|
|
8
|
+
* plain-text edits that do not change the pill set, which preserves the
|
|
9
|
+
* live caret and avoids any flicker.
|
|
10
|
+
*
|
|
11
|
+
* Returns an empty signature when pill rendering is disabled or the text
|
|
12
|
+
* contains no pill markers — both cases share a single "no pills" bucket.
|
|
13
|
+
*/
|
|
14
|
+
var pillSignature = (text, withVariables) => {
|
|
15
|
+
if (!withVariables || !text.includes("{{")) return "";
|
|
16
|
+
const regex = new RegExp(REGEX.VARIABLES.source, REGEX.VARIABLES.flags);
|
|
17
|
+
let signature = "";
|
|
18
|
+
let match;
|
|
19
|
+
while ((match = regex.exec(text)) !== null) signature += `|${match[1] ?? ""}`;
|
|
20
|
+
return signature;
|
|
21
|
+
};
|
|
22
|
+
//#endregion
|
|
23
|
+
export { pillSignature };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=pill-signature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pill-signature.js","names":[],"sources":["../../../../../src/v2/components/code-input/helpers/pill-signature.ts"],"sourcesContent":["import { REGEX } from '@scalar/helpers/regex/regex-helpers'\n\n/**\n * Build a structural signature for a model string.\n *\n * Two values produce the same signature iff their sequence of `{{name}}`\n * pills is identical. The editor uses this to skip a DOM rebuild for\n * plain-text edits that do not change the pill set, which preserves the\n * live caret and avoids any flicker.\n *\n * Returns an empty signature when pill rendering is disabled or the text\n * contains no pill markers — both cases share a single \"no pills\" bucket.\n */\nexport const pillSignature = (text: string, withVariables: boolean): string => {\n if (!withVariables || !text.includes('{{')) {\n return ''\n }\n const regex = new RegExp(REGEX.VARIABLES.source, REGEX.VARIABLES.flags)\n let signature = ''\n let match: RegExpExecArray | null\n while ((match = regex.exec(text)) !== null) {\n signature += `|${match[1] ?? ''}`\n }\n return signature\n}\n"],"mappings":";;;;;;;;;;;;;AAaA,IAAa,iBAAiB,MAAc,kBAAmC;AAC7E,KAAI,CAAC,iBAAiB,CAAC,KAAK,SAAS,KAAK,CACxC,QAAO;CAET,MAAM,QAAQ,IAAI,OAAO,MAAM,UAAU,QAAQ,MAAM,UAAU,MAAM;CACvE,IAAI,YAAY;CAChB,IAAI;AACJ,SAAQ,QAAQ,MAAM,KAAK,KAAK,MAAM,KACpC,cAAa,IAAI,MAAM,MAAM;AAE/B,QAAO"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CodeInputModelValue } from '../CodeInput.vue.js';
|
|
2
|
+
/**
|
|
3
|
+
* Convert any model value to a string suitable for the editor's serialized form.
|
|
4
|
+
*
|
|
5
|
+
* Strings pass through untouched, nullish values become an empty string, and
|
|
6
|
+
* everything else is JSON-stringified so booleans, numbers, arrays, and
|
|
7
|
+
* objects round-trip predictably through the editor.
|
|
8
|
+
*/
|
|
9
|
+
export declare const serializeValue: (value: CodeInputModelValue) => string;
|
|
10
|
+
//# sourceMappingURL=serialize-value.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serialize-value.d.ts","sourceRoot":"","sources":["../../../../../src/v2/components/code-input/helpers/serialize-value.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAE3D;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,mBAAmB,KAAG,MAQ3D,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/v2/components/code-input/helpers/serialize-value.ts
|
|
2
|
+
/**
|
|
3
|
+
* Convert any model value to a string suitable for the editor's serialized form.
|
|
4
|
+
*
|
|
5
|
+
* Strings pass through untouched, nullish values become an empty string, and
|
|
6
|
+
* everything else is JSON-stringified so booleans, numbers, arrays, and
|
|
7
|
+
* objects round-trip predictably through the editor.
|
|
8
|
+
*/
|
|
9
|
+
var serializeValue = (value) => {
|
|
10
|
+
if (typeof value === "string") return value;
|
|
11
|
+
if (value == null) return "";
|
|
12
|
+
return JSON.stringify(value);
|
|
13
|
+
};
|
|
14
|
+
//#endregion
|
|
15
|
+
export { serializeValue };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=serialize-value.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serialize-value.js","names":[],"sources":["../../../../../src/v2/components/code-input/helpers/serialize-value.ts"],"sourcesContent":["import type { CodeInputModelValue } from '../CodeInput.vue'\n\n/**\n * Convert any model value to a string suitable for the editor's serialized form.\n *\n * Strings pass through untouched, nullish values become an empty string, and\n * everything else is JSON-stringified so booleans, numbers, arrays, and\n * objects round-trip predictably through the editor.\n */\nexport const serializeValue = (value: CodeInputModelValue): string => {\n if (typeof value === 'string') {\n return value\n }\n if (value == null) {\n return ''\n }\n return JSON.stringify(value)\n}\n"],"mappings":";;;;;;;;AASA,IAAa,kBAAkB,UAAuC;AACpE,KAAI,OAAO,UAAU,SACnB,QAAO;AAET,KAAI,SAAS,KACX,QAAO;AAET,QAAO,KAAK,UAAU,MAAM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/v2/components/code-input/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,iBAAiB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/v2/components/code-input/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,iBAAiB,CAAA;AACtD,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,qBAAqB,CAAA"}
|
|
@@ -11,11 +11,8 @@ type __VLS_Props = {
|
|
|
11
11
|
canAddCustomEnumValue?: boolean;
|
|
12
12
|
readOnly?: boolean;
|
|
13
13
|
enum?: string[];
|
|
14
|
-
min?: number;
|
|
15
|
-
max?: number;
|
|
16
14
|
environment: XScalarEnvironment;
|
|
17
15
|
description?: string | undefined;
|
|
18
|
-
lineWrapping?: boolean;
|
|
19
16
|
/** Whether to show context function suggestions like $guid, $timestamp. Defaults to true */
|
|
20
17
|
withFakeData?: boolean;
|
|
21
18
|
};
|
|
@@ -40,7 +37,6 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {},
|
|
|
40
37
|
}>, {
|
|
41
38
|
required: boolean;
|
|
42
39
|
readOnly: boolean;
|
|
43
|
-
lineWrapping: boolean;
|
|
44
40
|
withFakeData: boolean;
|
|
45
41
|
canAddCustomEnumValue: boolean;
|
|
46
42
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataTableInput.vue.d.ts","sourceRoot":"","sources":["../../../../src/v2/components/data-table/DataTableInput.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DataTableInput.vue.d.ts","sourceRoot":"","sources":["../../../../src/v2/components/data-table/DataTableInput.vue"],"names":[],"mappings":"AAkLA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAA;AAGnH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAM/C,KAAK,WAAW,GAAG;IACf,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACzB,sEAAsE;IACtE,cAAc,CAAC,EAAE,YAAY,GAAG,SAAS,CAAA;IACzC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,0EAA0E;IAC1E,qBAAqB,CAAC,EAAE,OAAO,CAAA;IAC/B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;IACf,WAAW,EAAE,kBAAkB,CAAA;IAC/B,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAChC,4FAA4F;IAC5F,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB,CAAC;AAiVJ,QAAA,IAAI,OAAO,IAAU,EAAuB,QAAQ,IAAW,EAAE,QAAQ,IAAY,CAAE;AACvF,KAAK,WAAW,GAAG,EAAE,GACnB;IAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,GAC5C;IAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,QAAQ,KAAK,GAAG,CAAA;CAAE,GAC7C;IAAE,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,QAAQ,KAAK,GAAG,CAAA;CAAE,CAAC;AAO7C,QAAA,MAAM,UAAU;;;;;;;;;;;cAtWD,OAAO;cAIP,OAAO;kBAKH,OAAO;2BANE,OAAO;6EAuWjC,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AAWzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
|
|
@@ -2,7 +2,7 @@ import _plugin_vue_export_helper_default from "../../../_virtual/_plugin-vue_exp
|
|
|
2
2
|
import DataTableInput_vue_vue_type_script_setup_true_lang_default from "./DataTableInput.vue.script.js";
|
|
3
3
|
/* empty css */
|
|
4
4
|
//#region src/v2/components/data-table/DataTableInput.vue
|
|
5
|
-
var DataTableInput_default = /* @__PURE__ */ _plugin_vue_export_helper_default(DataTableInput_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-
|
|
5
|
+
var DataTableInput_default = /* @__PURE__ */ _plugin_vue_export_helper_default(DataTableInput_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-a6f4752a"]]);
|
|
6
6
|
//#endregion
|
|
7
7
|
export { DataTableInput_default as default };
|
|
8
8
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataTableInput.vue.js","names":[],"sources":["../../../../src/v2/components/data-table/DataTableInput.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarIconButton } from '@scalar/components/icon-button'\nimport { ScalarIconEye, ScalarIconEyeSlash, ScalarIconX } from '@scalar/icons'\nimport type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments'\nimport { computed, ref, useTemplateRef } from 'vue'\n\nimport type { VueClassProp } from '@/types/vue'\nimport {
|
|
1
|
+
{"version":3,"file":"DataTableInput.vue.js","names":[],"sources":["../../../../src/v2/components/data-table/DataTableInput.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarIconButton } from '@scalar/components/icon-button'\nimport { ScalarIconEye, ScalarIconEyeSlash, ScalarIconX } from '@scalar/icons'\nimport type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments'\nimport { computed, ref, useTemplateRef } from 'vue'\n\nimport type { VueClassProp } from '@/types/vue'\nimport { CodeInputLite } from '@/v2/components/code-input'\n\nimport DataTableCell from './DataTableCell.vue'\nimport DataTableInputSelect from './DataTableInputSelect.vue'\n\nconst props = withDefaults(\n defineProps<{\n id?: string\n type?: string | undefined\n /** Class for the wrapping cell because attrs is bound to the input */\n containerClass?: VueClassProp | undefined\n required?: boolean\n modelValue: string\n /** Allows adding a custom value to the enum dropdown, defaults to true */\n canAddCustomEnumValue?: boolean\n readOnly?: boolean\n enum?: string[]\n environment: XScalarEnvironment\n description?: string | undefined\n /** Whether to show context function suggestions like $guid, $timestamp. Defaults to true */\n withFakeData?: boolean\n }>(),\n {\n canAddCustomEnumValue: true,\n required: false,\n readOnly: false,\n withFakeData: true,\n },\n)\n\nconst emit = defineEmits<{\n (e: 'update:modelValue', v: string | number): void\n (e: 'inputFocus'): void\n (e: 'inputBlur'): void\n (e: 'selectVariable', value: string): void\n}>()\n\ndefineOptions({ inheritAttrs: false })\n\nconst mask = ref(true)\nconst interactingWithDropdown = ref(false)\nconst codeInput = useTemplateRef('codeInput')\n\nconst handleBlur = () => !interactingWithDropdown.value && emit('inputBlur')\n\nconst inputType = computed(() =>\n props.type === 'password' ? 'text' : (props.type ?? 'text'),\n)\n\n// If not an enum nor read only, focus the code input\nconst handleLabelClick = () => {\n if (!props.enum?.length && !props.readOnly) {\n codeInput.value?.focus()\n }\n}\n</script>\n<template>\n <DataTableCell\n class=\"relative flex\"\n :class=\"containerClass\">\n <div\n v-if=\"$slots.default\"\n class=\"text-c-1 flex items-center pr-0 pl-3\"\n :for=\"id ?? ''\"\n @click=\"handleLabelClick\">\n <slot />:\n </div>\n <div class=\"relative flex min-w-0 flex-1\">\n <template v-if=\"props.enum && props.enum.length\">\n <DataTableInputSelect\n :canAddCustomValue=\"props.canAddCustomEnumValue\"\n :modelValue=\"props.modelValue\"\n :value=\"props.enum\"\n @update:modelValue=\"emit('update:modelValue', $event)\" />\n </template>\n <template v-else>\n <input\n v-if=\"mask && type === 'password'\"\n v-bind=\"id ? { ...$attrs, id: id } : $attrs\"\n autocomplete=\"off\"\n class=\"text-c-1 disabled:text-c-2 peer w-full min-w-0 border-none px-2 py-1.25 -outline-offset-1\"\n :class=\"{ 'scalar-password-input': type === 'password' }\"\n data-1p-ignore\n :readOnly=\"readOnly\"\n spellcheck=\"false\"\n :type=\"inputType\"\n :value=\"modelValue\"\n @input=\"\n emit(\n 'update:modelValue',\n ($event.target as HTMLInputElement).value ?? '',\n )\n \" />\n <CodeInputLite\n v-else\n v-bind=\"$attrs\"\n :id=\"id\"\n ref=\"codeInput\"\n class=\"text-c-1 disabled:text-c-2 peer w-full min-w-0 border-none -outline-offset-1\"\n :class=\"[\n type === 'password' && description && 'pr-12',\n description && 'pr-8',\n type === 'password' && 'scalar-password-input',\n ]\"\n :environment=\"environment\"\n :modelValue=\"modelValue ?? ''\"\n :readOnly=\"readOnly\"\n :required=\"Boolean(required)\"\n :type=\"inputType\"\n :withFakeData=\"withFakeData\"\n @blur=\"handleBlur\"\n @focus=\"emit('inputFocus')\"\n @update:modelValue=\"(value) => emit('update:modelValue', value)\" />\n </template>\n </div>\n <div\n v-if=\"$slots.warning\"\n class=\"centered-y text-orange absolute right-7 text-xs\">\n <slot name=\"warning\" />\n </div>\n <slot name=\"icon\" />\n <!-- Clear -->\n <ScalarIconButton\n v-if=\"modelValue\"\n class=\"-ml-.25 h-6 w-6 self-center p-1.25\"\n :icon=\"ScalarIconX\"\n label=\"Clear Value\"\n @click=\"emit('update:modelValue', '')\" />\n <!-- Toggle Visibility -->\n <ScalarIconButton\n v-if=\"type === 'password'\"\n class=\"-ml-.5 mr-1.25 h-6 w-6 self-center p-1.25\"\n data-testid=\"data-table-password-toggle\"\n :icon=\"mask ? ScalarIconEye : ScalarIconEyeSlash\"\n :label=\"mask ? 'Show Password' : 'Hide Password'\"\n @click=\"mask = !mask\" />\n </DataTableCell>\n</template>\n\n<style scoped>\n:deep(.code-input-lite__editor) {\n background-color: transparent;\n font-family: var(--scalar-font);\n font-size: var(--scalar-small);\n padding: 5px 8px;\n}\n:deep(.scalar-pill:not(:last-of-type)) {\n margin-right: 0.15em;\n}\n:deep(.scalar-pill:not(:first-of-type)) {\n margin-left: 0.5px;\n}\n.required::after {\n content: 'Required';\n}\n/* Tailwind placeholder is busted */\ninput::placeholder {\n color: var(--scalar-color-3);\n}\n/* we want our inputs to look like a password input but not be one */\n.scalar-password-input {\n text-security: disc;\n -webkit-text-security: disc;\n -moz-text-security: disc;\n}\n</style>\n"],"mappings":""}
|