@tslite/react 1.2.0 → 1.4.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/dist/full.cjs +1 -1
- package/dist/full.d.cts +4 -11
- package/dist/full.d.ts +4 -11
- package/dist/full.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +1 -1
- package/dist/{useExpressionField-RmyW3D9R.d.cts → useExpressionField-BfIHCVtU.d.cts} +38 -20
- package/dist/{useExpressionField-RmyW3D9R.d.ts → useExpressionField-BfIHCVtU.d.ts} +38 -20
- package/package.json +7 -7
package/dist/full.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var search=require('@tslite/codemirror/search'),
|
|
1
|
+
'use strict';var search=require('@tslite/codemirror/search'),editor=require('@tslite/editor');function y(r={}){let{dark:s=true,layout:e="inline",mode:o="expression",segmenter:n="mustache",gutters:i=e==="block",search:a=e==="block",extensions:t=[]}=r;return {layout:e,mode:o,...o==="template"?{}:{segmenter:n},gutters:i,features:{chrome:{dark:s},theme:editor.tsliteTokenStyles},extensions:a?[search.searchEditing(),...t]:[...t]}}Object.defineProperty(exports,"searchEditing",{enumerable:true,get:function(){return search.searchEditing}});Object.defineProperty(exports,"tsliteTokenStyles",{enumerable:true,get:function(){return editor.tsliteTokenStyles}});exports.expressionFieldProps=y;
|
package/dist/full.d.cts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Extension } from '@codemirror/state';
|
|
2
|
-
import { F as FieldLayout, S as SegmenterOption, U as UseExpressionFieldOptions } from './useExpressionField-
|
|
2
|
+
import { F as FieldLayout, S as SegmenterOption, U as UseExpressionFieldOptions } from './useExpressionField-BfIHCVtU.cjs';
|
|
3
3
|
export { searchEditing } from '@tslite/codemirror/search';
|
|
4
|
-
export { format, formatExpression } from '@tslite/format';
|
|
5
4
|
export { tsliteTokenStyles } from '@tslite/editor';
|
|
6
5
|
import 'react';
|
|
7
6
|
import '@codemirror/view';
|
|
@@ -32,12 +31,6 @@ interface PresetOptions {
|
|
|
32
31
|
/**
|
|
33
32
|
* O que o código É. Padrão: `"expression"`.
|
|
34
33
|
*
|
|
35
|
-
* Decide também qual formatador entra: um programa é reimpresso com `;` e
|
|
36
|
-
* quebra de statement; uma expressão, não. Injetar o de expressão num programa
|
|
37
|
-
* faz o `parseExpression` lançar, e o serviço então declara que não sabe
|
|
38
|
-
* formatar — em silêncio. Foi um defeito real, e é por isso que o preset
|
|
39
|
-
* escolhe por você.
|
|
40
|
-
*
|
|
41
34
|
* **`"template"`** liga o controle de fluxo (`{% if %}` / `{% for %}` /
|
|
42
35
|
* `{# #}`). Ele não é o padrão porque um `{%` literal no texto deixaria de ser
|
|
43
36
|
* texto — e num campo que hoje aceita qualquer string isso seria mudança de
|
|
@@ -62,8 +55,8 @@ interface PresetOptions {
|
|
|
62
55
|
/** Extensões suas, acrescentadas às do preset. */
|
|
63
56
|
readonly extensions?: readonly Extension[];
|
|
64
57
|
}
|
|
65
|
-
/** As props que o preset resolve — o resto (`value`, `onChange`, `
|
|
66
|
-
type PresetProps = Pick<UseExpressionFieldOptions, "layout" | "mode" | "segmenter" | "gutters" | "
|
|
58
|
+
/** As props que o preset resolve — o resto (`value`, `onChange`, `world`) é seu. */
|
|
59
|
+
type PresetProps = Pick<UseExpressionFieldOptions, "layout" | "mode" | "segmenter" | "gutters" | "features" | "extensions">;
|
|
67
60
|
/**
|
|
68
61
|
* As props de um campo que já nasce certo.
|
|
69
62
|
*
|
|
@@ -75,7 +68,7 @@ type PresetProps = Pick<UseExpressionFieldOptions, "layout" | "mode" | "segmente
|
|
|
75
68
|
* {...expressionFieldProps()}
|
|
76
69
|
* value={v}
|
|
77
70
|
* onChange={setV}
|
|
78
|
-
*
|
|
71
|
+
* world={world}
|
|
79
72
|
* />
|
|
80
73
|
* ```
|
|
81
74
|
*
|
package/dist/full.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Extension } from '@codemirror/state';
|
|
2
|
-
import { F as FieldLayout, S as SegmenterOption, U as UseExpressionFieldOptions } from './useExpressionField-
|
|
2
|
+
import { F as FieldLayout, S as SegmenterOption, U as UseExpressionFieldOptions } from './useExpressionField-BfIHCVtU.js';
|
|
3
3
|
export { searchEditing } from '@tslite/codemirror/search';
|
|
4
|
-
export { format, formatExpression } from '@tslite/format';
|
|
5
4
|
export { tsliteTokenStyles } from '@tslite/editor';
|
|
6
5
|
import 'react';
|
|
7
6
|
import '@codemirror/view';
|
|
@@ -32,12 +31,6 @@ interface PresetOptions {
|
|
|
32
31
|
/**
|
|
33
32
|
* O que o código É. Padrão: `"expression"`.
|
|
34
33
|
*
|
|
35
|
-
* Decide também qual formatador entra: um programa é reimpresso com `;` e
|
|
36
|
-
* quebra de statement; uma expressão, não. Injetar o de expressão num programa
|
|
37
|
-
* faz o `parseExpression` lançar, e o serviço então declara que não sabe
|
|
38
|
-
* formatar — em silêncio. Foi um defeito real, e é por isso que o preset
|
|
39
|
-
* escolhe por você.
|
|
40
|
-
*
|
|
41
34
|
* **`"template"`** liga o controle de fluxo (`{% if %}` / `{% for %}` /
|
|
42
35
|
* `{# #}`). Ele não é o padrão porque um `{%` literal no texto deixaria de ser
|
|
43
36
|
* texto — e num campo que hoje aceita qualquer string isso seria mudança de
|
|
@@ -62,8 +55,8 @@ interface PresetOptions {
|
|
|
62
55
|
/** Extensões suas, acrescentadas às do preset. */
|
|
63
56
|
readonly extensions?: readonly Extension[];
|
|
64
57
|
}
|
|
65
|
-
/** As props que o preset resolve — o resto (`value`, `onChange`, `
|
|
66
|
-
type PresetProps = Pick<UseExpressionFieldOptions, "layout" | "mode" | "segmenter" | "gutters" | "
|
|
58
|
+
/** As props que o preset resolve — o resto (`value`, `onChange`, `world`) é seu. */
|
|
59
|
+
type PresetProps = Pick<UseExpressionFieldOptions, "layout" | "mode" | "segmenter" | "gutters" | "features" | "extensions">;
|
|
67
60
|
/**
|
|
68
61
|
* As props de um campo que já nasce certo.
|
|
69
62
|
*
|
|
@@ -75,7 +68,7 @@ type PresetProps = Pick<UseExpressionFieldOptions, "layout" | "mode" | "segmente
|
|
|
75
68
|
* {...expressionFieldProps()}
|
|
76
69
|
* value={v}
|
|
77
70
|
* onChange={setV}
|
|
78
|
-
*
|
|
71
|
+
* world={world}
|
|
79
72
|
* />
|
|
80
73
|
* ```
|
|
81
74
|
*
|
package/dist/full.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {searchEditing}from'@tslite/codemirror/search';export{searchEditing}from'@tslite/codemirror/search';import {
|
|
1
|
+
import {searchEditing}from'@tslite/codemirror/search';export{searchEditing}from'@tslite/codemirror/search';import {tsliteTokenStyles}from'@tslite/editor';export{tsliteTokenStyles}from'@tslite/editor';function y(r={}){let{dark:s=true,layout:e="inline",mode:o="expression",segmenter:n="mustache",gutters:i=e==="block",search:a=e==="block",extensions:t=[]}=r;return {layout:e,mode:o,...o==="template"?{}:{segmenter:n},gutters:i,features:{chrome:{dark:s},theme:tsliteTokenStyles},extensions:a?[searchEditing(),...t]:[...t]}}export{y as expressionFieldProps};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var n=require('react'),state=require('@codemirror/state'),view=require('@codemirror/view'),commands=require('@codemirror/commands'),autocomplete=require('@codemirror/autocomplete'),codemirror=require('@tslite/codemirror'),editor=require('@tslite/editor'),languageService=require('@tslite/language-service'),jsxRuntime=require('react/jsx-runtime');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var n__namespace=/*#__PURE__*/_interopNamespace(n);var ae={mustache:languageService.mustache,whole:languageService.whole},
|
|
1
|
+
'use strict';var n=require('react'),state=require('@codemirror/state'),view=require('@codemirror/view'),commands=require('@codemirror/commands'),autocomplete=require('@codemirror/autocomplete'),codemirror=require('@tslite/codemirror'),editor=require('@tslite/editor'),languageService=require('@tslite/language-service'),jsxRuntime=require('react/jsx-runtime');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var n__namespace=/*#__PURE__*/_interopNamespace(n);var ae={mustache:languageService.mustache,whole:languageService.whole},ce=t=>typeof t=="function"?t:ae[t];function I(t){let{world:o,service:c,segmenter:i="mustache",mode:s="expression",type:l,optional:d,profile:p,guards:a}=t,u=n__namespace.useMemo(()=>{if(c||!o)return null;let x={world:o,...l!==void 0?{type:l}:{},...d?{optional:d}:{}},S={...p?{profile:p}:{},...a?{guards:a}:{}};return s==="template"?editor.createHostService({...x,...S,mode:s}):editor.createHostService({...x,...S,segmenter:ce(i),mode:s})},[c,o,i,s,l,d,p,a]);return n__namespace.useEffect(()=>u?()=>u.dispose():void 0,[u]),c??u}var we=view.EditorView.theme({".cm-scroller":{overflowX:"auto",overflowY:"hidden"},".cm-content":{padding:"6px 8px"},".cm-line":{padding:"0"},"&.cm-focused":{outline:"none"}}),z=6,Oe=view.EditorView.theme({".cm-scroller":{overflowY:"auto"},".cm-content":{padding:`${z}px 8px`},".cm-line":{padding:"0"},"&.cm-focused":{outline:"none"}}),Ce=(t,o)=>`${o*t.defaultLineHeight+2*z}px`,Le=view.EditorView.theme({"&":{height:"100%"},".cm-scroller":{overflowY:"auto"},".cm-content":{padding:"8px"},"&.cm-focused":{outline:"none"}}),$=t=>t.replace(/\r?\n/g," "),Te=(t,o)=>{if(t===false)return [];let c=o==="block"?{}:{tab:false,indentOnInput:false};return codemirror.codeEditing(typeof t=="object"?{...c,...t}:c)},ke=t=>t?codemirror.gutters(typeof t=="object"?t:{}):[];function V(t){let{value:o,onChange:c,onCommit:i,layout:s="inline",maxLines:l,wrap:d=s!=="inline",editing:p,gutters:a,readOnly:u=false,placeholder:x,features:S,tooltipParent:T,onTokenAction:_,isTokenActionable:U,definition:k,extensions:ee}=t,h=I(t),H=n__namespace.useRef(null),v=n__namespace.useRef(null),[Y,G]=n__namespace.useState(null),[te,oe]=n__namespace.useState(false),R=n__namespace.useRef({value:o,onChange:c,onCommit:i,onTokenAction:_,isTokenActionable:U});R.current={value:o,onChange:c,onCommit:i,onTokenAction:_,isTokenActionable:U};let P=n__namespace.useCallback(e=>{let{value:r,onCommit:y}=R.current;if(!y)return;let g=e.state.doc.toString();g!==r&&y(g);},[]),f=n__namespace.useRef({service:new state.Compartment,layout:new state.Compartment,editable:new state.Compartment,actions:new state.Compartment}).current,M=n__namespace.useCallback(e=>e?codemirror.languageService(e,{theme:editor.tsliteTokenStyles,...T!==null?{tooltipParent:T??(typeof document<"u"?document.body:void 0)}:{},...S}):[],[S,T]),N=n__namespace.useCallback(e=>autocomplete.completionStatus(e.state)==="active"?autocomplete.acceptCompletion(e)||true:(P(e),true),[P]),A=n__namespace.useCallback((e,r,y,g)=>[e==="block"?[...r?[view.EditorView.lineWrapping]:[],Le]:e==="grow"?[...r?[view.EditorView.lineWrapping]:[],Oe,state.Prec.highest(view.keymap.of([{key:"Enter",run:N},{key:"Shift-Enter",run:commands.insertNewlineAndIndent}]))]:[codemirror.singleLine,we],Te(y,e),ke(g)],[N]),D=n__namespace.useCallback(()=>{let e=[];return R.current.onTokenAction&&e.push(codemirror.tokenAction({actionable:r=>R.current.isTokenActionable?.(r)??true,onAction:r=>R.current.onTokenAction?.(r)})),k&&h?.definitionAt&&e.push(codemirror.gotoDefinition(k)),e},[k,h]);n__namespace.useEffect(()=>{if(!H.current)return;let e=new view.EditorView({parent:H.current,state:state.EditorState.create({doc:s==="inline"?$(o):o,extensions:[commands.history(),f.service.of(M(h)),f.layout.of(A(s,d,p,a)),f.editable.of(view.EditorView.editable.of(!u)),f.actions.of(D()),...x?[view.placeholder(x)]:[],view.keymap.of([...commands.historyKeymap,...commands.defaultKeymap]),view.EditorView.updateListener.of(r=>{if(r.focusChanged&&oe(r.view.hasFocus),!r.docChanged)return;r.transactions.some(g=>g.annotation(codemirror.externalChange))||R.current.onChange?.(r.state.doc.toString());}),view.EditorView.contentAttributes.of({"aria-label":x??"expression"}),view.EditorView.domEventHandlers({blur:(r,y)=>{let g=r.relatedTarget;return g instanceof Element&&(y.dom.contains(g)||g.closest(".cm-tooltip"))||P(y),false}}),...ee??[]]})});return v.current=e,G(e),()=>{e.destroy(),v.current=null,G(null);}},[]),n__namespace.useEffect(()=>{v.current?.dispatch({effects:f.service.reconfigure(M(h))});},[h,M,f]),n__namespace.useEffect(()=>{v.current?.dispatch({effects:f.layout.reconfigure(A(s,d,p,a))});},[s,d,p,a,A,f]),n__namespace.useEffect(()=>{v.current?.dispatch({effects:f.editable.reconfigure(view.EditorView.editable.of(!u))});},[u,f]),n__namespace.useEffect(()=>{let e=v.current;e&&(e.scrollDOM.style.maxHeight=s==="grow"&&l!==void 0&&l>0?Ce(e,l):"");},[s,l,Y]),n__namespace.useEffect(()=>{v.current?.dispatch({effects:f.actions.reconfigure(D())});},[D,f]),n__namespace.useEffect(()=>{let e=v.current;if(!e)return;let r=s==="inline"?$(o):o;if(r===e.state.doc.toString())return;let{anchor:y,head:g}=e.state.selection.main,K=re=>Math.min(re,r.length);e.dispatch({changes:{from:0,to:e.state.doc.length,insert:r},selection:{anchor:K(y),head:K(g)},annotations:codemirror.externalChange.of(true)});},[o,s]);let ne=n__namespace.useCallback(()=>v.current?.focus(),[]);return {ref:H,view:Y,focused:te,service:h,focus:ne}}var X=n__namespace.createContext(null);function q(){let t=n__namespace.useContext(X);if(!t)throw new Error("useFieldContext must be used inside <ExpressionField.Root>");return t}var He=["value","onChange","onCommit","layout","maxLines","wrap","editing","gutters","readOnly","placeholder","features","tooltipParent","onTokenAction","isTokenActionable","definition","extensions","world","service","segmenter","mode","type","optional","profile","guards"];var J=n__namespace.forwardRef(function(o,c){let{children:i,...s}=o,l={},d={};for(let[a,u]of Object.entries(s))(He.includes(a)?l:d)[a]=u;let p=V(l);return jsxRuntime.jsx(X.Provider,{value:p,children:jsxRuntime.jsx("div",{ref:c,...d,children:typeof i=="function"?i(p):i})})}),Q=n__namespace.forwardRef(function(o,c){let i=q();return jsxRuntime.jsx("div",{ref:i.ref,...o})}),Z=n__namespace.forwardRef(function({children:o,...c},i){return jsxRuntime.jsx("button",{ref:i,type:"button",...c,children:o})}),F={Root:J,Editor:Q,ExpandTrigger:Z};var E={fg:"var(--foreground, #cccccc)",mutedFg:"var(--muted-foreground, #8b8b8b)",border:"var(--border, #2b2b2b)",ring:"var(--ring, #0078d4)",input:"var(--input, transparent)",destructive:"var(--destructive, #f14c4c)",font:"var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace)"},Pe=["--foreground","--muted-foreground","--border","--ring","--input","--destructive","--font-mono","--muted","--popover","--popover-foreground","--primary","--primary-foreground","--secondary","--accent"];var Me=jsxRuntime.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7"})});function Ae({invalid:t,className:o,style:c,onExpand:i,expandIcon:s,multiline:l,layout:d,...p}){let a=d??(l?"block":"inline");return jsxRuntime.jsx(F.Root,{...p,layout:a,className:o,children:u=>jsxRuntime.jsxs("div",{style:{position:"relative",border:`1px solid ${t?E.destructive:u.focused?E.ring:E.border}`,borderRadius:"6px",backgroundColor:E.input,color:E.fg,fontFamily:E.font,fontSize:"13px",overflow:"hidden",...a==="block"?{height:"100%",display:"flex",flexDirection:"column"}:{},...c},children:[jsxRuntime.jsx(F.Editor,{style:a==="block"?{flex:1,minHeight:0}:a==="grow"?{paddingRight:i?"28px":void 0}:{paddingRight:i?"24px":void 0}}),i&&jsxRuntime.jsx(F.ExpandTrigger,{onClick:i,"aria-label":"Expandir",title:"Expandir",onMouseEnter:x=>x.currentTarget.style.opacity="1",onMouseLeave:x=>x.currentTarget.style.opacity="0.55",style:{position:"absolute",top:a==="inline"?"50%":"6px",right:"4px",transform:a==="inline"?"translateY(-50%)":void 0,display:"flex",alignItems:"center",justifyContent:"center",width:"20px",height:"20px",padding:0,lineHeight:0,border:"none",borderRadius:"4px",background:E.input,color:E.mutedFg,cursor:"pointer",opacity:.55},children:s??Me})]})})}var Ie="1.4.0";exports.CSS_VARS=Pe;exports.ExpressionField=F;exports.ExpressionFieldEditor=Q;exports.ExpressionFieldExpandTrigger=Z;exports.ExpressionFieldRoot=J;exports.ExpressionInput=Ae;exports.V=E;exports.useExpressionField=V;exports.useFieldContext=q;exports.useLanguageService=I;exports.version=Ie;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { U as UseExpressionFieldOptions, E as ExpressionFieldHandle } from './useExpressionField-
|
|
3
|
-
export { F as FieldLayout, L as LanguageServiceOptions, S as SegmenterOption, u as useExpressionField, a as useLanguageService } from './useExpressionField-
|
|
2
|
+
import { U as UseExpressionFieldOptions, E as ExpressionFieldHandle } from './useExpressionField-BfIHCVtU.cjs';
|
|
3
|
+
export { F as FieldLayout, L as LanguageServiceOptions, S as SegmenterOption, u as useExpressionField, a as useLanguageService } from './useExpressionField-BfIHCVtU.cjs';
|
|
4
4
|
export { TokenActionTarget } from '@tslite/codemirror';
|
|
5
5
|
import '@codemirror/state';
|
|
6
6
|
import '@codemirror/view';
|
|
@@ -31,9 +31,9 @@ interface ExpressionInputProps extends UseExpressionFieldOptions {
|
|
|
31
31
|
* O campo de expressão pronto para uso.
|
|
32
32
|
*
|
|
33
33
|
* ```tsx
|
|
34
|
-
* <ExpressionInput value={v} onChange={setV}
|
|
35
|
-
* <ExpressionInput value={v} onChange={setV}
|
|
36
|
-
* <ExpressionInput value={v} onChange={setV}
|
|
34
|
+
* <ExpressionInput value={v} onChange={setV} world={world} /> // "Olá {{ user.name }}"
|
|
35
|
+
* <ExpressionInput value={v} onChange={setV} world={world} segmenter="whole" /> // "foo.bar >= 32"
|
|
36
|
+
* <ExpressionInput value={v} onChange={setV} world={world} layout="block" /> // o modal expandido
|
|
37
37
|
* ```
|
|
38
38
|
*/
|
|
39
39
|
declare function ExpressionInput({ invalid, className, style, onExpand, expandIcon, multiline, layout, ...options }: ExpressionInputProps): React.JSX.Element;
|
|
@@ -93,6 +93,6 @@ declare const V: {
|
|
|
93
93
|
declare const CSS_VARS: readonly ["--foreground", "--muted-foreground", "--border", "--ring", "--input", "--destructive", "--font-mono", "--muted", "--popover", "--popover-foreground", "--primary", "--primary-foreground", "--secondary", "--accent"];
|
|
94
94
|
|
|
95
95
|
/** A versão deste package, a do módulo de fato carregado. */
|
|
96
|
-
declare const version = "1.
|
|
96
|
+
declare const version = "1.4.0";
|
|
97
97
|
|
|
98
98
|
export { CSS_VARS, ExpressionField, Editor as ExpressionFieldEditor, type EditorProps as ExpressionFieldEditorProps, ExpandTrigger as ExpressionFieldExpandTrigger, type ExpandTriggerProps as ExpressionFieldExpandTriggerProps, ExpressionFieldHandle, Root as ExpressionFieldRoot, type RootProps as ExpressionFieldRootProps, ExpressionInput, type ExpressionInputProps, UseExpressionFieldOptions, V, useFieldContext, version };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { U as UseExpressionFieldOptions, E as ExpressionFieldHandle } from './useExpressionField-
|
|
3
|
-
export { F as FieldLayout, L as LanguageServiceOptions, S as SegmenterOption, u as useExpressionField, a as useLanguageService } from './useExpressionField-
|
|
2
|
+
import { U as UseExpressionFieldOptions, E as ExpressionFieldHandle } from './useExpressionField-BfIHCVtU.js';
|
|
3
|
+
export { F as FieldLayout, L as LanguageServiceOptions, S as SegmenterOption, u as useExpressionField, a as useLanguageService } from './useExpressionField-BfIHCVtU.js';
|
|
4
4
|
export { TokenActionTarget } from '@tslite/codemirror';
|
|
5
5
|
import '@codemirror/state';
|
|
6
6
|
import '@codemirror/view';
|
|
@@ -31,9 +31,9 @@ interface ExpressionInputProps extends UseExpressionFieldOptions {
|
|
|
31
31
|
* O campo de expressão pronto para uso.
|
|
32
32
|
*
|
|
33
33
|
* ```tsx
|
|
34
|
-
* <ExpressionInput value={v} onChange={setV}
|
|
35
|
-
* <ExpressionInput value={v} onChange={setV}
|
|
36
|
-
* <ExpressionInput value={v} onChange={setV}
|
|
34
|
+
* <ExpressionInput value={v} onChange={setV} world={world} /> // "Olá {{ user.name }}"
|
|
35
|
+
* <ExpressionInput value={v} onChange={setV} world={world} segmenter="whole" /> // "foo.bar >= 32"
|
|
36
|
+
* <ExpressionInput value={v} onChange={setV} world={world} layout="block" /> // o modal expandido
|
|
37
37
|
* ```
|
|
38
38
|
*/
|
|
39
39
|
declare function ExpressionInput({ invalid, className, style, onExpand, expandIcon, multiline, layout, ...options }: ExpressionInputProps): React.JSX.Element;
|
|
@@ -93,6 +93,6 @@ declare const V: {
|
|
|
93
93
|
declare const CSS_VARS: readonly ["--foreground", "--muted-foreground", "--border", "--ring", "--input", "--destructive", "--font-mono", "--muted", "--popover", "--popover-foreground", "--primary", "--primary-foreground", "--secondary", "--accent"];
|
|
94
94
|
|
|
95
95
|
/** A versão deste package, a do módulo de fato carregado. */
|
|
96
|
-
declare const version = "1.
|
|
96
|
+
declare const version = "1.4.0";
|
|
97
97
|
|
|
98
98
|
export { CSS_VARS, ExpressionField, Editor as ExpressionFieldEditor, type EditorProps as ExpressionFieldEditorProps, ExpandTrigger as ExpressionFieldExpandTrigger, type ExpandTriggerProps as ExpressionFieldExpandTriggerProps, ExpressionFieldHandle, Root as ExpressionFieldRoot, type RootProps as ExpressionFieldRootProps, ExpressionInput, type ExpressionInputProps, UseExpressionFieldOptions, V, useFieldContext, version };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as n from'react';import {Compartment,Prec,EditorState}from'@codemirror/state';import {EditorView,keymap,placeholder}from'@codemirror/view';import {insertNewlineAndIndent,history,historyKeymap,defaultKeymap}from'@codemirror/commands';import {completionStatus,acceptCompletion}from'@codemirror/autocomplete';import {languageService,singleLine,tokenAction,gotoDefinition,externalChange,codeEditing,gutters}from'@tslite/codemirror';import {tsliteTokenStyles,createHostService}from'@tslite/editor';import {whole,mustache}from'@tslite/language-service';import {jsx,jsxs}from'react/jsx-runtime';var ae={mustache:mustache,whole:whole},
|
|
1
|
+
import*as n from'react';import {Compartment,Prec,EditorState}from'@codemirror/state';import {EditorView,keymap,placeholder}from'@codemirror/view';import {insertNewlineAndIndent,history,historyKeymap,defaultKeymap}from'@codemirror/commands';import {completionStatus,acceptCompletion}from'@codemirror/autocomplete';import {languageService,singleLine,tokenAction,gotoDefinition,externalChange,codeEditing,gutters}from'@tslite/codemirror';import {tsliteTokenStyles,createHostService}from'@tslite/editor';import {whole,mustache}from'@tslite/language-service';import {jsx,jsxs}from'react/jsx-runtime';var ae={mustache:mustache,whole:whole},ce=t=>typeof t=="function"?t:ae[t];function I(t){let{world:o,service:c,segmenter:i="mustache",mode:s="expression",type:l,optional:d,profile:p,guards:a}=t,u=n.useMemo(()=>{if(c||!o)return null;let x={world:o,...l!==void 0?{type:l}:{},...d?{optional:d}:{}},S={...p?{profile:p}:{},...a?{guards:a}:{}};return s==="template"?createHostService({...x,...S,mode:s}):createHostService({...x,...S,segmenter:ce(i),mode:s})},[c,o,i,s,l,d,p,a]);return n.useEffect(()=>u?()=>u.dispose():void 0,[u]),c??u}var we=EditorView.theme({".cm-scroller":{overflowX:"auto",overflowY:"hidden"},".cm-content":{padding:"6px 8px"},".cm-line":{padding:"0"},"&.cm-focused":{outline:"none"}}),z=6,Oe=EditorView.theme({".cm-scroller":{overflowY:"auto"},".cm-content":{padding:`${z}px 8px`},".cm-line":{padding:"0"},"&.cm-focused":{outline:"none"}}),Ce=(t,o)=>`${o*t.defaultLineHeight+2*z}px`,Le=EditorView.theme({"&":{height:"100%"},".cm-scroller":{overflowY:"auto"},".cm-content":{padding:"8px"},"&.cm-focused":{outline:"none"}}),$=t=>t.replace(/\r?\n/g," "),Te=(t,o)=>{if(t===false)return [];let c=o==="block"?{}:{tab:false,indentOnInput:false};return codeEditing(typeof t=="object"?{...c,...t}:c)},ke=t=>t?gutters(typeof t=="object"?t:{}):[];function V(t){let{value:o,onChange:c,onCommit:i,layout:s="inline",maxLines:l,wrap:d=s!=="inline",editing:p,gutters:a,readOnly:u=false,placeholder:x,features:S,tooltipParent:T,onTokenAction:_,isTokenActionable:U,definition:k,extensions:ee}=t,h=I(t),H=n.useRef(null),v=n.useRef(null),[Y,G]=n.useState(null),[te,oe]=n.useState(false),R=n.useRef({value:o,onChange:c,onCommit:i,onTokenAction:_,isTokenActionable:U});R.current={value:o,onChange:c,onCommit:i,onTokenAction:_,isTokenActionable:U};let P=n.useCallback(e=>{let{value:r,onCommit:y}=R.current;if(!y)return;let g=e.state.doc.toString();g!==r&&y(g);},[]),f=n.useRef({service:new Compartment,layout:new Compartment,editable:new Compartment,actions:new Compartment}).current,M=n.useCallback(e=>e?languageService(e,{theme:tsliteTokenStyles,...T!==null?{tooltipParent:T??(typeof document<"u"?document.body:void 0)}:{},...S}):[],[S,T]),N=n.useCallback(e=>completionStatus(e.state)==="active"?acceptCompletion(e)||true:(P(e),true),[P]),A=n.useCallback((e,r,y,g)=>[e==="block"?[...r?[EditorView.lineWrapping]:[],Le]:e==="grow"?[...r?[EditorView.lineWrapping]:[],Oe,Prec.highest(keymap.of([{key:"Enter",run:N},{key:"Shift-Enter",run:insertNewlineAndIndent}]))]:[singleLine,we],Te(y,e),ke(g)],[N]),D=n.useCallback(()=>{let e=[];return R.current.onTokenAction&&e.push(tokenAction({actionable:r=>R.current.isTokenActionable?.(r)??true,onAction:r=>R.current.onTokenAction?.(r)})),k&&h?.definitionAt&&e.push(gotoDefinition(k)),e},[k,h]);n.useEffect(()=>{if(!H.current)return;let e=new EditorView({parent:H.current,state:EditorState.create({doc:s==="inline"?$(o):o,extensions:[history(),f.service.of(M(h)),f.layout.of(A(s,d,p,a)),f.editable.of(EditorView.editable.of(!u)),f.actions.of(D()),...x?[placeholder(x)]:[],keymap.of([...historyKeymap,...defaultKeymap]),EditorView.updateListener.of(r=>{if(r.focusChanged&&oe(r.view.hasFocus),!r.docChanged)return;r.transactions.some(g=>g.annotation(externalChange))||R.current.onChange?.(r.state.doc.toString());}),EditorView.contentAttributes.of({"aria-label":x??"expression"}),EditorView.domEventHandlers({blur:(r,y)=>{let g=r.relatedTarget;return g instanceof Element&&(y.dom.contains(g)||g.closest(".cm-tooltip"))||P(y),false}}),...ee??[]]})});return v.current=e,G(e),()=>{e.destroy(),v.current=null,G(null);}},[]),n.useEffect(()=>{v.current?.dispatch({effects:f.service.reconfigure(M(h))});},[h,M,f]),n.useEffect(()=>{v.current?.dispatch({effects:f.layout.reconfigure(A(s,d,p,a))});},[s,d,p,a,A,f]),n.useEffect(()=>{v.current?.dispatch({effects:f.editable.reconfigure(EditorView.editable.of(!u))});},[u,f]),n.useEffect(()=>{let e=v.current;e&&(e.scrollDOM.style.maxHeight=s==="grow"&&l!==void 0&&l>0?Ce(e,l):"");},[s,l,Y]),n.useEffect(()=>{v.current?.dispatch({effects:f.actions.reconfigure(D())});},[D,f]),n.useEffect(()=>{let e=v.current;if(!e)return;let r=s==="inline"?$(o):o;if(r===e.state.doc.toString())return;let{anchor:y,head:g}=e.state.selection.main,K=re=>Math.min(re,r.length);e.dispatch({changes:{from:0,to:e.state.doc.length,insert:r},selection:{anchor:K(y),head:K(g)},annotations:externalChange.of(true)});},[o,s]);let ne=n.useCallback(()=>v.current?.focus(),[]);return {ref:H,view:Y,focused:te,service:h,focus:ne}}var X=n.createContext(null);function q(){let t=n.useContext(X);if(!t)throw new Error("useFieldContext must be used inside <ExpressionField.Root>");return t}var He=["value","onChange","onCommit","layout","maxLines","wrap","editing","gutters","readOnly","placeholder","features","tooltipParent","onTokenAction","isTokenActionable","definition","extensions","world","service","segmenter","mode","type","optional","profile","guards"];var J=n.forwardRef(function(o,c){let{children:i,...s}=o,l={},d={};for(let[a,u]of Object.entries(s))(He.includes(a)?l:d)[a]=u;let p=V(l);return jsx(X.Provider,{value:p,children:jsx("div",{ref:c,...d,children:typeof i=="function"?i(p):i})})}),Q=n.forwardRef(function(o,c){let i=q();return jsx("div",{ref:i.ref,...o})}),Z=n.forwardRef(function({children:o,...c},i){return jsx("button",{ref:i,type:"button",...c,children:o})}),F={Root:J,Editor:Q,ExpandTrigger:Z};var E={fg:"var(--foreground, #cccccc)",mutedFg:"var(--muted-foreground, #8b8b8b)",border:"var(--border, #2b2b2b)",ring:"var(--ring, #0078d4)",input:"var(--input, transparent)",destructive:"var(--destructive, #f14c4c)",font:"var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace)"},Pe=["--foreground","--muted-foreground","--border","--ring","--input","--destructive","--font-mono","--muted","--popover","--popover-foreground","--primary","--primary-foreground","--secondary","--accent"];var Me=jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:jsx("path",{d:"M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7"})});function Ae({invalid:t,className:o,style:c,onExpand:i,expandIcon:s,multiline:l,layout:d,...p}){let a=d??(l?"block":"inline");return jsx(F.Root,{...p,layout:a,className:o,children:u=>jsxs("div",{style:{position:"relative",border:`1px solid ${t?E.destructive:u.focused?E.ring:E.border}`,borderRadius:"6px",backgroundColor:E.input,color:E.fg,fontFamily:E.font,fontSize:"13px",overflow:"hidden",...a==="block"?{height:"100%",display:"flex",flexDirection:"column"}:{},...c},children:[jsx(F.Editor,{style:a==="block"?{flex:1,minHeight:0}:a==="grow"?{paddingRight:i?"28px":void 0}:{paddingRight:i?"24px":void 0}}),i&&jsx(F.ExpandTrigger,{onClick:i,"aria-label":"Expandir",title:"Expandir",onMouseEnter:x=>x.currentTarget.style.opacity="1",onMouseLeave:x=>x.currentTarget.style.opacity="0.55",style:{position:"absolute",top:a==="inline"?"50%":"6px",right:"4px",transform:a==="inline"?"translateY(-50%)":void 0,display:"flex",alignItems:"center",justifyContent:"center",width:"20px",height:"20px",padding:0,lineHeight:0,border:"none",borderRadius:"4px",background:E.input,color:E.mutedFg,cursor:"pointer",opacity:.55},children:s??Me})]})})}var Ie="1.4.0";export{Pe as CSS_VARS,F as ExpressionField,Q as ExpressionFieldEditor,Z as ExpressionFieldExpandTrigger,J as ExpressionFieldRoot,Ae as ExpressionInput,E as V,V as useExpressionField,q as useFieldContext,I as useLanguageService,Ie as version};
|
|
@@ -3,7 +3,7 @@ import { Extension } from '@codemirror/state';
|
|
|
3
3
|
import { EditorView } from '@codemirror/view';
|
|
4
4
|
import { CodeEditingOptions, GuttersOptions, LanguageServiceOptions as LanguageServiceOptions$1, TokenActionTarget, GotoDefinitionOptions } from '@tslite/codemirror';
|
|
5
5
|
import { Segmenter, LanguageService, Token } from '@tslite/language-service';
|
|
6
|
-
import { HostServiceOptions } from '@tslite/editor';
|
|
6
|
+
import { HostServiceOptions, HostServiceCodeOptions } from '@tslite/editor';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Onde, no texto, mora o código.
|
|
@@ -16,14 +16,16 @@ type SegmenterOption = "mustache" | "whole" | Segmenter;
|
|
|
16
16
|
/** O que define o cérebro do campo. */
|
|
17
17
|
interface LanguageServiceOptions {
|
|
18
18
|
/**
|
|
19
|
-
* O
|
|
19
|
+
* O mundo em que o campo se tipa (`createWorld` do `@tslite/editor`): a lib da
|
|
20
|
+
* cópia do tsc, o `.d.ts` do `std` e as declarações do host. Os campos de uma
|
|
21
|
+
* tela dividem o mesmo mundo, e cada um é um arquivo virtual dele.
|
|
20
22
|
*
|
|
21
|
-
* **
|
|
22
|
-
*
|
|
23
|
+
* **Crie-o uma vez** (fora do render, ou num `useMemo`). Um mundo novo a cada
|
|
24
|
+
* render reconstrói o serviço e reparseia a lib.
|
|
23
25
|
*/
|
|
24
|
-
readonly
|
|
26
|
+
readonly world?: HostServiceOptions["world"];
|
|
25
27
|
/**
|
|
26
|
-
* Um serviço pronto, no lugar do `
|
|
28
|
+
* Um serviço pronto, no lugar do `world`. Tem precedência — e é o caminho para
|
|
27
29
|
* trocar o cérebro por outro (outra linguagem, outra implementação).
|
|
28
30
|
*/
|
|
29
31
|
readonly service?: LanguageService;
|
|
@@ -53,19 +55,12 @@ interface LanguageServiceOptions {
|
|
|
53
55
|
*/
|
|
54
56
|
readonly mode?: "expression" | "program" | "template";
|
|
55
57
|
/**
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
readonly profile?: HostServiceOptions["profile"];
|
|
63
|
-
/** Limites estruturais (anti-DoS). */
|
|
64
|
-
readonly limits?: HostServiceOptions["limits"];
|
|
65
|
-
/** Bindings nunca lidos. Ligado por padrão (é API de editor). */
|
|
66
|
-
readonly unused?: HostServiceOptions["unused"];
|
|
67
|
-
/** O formatador (`formatExpression` do `@tslite/format`). Sem ele, não formata. */
|
|
68
|
-
readonly format?: HostServiceOptions["format"];
|
|
58
|
+
* O tipo que o valor do campo tem de ter, como o texto de um tipo
|
|
59
|
+
* (`"boolean"`, `"Address"`): o campo acusa, enquanto se digita, o valor que
|
|
60
|
+
* não cabe nele. Vale para a expressão e para o template; um programa não tem
|
|
61
|
+
* valor. Sem ele, o campo aceita qualquer tipo.
|
|
62
|
+
*/
|
|
63
|
+
readonly type?: HostServiceOptions["type"];
|
|
69
64
|
/**
|
|
70
65
|
* O campo aceita ficar vazio: o texto vazio, ou só com espaços, é a ausência do
|
|
71
66
|
* valor, e não o erro de "falta a expressão". Padrão: `false`. As sugestões no
|
|
@@ -73,10 +68,33 @@ interface LanguageServiceOptions {
|
|
|
73
68
|
* (`createHostService({ optional })`).
|
|
74
69
|
*/
|
|
75
70
|
readonly optional?: HostServiceOptions["optional"];
|
|
71
|
+
/**
|
|
72
|
+
* O perfil de capability do campo (o `@tslite/capability`): o que o campo pode
|
|
73
|
+
* escrever. O que ele recusa sai nos diagnósticos, enquanto se digita, sobre o
|
|
74
|
+
* texto que parseia (a E32 do `@tslite/editor`), com o veredito do executor e o da
|
|
75
|
+
* camada de controle. Sem padrão: sem ele, nada se poda (R18).
|
|
76
|
+
*
|
|
77
|
+
* **Crie-o uma vez**, como o `world`: um perfil novo a cada render reconstrói o
|
|
78
|
+
* serviço. No `mode: "template"`, ele julga o que o template desaçucara (o `map`
|
|
79
|
+
* de um `{% for %}`), como o executor, e a violação pousa na diretiva (a E34 do
|
|
80
|
+
* `@tslite/editor`). Com `service`, o perfil é de quem montou o serviço.
|
|
81
|
+
*/
|
|
82
|
+
readonly profile?: HostServiceCodeOptions["profile"];
|
|
83
|
+
/**
|
|
84
|
+
* As regras a mais da camada de controle do `@tslite/behavior` (as de forma, as da
|
|
85
|
+
* aplicação), nos diagnósticos como as do perfil. Valem as mesmas regras do
|
|
86
|
+
* `profile`: crie-as uma vez.
|
|
87
|
+
*/
|
|
88
|
+
readonly guards?: HostServiceCodeOptions["guards"];
|
|
76
89
|
}
|
|
77
90
|
/**
|
|
78
|
-
* O `LanguageService` do campo. `null` quando não há `
|
|
91
|
+
* O `LanguageService` do campo. `null` quando não há `world` nem `service` — o
|
|
79
92
|
* editor continua editando texto, só sem inteligência.
|
|
93
|
+
*
|
|
94
|
+
* O serviço que o hook monta põe os arquivos virtuais do campo no mundo; quando
|
|
95
|
+
* ele é trocado (uma opção mudou) ou o campo desmonta, o hook os tira (o
|
|
96
|
+
* `dispose`, E28 do `@tslite/editor`). O `service` passado é de quem o montou, e
|
|
97
|
+
* o hook não o solta.
|
|
80
98
|
*/
|
|
81
99
|
declare function useLanguageService(options: LanguageServiceOptions): LanguageService | null;
|
|
82
100
|
|
|
@@ -3,7 +3,7 @@ import { Extension } from '@codemirror/state';
|
|
|
3
3
|
import { EditorView } from '@codemirror/view';
|
|
4
4
|
import { CodeEditingOptions, GuttersOptions, LanguageServiceOptions as LanguageServiceOptions$1, TokenActionTarget, GotoDefinitionOptions } from '@tslite/codemirror';
|
|
5
5
|
import { Segmenter, LanguageService, Token } from '@tslite/language-service';
|
|
6
|
-
import { HostServiceOptions } from '@tslite/editor';
|
|
6
|
+
import { HostServiceOptions, HostServiceCodeOptions } from '@tslite/editor';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Onde, no texto, mora o código.
|
|
@@ -16,14 +16,16 @@ type SegmenterOption = "mustache" | "whole" | Segmenter;
|
|
|
16
16
|
/** O que define o cérebro do campo. */
|
|
17
17
|
interface LanguageServiceOptions {
|
|
18
18
|
/**
|
|
19
|
-
* O
|
|
19
|
+
* O mundo em que o campo se tipa (`createWorld` do `@tslite/editor`): a lib da
|
|
20
|
+
* cópia do tsc, o `.d.ts` do `std` e as declarações do host. Os campos de uma
|
|
21
|
+
* tela dividem o mesmo mundo, e cada um é um arquivo virtual dele.
|
|
20
22
|
*
|
|
21
|
-
* **
|
|
22
|
-
*
|
|
23
|
+
* **Crie-o uma vez** (fora do render, ou num `useMemo`). Um mundo novo a cada
|
|
24
|
+
* render reconstrói o serviço e reparseia a lib.
|
|
23
25
|
*/
|
|
24
|
-
readonly
|
|
26
|
+
readonly world?: HostServiceOptions["world"];
|
|
25
27
|
/**
|
|
26
|
-
* Um serviço pronto, no lugar do `
|
|
28
|
+
* Um serviço pronto, no lugar do `world`. Tem precedência — e é o caminho para
|
|
27
29
|
* trocar o cérebro por outro (outra linguagem, outra implementação).
|
|
28
30
|
*/
|
|
29
31
|
readonly service?: LanguageService;
|
|
@@ -53,19 +55,12 @@ interface LanguageServiceOptions {
|
|
|
53
55
|
*/
|
|
54
56
|
readonly mode?: "expression" | "program" | "template";
|
|
55
57
|
/**
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
readonly profile?: HostServiceOptions["profile"];
|
|
63
|
-
/** Limites estruturais (anti-DoS). */
|
|
64
|
-
readonly limits?: HostServiceOptions["limits"];
|
|
65
|
-
/** Bindings nunca lidos. Ligado por padrão (é API de editor). */
|
|
66
|
-
readonly unused?: HostServiceOptions["unused"];
|
|
67
|
-
/** O formatador (`formatExpression` do `@tslite/format`). Sem ele, não formata. */
|
|
68
|
-
readonly format?: HostServiceOptions["format"];
|
|
58
|
+
* O tipo que o valor do campo tem de ter, como o texto de um tipo
|
|
59
|
+
* (`"boolean"`, `"Address"`): o campo acusa, enquanto se digita, o valor que
|
|
60
|
+
* não cabe nele. Vale para a expressão e para o template; um programa não tem
|
|
61
|
+
* valor. Sem ele, o campo aceita qualquer tipo.
|
|
62
|
+
*/
|
|
63
|
+
readonly type?: HostServiceOptions["type"];
|
|
69
64
|
/**
|
|
70
65
|
* O campo aceita ficar vazio: o texto vazio, ou só com espaços, é a ausência do
|
|
71
66
|
* valor, e não o erro de "falta a expressão". Padrão: `false`. As sugestões no
|
|
@@ -73,10 +68,33 @@ interface LanguageServiceOptions {
|
|
|
73
68
|
* (`createHostService({ optional })`).
|
|
74
69
|
*/
|
|
75
70
|
readonly optional?: HostServiceOptions["optional"];
|
|
71
|
+
/**
|
|
72
|
+
* O perfil de capability do campo (o `@tslite/capability`): o que o campo pode
|
|
73
|
+
* escrever. O que ele recusa sai nos diagnósticos, enquanto se digita, sobre o
|
|
74
|
+
* texto que parseia (a E32 do `@tslite/editor`), com o veredito do executor e o da
|
|
75
|
+
* camada de controle. Sem padrão: sem ele, nada se poda (R18).
|
|
76
|
+
*
|
|
77
|
+
* **Crie-o uma vez**, como o `world`: um perfil novo a cada render reconstrói o
|
|
78
|
+
* serviço. No `mode: "template"`, ele julga o que o template desaçucara (o `map`
|
|
79
|
+
* de um `{% for %}`), como o executor, e a violação pousa na diretiva (a E34 do
|
|
80
|
+
* `@tslite/editor`). Com `service`, o perfil é de quem montou o serviço.
|
|
81
|
+
*/
|
|
82
|
+
readonly profile?: HostServiceCodeOptions["profile"];
|
|
83
|
+
/**
|
|
84
|
+
* As regras a mais da camada de controle do `@tslite/behavior` (as de forma, as da
|
|
85
|
+
* aplicação), nos diagnósticos como as do perfil. Valem as mesmas regras do
|
|
86
|
+
* `profile`: crie-as uma vez.
|
|
87
|
+
*/
|
|
88
|
+
readonly guards?: HostServiceCodeOptions["guards"];
|
|
76
89
|
}
|
|
77
90
|
/**
|
|
78
|
-
* O `LanguageService` do campo. `null` quando não há `
|
|
91
|
+
* O `LanguageService` do campo. `null` quando não há `world` nem `service` — o
|
|
79
92
|
* editor continua editando texto, só sem inteligência.
|
|
93
|
+
*
|
|
94
|
+
* O serviço que o hook monta põe os arquivos virtuais do campo no mundo; quando
|
|
95
|
+
* ele é trocado (uma opção mudou) ou o campo desmonta, o hook os tira (o
|
|
96
|
+
* `dispose`, E28 do `@tslite/editor`). O `service` passado é de quem o montou, e
|
|
97
|
+
* o hook não o solta.
|
|
80
98
|
*/
|
|
81
99
|
declare function useLanguageService(options: LanguageServiceOptions): LanguageService | null;
|
|
82
100
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tslite/react",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "React bindings for TSLite — a headless expression field (CodeMirror 6) with type-aware highlighting, completion, diagnostics and quick-fixes, driven by the TSLite
|
|
3
|
+
"version": "1.4.0",
|
|
4
|
+
"description": "React bindings for TSLite — a headless expression field (CodeMirror 6) with type-aware highlighting, completion, diagnostics and quick-fixes, driven by the TypeScript language service ported to TSLite.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
7
7
|
"module": "./dist/index.js",
|
|
@@ -47,10 +47,9 @@
|
|
|
47
47
|
"access": "public"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@tslite/
|
|
51
|
-
"@tslite/
|
|
52
|
-
"@tslite/
|
|
53
|
-
"@tslite/language-service": "1.2.0"
|
|
50
|
+
"@tslite/editor": "^1.6.0",
|
|
51
|
+
"@tslite/language-service": "^1.2.0",
|
|
52
|
+
"@tslite/codemirror": "^1.3.0"
|
|
54
53
|
},
|
|
55
54
|
"peerDependencies": {
|
|
56
55
|
"@codemirror/autocomplete": "^6.0.0",
|
|
@@ -76,7 +75,8 @@
|
|
|
76
75
|
"@types/react-dom": "^18.3.1",
|
|
77
76
|
"react": "^18.3.1",
|
|
78
77
|
"react-dom": "^18.3.1",
|
|
79
|
-
"@tslite/
|
|
78
|
+
"@tslite/std": "1.4.0",
|
|
79
|
+
"@tslite/checker": "1.12.0"
|
|
80
80
|
},
|
|
81
81
|
"peerDependenciesMeta": {
|
|
82
82
|
"@codemirror/search": {
|