@vuu-ui/vuu-codemirror 0.8.34 → 0.8.36

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.
Files changed (60) hide show
  1. package/README.md +0 -0
  2. package/cjs/codemirror-basic-setup.js +22 -0
  3. package/cjs/codemirror-basic-setup.js.map +1 -0
  4. package/cjs/index.js +118 -0
  5. package/cjs/{packages/vuu-codemirror/src/index.js.map → index.js.map} +1 -1
  6. package/cjs/parser-utils.js.map +1 -0
  7. package/cjs/{packages/vuu-codemirror/src/suggestion-utils.js → suggestion-utils.js} +2 -2
  8. package/cjs/suggestion-utils.js.map +1 -0
  9. package/esm/codemirror-basic-setup.js +20 -0
  10. package/esm/codemirror-basic-setup.js.map +1 -0
  11. package/esm/{packages/vuu-codemirror/src/index.js → index.js} +6 -6
  12. package/esm/parser-utils.js.map +1 -0
  13. package/esm/{packages/vuu-codemirror/src/suggestion-utils.js → suggestion-utils.js} +1 -1
  14. package/esm/suggestion-utils.js.map +1 -0
  15. package/package.json +5 -4
  16. package/types/index.d.ts +3 -3
  17. package/cjs/node_modules/@codemirror/autocomplete/dist/index.js +0 -1519
  18. package/cjs/node_modules/@codemirror/autocomplete/dist/index.js.map +0 -1
  19. package/cjs/node_modules/@codemirror/commands/dist/index.js +0 -1476
  20. package/cjs/node_modules/@codemirror/commands/dist/index.js.map +0 -1
  21. package/cjs/node_modules/@codemirror/language/dist/index.js +0 -1308
  22. package/cjs/node_modules/@codemirror/language/dist/index.js.map +0 -1
  23. package/cjs/node_modules/@codemirror/state/dist/index.js +0 -3915
  24. package/cjs/node_modules/@codemirror/state/dist/index.js.map +0 -1
  25. package/cjs/node_modules/@codemirror/view/dist/index.js +0 -8716
  26. package/cjs/node_modules/@codemirror/view/dist/index.js.map +0 -1
  27. package/cjs/node_modules/@lezer/common/dist/index.js +0 -1336
  28. package/cjs/node_modules/@lezer/common/dist/index.js.map +0 -1
  29. package/cjs/node_modules/style-mod/src/style-mod.js +0 -165
  30. package/cjs/node_modules/style-mod/src/style-mod.js.map +0 -1
  31. package/cjs/node_modules/w3c-keyname/index.js +0 -126
  32. package/cjs/node_modules/w3c-keyname/index.js.map +0 -1
  33. package/cjs/packages/vuu-codemirror/src/codemirror-basic-setup.js +0 -22
  34. package/cjs/packages/vuu-codemirror/src/codemirror-basic-setup.js.map +0 -1
  35. package/cjs/packages/vuu-codemirror/src/index.js +0 -58
  36. package/cjs/packages/vuu-codemirror/src/parser-utils.js.map +0 -1
  37. package/cjs/packages/vuu-codemirror/src/suggestion-utils.js.map +0 -1
  38. package/esm/node_modules/@codemirror/autocomplete/dist/index.js +0 -1506
  39. package/esm/node_modules/@codemirror/autocomplete/dist/index.js.map +0 -1
  40. package/esm/node_modules/@codemirror/commands/dist/index.js +0 -1401
  41. package/esm/node_modules/@codemirror/commands/dist/index.js.map +0 -1
  42. package/esm/node_modules/@codemirror/language/dist/index.js +0 -1283
  43. package/esm/node_modules/@codemirror/language/dist/index.js.map +0 -1
  44. package/esm/node_modules/@codemirror/state/dist/index.js +0 -3887
  45. package/esm/node_modules/@codemirror/state/dist/index.js.map +0 -1
  46. package/esm/node_modules/@codemirror/view/dist/index.js +0 -8698
  47. package/esm/node_modules/@codemirror/view/dist/index.js.map +0 -1
  48. package/esm/node_modules/@lezer/common/dist/index.js +0 -1327
  49. package/esm/node_modules/@lezer/common/dist/index.js.map +0 -1
  50. package/esm/node_modules/style-mod/src/style-mod.js +0 -163
  51. package/esm/node_modules/style-mod/src/style-mod.js.map +0 -1
  52. package/esm/node_modules/w3c-keyname/index.js +0 -122
  53. package/esm/node_modules/w3c-keyname/index.js.map +0 -1
  54. package/esm/packages/vuu-codemirror/src/codemirror-basic-setup.js +0 -20
  55. package/esm/packages/vuu-codemirror/src/codemirror-basic-setup.js.map +0 -1
  56. package/esm/packages/vuu-codemirror/src/parser-utils.js.map +0 -1
  57. package/esm/packages/vuu-codemirror/src/suggestion-utils.js.map +0 -1
  58. /package/cjs/{packages/vuu-codemirror/src/parser-utils.js → parser-utils.js} +0 -0
  59. /package/esm/{packages/vuu-codemirror/src/index.js.map → index.js.map} +0 -0
  60. /package/esm/{packages/vuu-codemirror/src/parser-utils.js → parser-utils.js} +0 -0
package/README.md ADDED
File without changes
@@ -0,0 +1,22 @@
1
+ 'use strict';
2
+
3
+ var autocomplete = require('@codemirror/autocomplete');
4
+ var commands = require('@codemirror/commands');
5
+ var language = require('@codemirror/language');
6
+ var view = require('@codemirror/view');
7
+
8
+ const keyBindings = [
9
+ ...commands.defaultKeymap,
10
+ ...commands.historyKeymap
11
+ ];
12
+ const minimalSetup = (() => [
13
+ view.highlightSpecialChars(),
14
+ commands.history(),
15
+ view.drawSelection(),
16
+ autocomplete.closeBrackets(),
17
+ language.syntaxHighlighting(language.defaultHighlightStyle, { fallback: true }),
18
+ view.keymap.of(keyBindings)
19
+ ])();
20
+
21
+ exports.minimalSetup = minimalSetup;
22
+ //# sourceMappingURL=codemirror-basic-setup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codemirror-basic-setup.js","sources":["../src/codemirror-basic-setup.ts"],"sourcesContent":["import { closeBrackets } from \"@codemirror/autocomplete\";\nimport { defaultKeymap, history, historyKeymap } from \"@codemirror/commands\";\nimport {\n defaultHighlightStyle,\n syntaxHighlighting,\n} from \"@codemirror/language\";\nimport { Extension } from \"@codemirror/state\";\nimport {\n drawSelection,\n highlightSpecialChars,\n KeyBinding,\n keymap,\n} from \"@codemirror/view\";\n\nconst keyBindings = [\n ...defaultKeymap,\n ...historyKeymap,\n] as ReadonlyArray<KeyBinding>;\n\nexport const minimalSetup: Extension = (() => [\n highlightSpecialChars(),\n history(),\n drawSelection(),\n closeBrackets(),\n syntaxHighlighting(defaultHighlightStyle, { fallback: true }),\n keymap.of(keyBindings),\n])();\n"],"names":["defaultKeymap","historyKeymap","highlightSpecialChars","history","drawSelection","closeBrackets","syntaxHighlighting","defaultHighlightStyle","keymap"],"mappings":";;;;;;;AAcA,MAAM,WAAc,GAAA;AAAA,EAClB,GAAGA,sBAAA;AAAA,EACH,GAAGC,sBAAA;AACL,CAAA,CAAA;AAEO,MAAM,gBAA2B,MAAM;AAAA,EAC5CC,0BAAsB,EAAA;AAAA,EACtBC,gBAAQ,EAAA;AAAA,EACRC,kBAAc,EAAA;AAAA,EACdC,0BAAc,EAAA;AAAA,EACdC,2BAAmB,CAAAC,8BAAA,EAAuB,EAAE,QAAA,EAAU,MAAM,CAAA;AAAA,EAC5DC,WAAA,CAAO,GAAG,WAAW,CAAA;AACvB,CAAG;;;;"}
package/cjs/index.js ADDED
@@ -0,0 +1,118 @@
1
+ 'use strict';
2
+
3
+ var autocomplete = require('@codemirror/autocomplete');
4
+ var commands = require('@codemirror/commands');
5
+ var language = require('@codemirror/language');
6
+ var state = require('@codemirror/state');
7
+ var view = require('@codemirror/view');
8
+ var common = require('@lezer/common');
9
+ var highlight = require('@lezer/highlight');
10
+ var codemirrorBasicSetup = require('./codemirror-basic-setup.js');
11
+ var parserUtils = require('./parser-utils.js');
12
+ var suggestionUtils = require('./suggestion-utils.js');
13
+
14
+
15
+
16
+ Object.defineProperty(exports, "autocompletion", {
17
+ enumerable: true,
18
+ get: function () { return autocomplete.autocompletion; }
19
+ });
20
+ Object.defineProperty(exports, "closeBrackets", {
21
+ enumerable: true,
22
+ get: function () { return autocomplete.closeBrackets; }
23
+ });
24
+ Object.defineProperty(exports, "startCompletion", {
25
+ enumerable: true,
26
+ get: function () { return autocomplete.startCompletion; }
27
+ });
28
+ Object.defineProperty(exports, "defaultKeymap", {
29
+ enumerable: true,
30
+ get: function () { return commands.defaultKeymap; }
31
+ });
32
+ Object.defineProperty(exports, "history", {
33
+ enumerable: true,
34
+ get: function () { return commands.history; }
35
+ });
36
+ Object.defineProperty(exports, "historyKeymap", {
37
+ enumerable: true,
38
+ get: function () { return commands.historyKeymap; }
39
+ });
40
+ Object.defineProperty(exports, "HighlightStyle", {
41
+ enumerable: true,
42
+ get: function () { return language.HighlightStyle; }
43
+ });
44
+ Object.defineProperty(exports, "LRLanguage", {
45
+ enumerable: true,
46
+ get: function () { return language.LRLanguage; }
47
+ });
48
+ Object.defineProperty(exports, "LanguageSupport", {
49
+ enumerable: true,
50
+ get: function () { return language.LanguageSupport; }
51
+ });
52
+ Object.defineProperty(exports, "defaultHighlightStyle", {
53
+ enumerable: true,
54
+ get: function () { return language.defaultHighlightStyle; }
55
+ });
56
+ Object.defineProperty(exports, "ensureSyntaxTree", {
57
+ enumerable: true,
58
+ get: function () { return language.ensureSyntaxTree; }
59
+ });
60
+ Object.defineProperty(exports, "syntaxHighlighting", {
61
+ enumerable: true,
62
+ get: function () { return language.syntaxHighlighting; }
63
+ });
64
+ Object.defineProperty(exports, "syntaxTree", {
65
+ enumerable: true,
66
+ get: function () { return language.syntaxTree; }
67
+ });
68
+ Object.defineProperty(exports, "AnnotationType", {
69
+ enumerable: true,
70
+ get: function () { return state.AnnotationType; }
71
+ });
72
+ Object.defineProperty(exports, "EditorState", {
73
+ enumerable: true,
74
+ get: function () { return state.EditorState; }
75
+ });
76
+ Object.defineProperty(exports, "EditorView", {
77
+ enumerable: true,
78
+ get: function () { return view.EditorView; }
79
+ });
80
+ Object.defineProperty(exports, "drawSelection", {
81
+ enumerable: true,
82
+ get: function () { return view.drawSelection; }
83
+ });
84
+ Object.defineProperty(exports, "highlightSpecialChars", {
85
+ enumerable: true,
86
+ get: function () { return view.highlightSpecialChars; }
87
+ });
88
+ Object.defineProperty(exports, "keymap", {
89
+ enumerable: true,
90
+ get: function () { return view.keymap; }
91
+ });
92
+ Object.defineProperty(exports, "Tree", {
93
+ enumerable: true,
94
+ get: function () { return common.Tree; }
95
+ });
96
+ Object.defineProperty(exports, "styleTags", {
97
+ enumerable: true,
98
+ get: function () { return highlight.styleTags; }
99
+ });
100
+ Object.defineProperty(exports, "tags", {
101
+ enumerable: true,
102
+ get: function () { return highlight.tags; }
103
+ });
104
+ exports.minimalSetup = codemirrorBasicSetup.minimalSetup;
105
+ exports.getNamedParentNode = parserUtils.getNamedParentNode;
106
+ exports.getNodeByName = parserUtils.getNodeByName;
107
+ exports.getPreviousNamedNode = parserUtils.getPreviousNamedNode;
108
+ exports.getPreviousNode = parserUtils.getPreviousNode;
109
+ exports.getValue = parserUtils.getValue;
110
+ exports.asNameSuggestion = suggestionUtils.asNameSuggestion;
111
+ exports.booleanJoinSuggestions = suggestionUtils.booleanJoinSuggestions;
112
+ exports.equalityOperators = suggestionUtils.equalityOperators;
113
+ exports.getNamePrompt = suggestionUtils.getNamePrompt;
114
+ exports.getRelationalOperators = suggestionUtils.getRelationalOperators;
115
+ exports.numericOperators = suggestionUtils.numericOperators;
116
+ exports.stringOperators = suggestionUtils.stringOperators;
117
+ exports.toSuggestions = suggestionUtils.toSuggestions;
118
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser-utils.js","sources":["../src/parser-utils.ts"],"sourcesContent":["import { EditorState } from \"@codemirror/state\";\nimport type { SyntaxNode } from \"@lezer/common\";\n\nexport const getValue = (node: SyntaxNode, state: EditorState) =>\n state.doc.sliceString(node.from, node.to);\n\nexport const getNodeByName = (\n node: SyntaxNode,\n state: EditorState,\n nodeName = \"Column\"\n) => {\n if (node.firstChild?.name === nodeName) {\n return getValue(node.firstChild, state);\n } else {\n let maybeColumnNode = node.prevSibling || node.parent;\n while (maybeColumnNode && maybeColumnNode.name !== nodeName) {\n maybeColumnNode = maybeColumnNode.prevSibling || maybeColumnNode.parent;\n }\n if (maybeColumnNode) {\n return getValue(maybeColumnNode, state);\n }\n }\n};\n\nexport const getPreviousNode = (node: SyntaxNode) => {\n const prevNode = node.prevSibling;\n console.log(`prevNode ${prevNode?.name}`);\n return prevNode;\n};\n\nexport const getNamedParentNode = (node: SyntaxNode) => {\n let maybeParent = node.parent;\n while (maybeParent && maybeParent.name === \"⚠\") {\n maybeParent = maybeParent.parent;\n }\n return maybeParent;\n};\n\nexport const getPreviousNamedNode = (node: SyntaxNode) => {\n let maybeParent = node.prevSibling;\n while (maybeParent && maybeParent.name === \"⚠\") {\n maybeParent = maybeParent.prevSibling;\n }\n return maybeParent;\n};\n"],"names":[],"mappings":";;AAGa,MAAA,QAAA,GAAW,CAAC,IAAA,EAAkB,KACzC,KAAA,KAAA,CAAM,IAAI,WAAY,CAAA,IAAA,CAAK,IAAM,EAAA,IAAA,CAAK,EAAE,EAAA;AAEnC,MAAM,aAAgB,GAAA,CAC3B,IACA,EAAA,KAAA,EACA,WAAW,QACR,KAAA;AACH,EAAI,IAAA,IAAA,CAAK,UAAY,EAAA,IAAA,KAAS,QAAU,EAAA;AACtC,IAAO,OAAA,QAAA,CAAS,IAAK,CAAA,UAAA,EAAY,KAAK,CAAA,CAAA;AAAA,GACjC,MAAA;AACL,IAAI,IAAA,eAAA,GAAkB,IAAK,CAAA,WAAA,IAAe,IAAK,CAAA,MAAA,CAAA;AAC/C,IAAO,OAAA,eAAA,IAAmB,eAAgB,CAAA,IAAA,KAAS,QAAU,EAAA;AAC3D,MAAkB,eAAA,GAAA,eAAA,CAAgB,eAAe,eAAgB,CAAA,MAAA,CAAA;AAAA,KACnE;AACA,IAAA,IAAI,eAAiB,EAAA;AACnB,MAAO,OAAA,QAAA,CAAS,iBAAiB,KAAK,CAAA,CAAA;AAAA,KACxC;AAAA,GACF;AACF,EAAA;AAEa,MAAA,eAAA,GAAkB,CAAC,IAAqB,KAAA;AACnD,EAAA,MAAM,WAAW,IAAK,CAAA,WAAA,CAAA;AACtB,EAAA,OAAA,CAAQ,GAAI,CAAA,CAAA,SAAA,EAAY,QAAU,EAAA,IAAI,CAAE,CAAA,CAAA,CAAA;AACxC,EAAO,OAAA,QAAA,CAAA;AACT,EAAA;AAEa,MAAA,kBAAA,GAAqB,CAAC,IAAqB,KAAA;AACtD,EAAA,IAAI,cAAc,IAAK,CAAA,MAAA,CAAA;AACvB,EAAO,OAAA,WAAA,IAAe,WAAY,CAAA,IAAA,KAAS,QAAK,EAAA;AAC9C,IAAA,WAAA,GAAc,WAAY,CAAA,MAAA,CAAA;AAAA,GAC5B;AACA,EAAO,OAAA,WAAA,CAAA;AACT,EAAA;AAEa,MAAA,oBAAA,GAAuB,CAAC,IAAqB,KAAA;AACxD,EAAA,IAAI,cAAc,IAAK,CAAA,WAAA,CAAA;AACvB,EAAO,OAAA,WAAA,IAAe,WAAY,CAAA,IAAA,KAAS,QAAK,EAAA;AAC9C,IAAA,WAAA,GAAc,WAAY,CAAA,WAAA,CAAA;AAAA,GAC5B;AACA,EAAO,OAAA,WAAA,CAAA;AACT;;;;;;;;"}
@@ -1,11 +1,11 @@
1
1
  'use strict';
2
2
 
3
- var index = require('../../../node_modules/@codemirror/state/dist/index.js');
3
+ var state = require('@codemirror/state');
4
4
  var vuuUtils = require('@vuu-ui/vuu-utils');
5
5
 
6
6
  const NO_OPTIONS = {};
7
7
  const applyWithCursorMove = () => (view, completion, from) => {
8
- const annotation = new index.AnnotationType();
8
+ const annotation = new state.AnnotationType();
9
9
  view.dispatch(
10
10
  {
11
11
  changes: { from, insert: completion.label },
@@ -0,0 +1 @@
1
+ {"version":3,"file":"suggestion-utils.js","sources":["../src/suggestion-utils.ts"],"sourcesContent":["import { Completion } from \"@codemirror/autocomplete\";\nimport { AnnotationType } from \"@codemirror/state\";\nimport { EditorView } from \"@codemirror/view\";\nimport type { ColumnDescriptor } from \"@vuu-ui/vuu-table-types\";\nimport { isNumericColumn } from \"@vuu-ui/vuu-utils\";\n\nexport interface VuuCompletion extends Completion {\n isIllustration?: boolean;\n}\n\nexport type CompletionOptions = {\n moveCursorToEnd?: boolean;\n prefix?: string;\n quoted?: boolean;\n suffix?: string;\n isIllustration?: boolean;\n};\n\nconst NO_OPTIONS: CompletionOptions = {};\n\nconst applyWithCursorMove =\n () => (view: EditorView, completion: Completion, from: number) => {\n const annotation = new AnnotationType<Completion>();\n view.dispatch(\n {\n changes: { from, insert: completion.label },\n annotations: annotation.of(completion),\n },\n {\n changes: { from: from + 1, insert: \" \" },\n selection: { anchor: from + 2, head: from + 2 },\n annotations: annotation.of(completion),\n }\n );\n };\n\nexport const toSuggestions = (\n values: string[],\n options = NO_OPTIONS\n): VuuCompletion[] => {\n const {\n moveCursorToEnd = false,\n prefix = \"\",\n quoted = false,\n suffix = \" \",\n isIllustration = false,\n } = options;\n const quote = quoted ? '\"' : \"\";\n return values.map((value) => ({\n isIllustration,\n label: value,\n apply: moveCursorToEnd\n ? applyWithCursorMove()\n : isIllustration\n ? `${quote}${prefix}${quote}`\n : `${prefix}${quote}${value}${quote}${suffix}`,\n }));\n};\n\nexport const asNameSuggestion = { label: \"as\", apply: \"as \", boost: 1 };\n\nexport const booleanJoinSuggestions: Completion[] = [\n { label: \"and\", apply: \"and \", boost: 5 },\n { label: \"or\", apply: \"or \", boost: 3 },\n];\n\nexport const equalityOperators: Completion[] = [\n { label: \"=\", boost: 10, type: \"operator\" },\n { label: \"!=\", boost: 9, type: \"operator\" },\n];\n\nexport const stringOperators: Completion[] = [\n ...equalityOperators,\n { label: \"in\", boost: 6, type: \"operator\" },\n { label: \"starts\", boost: 5, type: \"operator\" },\n { label: \"ends\", boost: 4, type: \"operator\" },\n];\n\nexport const numericOperators: Completion[] = [\n ...equalityOperators,\n { label: \">\", boost: 8, type: \"operator\" },\n { label: \"<\", boost: 7, type: \"operator\" },\n];\n\nexport const getRelationalOperators = (column?: ColumnDescriptor) => {\n if (column === undefined || isNumericColumn(column)) {\n return numericOperators;\n } else {\n return equalityOperators;\n }\n};\n\nexport const getNamePrompt = (entity?: string) => {\n const label = entity ? `enter name for this ${entity}` : \"enter name\";\n return [{ label, boost: 5 }];\n};\n"],"names":["AnnotationType","isNumericColumn"],"mappings":";;;;;AAkBA,MAAM,aAAgC,EAAC,CAAA;AAEvC,MAAM,mBACJ,GAAA,MAAM,CAAC,IAAA,EAAkB,YAAwB,IAAiB,KAAA;AAChE,EAAM,MAAA,UAAA,GAAa,IAAIA,oBAA2B,EAAA,CAAA;AAClD,EAAK,IAAA,CAAA,QAAA;AAAA,IACH;AAAA,MACE,OAAS,EAAA,EAAE,IAAM,EAAA,MAAA,EAAQ,WAAW,KAAM,EAAA;AAAA,MAC1C,WAAA,EAAa,UAAW,CAAA,EAAA,CAAG,UAAU,CAAA;AAAA,KACvC;AAAA,IACA;AAAA,MACE,SAAS,EAAE,IAAA,EAAM,IAAO,GAAA,CAAA,EAAG,QAAQ,GAAI,EAAA;AAAA,MACvC,WAAW,EAAE,MAAA,EAAQ,OAAO,CAAG,EAAA,IAAA,EAAM,OAAO,CAAE,EAAA;AAAA,MAC9C,WAAA,EAAa,UAAW,CAAA,EAAA,CAAG,UAAU,CAAA;AAAA,KACvC;AAAA,GACF,CAAA;AACF,CAAA,CAAA;AAEK,MAAM,aAAgB,GAAA,CAC3B,MACA,EAAA,OAAA,GAAU,UACU,KAAA;AACpB,EAAM,MAAA;AAAA,IACJ,eAAkB,GAAA,KAAA;AAAA,IAClB,MAAS,GAAA,EAAA;AAAA,IACT,MAAS,GAAA,KAAA;AAAA,IACT,MAAS,GAAA,GAAA;AAAA,IACT,cAAiB,GAAA,KAAA;AAAA,GACf,GAAA,OAAA,CAAA;AACJ,EAAM,MAAA,KAAA,GAAQ,SAAS,GAAM,GAAA,EAAA,CAAA;AAC7B,EAAO,OAAA,MAAA,CAAO,GAAI,CAAA,CAAC,KAAW,MAAA;AAAA,IAC5B,cAAA;AAAA,IACA,KAAO,EAAA,KAAA;AAAA,IACP,KAAA,EAAO,kBACH,mBAAoB,EAAA,GACpB,i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,EAAG,MAAM,UAAW,EAAA;AAC3C,EAAA;AAEa,MAAA,sBAAA,GAAyB,CAAC,MAA8B,KAAA;AACnE,EAAA,IAAI,MAAW,KAAA,KAAA,CAAA,IAAaC,wBAAgB,CAAA,MAAM,CAAG,EAAA;AACnD,IAAO,OAAA,gBAAA,CAAA;AAAA,GACF,MAAA;AACL,IAAO,OAAA,iBAAA,CAAA;AAAA,GACT;AACF,EAAA;AAEa,MAAA,aAAA,GAAgB,CAAC,MAAoB,KAAA;AAChD,EAAA,MAAM,KAAQ,GAAA,MAAA,GAAS,CAAuB,oBAAA,EAAA,MAAM,CAAK,CAAA,GAAA,YAAA,CAAA;AACzD,EAAA,OAAO,CAAC,EAAE,KAAO,EAAA,KAAA,EAAO,GAAG,CAAA,CAAA;AAC7B;;;;;;;;;;;"}
@@ -0,0 +1,20 @@
1
+ import { closeBrackets } from '@codemirror/autocomplete';
2
+ import { defaultKeymap, historyKeymap, history } from '@codemirror/commands';
3
+ import { syntaxHighlighting, defaultHighlightStyle } from '@codemirror/language';
4
+ import { highlightSpecialChars, drawSelection, keymap } from '@codemirror/view';
5
+
6
+ const keyBindings = [
7
+ ...defaultKeymap,
8
+ ...historyKeymap
9
+ ];
10
+ const minimalSetup = (() => [
11
+ highlightSpecialChars(),
12
+ history(),
13
+ drawSelection(),
14
+ closeBrackets(),
15
+ syntaxHighlighting(defaultHighlightStyle, { fallback: true }),
16
+ keymap.of(keyBindings)
17
+ ])();
18
+
19
+ export { minimalSetup };
20
+ //# sourceMappingURL=codemirror-basic-setup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codemirror-basic-setup.js","sources":["../src/codemirror-basic-setup.ts"],"sourcesContent":["import { closeBrackets } from \"@codemirror/autocomplete\";\nimport { defaultKeymap, history, historyKeymap } from \"@codemirror/commands\";\nimport {\n defaultHighlightStyle,\n syntaxHighlighting,\n} from \"@codemirror/language\";\nimport { Extension } from \"@codemirror/state\";\nimport {\n drawSelection,\n highlightSpecialChars,\n KeyBinding,\n keymap,\n} from \"@codemirror/view\";\n\nconst keyBindings = [\n ...defaultKeymap,\n ...historyKeymap,\n] as ReadonlyArray<KeyBinding>;\n\nexport const minimalSetup: Extension = (() => [\n highlightSpecialChars(),\n history(),\n drawSelection(),\n closeBrackets(),\n syntaxHighlighting(defaultHighlightStyle, { fallback: true }),\n keymap.of(keyBindings),\n])();\n"],"names":[],"mappings":";;;;;AAcA,MAAM,WAAc,GAAA;AAAA,EAClB,GAAG,aAAA;AAAA,EACH,GAAG,aAAA;AACL,CAAA,CAAA;AAEO,MAAM,gBAA2B,MAAM;AAAA,EAC5C,qBAAsB,EAAA;AAAA,EACtB,OAAQ,EAAA;AAAA,EACR,aAAc,EAAA;AAAA,EACd,aAAc,EAAA;AAAA,EACd,kBAAmB,CAAA,qBAAA,EAAuB,EAAE,QAAA,EAAU,MAAM,CAAA;AAAA,EAC5D,MAAA,CAAO,GAAG,WAAW,CAAA;AACvB,CAAG;;;;"}
@@ -1,9 +1,9 @@
1
- export { autocompletion, closeBrackets, startCompletion } from '../../../node_modules/@codemirror/autocomplete/dist/index.js';
2
- export { defaultKeymap, history, historyKeymap } from '../../../node_modules/@codemirror/commands/dist/index.js';
3
- export { HighlightStyle, LRLanguage, LanguageSupport, defaultHighlightStyle, ensureSyntaxTree, syntaxHighlighting, syntaxTree } from '../../../node_modules/@codemirror/language/dist/index.js';
4
- export { AnnotationType, EditorState } from '../../../node_modules/@codemirror/state/dist/index.js';
5
- export { EditorView, drawSelection, highlightSpecialChars, keymap } from '../../../node_modules/@codemirror/view/dist/index.js';
6
- export { Tree } from '../../../node_modules/@lezer/common/dist/index.js';
1
+ export { autocompletion, closeBrackets, startCompletion } from '@codemirror/autocomplete';
2
+ export { defaultKeymap, history, historyKeymap } from '@codemirror/commands';
3
+ export { HighlightStyle, LRLanguage, LanguageSupport, defaultHighlightStyle, ensureSyntaxTree, syntaxHighlighting, syntaxTree } from '@codemirror/language';
4
+ export { AnnotationType, EditorState } from '@codemirror/state';
5
+ export { EditorView, drawSelection, highlightSpecialChars, keymap } from '@codemirror/view';
6
+ export { Tree } from '@lezer/common';
7
7
  export { styleTags, tags } from '@lezer/highlight';
8
8
  export { minimalSetup } from './codemirror-basic-setup.js';
9
9
  export { getNamedParentNode, getNodeByName, getPreviousNamedNode, getPreviousNode, getValue } from './parser-utils.js';
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser-utils.js","sources":["../src/parser-utils.ts"],"sourcesContent":["import { EditorState } from \"@codemirror/state\";\nimport type { SyntaxNode } from \"@lezer/common\";\n\nexport const getValue = (node: SyntaxNode, state: EditorState) =>\n state.doc.sliceString(node.from, node.to);\n\nexport const getNodeByName = (\n node: SyntaxNode,\n state: EditorState,\n nodeName = \"Column\"\n) => {\n if (node.firstChild?.name === nodeName) {\n return getValue(node.firstChild, state);\n } else {\n let maybeColumnNode = node.prevSibling || node.parent;\n while (maybeColumnNode && maybeColumnNode.name !== nodeName) {\n maybeColumnNode = maybeColumnNode.prevSibling || maybeColumnNode.parent;\n }\n if (maybeColumnNode) {\n return getValue(maybeColumnNode, state);\n }\n }\n};\n\nexport const getPreviousNode = (node: SyntaxNode) => {\n const prevNode = node.prevSibling;\n console.log(`prevNode ${prevNode?.name}`);\n return prevNode;\n};\n\nexport const getNamedParentNode = (node: SyntaxNode) => {\n let maybeParent = node.parent;\n while (maybeParent && maybeParent.name === \"⚠\") {\n maybeParent = maybeParent.parent;\n }\n return maybeParent;\n};\n\nexport const getPreviousNamedNode = (node: SyntaxNode) => {\n let maybeParent = node.prevSibling;\n while (maybeParent && maybeParent.name === \"⚠\") {\n maybeParent = maybeParent.prevSibling;\n }\n return maybeParent;\n};\n"],"names":[],"mappings":"AAGa,MAAA,QAAA,GAAW,CAAC,IAAA,EAAkB,KACzC,KAAA,KAAA,CAAM,IAAI,WAAY,CAAA,IAAA,CAAK,IAAM,EAAA,IAAA,CAAK,EAAE,EAAA;AAEnC,MAAM,aAAgB,GAAA,CAC3B,IACA,EAAA,KAAA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AAAA,GAC5B;AACA,EAAO,OAAA,WAAA,CAAA;AACT;;;;"}
@@ -1,4 +1,4 @@
1
- import { AnnotationType } from '../../../node_modules/@codemirror/state/dist/index.js';
1
+ import { AnnotationType } from '@codemirror/state';
2
2
  import { isNumericColumn } from '@vuu-ui/vuu-utils';
3
3
 
4
4
  const NO_OPTIONS = {};
@@ -0,0 +1 @@
1
+ {"version":3,"file":"suggestion-utils.js","sources":["../src/suggestion-utils.ts"],"sourcesContent":["import { Completion } from \"@codemirror/autocomplete\";\nimport { AnnotationType } from \"@codemirror/state\";\nimport { EditorView } from \"@codemirror/view\";\nimport type { ColumnDescriptor } from \"@vuu-ui/vuu-table-types\";\nimport { isNumericColumn } from \"@vuu-ui/vuu-utils\";\n\nexport interface VuuCompletion extends Completion {\n isIllustration?: boolean;\n}\n\nexport type CompletionOptions = {\n moveCursorToEnd?: boolean;\n prefix?: string;\n quoted?: boolean;\n suffix?: string;\n isIllustration?: boolean;\n};\n\nconst NO_OPTIONS: CompletionOptions = {};\n\nconst applyWithCursorMove =\n () => (view: EditorView, completion: Completion, from: number) => {\n const annotation = new AnnotationType<Completion>();\n view.dispatch(\n {\n changes: { from, insert: completion.label },\n annotations: annotation.of(completion),\n },\n {\n changes: { from: from + 1, insert: \" \" },\n selection: { anchor: from + 2, head: from + 2 },\n annotations: annotation.of(completion),\n }\n );\n };\n\nexport const toSuggestions = (\n values: string[],\n options = NO_OPTIONS\n): VuuCompletion[] => {\n const {\n moveCursorToEnd = false,\n prefix = \"\",\n quoted = false,\n suffix = \" \",\n isIllustration = false,\n } = options;\n const quote = quoted ? '\"' : \"\";\n return values.map((value) => ({\n isIllustration,\n label: value,\n apply: moveCursorToEnd\n ? applyWithCursorMove()\n : isIllustration\n ? `${quote}${prefix}${quote}`\n : `${prefix}${quote}${value}${quote}${suffix}`,\n }));\n};\n\nexport const asNameSuggestion = { label: \"as\", apply: \"as \", boost: 1 };\n\nexport const booleanJoinSuggestions: Completion[] = [\n { label: \"and\", apply: \"and \", boost: 5 },\n { label: \"or\", apply: \"or \", boost: 3 },\n];\n\nexport const equalityOperators: Completion[] = [\n { label: \"=\", boost: 10, type: \"operator\" },\n { label: \"!=\", boost: 9, type: \"operator\" },\n];\n\nexport const stringOperators: Completion[] = [\n ...equalityOperators,\n { label: \"in\", boost: 6, type: \"operator\" },\n { label: \"starts\", boost: 5, type: \"operator\" },\n { label: \"ends\", boost: 4, type: \"operator\" },\n];\n\nexport const numericOperators: Completion[] = [\n ...equalityOperators,\n { label: \">\", boost: 8, type: \"operator\" },\n { label: \"<\", boost: 7, type: \"operator\" },\n];\n\nexport const getRelationalOperators = (column?: ColumnDescriptor) => {\n if (column === undefined || isNumericColumn(column)) {\n return numericOperators;\n } else {\n return equalityOperators;\n }\n};\n\nexport const getNamePrompt = (entity?: string) => {\n const label = entity ? `enter name for this ${entity}` : \"enter name\";\n return [{ label, boost: 5 }];\n};\n"],"names":[],"mappings":";;;AAkBA,MAAM,aAAgC,EAAC,CAAA;AAEvC,MAAM,mBACJ,GAAA,MAAM,CAAC,IAAA,EAAkB,YAAwB,IAAiB,KAAA;AAChE,EAAM,MAAA,UAAA,GAAa,IAAI,cAA2B,EAAA,CAAA;AAClD,EAAK,IAAA,CAAA,QAAA;AAAA,IACH;AAAA,MACE,OAAS,EAAA,EAAE,IAAM,EAAA,MAAA,EAAQ,WAAW,KAAM,EAAA;AAAA,MAC1C,WAAA,EAAa,UAAW,CAAA,EAAA,CAAG,UAAU,CAAA;AAAA,KACvC;AAAA,IACA;AAAA,MACE,SAAS,EAAE,IAAA,EAAM,IAAO,GAAA,CAAA,EAAG,QAAQ,GAAI,EAAA;AAAA,MACvC,WAAW,EAAE,MAAA,EAAQ,OAAO,CAAG,EAAA,IAAA,EAAM,OAAO,CAAE,EAAA;AAAA,MAC9C,WAAA,EAAa,UAAW,CAAA,EAAA,CAAG,UAAU,CAAA;AAAA,KACvC;AAAA,GACF,CAAA;AACF,CAAA,CAAA;AAEK,MAAM,aAAgB,GA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AAA,EACH,EAAE,KAAO,EAAA,IAAA,EAAM,KAAO,EAAA,CAAA,EAAG,MAAM,UAAW,EAAA;AAAA,EAC1C,EAAE,KAAO,EAAA,QAAA,EAAU,KAAO,EAAA,CAAA,EAAG,MAAM,UAAW,EAAA;AAAA,EAC9C,EAAE,KAAO,EAAA,MAAA,EAAQ,KAAO,EAAA,CAAA,EAAG,MAAM,UAAW,EAAA;AAC9C,EAAA;AAEO,MAAM,gBAAiC,GAAA;AAAA,EAC5C,GAAG,iBAAA;AAAA,EACH,EAAE,KAAO,EAAA,GAAA,EAAK,KAAO,EAAA,CAAA,EAAG,MAAM,UAAW,EAAA;AAAA,EACzC,EAAE,KAAO,EAAA,GAAA,EAAK,KAAO,EAAA,CAAA,EAAG,MAAM,UAAW,EAAA;AAC3C,EAAA;AAEa,MAAA,sBAAA,GAAyB,CAAC,MAA8B,KAAA;AACnE,EAAA,IAAI,MAAW,KAAA,KAAA,CAAA,IAAa,eAAgB,CAAA,MAAM,CAAG,EAAA;AACnD,IAAO,OAAA,gBAAA,CAAA;AAAA,GACF,MAAA;AACL,IAAO,OAAA,iBAAA,CAAA;AAAA,GACT;AACF,EAAA;AAEa,MAAA,aAAA,GAAgB,CAAC,MAAoB,KAAA;AAChD,EAAA,MAAM,KAAQ,GAAA,MAAA,GAAS,CAAuB,oBAAA,EAAA,MAAM,CAAK,CAAA,GAAA,YAAA,CAAA;AACzD,EAAA,OAAO,CAAC,EAAE,KAAO,EAAA,KAAA,EAAO,GAAG,CAAA,CAAA;AAC7B;;;;"}
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
- "version": "0.8.34",
2
+ "version": "0.8.36",
3
3
  "author": "heswell",
4
4
  "license": "Apache-2.0",
5
5
  "devDependencies": {
6
- "@vuu-ui/vuu-table-types": "0.8.34"
6
+ "@vuu-ui/vuu-table-types": "0.8.36"
7
7
  },
8
8
  "dependencies": {
9
9
  "@codemirror/autocomplete": "^6.4.2",
@@ -11,14 +11,15 @@
11
11
  "@codemirror/language": "^6.6.0",
12
12
  "@codemirror/state": "^6.2.0",
13
13
  "@codemirror/view": "^6.9.3",
14
- "@vuu-ui/vuu-utils": "0.8.34",
14
+ "@vuu-ui/vuu-utils": "0.8.36",
15
+ "@lezer/common": "1.0.3",
15
16
  "@lezer/highlight": "^1.1.3"
16
17
  },
17
18
  "type": "module",
18
19
  "files": [
20
+ "README.md",
19
21
  "esm",
20
22
  "cjs",
21
- "README.md",
22
23
  "/types"
23
24
  ],
24
25
  "main": "cjs/index.js",
package/types/index.d.ts CHANGED
@@ -7,6 +7,9 @@ import { drawSelection, EditorView, highlightSpecialChars, keymap } from "@codem
7
7
  import type { SyntaxNode } from "@lezer/common";
8
8
  import { Tree } from "@lezer/common";
9
9
  import { styleTags, tags } from "@lezer/highlight";
10
+ export * from "./codemirror-basic-setup";
11
+ export * from "./parser-utils";
12
+ export * from "./suggestion-utils";
10
13
  export { autocompletion, closeBrackets, startCompletion };
11
14
  export type { Completion, CompletionContext, CompletionSource };
12
15
  export { defaultKeymap, history, historyKeymap };
@@ -16,6 +19,3 @@ export type { Extension };
16
19
  export { drawSelection, EditorView, highlightSpecialChars, KeyBinding, keymap };
17
20
  export { styleTags, tags };
18
21
  export { SyntaxNode, Tree };
19
- export * from "./codemirror-basic-setup";
20
- export * from "./parser-utils";
21
- export * from "./suggestion-utils";