dequel-editor 0.6.0 → 0.7.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.
@@ -1,8 +1,8 @@
1
- import { syntaxTree as b, LRLanguage as P, indentNodeProp as v, foldNodeProp as I, foldInside as N, HighlightStyle as O, LanguageSupport as V, syntaxHighlighting as w } from "@codemirror/language";
2
- import { Tag as s, tags as o, styleTags as A } from "@lezer/highlight";
3
- import { buildParser as E } from "@lezer/generator";
4
- import { Facet as L, StateEffect as D, StateField as Q } from "@codemirror/state";
5
- const T = E(`
1
+ import { syntaxTree as P, LRLanguage as O, indentNodeProp as I, foldNodeProp as V, foldInside as w, HighlightStyle as A, LanguageSupport as E, syntaxHighlighting as D } from "@codemirror/language";
2
+ import { Tag as m, tags as i, styleTags as L } from "@lezer/highlight";
3
+ import { buildParser as Q } from "@lezer/generator";
4
+ import { Facet as T, StateEffect as k, StateField as q } from "@codemirror/state";
5
+ const j = Q(`
6
6
  @top QueryList { Query }
7
7
  @skip { "
8
8
  " | Comment }
@@ -11,12 +11,11 @@ Query {
11
11
  anyCondition ((" " | " ")+ anyCondition)*
12
12
  }
13
13
 
14
- anyCondition { Condition | ExcludeCondition | IgnoredCondition }
14
+ anyCondition { Condition | ExcludeCondition }
15
15
  Condition { Field ":" Predicate }
16
16
  ExcludeCondition { "-" Field ":" Predicate }
17
- IgnoredCondition { "!" Field ":" Predicate }
18
17
 
19
- Predicate { Regex | Value | Command }
18
+ Predicate { Value | Command }
20
19
  Command { Identifier "(" Argument ("," Argument)* ")" }
21
20
  Argument { Identifier | Number | String }
22
21
  Value { Identifier | Number | String }
@@ -24,149 +23,140 @@ Value { Identifier | Number | String }
24
23
  @tokens {
25
24
  ":"
26
25
  Field { Identifier }
27
- Function { Identifier }
28
26
  Identifier { $[a-zA-Z_]+ ("." $[a-zA-Z_]+)* }
29
27
  Number { std.digit+ }
30
28
  String { '"' !["]* '"' }
31
- Regex { RegexContent (RegexFlag)* }
32
- RegexFlag { std.asciiLetter+ }
33
- RegexContent { "/" (![/] | "\\/")* "/" }
34
29
  Comment { "#" (![
35
30
  ])* }
36
31
  }
37
- `), t = {
38
- Condition: s.define(o.keyword),
39
- Field: s.define(o.propertyName),
40
- Command: o.function(o.variableName),
41
- Predicate: s.define(o.variableName),
42
- Value: s.define(o.attributeValue),
43
- Operator: s.define(o.operator),
44
- Regex: s.define(o.regexp),
45
- RegexContent: s.define(o.regexp)
46
- }, q = L.define(), k = (e, i) => {
47
- for (; i.parent; ) {
48
- if (i.parent.name === e)
49
- return i.parent;
50
- i = i.parent;
32
+ `), n = {
33
+ Condition: m.define(i.keyword),
34
+ Field: m.define(i.propertyName),
35
+ Command: i.function(i.variableName),
36
+ Predicate: m.define(i.variableName),
37
+ Value: m.define(i.attributeValue),
38
+ Operator: m.define(i.operator)
39
+ }, B = T.define(), H = (e, o) => {
40
+ for (; o.parent; ) {
41
+ if (o.parent.name === e)
42
+ return o.parent;
43
+ o = o.parent;
51
44
  }
52
45
  return null;
53
46
  };
54
- async function B(e, i, n) {
55
- let d = i;
56
- for (const c of e) {
57
- const a = d.fields.find((l) => l.label === c);
58
- if (a?.type !== "relationship" || !a.target)
47
+ async function $(e, o, t) {
48
+ let r = o;
49
+ for (const s of e) {
50
+ const a = r.fields[s];
51
+ if (a?.type !== "relationship" || !a.schema)
59
52
  return null;
60
- d = await n.get(a.target);
53
+ r = await t.get(a.schema);
61
54
  }
62
- return d;
55
+ return r;
63
56
  }
64
- const H = D.define(), $ = Q.define({
65
- create: () => ({ fields: [] }),
66
- update: (e, i) => {
67
- for (const n of i.effects)
68
- if (n.is(H))
69
- return n.value;
57
+ const z = k.define(), Z = q.define({
58
+ create: () => ({ fields: {} }),
59
+ update: (e, o) => {
60
+ for (const t of o.effects)
61
+ if (t.is(z))
62
+ return t.value;
70
63
  return e;
71
64
  }
72
- }), z = S.data.of({
65
+ }), _ = b.data.of({
73
66
  autocomplete: async (e) => {
74
- const n = b(e.state).resolveInner(e.pos, -1), d = e.state.sliceDoc(n.from, e.pos), c = /[\w.]*$/.exec(d);
75
- if (!c && !e.explicit) return null;
76
- const a = c ? n.from + c.index : e.pos, l = e.state.field($, !1), C = e.state.facet(q)[0]?.schemaCache, h = k("Condition", n), g = h?.getChild("Field"), y = h?.getChild(":");
77
- if (g && y && e.pos > y.to) {
78
- const m = e.state.doc.sliceString(g.from, g.to), f = l?.values?.[m];
79
- if (f?.length) {
80
- const p = f.map((r) => ({
81
- label: r,
67
+ const t = P(e.state).resolveInner(e.pos, -1), r = e.state.sliceDoc(t.from, e.pos), s = /[\w.]*$/.exec(r);
68
+ if (!s && !e.explicit) return null;
69
+ const a = s ? t.from + s.index : e.pos, l = e.state.field(Z, !1), h = e.state.facet(B)[0]?.schemaCache, C = H("Condition", t), u = C?.getChild("Field"), y = C?.getChild(":");
70
+ if (u && y && e.pos > y.to) {
71
+ const p = e.state.doc.sliceString(u.from, u.to), d = l?.fields[p]?.values;
72
+ if (d?.length) {
73
+ const g = d.map((c) => ({
74
+ label: c,
82
75
  type: "value"
83
76
  }));
84
77
  return {
85
78
  from: a,
86
- options: p
79
+ options: g
87
80
  };
88
81
  }
89
82
  }
90
- if (n.name === "Field" && l?.fields?.length) {
91
- const m = e.state.doc.sliceString(n.from, e.pos), f = m.split(".");
92
- if (f.length > 1 && C) {
93
- const r = f.slice(0, -1), F = n.from + m.lastIndexOf(".") + 1, x = await B(
94
- r,
83
+ if (t.name === "Field" && l && Object.keys(l.fields).length) {
84
+ const p = e.state.doc.sliceString(t.from, e.pos), d = p.split(".");
85
+ if (d.length > 1 && h) {
86
+ const c = d.slice(0, -1), f = t.from + p.lastIndexOf(".") + 1, F = await $(
87
+ c,
95
88
  l,
96
- C
89
+ h
97
90
  );
98
- if (x) {
99
- const R = x.fields.map((u) => ({
100
- label: u.label,
101
- type: u.type,
102
- info: u.info
91
+ if (F) {
92
+ const v = Object.entries(F.fields).map(([N, S]) => ({
93
+ label: N,
94
+ type: S.type,
95
+ info: S.info
103
96
  }));
104
97
  return {
105
- from: F,
106
- options: R
98
+ from: f,
99
+ options: v
107
100
  };
108
101
  }
109
102
  return {
110
- from: F,
103
+ from: f,
111
104
  options: []
112
105
  };
113
106
  }
114
- const p = l.fields.map((r) => ({
115
- label: r.label,
116
- type: r.type,
117
- info: r.info
107
+ const g = Object.entries(l.fields).map(([c, f]) => ({
108
+ label: c,
109
+ type: f.type,
110
+ info: f.info
118
111
  }));
119
112
  return {
120
113
  from: a,
121
- options: p
114
+ options: g
122
115
  };
123
116
  }
124
- return n.name === "Field" ? {
117
+ return t.name === "Field" ? {
125
118
  from: a,
126
119
  options: []
127
120
  } : null;
128
121
  }
129
- }), Z = O.define([
130
- { tag: t.Condition, class: "cnd" },
131
- { tag: t.Operator, class: "cnd-op" },
132
- { tag: t.Value, class: "cnd-val" },
133
- { tag: t.Command, class: "cnd-val cnd-cmd" },
134
- { tag: t.Field, class: "cnd-fld" },
135
- { tag: t.Regex, class: "cnd-val cnd-rgx cnd-rgx-f" },
136
- { tag: o.string, class: "string" },
137
- { tag: o.lineComment, class: "comment" }
138
- ]), _ = T.configure({
122
+ }), M = A.define([
123
+ { tag: n.Condition, class: "cnd" },
124
+ { tag: n.Operator, class: "cnd-op" },
125
+ { tag: n.Value, class: "cnd-val" },
126
+ { tag: n.Command, class: "cnd-val cnd-cmd" },
127
+ { tag: n.Field, class: "cnd-fld" },
128
+ { tag: i.string, class: "string" },
129
+ { tag: i.lineComment, class: "comment" }
130
+ ]), R = j.configure({
139
131
  props: [
140
- A({
141
- "Condition/:": t.Operator,
142
- "ExcludeCondition/:": t.Operator,
143
- "Condition/Field/...": t.Field,
144
- "Condition/Predicate/RegexContent!": t.RegexContent,
145
- "Command!": t.Command,
146
- "Separator!": t.Operator,
147
- Regex: t.Regex,
148
- Comment: o.lineComment,
149
- Field: t.Field,
150
- "Value!": t.Value
132
+ L({
133
+ "Condition/:": n.Operator,
134
+ "ExcludeCondition/:": n.Operator,
135
+ "Condition/Field/...": n.Field,
136
+ "Command!": n.Command,
137
+ "Separator!": n.Operator,
138
+ Comment: i.lineComment,
139
+ Field: n.Field,
140
+ "Value!": n.Value
151
141
  }),
152
- v.add({
142
+ I.add({
153
143
  Query: (e) => e.column(e.node.from) + e.unit
154
144
  }),
155
- I.add({
156
- Query: N
145
+ V.add({
146
+ Query: w
157
147
  })
158
148
  ]
159
- }), S = P.define({
160
- parser: _,
149
+ }), b = O.define({
150
+ parser: R,
161
151
  languageData: {}
162
152
  });
163
- function K() {
164
- return new V(S, [
165
- w(Z),
166
- z
153
+ function U() {
154
+ return new E(b, [
155
+ D(M),
156
+ _
167
157
  ]);
168
158
  }
169
159
  export {
170
- K as DequelLang,
171
- S as dequelParser
160
+ U as DequelLang,
161
+ b as dequelParser
172
162
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dequel-editor",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "CodeMirror-based editor for Dequel query language",
5
5
  "type": "module",
6
6
  "main": "./dist/dequel-editor.js",
@@ -40,14 +40,14 @@
40
40
  "@lezer/common": "^1.5.0",
41
41
  "@lezer/generator": "^1.8.0",
42
42
  "@lezer/highlight": "^1.2.3",
43
- "@preact/preset-vite": "^2.10.3",
44
- "@tailwindcss/vite": "^4.1.18",
45
43
  "axios": "^1.13.4",
46
44
  "preact": "^10.28.3"
47
45
  },
48
46
  "devDependencies": {
49
47
  "@open-wc/testing": "^4.0.0",
48
+ "@preact/preset-vite": "^2.10.3",
50
49
  "@remcovaes/web-test-runner-vite-plugin": "^1.4.0",
50
+ "@tailwindcss/vite": "^4.1.18",
51
51
  "@types/node": "^20.19.31",
52
52
  "@typescript-eslint/eslint-plugin": "^7.18.0",
53
53
  "@typescript-eslint/parser": "^7.18.0",
@@ -57,6 +57,7 @@
57
57
  "eslint": "^8.57.1",
58
58
  "gettext-parser": "^8.0.0",
59
59
  "http-proxy-middleware": "^3.0.5",
60
+ "jsdom": "^28.1.0",
60
61
  "tailwindcss": "^4.1.18",
61
62
  "tsx": "^4.19.4",
62
63
  "typescript": "^5.9.3",