@definable/ui 0.1.9 → 0.1.12
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/dist/MonacoEditor-COZcVMEj.cjs +8 -0
- package/dist/MonacoEditor-COZcVMEj.cjs.map +1 -0
- package/dist/MonacoEditor-D3QSSKa4.js +295 -0
- package/dist/MonacoEditor-D3QSSKa4.js.map +1 -0
- package/dist/alert.d.ts +7 -0
- package/dist/badge.d.ts +1 -1
- package/dist/command.d.ts +13 -13
- package/dist/components/alert.d.ts +7 -0
- package/dist/components/alert.esm.js +35 -22
- package/dist/components/alert.esm.js.map +1 -1
- package/dist/components/alert.js +1 -1
- package/dist/components/alert.js.map +1 -1
- package/dist/components/badge.d.ts +1 -1
- package/dist/components/card.esm.js +13 -13
- package/dist/components/card.esm.js.map +1 -1
- package/dist/components/card.js +1 -1
- package/dist/components/card.js.map +1 -1
- package/dist/components/command.d.ts +13 -13
- package/dist/components/modal.esm.js +64 -46
- package/dist/components/modal.esm.js.map +1 -1
- package/dist/components/modal.js +1 -1
- package/dist/components/modal.js.map +1 -1
- package/dist/components/monaco-editor.esm.js +6 -292
- package/dist/components/monaco-editor.esm.js.map +1 -1
- package/dist/components/monaco-editor.js +1 -7
- package/dist/components/monaco-editor.js.map +1 -1
- package/dist/components/selection-bar.esm.js +7 -7
- package/dist/components/selection-bar.esm.js.map +1 -1
- package/dist/components/selection-bar.js +1 -1
- package/dist/components/selection-bar.js.map +1 -1
- package/dist/components/sheet.esm.js +22 -22
- package/dist/components/sheet.esm.js.map +1 -1
- package/dist/components/sheet.js +1 -1
- package/dist/components/sheet.js.map +1 -1
- package/dist/components/stepper.esm.js +4 -211
- package/dist/components/stepper.esm.js.map +1 -1
- package/dist/components/stepper.js +1 -1
- package/dist/components/stepper.js.map +1 -1
- package/dist/components/tooltip.esm.js +25 -49
- package/dist/components/tooltip.esm.js.map +1 -1
- package/dist/components/tooltip.js +1 -1
- package/dist/components/tooltip.js.map +1 -1
- package/dist/index.d.ts +432 -1
- package/dist/index.esm.js +193 -135
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/stepper-modal-CPlBpxWy.cjs +2 -0
- package/dist/stepper-modal-CPlBpxWy.cjs.map +1 -0
- package/dist/stepper-modal-SYU9mbXs.js +214 -0
- package/dist/stepper-modal-SYU9mbXs.js.map +1 -0
- package/dist/styles.css +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";const a=require("./jsx-runtime-BYECrxsp.cjs"),x=require("react"),P=require("@monaco-editor/react"),T=require("./components/modal.js"),M=require("./components/button.js"),S=require("lucide-react"),O={minimap:{enabled:!1},fontSize:14,scrollBeyondLastLine:!1,wordWrap:"on",lineNumbers:"on",automaticLayout:!0,scrollbar:{vertical:"auto",horizontal:"auto"}},U={javascript:{},typescript:{},python:{},json:{},html:{},css:{},markdown:{wordWrap:"on"},plaintext:{}},k=new Map;let K=0;function C(s,c,t,b){const{language:j,variablePrefix:o,variableSuffix:y}=b,e=`provider_${++K}`;console.log(`Setting up variable suggestions with ID ${e} (${t.length} variables)`);const r=c.languages.registerCompletionItemProvider(j,{triggerCharacters:["{"],provideCompletionItems:(u,l)=>{if(u.getLineContent(l.lineNumber).substring(0,l.column-1).endsWith(o)){if(console.log(`[${e}] Detected ${o} - showing ${t.length} variable suggestions`),t.length===0)return console.log(`[${e}] No variables available for suggestions`),{suggestions:[]};const i=Array.from(new Map(t.map(n=>[n.name,n])).values()).map(n=>({label:n.name,kind:c.languages.CompletionItemKind.Variable,detail:n.type,documentation:{value:n.description||"",isTrusted:!0},insertText:n.name,sortText:"0"+n.name,range:{startLineNumber:l.lineNumber,startColumn:l.column,endLineNumber:l.lineNumber,endColumn:l.column}}));return console.log(`[${e}] Created ${i.length} suggestions`),{suggestions:i}}return{suggestions:[]}}}),m=s.onKeyUp(u=>{if(u.code!=="BracketLeft"&&u.code!=="Digit2")return;const l=s.getPosition();if(!l)return;const h=s.getModel();if(!h)return;h.getLineContent(l.lineNumber).substring(0,l.column-1).endsWith(o)&&(console.log(`[${e}] Manually triggering suggestions on ${o}`),setTimeout(()=>{s.trigger("keyboard","editor.action.triggerSuggest",{})},20))}),p=()=>{console.log(`Disposing provider ${e}`),r.dispose(),m.dispose(),k.delete(e)};return k.set(e,{dispose:p,variables:t,config:b}),p}function V(s,c,t,b){const j=Array.from(new Map(t.map(o=>[o.name,o])).values());console.log(`Updating provider with ${j.length} variables`),C(s,c,j,b)}function I(s,c,t){var b;if(!(!t||t.length===0)){if(c==="javascript"||c==="typescript"){const j=t.map(e=>{if(e.isObject&&e.properties&&e.properties.length>0){const r=`I${e.name.charAt(0).toUpperCase()+e.name.slice(1)}`,m=e.properties.map(p=>` ${p.name}: ${p.type};`).join(`
|
|
2
|
+
`);return`
|
|
3
|
+
interface ${r} {
|
|
4
|
+
${m}
|
|
5
|
+
}
|
|
6
|
+
declare const ${e.name}: ${r};`}else return`declare const ${e.name}: ${e.type};`}).join(`
|
|
7
|
+
`),o="predefined-variables";(b=s.__extraLibDisposables)!=null&&b[o]&&s.__extraLibDisposables[o].dispose();const y=s.languages.typescript.javascriptDefaults.addExtraLib(j,`ts:filename/${o}.d.ts`);s.__extraLibDisposables||(s.__extraLibDisposables={}),s.__extraLibDisposables[o]=y}if(c==="python"){["python-hover-provider","python-completion-provider"].forEach(e=>{var m;const r=(m=s.__customDisposables)==null?void 0:m[e];r&&r.dispose()}),s.__customDisposables||(s.__customDisposables={});const o=s.languages.registerHoverProvider("python",{provideHover:(e,r)=>{const m=e.getWordAtPosition(r);if(!m)return null;const p=t.find(h=>h.name===m.word);if(p)return{contents:[{value:`(variable) ${p.name}: ${p.type}`},{value:p.documentation||""}]};const l=e.getLineContent(r.lineNumber).substring(0,r.column).match(/(\w+)\.(\w+)$/);if(l){const[h,g,d]=l,i=t.find(n=>n.name===g&&n.isObject);if(i&&i.properties){const n=i.properties.find($=>$.name===d);if(n)return{contents:[{value:`(property) ${g}.${n.name}: ${n.type}`},{value:n.documentation||""}]}}}return null}}),y=s.languages.registerCompletionItemProvider("python",{triggerCharacters:["."],provideCompletionItems:(e,r)=>{const u=e.getLineContent(r.lineNumber).substring(0,r.column).match(/(\w+)\.\s*$/);if(!u)return{suggestions:[]};const[l,h]=u,g=t.find(d=>d.name===h&&d.isObject);return g&&g.properties&&g.properties.length>0?{suggestions:g.properties.map(i=>({label:i.name,kind:s.languages.CompletionItemKind.Property,detail:i.type,documentation:{value:i.documentation||"",isTrusted:!0},insertText:i.name,range:{startLineNumber:r.lineNumber,startColumn:r.column,endLineNumber:r.lineNumber,endColumn:r.column}}))}:{suggestions:[]}}});s.__customDisposables["python-hover-provider"]=o,s.__customDisposables["python-completion-provider"]=y}}}function W({value:s,onChange:c,language:t="javascript",height:b="300px",className:j="",options:o={},onMount:y,title:e="Code Editor",variables:r=[],variablePrefix:m="{{",variableSuffix:p="}}",predefinedVariables:u=[],allowFullscreen:l=!0,isDark:h=!1}){const g=!h,d=x.useRef(null),i=x.useRef(null),[n,$]=x.useState(!1),v=x.useRef(null),E=x.useRef(`editor-${Math.random().toString(36).substr(2,9)}`),[q,z]=x.useState(null);x.useEffect(()=>{if(!(!d.current||!i.current))return v.current&&(v.current(),v.current=null),console.log(`Setting up variable suggestions for ${E.current}`),v.current=C(d.current,i.current,r,{language:t,variablePrefix:m,variableSuffix:p}),()=>{v.current&&(v.current(),v.current=null)}},[q,r,t,m,p]),x.useEffect(()=>{!i.current||u.length===0||(console.log("registering predefined variables",u),I(i.current,t,u))},[t,u]),x.useEffect(()=>{d.current&&setTimeout(()=>{var f;(f=d.current)==null||f.layout()},100)},[n]);const R=x.useCallback((f,N)=>{var D,L;console.log(`Editor ${E.current} mounted`),d.current=f,i.current=N,z(f),u.length>0&&I(N,t,u),t==="python"?(D=f.getModel())==null||D.updateOptions({tabSize:4,insertSpaces:!0}):t!=="markdown"&&((L=f.getModel())==null||L.updateOptions({tabSize:2,insertSpaces:!0})),y&&y(f,N)},[t,y,u]),_=x.useMemo(()=>({...O,...U[t]||{},...o}),[t,o]),w=x.useCallback(()=>{$(!n)},[n]);return a.jsxRuntimeExports.jsxs(a.jsxRuntimeExports.Fragment,{children:[a.jsxRuntimeExports.jsxs("div",{className:j,children:[l&&a.jsxRuntimeExports.jsx("div",{className:"flex justify-end mb-1",children:a.jsxRuntimeExports.jsx(M.Button,{variant:"ghost",size:"sm",onClick:w,className:"h-7 w-7 p-0",children:a.jsxRuntimeExports.jsx(S.Maximize,{className:"h-4 w-4"})})}),a.jsxRuntimeExports.jsx("div",{className:"relative",style:{display:n?"none":"block"},children:a.jsxRuntimeExports.jsx(P,{height:b,language:t,value:s,onChange:f=>c==null?void 0:c(f||""),options:_,onMount:R,theme:g?"vs-light":"vs-dark"},E.current)})]}),n&&a.jsxRuntimeExports.jsx(T.Modal,{isOpen:n,onClose:()=>$(!1),size:"2xl",title:e,header:a.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between w-full",children:[a.jsxRuntimeExports.jsx("h2",{className:"text-sm font-medium",children:e}),a.jsxRuntimeExports.jsx(M.Button,{variant:"ghost",size:"sm",onClick:w,className:"h-7 w-7 p-0",children:a.jsxRuntimeExports.jsx(S.Minimize2,{className:"h-4 w-4"})})]}),children:a.jsxRuntimeExports.jsx("div",{className:"h-[80vh] w-full",children:a.jsxRuntimeExports.jsx(P,{height:"100%",language:t,value:s,onChange:f=>c==null?void 0:c(f||""),options:_,onMount:R,theme:g?"vs-light":"vs-dark"},`${E.current}-fullscreen`)})})]})}exports.MonacoEditor=W;exports.defaultOptions=O;exports.languageOptions=U;exports.setupVariableSuggestions=C;exports.updateVariableSuggestions=V;
|
|
8
|
+
//# sourceMappingURL=MonacoEditor-COZcVMEj.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MonacoEditor-COZcVMEj.cjs","sources":["../src/components/monaco-editor/constants.ts","../src/components/monaco-editor/variableSuggestions.ts","../src/components/monaco-editor/utils.ts","../src/components/monaco-editor/MonacoEditor.tsx"],"sourcesContent":["import { editor as monacoEditor } from 'monaco-editor';\nimport { MonacoEditorLanguage } from './types';\n\nexport const defaultOptions: monacoEditor.IEditorOptions = {\n minimap: { enabled: false },\n fontSize: 14,\n scrollBeyondLastLine: false,\n wordWrap: 'on',\n lineNumbers: 'on',\n automaticLayout: true,\n scrollbar: {\n vertical: 'auto',\n horizontal: 'auto',\n },\n};\n\nexport const languageOptions: Record<MonacoEditorLanguage, monacoEditor.IEditorOptions> = {\n javascript: {},\n typescript: {},\n python: {},\n json: {},\n html: {},\n css: {},\n markdown: {\n wordWrap: 'on',\n },\n plaintext: {},\n}; ","import { Monaco } from '@monaco-editor/react';\nimport { editor as monacoEditor } from 'monaco-editor';\nimport { VariableSuggestion } from './types';\n\ntype VariableSuggestionProviderConfig = {\n language: string;\n variablePrefix: string;\n variableSuffix: string;\n};\n\n// Keep track of registered providers with a uniqueId\nconst registeredProviders = new Map<string, {\n dispose: () => void,\n variables: VariableSuggestion[],\n config: VariableSuggestionProviderConfig\n}>();\n\n// Counter for unique IDs\nlet providerCounter = 0;\n\n/**\n * Setup variable suggestions for Monaco editor\n */\nexport function setupVariableSuggestions(\n editor: monacoEditor.IStandaloneCodeEditor,\n monaco: Monaco,\n variables: VariableSuggestion[],\n config: VariableSuggestionProviderConfig\n): () => void {\n const { language, variablePrefix, variableSuffix } = config;\n \n // Generate a unique ID for this provider\n const providerId = `provider_${++providerCounter}`;\n \n console.log(`Setting up variable suggestions with ID ${providerId} (${variables.length} variables)`);\n \n // Register completion provider\n const completionProvider = monaco.languages.registerCompletionItemProvider(language, {\n triggerCharacters: ['{'], \n \n provideCompletionItems: (model, position) => {\n // Get text before cursor\n const lineContent = model.getLineContent(position.lineNumber);\n const textUntilPosition = lineContent.substring(0, position.column - 1);\n \n // Check if we've just typed the variable prefix\n if (textUntilPosition.endsWith(variablePrefix)) {\n console.log(`[${providerId}] Detected ${variablePrefix} - showing ${variables.length} variable suggestions`);\n \n if (variables.length === 0) {\n console.log(`[${providerId}] No variables available for suggestions`);\n return { suggestions: [] };\n }\n \n // Use Set to ensure unique variable names\n const uniqueVariables = Array.from(\n new Map(variables.map(v => [v.name, v])).values()\n );\n \n // Create suggestions\n const suggestions = uniqueVariables.map(variable => ({\n label: variable.name,\n kind: monaco.languages.CompletionItemKind.Variable,\n detail: variable.type,\n documentation: {\n value: variable.description || '',\n isTrusted: true\n },\n insertText: variable.name,\n sortText: '0' + variable.name, // Force variable suggestions to appear at top\n range: {\n startLineNumber: position.lineNumber,\n startColumn: position.column,\n endLineNumber: position.lineNumber,\n endColumn: position.column\n }\n }));\n \n console.log(`[${providerId}] Created ${suggestions.length} suggestions`);\n return { suggestions };\n }\n \n return { suggestions: [] };\n }\n });\n \n // Add manual KeyUp handler to trigger suggestions\n const keyUpDisposable = editor.onKeyUp(e => {\n // Skip if not the right key\n if (e.code !== 'BracketLeft' && e.code !== 'Digit2') return;\n \n const position = editor.getPosition();\n if (!position) return;\n \n const model = editor.getModel();\n if (!model) return;\n \n const lineContent = model.getLineContent(position.lineNumber);\n const textUntilPosition = lineContent.substring(0, position.column - 1);\n \n if (textUntilPosition.endsWith(variablePrefix)) {\n console.log(`[${providerId}] Manually triggering suggestions on ${variablePrefix}`);\n \n // Delay slightly to ensure the model is updated\n setTimeout(() => {\n // Force suggestions to appear\n editor.trigger('keyboard', 'editor.action.triggerSuggest', {});\n }, 20);\n }\n });\n \n // Create dispose function\n const dispose = () => {\n console.log(`Disposing provider ${providerId}`);\n completionProvider.dispose();\n keyUpDisposable.dispose();\n registeredProviders.delete(providerId);\n };\n \n // Store in registeredProviders\n registeredProviders.set(providerId, {\n dispose,\n variables,\n config\n });\n \n return dispose;\n}\n\n/**\n * Update variables for an existing provider\n * Creates a new provider with the updated variables\n */\nexport function updateVariableSuggestions(\n editor: monacoEditor.IStandaloneCodeEditor,\n monaco: Monaco,\n variables: VariableSuggestion[],\n config: VariableSuggestionProviderConfig\n): void {\n // Remove duplicates from variables array\n const uniqueVariables = Array.from(\n new Map(variables.map(v => [v.name, v])).values()\n );\n \n console.log(`Updating provider with ${uniqueVariables.length} variables`);\n \n // Create a new provider with the updated variables\n setupVariableSuggestions(editor, monaco, uniqueVariables, config);\n} ","import { Monaco } from \"@monaco-editor/react\";\nimport { PredefinedVariable } from \"./types\";\n\n/**\n * Find the position of a variable prefix in a text string\n * \n * @param lineContent The current line content\n * @param currentColumn The current cursor column\n * @param variablePrefix The variable prefix to look for\n * @returns The starting position of the prefix, or -1 if not found\n */\nexport function findVariablePrefixPosition(\n lineContent: string, \n currentColumn: number, \n variablePrefix: string\n): number {\n let prefixStart = -1;\n \n // Look for the variable prefix before the cursor within a reasonable range\n for (let i = currentColumn - 1; i >= 0 && i >= currentColumn - variablePrefix.length - 10; i--) {\n if (i - variablePrefix.length + 1 >= 0) {\n const substring = lineContent.substring(i - variablePrefix.length + 1, i + 1);\n if (substring === variablePrefix) {\n prefixStart = i - variablePrefix.length + 1;\n break;\n }\n }\n }\n \n return prefixStart;\n}\n\n/**\n * Format a preview text with variable prefix and suffix\n * \n * @param variableName The variable name to format\n * @param variablePrefix The prefix to add\n * @param variableSuffix The suffix to add\n * @returns Formatted variable string\n */\nexport function formatVariablePreview(\n variableName: string | null, \n variablePrefix: string, \n variableSuffix: string\n): string {\n if (!variableName) return variablePrefix + '....' + variableSuffix;\n return variablePrefix + variableName + variableSuffix;\n}\n\n/**\n * Format code according to the specified language\n */\nexport function formatCode(monaco: Monaco, editor: any, language: string) {\n editor.getAction('editor.action.formatDocument').run();\n}\n\n/**\n * Get the appropriate EOL character for the current operating system\n */\nexport function getEOL() {\n return '\\n';\n}\n\n/**\n * Register predefined variables with the Monaco editor\n */\nexport function registerPredefinedVariables(\n monaco: Monaco, \n language: string, \n variables: PredefinedVariable[]\n) {\n if (!variables || variables.length === 0) return;\n \n // For JavaScript/TypeScript editor\n if (language === 'javascript' || language === 'typescript') {\n // Create TypeScript definitions for our variables\n const declarations = variables.map(variable => {\n if (variable.isObject && variable.properties && variable.properties.length > 0) {\n // Create a detailed interface for object types with properties\n const interfaceName = `I${variable.name.charAt(0).toUpperCase() + variable.name.slice(1)}`;\n const propertyDeclarations = variable.properties.map(prop => \n ` ${prop.name}: ${prop.type};`\n ).join('\\n');\n \n return `\ninterface ${interfaceName} {\n${propertyDeclarations}\n}\ndeclare const ${variable.name}: ${interfaceName};`;\n } else {\n // Simple variable declaration\n return `declare const ${variable.name}: ${variable.type};`;\n }\n }).join('\\n');\n \n // Check if we already have a stored disposable for the lib\n const libKey = 'predefined-variables';\n if ((monaco as any).__extraLibDisposables?.[libKey]) {\n (monaco as any).__extraLibDisposables[libKey].dispose();\n }\n \n // Add the library and store its disposable\n const disposable = monaco.languages.typescript.javascriptDefaults.addExtraLib(\n declarations,\n `ts:filename/${libKey}.d.ts`\n );\n \n // Initialize storage for disposables if needed\n if (!(monaco as any).__extraLibDisposables) {\n (monaco as any).__extraLibDisposables = {};\n }\n \n // Store the disposable for later cleanup\n (monaco as any).__extraLibDisposables[libKey] = disposable;\n }\n \n // For Python, we add hover providers and completion providers\n if (language === 'python') {\n // Remove previous providers if they exist\n const providerKeys = ['python-hover-provider', 'python-completion-provider'];\n providerKeys.forEach(key => {\n const disposable = (monaco as any).__customDisposables?.[key];\n if (disposable) {\n disposable.dispose();\n }\n });\n \n // Initialize storage for disposables if needed\n if (!(monaco as any).__customDisposables) {\n (monaco as any).__customDisposables = {};\n }\n \n // Create a new hover provider\n const hoverProvider = monaco.languages.registerHoverProvider('python', {\n provideHover: (model, position) => {\n const word = model.getWordAtPosition(position);\n if (!word) return null;\n \n // Check if it's a direct variable match\n const variable = variables.find(v => v.name === word.word);\n if (variable) {\n return {\n contents: [\n { value: `(variable) ${variable.name}: ${variable.type}` },\n { value: variable.documentation || '' }\n ]\n };\n }\n \n // Check if it's a property access (e.g., self.property)\n const lineContent = model.getLineContent(position.lineNumber);\n const dotMatch = lineContent.substring(0, position.column).match(/(\\w+)\\.(\\w+)$/);\n \n if (dotMatch) {\n const [_, objName, propName] = dotMatch;\n const objVar = variables.find(v => v.name === objName && v.isObject);\n \n if (objVar && objVar.properties) {\n const property = objVar.properties.find(p => p.name === propName);\n if (property) {\n return {\n contents: [\n { value: `(property) ${objName}.${property.name}: ${property.type}` },\n { value: property.documentation || '' }\n ]\n };\n }\n }\n }\n \n return null;\n }\n });\n \n // Create completion provider for object properties\n const completionProvider = monaco.languages.registerCompletionItemProvider('python', {\n triggerCharacters: ['.'],\n provideCompletionItems: (model, position) => {\n const lineContent = model.getLineContent(position.lineNumber);\n const textUntilPosition = lineContent.substring(0, position.column);\n \n // Match for object property access\n const match = textUntilPosition.match(/(\\w+)\\.\\s*$/);\n if (!match) return { suggestions: [] };\n \n const [_, objName] = match;\n const objVar = variables.find(v => v.name === objName && v.isObject);\n \n if (objVar && objVar.properties && objVar.properties.length > 0) {\n const suggestions = objVar.properties.map(prop => ({\n label: prop.name,\n kind: monaco.languages.CompletionItemKind.Property,\n detail: prop.type,\n documentation: {\n value: prop.documentation || '',\n isTrusted: true\n },\n insertText: prop.name,\n range: {\n startLineNumber: position.lineNumber,\n startColumn: position.column,\n endLineNumber: position.lineNumber,\n endColumn: position.column\n }\n }));\n \n return { suggestions };\n }\n \n return { suggestions: [] };\n }\n });\n \n // Store providers for later disposal\n (monaco as any).__customDisposables['python-hover-provider'] = hoverProvider;\n (monaco as any).__customDisposables['python-completion-provider'] = completionProvider;\n }\n} ","import { useRef, useState, useEffect, useMemo, useCallback } from \"react\";\nimport Editor, { Monaco } from '@monaco-editor/react';\nimport { editor as monacoEditor } from 'monaco-editor';\nimport { Modal } from \"../modal\";\nimport { Button } from \"../button\";\nimport { Maximize2, Minimize2, Maximize } from \"lucide-react\";\nimport { MonacoEditorProps } from \"./types\";\nimport { defaultOptions, languageOptions } from \"./constants\";\nimport { setupVariableSuggestions } from \"./variableSuggestions\";\nimport { registerPredefinedVariables } from \"./utils\";\n\nexport function MonacoEditor({\n value,\n onChange,\n language = 'javascript',\n height = '300px',\n className = '',\n options = {},\n onMount,\n title = 'Code Editor',\n variables = [],\n variablePrefix = '{{',\n variableSuffix = '}}',\n predefinedVariables = [],\n allowFullscreen = true,\n isDark = false,\n}: MonacoEditorProps) {\n const isLight = !isDark;\n const editorRef = useRef<monacoEditor.IStandaloneCodeEditor | null>(null);\n const monacoRef = useRef<Monaco | null>(null);\n const [isFullscreen, setIsFullscreen] = useState(false);\n const suggestionDisposableRef = useRef<(() => void) | null>(null);\n const editorIdRef = useRef<string>(`editor-${Math.random().toString(36).substr(2, 9)}`);\n const [editorInstance, setEditorInstance] = useState<monacoEditor.IStandaloneCodeEditor | null>(null);\n\n // Setup variable suggestions once the editor is mounted\n useEffect(() => {\n if (!editorRef.current || !monacoRef.current) return;\n \n // Clear any previous provider\n if (suggestionDisposableRef.current) {\n suggestionDisposableRef.current();\n suggestionDisposableRef.current = null;\n }\n \n // Setup a new provider with current variables\n console.log(`Setting up variable suggestions for ${editorIdRef.current}`);\n suggestionDisposableRef.current = setupVariableSuggestions(\n editorRef.current,\n monacoRef.current,\n variables,\n { language, variablePrefix, variableSuffix }\n );\n \n return () => {\n if (suggestionDisposableRef.current) {\n suggestionDisposableRef.current();\n suggestionDisposableRef.current = null;\n }\n };\n }, [editorInstance, variables, language, variablePrefix, variableSuffix]);\n\n // Register predefined variables like 'self'\n useEffect(() => {\n if (!monacoRef.current || predefinedVariables.length === 0) return;\n \n console.log('registering predefined variables', predefinedVariables);\n registerPredefinedVariables(\n monacoRef.current,\n language,\n predefinedVariables\n );\n }, [language, predefinedVariables]);\n\n // Handle fullscreen toggle - need to relayout the editor\n useEffect(() => {\n if (editorRef.current) {\n // Give the modal time to animate\n setTimeout(() => {\n editorRef.current?.layout();\n }, 100);\n }\n }, [isFullscreen]);\n\n // Handle editor mounting\n const handleEditorDidMount = useCallback((editor: monacoEditor.IStandaloneCodeEditor, monaco: Monaco) => {\n console.log(`Editor ${editorIdRef.current} mounted`);\n editorRef.current = editor;\n monacoRef.current = monaco;\n setEditorInstance(editor);\n \n // Register predefined variables immediately after mount\n if (predefinedVariables.length > 0) {\n registerPredefinedVariables(monaco, language, predefinedVariables);\n }\n \n // Set language-specific model options\n if (language === 'python') {\n editor.getModel()?.updateOptions({ tabSize: 4, insertSpaces: true });\n } else if (language !== 'markdown') {\n editor.getModel()?.updateOptions({ tabSize: 2, insertSpaces: true });\n }\n \n if (onMount) {\n onMount(editor, monaco);\n }\n }, [language, onMount, predefinedVariables]);\n\n // Merge default options with language-specific options and user options\n const mergedOptions = useMemo(() => {\n return {\n ...defaultOptions,\n ...(languageOptions[language] || {}),\n ...options,\n };\n }, [language, options]);\n\n const toggleFullscreen = useCallback(() => {\n setIsFullscreen(!isFullscreen);\n }, [isFullscreen]);\n\n return (\n <>\n <div className={className}>\n {allowFullscreen && (\n <div className=\"flex justify-end mb-1\">\n <Button \n variant=\"ghost\" \n size=\"sm\" \n onClick={toggleFullscreen} \n className=\"h-7 w-7 p-0\"\n >\n <Maximize className=\"h-4 w-4\" />\n </Button>\n </div>\n )}\n <div className=\"relative\" style={{ display: isFullscreen ? 'none' : 'block' }}>\n <Editor\n height={height}\n language={language}\n value={value}\n onChange={(value) => onChange?.(value || '')}\n options={mergedOptions}\n onMount={handleEditorDidMount}\n theme={isLight ? 'vs-light' : 'vs-dark'}\n key={editorIdRef.current} // Use the stable ID\n />\n </div>\n </div>\n\n {isFullscreen && (\n <Modal \n isOpen={isFullscreen} \n onClose={() => setIsFullscreen(false)}\n size=\"2xl\"\n title={title}\n header={\n <div className=\"flex items-center justify-between w-full\">\n <h2 className=\"text-sm font-medium\">{title}</h2>\n <Button \n variant=\"ghost\" \n size=\"sm\" \n onClick={toggleFullscreen} \n className=\"h-7 w-7 p-0\"\n >\n <Minimize2 className=\"h-4 w-4\" />\n </Button>\n </div>\n }\n >\n <div className=\"h-[80vh] w-full\">\n <Editor\n height=\"100%\"\n language={language}\n value={value}\n onChange={(value) => onChange?.(value || '')}\n options={mergedOptions}\n onMount={handleEditorDidMount}\n theme={isLight ? 'vs-light' : 'vs-dark'}\n key={`${editorIdRef.current}-fullscreen`} // Use the same ID with a suffix\n />\n </div>\n </Modal>\n )}\n </>\n );\n} "],"names":["defaultOptions","languageOptions","registeredProviders","providerCounter","setupVariableSuggestions","editor","monaco","variables","config","language","variablePrefix","variableSuffix","providerId","completionProvider","model","position","suggestions","v","variable","keyUpDisposable","e","dispose","updateVariableSuggestions","uniqueVariables","registerPredefinedVariables","declarations","interfaceName","propertyDeclarations","prop","libKey","_a","disposable","key","hoverProvider","word","dotMatch","_","objName","propName","objVar","property","p","match","MonacoEditor","value","onChange","height","className","options","onMount","title","predefinedVariables","allowFullscreen","isDark","isLight","editorRef","useRef","monacoRef","isFullscreen","setIsFullscreen","useState","suggestionDisposableRef","editorIdRef","editorInstance","setEditorInstance","useEffect","handleEditorDidMount","useCallback","_b","mergedOptions","useMemo","toggleFullscreen","jsxs","Fragment","jsx","Button","Maximize","Editor","Modal","Minimize2"],"mappings":"iNAGaA,EAA8C,CACzD,QAAS,CAAE,QAAS,EAAA,EACpB,SAAU,GACV,qBAAsB,GACtB,SAAU,KACV,YAAa,KACb,gBAAiB,GACjB,UAAW,CACT,SAAU,OACV,WAAY,MAAA,CAEhB,EAEaC,EAA6E,CACxF,WAAY,CAAA,EACZ,WAAY,CAAA,EACZ,OAAQ,CAAA,EACR,KAAM,CAAA,EACN,KAAM,CAAA,EACN,IAAK,CAAA,EACL,SAAU,CACR,SAAU,IAAA,EAEZ,UAAW,CAAA,CACb,EChBMC,MAA0B,IAOhC,IAAIC,EAAkB,EAKf,SAASC,EACdC,EACAC,EACAC,EACAC,EACY,CACZ,KAAM,CAAE,SAAAC,EAAU,eAAAC,EAAgB,eAAAC,CAAA,EAAmBH,EAG/CI,EAAa,YAAY,EAAET,CAAe,GAEhD,QAAQ,IAAI,2CAA2CS,CAAU,KAAKL,EAAU,MAAM,aAAa,EAGnG,MAAMM,EAAqBP,EAAO,UAAU,+BAA+BG,EAA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,EACA,SAAArC,EACA,MAAAmC,EACA,SAAWA,GAAUC,GAAA,YAAAA,EAAWD,GAAS,IACzC,QAASyB,EACT,QAASH,EACT,MAAOZ,EAAU,WAAa,SAAA,EACzBQ,EAAY,OAAA,CACnB,CACF,CAAA,EACF,EAECJ,GACCgB,EAAAA,kBAAAA,IAACI,EAAAA,MAAA,CACC,OAAQpB,EACR,QAAS,IAAMC,EAAgB,EAAK,EACpC,KAAK,MACL,MAAAT,EACA,OACEsB,EAAAA,kBAAAA,KAAC,MAAA,CAAI,UAAU,2CACb,SAAA,CAAAE,EAAAA,kBAAAA,IAAC,KAAA,CAAG,UAAU,sBAAuB,SAAAxB,EAAM,EAC3CwB,EAAAA,kBAAAA,IAACC,EAAAA,OAAA,CACC,QAAQ,QACR,KAAK,KACL,QAASJ,EACT,UAAU,cAEV,SAAAG,EAAAA,kBAAAA,IAACK,EAAAA,UAAA,CAAU,UAAU,SAAA,CAAU,CAAA,CAAA,CACjC,EACF,EAGF,SAAAL,EAAAA,kBAAAA,IAAC,MAAA,CAAI,UAAU,kBACb,SAAAA,EAAAA,kBAAAA,IAACG,EAAA,CACC,OAAO,OACP,SAAApE,EACA,MAAAmC,EACA,SAAWA,GAAUC,GAAA,YAAAA,EAAWD,GAAS,IACzC,QAASyB,EACT,QAASH,EACT,MAAOZ,EAAU,WAAa,SAAA,EACzB,GAAGQ,EAAY,OAAO,aAAA,CAC7B,CACF,CAAA,CAAA,CACF,EAEJ,CAEJ"}
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import { j as a } from "./jsx-runtime-DGlMoOmv.js";
|
|
2
|
+
import { useRef as N, useState as k, useEffect as _, useCallback as I, useMemo as R } from "react";
|
|
3
|
+
import S from "@monaco-editor/react";
|
|
4
|
+
import { Modal as W } from "./components/modal.esm.js";
|
|
5
|
+
import { Button as E } from "./components/button.esm.js";
|
|
6
|
+
import { Maximize as A, Minimize2 as F } from "lucide-react";
|
|
7
|
+
const q = {
|
|
8
|
+
minimap: { enabled: !1 },
|
|
9
|
+
fontSize: 14,
|
|
10
|
+
scrollBeyondLastLine: !1,
|
|
11
|
+
wordWrap: "on",
|
|
12
|
+
lineNumbers: "on",
|
|
13
|
+
automaticLayout: !0,
|
|
14
|
+
scrollbar: {
|
|
15
|
+
vertical: "auto",
|
|
16
|
+
horizontal: "auto"
|
|
17
|
+
}
|
|
18
|
+
}, B = {
|
|
19
|
+
javascript: {},
|
|
20
|
+
typescript: {},
|
|
21
|
+
python: {},
|
|
22
|
+
json: {},
|
|
23
|
+
html: {},
|
|
24
|
+
css: {},
|
|
25
|
+
markdown: {
|
|
26
|
+
wordWrap: "on"
|
|
27
|
+
},
|
|
28
|
+
plaintext: {}
|
|
29
|
+
}, U = /* @__PURE__ */ new Map();
|
|
30
|
+
let V = 0;
|
|
31
|
+
function O(n, u, t, b) {
|
|
32
|
+
const { language: x, variablePrefix: o, variableSuffix: y } = b, e = `provider_${++V}`;
|
|
33
|
+
console.log(`Setting up variable suggestions with ID ${e} (${t.length} variables)`);
|
|
34
|
+
const r = u.languages.registerCompletionItemProvider(x, {
|
|
35
|
+
triggerCharacters: ["{"],
|
|
36
|
+
provideCompletionItems: (l, c) => {
|
|
37
|
+
if (l.getLineContent(c.lineNumber).substring(0, c.column - 1).endsWith(o)) {
|
|
38
|
+
if (console.log(`[${e}] Detected ${o} - showing ${t.length} variable suggestions`), t.length === 0)
|
|
39
|
+
return console.log(`[${e}] No variables available for suggestions`), { suggestions: [] };
|
|
40
|
+
const i = Array.from(
|
|
41
|
+
new Map(t.map((s) => [s.name, s])).values()
|
|
42
|
+
).map((s) => ({
|
|
43
|
+
label: s.name,
|
|
44
|
+
kind: u.languages.CompletionItemKind.Variable,
|
|
45
|
+
detail: s.type,
|
|
46
|
+
documentation: {
|
|
47
|
+
value: s.description || "",
|
|
48
|
+
isTrusted: !0
|
|
49
|
+
},
|
|
50
|
+
insertText: s.name,
|
|
51
|
+
sortText: "0" + s.name,
|
|
52
|
+
// Force variable suggestions to appear at top
|
|
53
|
+
range: {
|
|
54
|
+
startLineNumber: c.lineNumber,
|
|
55
|
+
startColumn: c.column,
|
|
56
|
+
endLineNumber: c.lineNumber,
|
|
57
|
+
endColumn: c.column
|
|
58
|
+
}
|
|
59
|
+
}));
|
|
60
|
+
return console.log(`[${e}] Created ${i.length} suggestions`), { suggestions: i };
|
|
61
|
+
}
|
|
62
|
+
return { suggestions: [] };
|
|
63
|
+
}
|
|
64
|
+
}), m = n.onKeyUp((l) => {
|
|
65
|
+
if (l.code !== "BracketLeft" && l.code !== "Digit2") return;
|
|
66
|
+
const c = n.getPosition();
|
|
67
|
+
if (!c) return;
|
|
68
|
+
const h = n.getModel();
|
|
69
|
+
if (!h) return;
|
|
70
|
+
h.getLineContent(c.lineNumber).substring(0, c.column - 1).endsWith(o) && (console.log(`[${e}] Manually triggering suggestions on ${o}`), setTimeout(() => {
|
|
71
|
+
n.trigger("keyboard", "editor.action.triggerSuggest", {});
|
|
72
|
+
}, 20));
|
|
73
|
+
}), p = () => {
|
|
74
|
+
console.log(`Disposing provider ${e}`), r.dispose(), m.dispose(), U.delete(e);
|
|
75
|
+
};
|
|
76
|
+
return U.set(e, {
|
|
77
|
+
dispose: p,
|
|
78
|
+
variables: t,
|
|
79
|
+
config: b
|
|
80
|
+
}), p;
|
|
81
|
+
}
|
|
82
|
+
function Z(n, u, t, b) {
|
|
83
|
+
const x = Array.from(
|
|
84
|
+
new Map(t.map((o) => [o.name, o])).values()
|
|
85
|
+
);
|
|
86
|
+
console.log(`Updating provider with ${x.length} variables`), O(n, u, x, b);
|
|
87
|
+
}
|
|
88
|
+
function z(n, u, t) {
|
|
89
|
+
var b;
|
|
90
|
+
if (!(!t || t.length === 0)) {
|
|
91
|
+
if (u === "javascript" || u === "typescript") {
|
|
92
|
+
const x = t.map((e) => {
|
|
93
|
+
if (e.isObject && e.properties && e.properties.length > 0) {
|
|
94
|
+
const r = `I${e.name.charAt(0).toUpperCase() + e.name.slice(1)}`, m = e.properties.map(
|
|
95
|
+
(p) => ` ${p.name}: ${p.type};`
|
|
96
|
+
).join(`
|
|
97
|
+
`);
|
|
98
|
+
return `
|
|
99
|
+
interface ${r} {
|
|
100
|
+
${m}
|
|
101
|
+
}
|
|
102
|
+
declare const ${e.name}: ${r};`;
|
|
103
|
+
} else
|
|
104
|
+
return `declare const ${e.name}: ${e.type};`;
|
|
105
|
+
}).join(`
|
|
106
|
+
`), o = "predefined-variables";
|
|
107
|
+
(b = n.__extraLibDisposables) != null && b[o] && n.__extraLibDisposables[o].dispose();
|
|
108
|
+
const y = n.languages.typescript.javascriptDefaults.addExtraLib(
|
|
109
|
+
x,
|
|
110
|
+
`ts:filename/${o}.d.ts`
|
|
111
|
+
);
|
|
112
|
+
n.__extraLibDisposables || (n.__extraLibDisposables = {}), n.__extraLibDisposables[o] = y;
|
|
113
|
+
}
|
|
114
|
+
if (u === "python") {
|
|
115
|
+
["python-hover-provider", "python-completion-provider"].forEach((e) => {
|
|
116
|
+
var m;
|
|
117
|
+
const r = (m = n.__customDisposables) == null ? void 0 : m[e];
|
|
118
|
+
r && r.dispose();
|
|
119
|
+
}), n.__customDisposables || (n.__customDisposables = {});
|
|
120
|
+
const o = n.languages.registerHoverProvider("python", {
|
|
121
|
+
provideHover: (e, r) => {
|
|
122
|
+
const m = e.getWordAtPosition(r);
|
|
123
|
+
if (!m) return null;
|
|
124
|
+
const p = t.find((h) => h.name === m.word);
|
|
125
|
+
if (p)
|
|
126
|
+
return {
|
|
127
|
+
contents: [
|
|
128
|
+
{ value: `(variable) ${p.name}: ${p.type}` },
|
|
129
|
+
{ value: p.documentation || "" }
|
|
130
|
+
]
|
|
131
|
+
};
|
|
132
|
+
const c = e.getLineContent(r.lineNumber).substring(0, r.column).match(/(\w+)\.(\w+)$/);
|
|
133
|
+
if (c) {
|
|
134
|
+
const [h, g, d] = c, i = t.find((s) => s.name === g && s.isObject);
|
|
135
|
+
if (i && i.properties) {
|
|
136
|
+
const s = i.properties.find(($) => $.name === d);
|
|
137
|
+
if (s)
|
|
138
|
+
return {
|
|
139
|
+
contents: [
|
|
140
|
+
{ value: `(property) ${g}.${s.name}: ${s.type}` },
|
|
141
|
+
{ value: s.documentation || "" }
|
|
142
|
+
]
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
}), y = n.languages.registerCompletionItemProvider("python", {
|
|
149
|
+
triggerCharacters: ["."],
|
|
150
|
+
provideCompletionItems: (e, r) => {
|
|
151
|
+
const l = e.getLineContent(r.lineNumber).substring(0, r.column).match(/(\w+)\.\s*$/);
|
|
152
|
+
if (!l) return { suggestions: [] };
|
|
153
|
+
const [c, h] = l, g = t.find((d) => d.name === h && d.isObject);
|
|
154
|
+
return g && g.properties && g.properties.length > 0 ? { suggestions: g.properties.map((i) => ({
|
|
155
|
+
label: i.name,
|
|
156
|
+
kind: n.languages.CompletionItemKind.Property,
|
|
157
|
+
detail: i.type,
|
|
158
|
+
documentation: {
|
|
159
|
+
value: i.documentation || "",
|
|
160
|
+
isTrusted: !0
|
|
161
|
+
},
|
|
162
|
+
insertText: i.name,
|
|
163
|
+
range: {
|
|
164
|
+
startLineNumber: r.lineNumber,
|
|
165
|
+
startColumn: r.column,
|
|
166
|
+
endLineNumber: r.lineNumber,
|
|
167
|
+
endColumn: r.column
|
|
168
|
+
}
|
|
169
|
+
})) } : { suggestions: [] };
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
n.__customDisposables["python-hover-provider"] = o, n.__customDisposables["python-completion-provider"] = y;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
function ee({
|
|
177
|
+
value: n,
|
|
178
|
+
onChange: u,
|
|
179
|
+
language: t = "javascript",
|
|
180
|
+
height: b = "300px",
|
|
181
|
+
className: x = "",
|
|
182
|
+
options: o = {},
|
|
183
|
+
onMount: y,
|
|
184
|
+
title: e = "Code Editor",
|
|
185
|
+
variables: r = [],
|
|
186
|
+
variablePrefix: m = "{{",
|
|
187
|
+
variableSuffix: p = "}}",
|
|
188
|
+
predefinedVariables: l = [],
|
|
189
|
+
allowFullscreen: c = !0,
|
|
190
|
+
isDark: h = !1
|
|
191
|
+
}) {
|
|
192
|
+
const g = !h, d = N(null), i = N(null), [s, $] = k(!1), v = N(null), j = N(`editor-${Math.random().toString(36).substr(2, 9)}`), [T, K] = k(null);
|
|
193
|
+
_(() => {
|
|
194
|
+
if (!(!d.current || !i.current))
|
|
195
|
+
return v.current && (v.current(), v.current = null), console.log(`Setting up variable suggestions for ${j.current}`), v.current = O(
|
|
196
|
+
d.current,
|
|
197
|
+
i.current,
|
|
198
|
+
r,
|
|
199
|
+
{ language: t, variablePrefix: m, variableSuffix: p }
|
|
200
|
+
), () => {
|
|
201
|
+
v.current && (v.current(), v.current = null);
|
|
202
|
+
};
|
|
203
|
+
}, [T, r, t, m, p]), _(() => {
|
|
204
|
+
!i.current || l.length === 0 || (console.log("registering predefined variables", l), z(
|
|
205
|
+
i.current,
|
|
206
|
+
t,
|
|
207
|
+
l
|
|
208
|
+
));
|
|
209
|
+
}, [t, l]), _(() => {
|
|
210
|
+
d.current && setTimeout(() => {
|
|
211
|
+
var f;
|
|
212
|
+
(f = d.current) == null || f.layout();
|
|
213
|
+
}, 100);
|
|
214
|
+
}, [s]);
|
|
215
|
+
const w = I((f, C) => {
|
|
216
|
+
var P, M;
|
|
217
|
+
console.log(`Editor ${j.current} mounted`), d.current = f, i.current = C, K(f), l.length > 0 && z(C, t, l), t === "python" ? (P = f.getModel()) == null || P.updateOptions({ tabSize: 4, insertSpaces: !0 }) : t !== "markdown" && ((M = f.getModel()) == null || M.updateOptions({ tabSize: 2, insertSpaces: !0 })), y && y(f, C);
|
|
218
|
+
}, [t, y, l]), D = R(() => ({
|
|
219
|
+
...q,
|
|
220
|
+
...B[t] || {},
|
|
221
|
+
...o
|
|
222
|
+
}), [t, o]), L = I(() => {
|
|
223
|
+
$(!s);
|
|
224
|
+
}, [s]);
|
|
225
|
+
return /* @__PURE__ */ a.jsxs(a.Fragment, { children: [
|
|
226
|
+
/* @__PURE__ */ a.jsxs("div", { className: x, children: [
|
|
227
|
+
c && /* @__PURE__ */ a.jsx("div", { className: "flex justify-end mb-1", children: /* @__PURE__ */ a.jsx(
|
|
228
|
+
E,
|
|
229
|
+
{
|
|
230
|
+
variant: "ghost",
|
|
231
|
+
size: "sm",
|
|
232
|
+
onClick: L,
|
|
233
|
+
className: "h-7 w-7 p-0",
|
|
234
|
+
children: /* @__PURE__ */ a.jsx(A, { className: "h-4 w-4" })
|
|
235
|
+
}
|
|
236
|
+
) }),
|
|
237
|
+
/* @__PURE__ */ a.jsx("div", { className: "relative", style: { display: s ? "none" : "block" }, children: /* @__PURE__ */ a.jsx(
|
|
238
|
+
S,
|
|
239
|
+
{
|
|
240
|
+
height: b,
|
|
241
|
+
language: t,
|
|
242
|
+
value: n,
|
|
243
|
+
onChange: (f) => u == null ? void 0 : u(f || ""),
|
|
244
|
+
options: D,
|
|
245
|
+
onMount: w,
|
|
246
|
+
theme: g ? "vs-light" : "vs-dark"
|
|
247
|
+
},
|
|
248
|
+
j.current
|
|
249
|
+
) })
|
|
250
|
+
] }),
|
|
251
|
+
s && /* @__PURE__ */ a.jsx(
|
|
252
|
+
W,
|
|
253
|
+
{
|
|
254
|
+
isOpen: s,
|
|
255
|
+
onClose: () => $(!1),
|
|
256
|
+
size: "2xl",
|
|
257
|
+
title: e,
|
|
258
|
+
header: /* @__PURE__ */ a.jsxs("div", { className: "flex items-center justify-between w-full", children: [
|
|
259
|
+
/* @__PURE__ */ a.jsx("h2", { className: "text-sm font-medium", children: e }),
|
|
260
|
+
/* @__PURE__ */ a.jsx(
|
|
261
|
+
E,
|
|
262
|
+
{
|
|
263
|
+
variant: "ghost",
|
|
264
|
+
size: "sm",
|
|
265
|
+
onClick: L,
|
|
266
|
+
className: "h-7 w-7 p-0",
|
|
267
|
+
children: /* @__PURE__ */ a.jsx(F, { className: "h-4 w-4" })
|
|
268
|
+
}
|
|
269
|
+
)
|
|
270
|
+
] }),
|
|
271
|
+
children: /* @__PURE__ */ a.jsx("div", { className: "h-[80vh] w-full", children: /* @__PURE__ */ a.jsx(
|
|
272
|
+
S,
|
|
273
|
+
{
|
|
274
|
+
height: "100%",
|
|
275
|
+
language: t,
|
|
276
|
+
value: n,
|
|
277
|
+
onChange: (f) => u == null ? void 0 : u(f || ""),
|
|
278
|
+
options: D,
|
|
279
|
+
onMount: w,
|
|
280
|
+
theme: g ? "vs-light" : "vs-dark"
|
|
281
|
+
},
|
|
282
|
+
`${j.current}-fullscreen`
|
|
283
|
+
) })
|
|
284
|
+
}
|
|
285
|
+
)
|
|
286
|
+
] });
|
|
287
|
+
}
|
|
288
|
+
export {
|
|
289
|
+
ee as M,
|
|
290
|
+
q as d,
|
|
291
|
+
B as l,
|
|
292
|
+
O as s,
|
|
293
|
+
Z as u
|
|
294
|
+
};
|
|
295
|
+
//# sourceMappingURL=MonacoEditor-D3QSSKa4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MonacoEditor-D3QSSKa4.js","sources":["../src/components/monaco-editor/constants.ts","../src/components/monaco-editor/variableSuggestions.ts","../src/components/monaco-editor/utils.ts","../src/components/monaco-editor/MonacoEditor.tsx"],"sourcesContent":["import { editor as monacoEditor } from 'monaco-editor';\nimport { MonacoEditorLanguage } from './types';\n\nexport const defaultOptions: monacoEditor.IEditorOptions = {\n minimap: { enabled: false },\n fontSize: 14,\n scrollBeyondLastLine: false,\n wordWrap: 'on',\n lineNumbers: 'on',\n automaticLayout: true,\n scrollbar: {\n vertical: 'auto',\n horizontal: 'auto',\n },\n};\n\nexport const languageOptions: Record<MonacoEditorLanguage, monacoEditor.IEditorOptions> = {\n javascript: {},\n typescript: {},\n python: {},\n json: {},\n html: {},\n css: {},\n markdown: {\n wordWrap: 'on',\n },\n plaintext: {},\n}; ","import { Monaco } from '@monaco-editor/react';\nimport { editor as monacoEditor } from 'monaco-editor';\nimport { VariableSuggestion } from './types';\n\ntype VariableSuggestionProviderConfig = {\n language: string;\n variablePrefix: string;\n variableSuffix: string;\n};\n\n// Keep track of registered providers with a uniqueId\nconst registeredProviders = new Map<string, {\n dispose: () => void,\n variables: VariableSuggestion[],\n config: VariableSuggestionProviderConfig\n}>();\n\n// Counter for unique IDs\nlet providerCounter = 0;\n\n/**\n * Setup variable suggestions for Monaco editor\n */\nexport function setupVariableSuggestions(\n editor: monacoEditor.IStandaloneCodeEditor,\n monaco: Monaco,\n variables: VariableSuggestion[],\n config: VariableSuggestionProviderConfig\n): () => void {\n const { language, variablePrefix, variableSuffix } = config;\n \n // Generate a unique ID for this provider\n const providerId = `provider_${++providerCounter}`;\n \n console.log(`Setting up variable suggestions with ID ${providerId} (${variables.length} variables)`);\n \n // Register completion provider\n const completionProvider = monaco.languages.registerCompletionItemProvider(language, {\n triggerCharacters: ['{'], \n \n provideCompletionItems: (model, position) => {\n // Get text before cursor\n const lineContent = model.getLineContent(position.lineNumber);\n const textUntilPosition = lineContent.substring(0, position.column - 1);\n \n // Check if we've just typed the variable prefix\n if (textUntilPosition.endsWith(variablePrefix)) {\n console.log(`[${providerId}] Detected ${variablePrefix} - showing ${variables.length} variable suggestions`);\n \n if (variables.length === 0) {\n console.log(`[${providerId}] No variables available for suggestions`);\n return { suggestions: [] };\n }\n \n // Use Set to ensure unique variable names\n const uniqueVariables = Array.from(\n new Map(variables.map(v => [v.name, v])).values()\n );\n \n // Create suggestions\n const suggestions = uniqueVariables.map(variable => ({\n label: variable.name,\n kind: monaco.languages.CompletionItemKind.Variable,\n detail: variable.type,\n documentation: {\n value: variable.description || '',\n isTrusted: true\n },\n insertText: variable.name,\n sortText: '0' + variable.name, // Force variable suggestions to appear at top\n range: {\n startLineNumber: position.lineNumber,\n startColumn: position.column,\n endLineNumber: position.lineNumber,\n endColumn: position.column\n }\n }));\n \n console.log(`[${providerId}] Created ${suggestions.length} suggestions`);\n return { suggestions };\n }\n \n return { suggestions: [] };\n }\n });\n \n // Add manual KeyUp handler to trigger suggestions\n const keyUpDisposable = editor.onKeyUp(e => {\n // Skip if not the right key\n if (e.code !== 'BracketLeft' && e.code !== 'Digit2') return;\n \n const position = editor.getPosition();\n if (!position) return;\n \n const model = editor.getModel();\n if (!model) return;\n \n const lineContent = model.getLineContent(position.lineNumber);\n const textUntilPosition = lineContent.substring(0, position.column - 1);\n \n if (textUntilPosition.endsWith(variablePrefix)) {\n console.log(`[${providerId}] Manually triggering suggestions on ${variablePrefix}`);\n \n // Delay slightly to ensure the model is updated\n setTimeout(() => {\n // Force suggestions to appear\n editor.trigger('keyboard', 'editor.action.triggerSuggest', {});\n }, 20);\n }\n });\n \n // Create dispose function\n const dispose = () => {\n console.log(`Disposing provider ${providerId}`);\n completionProvider.dispose();\n keyUpDisposable.dispose();\n registeredProviders.delete(providerId);\n };\n \n // Store in registeredProviders\n registeredProviders.set(providerId, {\n dispose,\n variables,\n config\n });\n \n return dispose;\n}\n\n/**\n * Update variables for an existing provider\n * Creates a new provider with the updated variables\n */\nexport function updateVariableSuggestions(\n editor: monacoEditor.IStandaloneCodeEditor,\n monaco: Monaco,\n variables: VariableSuggestion[],\n config: VariableSuggestionProviderConfig\n): void {\n // Remove duplicates from variables array\n const uniqueVariables = Array.from(\n new Map(variables.map(v => [v.name, v])).values()\n );\n \n console.log(`Updating provider with ${uniqueVariables.length} variables`);\n \n // Create a new provider with the updated variables\n setupVariableSuggestions(editor, monaco, uniqueVariables, config);\n} ","import { Monaco } from \"@monaco-editor/react\";\nimport { PredefinedVariable } from \"./types\";\n\n/**\n * Find the position of a variable prefix in a text string\n * \n * @param lineContent The current line content\n * @param currentColumn The current cursor column\n * @param variablePrefix The variable prefix to look for\n * @returns The starting position of the prefix, or -1 if not found\n */\nexport function findVariablePrefixPosition(\n lineContent: string, \n currentColumn: number, \n variablePrefix: string\n): number {\n let prefixStart = -1;\n \n // Look for the variable prefix before the cursor within a reasonable range\n for (let i = currentColumn - 1; i >= 0 && i >= currentColumn - variablePrefix.length - 10; i--) {\n if (i - variablePrefix.length + 1 >= 0) {\n const substring = lineContent.substring(i - variablePrefix.length + 1, i + 1);\n if (substring === variablePrefix) {\n prefixStart = i - variablePrefix.length + 1;\n break;\n }\n }\n }\n \n return prefixStart;\n}\n\n/**\n * Format a preview text with variable prefix and suffix\n * \n * @param variableName The variable name to format\n * @param variablePrefix The prefix to add\n * @param variableSuffix The suffix to add\n * @returns Formatted variable string\n */\nexport function formatVariablePreview(\n variableName: string | null, \n variablePrefix: string, \n variableSuffix: string\n): string {\n if (!variableName) return variablePrefix + '....' + variableSuffix;\n return variablePrefix + variableName + variableSuffix;\n}\n\n/**\n * Format code according to the specified language\n */\nexport function formatCode(monaco: Monaco, editor: any, language: string) {\n editor.getAction('editor.action.formatDocument').run();\n}\n\n/**\n * Get the appropriate EOL character for the current operating system\n */\nexport function getEOL() {\n return '\\n';\n}\n\n/**\n * Register predefined variables with the Monaco editor\n */\nexport function registerPredefinedVariables(\n monaco: Monaco, \n language: string, \n variables: PredefinedVariable[]\n) {\n if (!variables || variables.length === 0) return;\n \n // For JavaScript/TypeScript editor\n if (language === 'javascript' || language === 'typescript') {\n // Create TypeScript definitions for our variables\n const declarations = variables.map(variable => {\n if (variable.isObject && variable.properties && variable.properties.length > 0) {\n // Create a detailed interface for object types with properties\n const interfaceName = `I${variable.name.charAt(0).toUpperCase() + variable.name.slice(1)}`;\n const propertyDeclarations = variable.properties.map(prop => \n ` ${prop.name}: ${prop.type};`\n ).join('\\n');\n \n return `\ninterface ${interfaceName} {\n${propertyDeclarations}\n}\ndeclare const ${variable.name}: ${interfaceName};`;\n } else {\n // Simple variable declaration\n return `declare const ${variable.name}: ${variable.type};`;\n }\n }).join('\\n');\n \n // Check if we already have a stored disposable for the lib\n const libKey = 'predefined-variables';\n if ((monaco as any).__extraLibDisposables?.[libKey]) {\n (monaco as any).__extraLibDisposables[libKey].dispose();\n }\n \n // Add the library and store its disposable\n const disposable = monaco.languages.typescript.javascriptDefaults.addExtraLib(\n declarations,\n `ts:filename/${libKey}.d.ts`\n );\n \n // Initialize storage for disposables if needed\n if (!(monaco as any).__extraLibDisposables) {\n (monaco as any).__extraLibDisposables = {};\n }\n \n // Store the disposable for later cleanup\n (monaco as any).__extraLibDisposables[libKey] = disposable;\n }\n \n // For Python, we add hover providers and completion providers\n if (language === 'python') {\n // Remove previous providers if they exist\n const providerKeys = ['python-hover-provider', 'python-completion-provider'];\n providerKeys.forEach(key => {\n const disposable = (monaco as any).__customDisposables?.[key];\n if (disposable) {\n disposable.dispose();\n }\n });\n \n // Initialize storage for disposables if needed\n if (!(monaco as any).__customDisposables) {\n (monaco as any).__customDisposables = {};\n }\n \n // Create a new hover provider\n const hoverProvider = monaco.languages.registerHoverProvider('python', {\n provideHover: (model, position) => {\n const word = model.getWordAtPosition(position);\n if (!word) return null;\n \n // Check if it's a direct variable match\n const variable = variables.find(v => v.name === word.word);\n if (variable) {\n return {\n contents: [\n { value: `(variable) ${variable.name}: ${variable.type}` },\n { value: variable.documentation || '' }\n ]\n };\n }\n \n // Check if it's a property access (e.g., self.property)\n const lineContent = model.getLineContent(position.lineNumber);\n const dotMatch = lineContent.substring(0, position.column).match(/(\\w+)\\.(\\w+)$/);\n \n if (dotMatch) {\n const [_, objName, propName] = dotMatch;\n const objVar = variables.find(v => v.name === objName && v.isObject);\n \n if (objVar && objVar.properties) {\n const property = objVar.properties.find(p => p.name === propName);\n if (property) {\n return {\n contents: [\n { value: `(property) ${objName}.${property.name}: ${property.type}` },\n { value: property.documentation || '' }\n ]\n };\n }\n }\n }\n \n return null;\n }\n });\n \n // Create completion provider for object properties\n const completionProvider = monaco.languages.registerCompletionItemProvider('python', {\n triggerCharacters: ['.'],\n provideCompletionItems: (model, position) => {\n const lineContent = model.getLineContent(position.lineNumber);\n const textUntilPosition = lineContent.substring(0, position.column);\n \n // Match for object property access\n const match = textUntilPosition.match(/(\\w+)\\.\\s*$/);\n if (!match) return { suggestions: [] };\n \n const [_, objName] = match;\n const objVar = variables.find(v => v.name === objName && v.isObject);\n \n if (objVar && objVar.properties && objVar.properties.length > 0) {\n const suggestions = objVar.properties.map(prop => ({\n label: prop.name,\n kind: monaco.languages.CompletionItemKind.Property,\n detail: prop.type,\n documentation: {\n value: prop.documentation || '',\n isTrusted: true\n },\n insertText: prop.name,\n range: {\n startLineNumber: position.lineNumber,\n startColumn: position.column,\n endLineNumber: position.lineNumber,\n endColumn: position.column\n }\n }));\n \n return { suggestions };\n }\n \n return { suggestions: [] };\n }\n });\n \n // Store providers for later disposal\n (monaco as any).__customDisposables['python-hover-provider'] = hoverProvider;\n (monaco as any).__customDisposables['python-completion-provider'] = completionProvider;\n }\n} ","import { useRef, useState, useEffect, useMemo, useCallback } from \"react\";\nimport Editor, { Monaco } from '@monaco-editor/react';\nimport { editor as monacoEditor } from 'monaco-editor';\nimport { Modal } from \"../modal\";\nimport { Button } from \"../button\";\nimport { Maximize2, Minimize2, Maximize } from \"lucide-react\";\nimport { MonacoEditorProps } from \"./types\";\nimport { defaultOptions, languageOptions } from \"./constants\";\nimport { setupVariableSuggestions } from \"./variableSuggestions\";\nimport { registerPredefinedVariables } from \"./utils\";\n\nexport function MonacoEditor({\n value,\n onChange,\n language = 'javascript',\n height = '300px',\n className = '',\n options = {},\n onMount,\n title = 'Code Editor',\n variables = [],\n variablePrefix = '{{',\n variableSuffix = '}}',\n predefinedVariables = [],\n allowFullscreen = true,\n isDark = false,\n}: MonacoEditorProps) {\n const isLight = !isDark;\n const editorRef = useRef<monacoEditor.IStandaloneCodeEditor | null>(null);\n const monacoRef = useRef<Monaco | null>(null);\n const [isFullscreen, setIsFullscreen] = useState(false);\n const suggestionDisposableRef = useRef<(() => void) | null>(null);\n const editorIdRef = useRef<string>(`editor-${Math.random().toString(36).substr(2, 9)}`);\n const [editorInstance, setEditorInstance] = useState<monacoEditor.IStandaloneCodeEditor | null>(null);\n\n // Setup variable suggestions once the editor is mounted\n useEffect(() => {\n if (!editorRef.current || !monacoRef.current) return;\n \n // Clear any previous provider\n if (suggestionDisposableRef.current) {\n suggestionDisposableRef.current();\n suggestionDisposableRef.current = null;\n }\n \n // Setup a new provider with current variables\n console.log(`Setting up variable suggestions for ${editorIdRef.current}`);\n suggestionDisposableRef.current = setupVariableSuggestions(\n editorRef.current,\n monacoRef.current,\n variables,\n { language, variablePrefix, variableSuffix }\n );\n \n return () => {\n if (suggestionDisposableRef.current) {\n suggestionDisposableRef.current();\n suggestionDisposableRef.current = null;\n }\n };\n }, [editorInstance, variables, language, variablePrefix, variableSuffix]);\n\n // Register predefined variables like 'self'\n useEffect(() => {\n if (!monacoRef.current || predefinedVariables.length === 0) return;\n \n console.log('registering predefined variables', predefinedVariables);\n registerPredefinedVariables(\n monacoRef.current,\n language,\n predefinedVariables\n );\n }, [language, predefinedVariables]);\n\n // Handle fullscreen toggle - need to relayout the editor\n useEffect(() => {\n if (editorRef.current) {\n // Give the modal time to animate\n setTimeout(() => {\n editorRef.current?.layout();\n }, 100);\n }\n }, [isFullscreen]);\n\n // Handle editor mounting\n const handleEditorDidMount = useCallback((editor: monacoEditor.IStandaloneCodeEditor, monaco: Monaco) => {\n console.log(`Editor ${editorIdRef.current} mounted`);\n editorRef.current = editor;\n monacoRef.current = monaco;\n setEditorInstance(editor);\n \n // Register predefined variables immediately after mount\n if (predefinedVariables.length > 0) {\n registerPredefinedVariables(monaco, language, predefinedVariables);\n }\n \n // Set language-specific model options\n if (language === 'python') {\n editor.getModel()?.updateOptions({ tabSize: 4, insertSpaces: true });\n } else if (language !== 'markdown') {\n editor.getModel()?.updateOptions({ tabSize: 2, insertSpaces: true });\n }\n \n if (onMount) {\n onMount(editor, monaco);\n }\n }, [language, onMount, predefinedVariables]);\n\n // Merge default options with language-specific options and user options\n const mergedOptions = useMemo(() => {\n return {\n ...defaultOptions,\n ...(languageOptions[language] || {}),\n ...options,\n };\n }, [language, options]);\n\n const toggleFullscreen = useCallback(() => {\n setIsFullscreen(!isFullscreen);\n }, [isFullscreen]);\n\n return (\n <>\n <div className={className}>\n {allowFullscreen && (\n <div className=\"flex justify-end mb-1\">\n <Button \n variant=\"ghost\" \n size=\"sm\" \n onClick={toggleFullscreen} \n className=\"h-7 w-7 p-0\"\n >\n <Maximize className=\"h-4 w-4\" />\n </Button>\n </div>\n )}\n <div className=\"relative\" style={{ display: isFullscreen ? 'none' : 'block' }}>\n <Editor\n height={height}\n language={language}\n value={value}\n onChange={(value) => onChange?.(value || '')}\n options={mergedOptions}\n onMount={handleEditorDidMount}\n theme={isLight ? 'vs-light' : 'vs-dark'}\n key={editorIdRef.current} // Use the stable ID\n />\n </div>\n </div>\n\n {isFullscreen && (\n <Modal \n isOpen={isFullscreen} \n onClose={() => setIsFullscreen(false)}\n size=\"2xl\"\n title={title}\n header={\n <div className=\"flex items-center justify-between w-full\">\n <h2 className=\"text-sm font-medium\">{title}</h2>\n <Button \n variant=\"ghost\" \n size=\"sm\" \n onClick={toggleFullscreen} \n className=\"h-7 w-7 p-0\"\n >\n <Minimize2 className=\"h-4 w-4\" />\n </Button>\n </div>\n }\n >\n <div className=\"h-[80vh] w-full\">\n <Editor\n height=\"100%\"\n language={language}\n value={value}\n onChange={(value) => onChange?.(value || '')}\n options={mergedOptions}\n onMount={handleEditorDidMount}\n theme={isLight ? 'vs-light' : 'vs-dark'}\n key={`${editorIdRef.current}-fullscreen`} // Use the same ID with a suffix\n />\n </div>\n </Modal>\n )}\n </>\n );\n} "],"names":["defaultOptions","languageOptions","registeredProviders","providerCounter","setupVariableSuggestions","editor","monaco","variables","config","language","variablePrefix","variableSuffix","providerId","completionProvider","model","position","suggestions","v","variable","keyUpDisposable","e","dispose","updateVariableSuggestions","uniqueVariables","registerPredefinedVariables","declarations","interfaceName","propertyDeclarations","prop","libKey","_a","disposable","key","hoverProvider","word","dotMatch","_","objName","propName","objVar","property","p","match","MonacoEditor","value","onChange","height","className","options","onMount","title","predefinedVariables","allowFullscreen","isDark","isLight","editorRef","useRef","monacoRef","isFullscreen","setIsFullscreen","useState","suggestionDisposableRef","editorIdRef","editorInstance","setEditorInstance","useEffect","handleEditorDidMount","useCallback","_b","mergedOptions","useMemo","toggleFullscreen","jsxs","Fragment","jsx","Button","Maximize","Editor","Modal","Minimize2"],"mappings":";;;;;;AAGO,MAAMA,IAA8C;AAAA,EACzD,SAAS,EAAE,SAAS,GAAA;AAAA,EACpB,UAAU;AAAA,EACV,sBAAsB;AAAA,EACtB,UAAU;AAAA,EACV,aAAa;AAAA,EACb,iBAAiB;AAAA,EACjB,WAAW;AAAA,IACT,UAAU;AAAA,IACV,YAAY;AAAA,EAAA;AAEhB,GAEaC,IAA6E;AAAA,EACxF,YAAY,CAAA;AAAA,EACZ,YAAY,CAAA;AAAA,EACZ,QAAQ,CAAA;AAAA,EACR,MAAM,CAAA;AAAA,EACN,MAAM,CAAA;AAAA,EACN,KAAK,CAAA;AAAA,EACL,UAAU;AAAA,IACR,UAAU;AAAA,EAAA;AAAA,EAEZ,WAAW,CAAA;AACb,GChBMC,wBAA0B,IAAA;AAOhC,IAAIC,IAAkB;AAKf,SAASC,EACdC,GACAC,GACAC,GACAC,GACY;AACZ,QAAM,EAAE,UAAAC,GAAU,gBAAAC,GAAgB,gBAAAC,EAAA,IAAmBH,GAG/CI,IAAa,YAAY,EAAET,CAAe;AAEhD,UAAQ,IAAI,2CAA2CS,CAAU,KAAKL,EAAU,MAAM,aAAa;AAGnG,QAAMM,IAAqBP,EAAO,UAAU,+BAA+BG,GAAU;AAAA,IACnF,mBAAmB,CAAC,GAAG;AAAA,IAEvB,wBAAwB,CAACK,GAAOC,MAAa;AAM3C,UAJoBD,EAAM,eAAeC,EAAS,UAAU,EACtB,UAAU,GAAGA,EAAS,SAAS,CAAC,EAGhD,SAASL,CAAc,GAAG;AAG9C,YAFA,QAAQ,IAAI,IAAIE,CAAU,cAAcF,CAAc,cAAcH,EAAU,MAAM,uBAAuB,GAEvGA,EAAU,WAAW;AACvB,yBAAQ,IAAI,IAAIK,CAAU,0CAA0C,GAC7D,EAAE,aAAa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GAAA,EAAU,WAAU,UAAA,CAAU;AAAA,YAAA;AAAA,UAAA;AAAA,QACjC,GACF;AAAA,QAGF,UAAAL,gBAAAA,EAAAA,IAAC,OAAA,EAAI,WAAU,mBACb,UAAAA,gBAAAA,EAAAA;AAAAA,UAACG;AAAA,UAAA;AAAA,YACC,QAAO;AAAA,YACP,UAAApE;AAAA,YACA,OAAAmC;AAAA,YACA,UAAU,CAACA,MAAUC,KAAA,gBAAAA,EAAWD,KAAS;AAAA,YACzC,SAASyB;AAAA,YACT,SAASH;AAAA,YACT,OAAOZ,IAAU,aAAa;AAAA,UAAA;AAAA,UACzB,GAAGQ,EAAY,OAAO;AAAA,QAAA,EAC7B,CACF;AAAA,MAAA;AAAA,IAAA;AAAA,EACF,GAEJ;AAEJ;"}
|
package/dist/alert.d.ts
CHANGED
|
@@ -7,6 +7,13 @@ export declare const Alert: React_2.ForwardRefExoticComponent<AlertProps & React
|
|
|
7
7
|
export declare const AlertDescription: React_2.ForwardRefExoticComponent<React_2.HTMLAttributes<HTMLParagraphElement> & React_2.RefAttributes<HTMLParagraphElement>>;
|
|
8
8
|
|
|
9
9
|
export declare interface AlertProps extends React_2.HTMLAttributes<HTMLDivElement>, VariantProps<typeof alertVariants> {
|
|
10
|
+
isOpen?: boolean;
|
|
11
|
+
onClose?: () => void;
|
|
12
|
+
onConfirm?: () => void;
|
|
13
|
+
title?: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
confirmText?: string;
|
|
16
|
+
cancelText?: string;
|
|
10
17
|
}
|
|
11
18
|
|
|
12
19
|
export declare const AlertTitle: React_2.ForwardRefExoticComponent<React_2.HTMLAttributes<HTMLHeadingElement> & React_2.RefAttributes<HTMLParagraphElement>>;
|
package/dist/badge.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export declare interface BadgeProps extends React_2.HTMLAttributes<HTMLDivElemen
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export declare const badgeVariants: (props?: ({
|
|
12
|
-
variant?: "default" | "
|
|
12
|
+
variant?: "default" | "outline" | "secondary" | "destructive" | null | undefined;
|
|
13
13
|
} & ClassProp) | undefined) => string;
|
|
14
14
|
|
|
15
15
|
export { }
|
package/dist/command.d.ts
CHANGED
|
@@ -3,11 +3,11 @@ import * as React_2 from 'react';
|
|
|
3
3
|
|
|
4
4
|
export declare const Command: React_2.ForwardRefExoticComponent<Omit<{
|
|
5
5
|
children?: React_2.ReactNode;
|
|
6
|
-
} & Pick<Pick<React_2.DetailedHTMLProps<React_2.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React_2.HTMLAttributes<HTMLDivElement
|
|
6
|
+
} & Pick<Pick<React_2.DetailedHTMLProps<React_2.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React_2.HTMLAttributes<HTMLDivElement>> & {
|
|
7
7
|
ref?: React_2.Ref<HTMLDivElement>;
|
|
8
8
|
} & {
|
|
9
9
|
asChild?: boolean;
|
|
10
|
-
}, keyof React_2.HTMLAttributes<HTMLDivElement> | "asChild"
|
|
10
|
+
}, "key" | keyof React_2.HTMLAttributes<HTMLDivElement> | "asChild"> & {
|
|
11
11
|
label?: string;
|
|
12
12
|
shouldFilter?: boolean;
|
|
13
13
|
filter?: (value: string, search: string, keywords?: string[]) => number;
|
|
@@ -27,19 +27,19 @@ export declare const CommandDialog: ({ children, open, onOpenChange, }: {
|
|
|
27
27
|
|
|
28
28
|
export declare const CommandEmpty: React_2.ForwardRefExoticComponent<Omit<{
|
|
29
29
|
children?: React_2.ReactNode;
|
|
30
|
-
} & Pick<Pick<React_2.DetailedHTMLProps<React_2.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React_2.HTMLAttributes<HTMLDivElement
|
|
30
|
+
} & Pick<Pick<React_2.DetailedHTMLProps<React_2.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React_2.HTMLAttributes<HTMLDivElement>> & {
|
|
31
31
|
ref?: React_2.Ref<HTMLDivElement>;
|
|
32
32
|
} & {
|
|
33
33
|
asChild?: boolean;
|
|
34
|
-
}, keyof React_2.HTMLAttributes<HTMLDivElement> | "asChild"
|
|
34
|
+
}, "key" | keyof React_2.HTMLAttributes<HTMLDivElement> | "asChild"> & React_2.RefAttributes<HTMLDivElement>, "ref"> & React_2.RefAttributes<HTMLDivElement>>;
|
|
35
35
|
|
|
36
36
|
export declare const CommandGroup: React_2.ForwardRefExoticComponent<Omit<{
|
|
37
37
|
children?: React_2.ReactNode;
|
|
38
|
-
} & Omit<Pick<Pick<React_2.DetailedHTMLProps<React_2.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React_2.HTMLAttributes<HTMLDivElement
|
|
38
|
+
} & Omit<Pick<Pick<React_2.DetailedHTMLProps<React_2.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React_2.HTMLAttributes<HTMLDivElement>> & {
|
|
39
39
|
ref?: React_2.Ref<HTMLDivElement>;
|
|
40
40
|
} & {
|
|
41
41
|
asChild?: boolean;
|
|
42
|
-
}, keyof React_2.HTMLAttributes<HTMLDivElement> | "asChild"
|
|
42
|
+
}, "key" | keyof React_2.HTMLAttributes<HTMLDivElement> | "asChild">, "value" | "heading"> & {
|
|
43
43
|
heading?: React_2.ReactNode;
|
|
44
44
|
value?: string;
|
|
45
45
|
forceMount?: boolean;
|
|
@@ -49,18 +49,18 @@ export declare const CommandInput: React_2.ForwardRefExoticComponent<Omit<Omit<P
|
|
|
49
49
|
ref?: React_2.Ref<HTMLInputElement>;
|
|
50
50
|
} & {
|
|
51
51
|
asChild?: boolean;
|
|
52
|
-
}, "
|
|
52
|
+
}, "key" | "asChild" | keyof React_2.InputHTMLAttributes<HTMLInputElement>>, "onChange" | "type" | "value"> & {
|
|
53
53
|
value?: string;
|
|
54
54
|
onValueChange?: (search: string) => void;
|
|
55
55
|
} & React_2.RefAttributes<HTMLInputElement>, "ref"> & React_2.RefAttributes<HTMLInputElement>>;
|
|
56
56
|
|
|
57
57
|
export declare const CommandItem: React_2.ForwardRefExoticComponent<Omit<{
|
|
58
58
|
children?: React_2.ReactNode;
|
|
59
|
-
} & Omit<Pick<Pick<React_2.DetailedHTMLProps<React_2.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React_2.HTMLAttributes<HTMLDivElement
|
|
59
|
+
} & Omit<Pick<Pick<React_2.DetailedHTMLProps<React_2.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React_2.HTMLAttributes<HTMLDivElement>> & {
|
|
60
60
|
ref?: React_2.Ref<HTMLDivElement>;
|
|
61
61
|
} & {
|
|
62
62
|
asChild?: boolean;
|
|
63
|
-
}, keyof React_2.HTMLAttributes<HTMLDivElement> | "asChild"
|
|
63
|
+
}, "key" | keyof React_2.HTMLAttributes<HTMLDivElement> | "asChild">, "onSelect" | "disabled" | "value"> & {
|
|
64
64
|
disabled?: boolean;
|
|
65
65
|
onSelect?: (value: string) => void;
|
|
66
66
|
value?: string;
|
|
@@ -70,19 +70,19 @@ export declare const CommandItem: React_2.ForwardRefExoticComponent<Omit<{
|
|
|
70
70
|
|
|
71
71
|
export declare const CommandList: React_2.ForwardRefExoticComponent<Omit<{
|
|
72
72
|
children?: React_2.ReactNode;
|
|
73
|
-
} & Pick<Pick<React_2.DetailedHTMLProps<React_2.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React_2.HTMLAttributes<HTMLDivElement
|
|
73
|
+
} & Pick<Pick<React_2.DetailedHTMLProps<React_2.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React_2.HTMLAttributes<HTMLDivElement>> & {
|
|
74
74
|
ref?: React_2.Ref<HTMLDivElement>;
|
|
75
75
|
} & {
|
|
76
76
|
asChild?: boolean;
|
|
77
|
-
}, keyof React_2.HTMLAttributes<HTMLDivElement> | "asChild"
|
|
77
|
+
}, "key" | keyof React_2.HTMLAttributes<HTMLDivElement> | "asChild"> & {
|
|
78
78
|
label?: string;
|
|
79
79
|
} & React_2.RefAttributes<HTMLDivElement>, "ref"> & React_2.RefAttributes<HTMLDivElement>>;
|
|
80
80
|
|
|
81
|
-
export declare const CommandSeparator: React_2.ForwardRefExoticComponent<Omit<Pick<Pick<React_2.DetailedHTMLProps<React_2.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React_2.HTMLAttributes<HTMLDivElement
|
|
81
|
+
export declare const CommandSeparator: React_2.ForwardRefExoticComponent<Omit<Pick<Pick<React_2.DetailedHTMLProps<React_2.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React_2.HTMLAttributes<HTMLDivElement>> & {
|
|
82
82
|
ref?: React_2.Ref<HTMLDivElement>;
|
|
83
83
|
} & {
|
|
84
84
|
asChild?: boolean;
|
|
85
|
-
}, keyof React_2.HTMLAttributes<HTMLDivElement> | "asChild"
|
|
85
|
+
}, "key" | keyof React_2.HTMLAttributes<HTMLDivElement> | "asChild"> & {
|
|
86
86
|
alwaysRender?: boolean;
|
|
87
87
|
} & React_2.RefAttributes<HTMLDivElement>, "ref"> & React_2.RefAttributes<HTMLDivElement>>;
|
|
88
88
|
|
|
@@ -4,6 +4,13 @@ declare const alertVariants: (props?: ({
|
|
|
4
4
|
variant?: "default" | "destructive" | null | undefined;
|
|
5
5
|
} & import('class-variance-authority/dist/types').ClassProp) | undefined) => string;
|
|
6
6
|
export interface AlertProps extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof alertVariants> {
|
|
7
|
+
isOpen?: boolean;
|
|
8
|
+
onClose?: () => void;
|
|
9
|
+
onConfirm?: () => void;
|
|
10
|
+
title?: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
confirmText?: string;
|
|
13
|
+
cancelText?: string;
|
|
7
14
|
}
|
|
8
15
|
declare const Alert: React.ForwardRefExoticComponent<AlertProps & React.RefAttributes<HTMLDivElement>>;
|
|
9
16
|
declare const AlertTitle: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLHeadingElement> & React.RefAttributes<HTMLParagraphElement>>;
|