@ibiz-template/vue3-components 0.7.30 → 0.7.31-alpha.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.
Files changed (122) hide show
  1. package/dist/chart-0UV2FAN6.js +1 -0
  2. package/dist/index-maJGu4b8.js +4 -0
  3. package/dist/index.min.css +1 -1
  4. package/dist/index.system.min.js +1 -1
  5. package/dist/{xlsx-util-sKVlHqdj.js → xlsx-util-OUxT4A8O.js} +1 -1
  6. package/es/common/index.mjs +2 -0
  7. package/es/common/pql-editor/components/index.d.ts +1 -0
  8. package/es/common/pql-editor/components/index.mjs +3 -0
  9. package/es/common/pql-editor/components/pql-editor-suggestion/pql-editor-suggestion.css +1 -0
  10. package/es/common/pql-editor/components/pql-editor-suggestion/pql-editor-suggestion.d.ts +28 -0
  11. package/es/common/pql-editor/components/pql-editor-suggestion/pql-editor-suggestion.mjs +49 -0
  12. package/es/common/pql-editor/pql-editor.css +1 -0
  13. package/es/common/pql-editor/pql-editor.d.ts +68 -0
  14. package/es/common/pql-editor/pql-editor.mjs +606 -0
  15. package/es/common/pql-editor/pql-editor.module.d.ts +47 -0
  16. package/es/common/pql-editor/pql-editor.module.mjs +176 -0
  17. package/es/common/pql-editor/utils/index.d.ts +15 -0
  18. package/es/common/pql-editor/utils/index.mjs +270 -0
  19. package/es/control/chart/chart.mjs +32 -19
  20. package/es/control/dashboard/portlet/portlet-layout/portlet-layout.css +1 -1
  21. package/es/control/dashboard/portlet/portlet-layout/portlet-layout.d.ts +8 -0
  22. package/es/control/dashboard/portlet/portlet-layout/portlet-layout.mjs +12 -2
  23. package/es/control/dashboard/portlet/report-portlet/index.d.ts +1 -0
  24. package/es/control/dashboard/portlet/report-portlet/report-portlet.d.ts +1 -0
  25. package/es/control/dashboard/portlet/report-portlet/report-portlet.mjs +10 -2
  26. package/es/control/grid/grid/grid.mjs +2 -2
  27. package/es/control/grid/grid-column/grid-field-column/grid-field-column.d.ts +4 -2
  28. package/es/control/grid/grid-column/grid-field-column/grid-field-column.mjs +32 -2
  29. package/es/control/grid/grid-column/grid-field-column/index.d.ts +4 -0
  30. package/es/control/search-bar/filter-tree/filter-tree.css +1 -1
  31. package/es/control/search-bar/filter-tree/filter-tree.d.ts +30 -3
  32. package/es/control/search-bar/filter-tree/filter-tree.mjs +83 -9
  33. package/es/control/search-bar/search-bar.mjs +10 -1
  34. package/es/editor/array/ibiz-array/ibiz-array.d.ts +1 -1
  35. package/es/editor/autocomplete/ibiz-autocomplete/ibiz-autocomplete.d.ts +1 -1
  36. package/es/editor/carousel/ibiz-carousel/ibiz-carousel.d.ts +1 -1
  37. package/es/editor/cascader/ibiz-cascader/ibiz-cascader.d.ts +1 -1
  38. package/es/editor/check-box/ibiz-checkbox/ibiz-checkbox.d.ts +1 -1
  39. package/es/editor/check-box-list/checkbox-list-editor.controller.d.ts +7 -0
  40. package/es/editor/check-box-list/checkbox-list-editor.controller.mjs +11 -0
  41. package/es/editor/check-box-list/ibiz-checkbox-list/ibiz-checkbox-list.css +1 -1
  42. package/es/editor/check-box-list/ibiz-checkbox-list/ibiz-checkbox-list.d.ts +1 -1
  43. package/es/editor/check-box-list/ibiz-checkbox-list/ibiz-checkbox-list.mjs +2 -1
  44. package/es/editor/code/monaco-editor/monaco-editor.d.ts +1 -1
  45. package/es/editor/color-picker/ibiz-color-picker/ibiz-color-picker.d.ts +1 -1
  46. package/es/editor/data-picker/ibiz-mpicker/ibiz-mpicker.d.ts +1 -1
  47. package/es/editor/data-picker/ibiz-picker/ibiz-picker.d.ts +1 -1
  48. package/es/editor/data-picker/ibiz-picker-dropdown/ibiz-picker-dropdown.d.ts +1 -1
  49. package/es/editor/data-picker/ibiz-picker-embed-view/ibiz-picker-embed-view.d.ts +1 -1
  50. package/es/editor/data-picker/ibiz-picker-link/ibiz-picker-link.d.ts +1 -1
  51. package/es/editor/data-picker/ibiz-picker-select-view/ibiz-picker-select-view.d.ts +1 -1
  52. package/es/editor/date-picker/ibiz-date-picker/ibiz-date-picker.d.ts +1 -1
  53. package/es/editor/date-range/ibiz-date-range-picker/ibiz-date-range-picker.d.ts +1 -1
  54. package/es/editor/dropdown-list/ibiz-dropdown/ibiz-dropdown.d.ts +1 -1
  55. package/es/editor/dropdown-list/ibiz-dropdown/ibiz-dropdown.mjs +1 -1
  56. package/es/editor/dropdown-list/ibiz-emoji-picker/ibiz-emoji-picker.d.ts +1 -1
  57. package/es/editor/html/wang-editor/wang-editor.d.ts +1 -1
  58. package/es/editor/list-box/ibiz-list-box/ibiz-list-box.d.ts +1 -1
  59. package/es/editor/number-range/ibiz-number-range-picker/ibiz-number-range-picker.d.ts +1 -1
  60. package/es/editor/preset/preset-rawitem/ibiz-preset-rawitem/ibiz-preset-rawitem.d.ts +1 -1
  61. package/es/editor/radio-button-list/ibiz-radio/ibiz-radio.css +1 -1
  62. package/es/editor/radio-button-list/ibiz-radio/ibiz-radio.d.ts +1 -1
  63. package/es/editor/radio-button-list/ibiz-radio/ibiz-radio.mjs +2 -1
  64. package/es/editor/radio-button-list/radio-button-list.controller.d.ts +8 -0
  65. package/es/editor/radio-button-list/radio-button-list.controller.mjs +23 -0
  66. package/es/editor/rate/ibiz-rate/ibiz-rate.d.ts +1 -1
  67. package/es/editor/raw/ibiz-raw/ibiz-raw.d.ts +1 -1
  68. package/es/editor/slider/ibiz-slider/ibiz-slider.d.ts +1 -1
  69. package/es/editor/span/span/span.css +1 -1
  70. package/es/editor/span/span/span.d.ts +1 -1
  71. package/es/editor/span/span/span.mjs +2 -1
  72. package/es/editor/span/span-link/span-link.d.ts +1 -1
  73. package/es/editor/stepper/ibiz-stepper/ibiz-stepper.d.ts +1 -1
  74. package/es/editor/switch/ibiz-switch/ibiz-switch.d.ts +1 -1
  75. package/es/editor/text-box/ibiz-input-ip/ibiz-input-ip.d.ts +1 -1
  76. package/es/editor/text-box/ibiz-input-number/ibiz-input-number.d.ts +1 -1
  77. package/es/editor/text-box/input/input.d.ts +1 -1
  78. package/es/editor/upload/ibiz-file-upload/ibiz-file-upload.d.ts +1 -1
  79. package/es/editor/upload/ibiz-image-preview/ibiz-image-preview.d.ts +1 -1
  80. package/es/editor/upload/ibiz-image-upload/ibiz-image-upload.d.ts +1 -1
  81. package/es/editor/user/ibiz-searchcond-edit/ibiz-searchcond-edit.d.ts +1 -1
  82. package/es/interface/i-pql-item.d.ts +52 -0
  83. package/es/interface/i-pql-item.mjs +1 -0
  84. package/es/interface/i-pql-node.d.ts +37 -0
  85. package/es/interface/i-pql-node.mjs +1 -0
  86. package/es/interface/i-schema-field.d.ts +51 -0
  87. package/es/interface/i-schema-field.mjs +1 -0
  88. package/es/interface/index.d.ts +3 -0
  89. package/es/interface/index.mjs +5 -0
  90. package/lib/common/index.cjs +2 -0
  91. package/lib/common/pql-editor/components/index.cjs +7 -0
  92. package/lib/common/pql-editor/components/pql-editor-suggestion/pql-editor-suggestion.cjs +51 -0
  93. package/lib/common/pql-editor/components/pql-editor-suggestion/pql-editor-suggestion.css +1 -0
  94. package/lib/common/pql-editor/pql-editor.cjs +608 -0
  95. package/lib/common/pql-editor/pql-editor.css +1 -0
  96. package/lib/common/pql-editor/pql-editor.module.cjs +182 -0
  97. package/lib/common/pql-editor/utils/index.cjs +280 -0
  98. package/lib/control/chart/chart.cjs +31 -18
  99. package/lib/control/dashboard/portlet/portlet-layout/portlet-layout.cjs +12 -2
  100. package/lib/control/dashboard/portlet/portlet-layout/portlet-layout.css +1 -1
  101. package/lib/control/dashboard/portlet/report-portlet/report-portlet.cjs +9 -1
  102. package/lib/control/grid/grid/grid.cjs +2 -2
  103. package/lib/control/grid/grid-column/grid-field-column/grid-field-column.cjs +32 -2
  104. package/lib/control/search-bar/filter-tree/filter-tree.cjs +82 -8
  105. package/lib/control/search-bar/filter-tree/filter-tree.css +1 -1
  106. package/lib/control/search-bar/search-bar.cjs +10 -1
  107. package/lib/editor/check-box-list/checkbox-list-editor.controller.cjs +11 -0
  108. package/lib/editor/check-box-list/ibiz-checkbox-list/ibiz-checkbox-list.cjs +2 -1
  109. package/lib/editor/check-box-list/ibiz-checkbox-list/ibiz-checkbox-list.css +1 -1
  110. package/lib/editor/dropdown-list/ibiz-dropdown/ibiz-dropdown.cjs +1 -1
  111. package/lib/editor/radio-button-list/ibiz-radio/ibiz-radio.cjs +2 -1
  112. package/lib/editor/radio-button-list/ibiz-radio/ibiz-radio.css +1 -1
  113. package/lib/editor/radio-button-list/radio-button-list.controller.cjs +23 -0
  114. package/lib/editor/span/span/span.cjs +2 -1
  115. package/lib/editor/span/span/span.css +1 -1
  116. package/lib/interface/i-pql-item.cjs +3 -0
  117. package/lib/interface/i-pql-node.cjs +3 -0
  118. package/lib/interface/i-schema-field.cjs +3 -0
  119. package/lib/interface/index.cjs +7 -0
  120. package/package.json +6 -6
  121. package/dist/chart-J-0VPQfg.js +0 -1
  122. package/dist/index-5Hb8nfPm.js +0 -4
@@ -0,0 +1,608 @@
1
+ 'use strict';
2
+
3
+ var vue = require('vue');
4
+ var vue3Util = require('@ibiz-template/vue3-util');
5
+ var core = require('@ibiz-template/core');
6
+ var editor = require('@wangeditor/editor');
7
+ var pqlEditor_module = require('./pql-editor.module.cjs');
8
+ require('./components/index.cjs');
9
+ var index = require('./utils/index.cjs');
10
+ require('./pql-editor.css');
11
+ var pqlEditorSuggestion = require('./components/pql-editor-suggestion/pql-editor-suggestion.cjs');
12
+
13
+ "use strict";
14
+ const IBizPqlEditor = /* @__PURE__ */ vue.defineComponent({
15
+ name: "IBizPqlEditor",
16
+ props: {
17
+ fields: {
18
+ type: Array,
19
+ default: () => []
20
+ },
21
+ value: {
22
+ type: String,
23
+ default: ""
24
+ },
25
+ readonly: {
26
+ type: Boolean,
27
+ default: false
28
+ },
29
+ placeholder: {
30
+ type: String,
31
+ default: ""
32
+ },
33
+ context: {
34
+ type: Object,
35
+ required: true
36
+ },
37
+ renderItem: {
38
+ type: Function
39
+ }
40
+ },
41
+ emits: {
42
+ change: (_value) => true
43
+ },
44
+ setup(props, {
45
+ emit
46
+ }) {
47
+ const ns = vue3Util.useNamespace("pql-editor");
48
+ const editorRef = vue.ref();
49
+ let editor$1;
50
+ let overlayPopover;
51
+ const connectionList = [{
52
+ type: "pql-field-connection",
53
+ label: "and",
54
+ value: "and"
55
+ }, {
56
+ type: "pql-field-connection",
57
+ label: "or",
58
+ value: "or"
59
+ }];
60
+ const getCodeListItems = async (appCodeListId) => {
61
+ if (!props.context) {
62
+ return [];
63
+ }
64
+ const app = ibiz.hub.getApp(props.context.srfappid);
65
+ const items = await app.codeList.get(appCodeListId, props.context);
66
+ return items;
67
+ };
68
+ const getPreviousNode = (node) => {
69
+ var _a;
70
+ if (!editor$1 || !node) {
71
+ return;
72
+ }
73
+ const path = editor.DomEditor.findPath(editor$1, node);
74
+ if (path && editor.SlatePath.hasPrevious(path)) {
75
+ const slateNode = (_a = editor.SlateEditor.node(editor$1, editor.SlatePath.previous(path))) == null ? void 0 : _a[0];
76
+ if (slateNode) {
77
+ if (slateNode.type || slateNode.text) {
78
+ return slateNode;
79
+ }
80
+ return getPreviousNode(slateNode);
81
+ }
82
+ }
83
+ };
84
+ const getCurrentNode = () => {
85
+ var _a;
86
+ if (!editor$1) {
87
+ return;
88
+ }
89
+ const selection = editor$1.selection;
90
+ if (selection) {
91
+ const slateNode = (_a = editor.SlateEditor.node(editor$1, selection)) == null ? void 0 : _a[0];
92
+ if (slateNode) {
93
+ if (slateNode.type || slateNode.text) {
94
+ return slateNode;
95
+ }
96
+ return getPreviousNode(slateNode);
97
+ }
98
+ }
99
+ };
100
+ const getSuggestionItems = async () => {
101
+ var _a, _b, _c, _d, _e;
102
+ if (!editor$1) {
103
+ return [];
104
+ }
105
+ const currenNode = getCurrentNode();
106
+ const nodes = ((_a = editor$1.children[0]) == null ? void 0 : _a.children) || [];
107
+ const children = nodes.filter((node) => node.type || node.text);
108
+ if (!currenNode && children.length) {
109
+ return [];
110
+ }
111
+ if (editor$1.selection) {
112
+ const node = editor.SlateEditor.node(editor$1, editor$1.selection);
113
+ if (node && ((_b = node[0]) == null ? void 0 : _b.type)) {
114
+ return [];
115
+ }
116
+ }
117
+ if (currenNode && currenNode.type === "pql-field") {
118
+ const field = props.fields.find((item) => item.appDEFieldId === currenNode.value);
119
+ if (field && field.valueOPs) {
120
+ return index.FilterModes.filter((mode) => field.valueOPs.includes(mode.valueOP)).map((item) => {
121
+ return {
122
+ type: "pql-field-operator",
123
+ label: item.label,
124
+ value: item.valueOP
125
+ };
126
+ });
127
+ }
128
+ return [];
129
+ }
130
+ if (currenNode && currenNode.type === "pql-field-value") {
131
+ return connectionList;
132
+ }
133
+ if (currenNode && currenNode.type === "pql-field-operator") {
134
+ const mode = index.FilterModes.find((_mode) => _mode.valueOP === currenNode.value);
135
+ if (mode) {
136
+ if (index.ExcludeOPs.includes(mode.valueOP)) {
137
+ return connectionList;
138
+ }
139
+ const previousNode = getPreviousNode(currenNode);
140
+ if (previousNode && previousNode.type === "pql-field") {
141
+ const field = props.fields.find((item) => item.appDEFieldId === previousNode.value);
142
+ if (field && field.appCodeListId) {
143
+ const items = await getCodeListItems(field.appCodeListId);
144
+ return items.map((item) => {
145
+ return {
146
+ type: "pql-field-value",
147
+ label: item.text,
148
+ value: item.value
149
+ };
150
+ });
151
+ }
152
+ }
153
+ }
154
+ return [];
155
+ }
156
+ if (currenNode && currenNode.type === "pql-field-connection") {
157
+ return props.fields.map((item) => {
158
+ return {
159
+ type: "pql-field",
160
+ label: item.caption,
161
+ value: item.appDEFieldId
162
+ };
163
+ });
164
+ }
165
+ if (currenNode && !currenNode.type) {
166
+ const previousNode = getPreviousNode(currenNode);
167
+ if (previousNode && previousNode.type === "pql-field-operator") {
168
+ if (((_c = editor$1.selection) == null ? void 0 : _c.focus.offset) !== 0) {
169
+ return connectionList;
170
+ }
171
+ return [];
172
+ }
173
+ if (previousNode && previousNode.type === "pql-field") {
174
+ if (((_d = editor$1.selection) == null ? void 0 : _d.focus.offset) !== 0) {
175
+ return connectionList;
176
+ }
177
+ const field = props.fields.find((item) => item.appDEFieldId === previousNode.value);
178
+ if (field && field.valueOPs) {
179
+ return index.FilterModes.filter((mode) => field.valueOPs.includes(mode.valueOP)).map((item) => {
180
+ return {
181
+ type: "pql-field-operator",
182
+ label: item.label,
183
+ value: item.valueOP
184
+ };
185
+ });
186
+ }
187
+ }
188
+ if (previousNode && previousNode.type === "pql-field-connection") {
189
+ if (((_e = editor$1.selection) == null ? void 0 : _e.focus.offset) !== 0) {
190
+ return connectionList;
191
+ }
192
+ return props.fields.map((item) => {
193
+ return {
194
+ type: "pql-field",
195
+ label: item.caption,
196
+ value: item.appDEFieldId
197
+ };
198
+ });
199
+ }
200
+ if (previousNode && previousNode.type === "pql-field-value") {
201
+ return connectionList;
202
+ }
203
+ return [];
204
+ }
205
+ return props.fields.map((item) => {
206
+ return {
207
+ type: "pql-field",
208
+ label: item.caption,
209
+ value: item.appDEFieldId
210
+ };
211
+ });
212
+ };
213
+ const handelSuggestionSelect = (item) => {
214
+ if (!editor$1) {
215
+ return;
216
+ }
217
+ editor$1.restoreSelection();
218
+ if (!item.type) {
219
+ editor$1.insertText(item.label);
220
+ return;
221
+ }
222
+ const node = {
223
+ type: item.type,
224
+ label: item.label,
225
+ value: item.value,
226
+ children: [{
227
+ text: ""
228
+ }]
229
+ };
230
+ editor$1.insertNode(node);
231
+ editor$1.move(1);
232
+ };
233
+ const showSuggestion = async () => {
234
+ if (!editor$1) {
235
+ return;
236
+ }
237
+ const popover = overlayPopover;
238
+ overlayPopover = void 0;
239
+ await (popover == null ? void 0 : popover.dismiss());
240
+ const selection = window.getSelection();
241
+ if (!selection) {
242
+ return;
243
+ }
244
+ const {
245
+ focusNode
246
+ } = selection;
247
+ if (!focusNode || !focusNode.parentNode) {
248
+ return;
249
+ }
250
+ const items = await getSuggestionItems();
251
+ if (!items || !items.length) {
252
+ return;
253
+ }
254
+ overlayPopover = ibiz.overlay.createPopover(() => {
255
+ return vue.createVNode(pqlEditorSuggestion.IBizPqlEditorSuggestion, {
256
+ "items": items,
257
+ "renderItem": props.renderItem,
258
+ "onSelect": handelSuggestionSelect
259
+ }, null);
260
+ }, void 0, {
261
+ placement: "bottom-start",
262
+ autoClose: true,
263
+ width: "200px",
264
+ noArrow: true
265
+ });
266
+ await overlayPopover.present(focusNode.parentNode);
267
+ await overlayPopover.onWillDismiss();
268
+ overlayPopover = void 0;
269
+ };
270
+ const errorMsg = vue.ref();
271
+ const errorMsgEl = vue.ref();
272
+ const verifyNode = () => {
273
+ var _a;
274
+ if (!editor$1) {
275
+ return;
276
+ }
277
+ const nodes = ((_a = editor$1.children[0]) == null ? void 0 : _a.children) || [];
278
+ const children = nodes.filter((node) => node.type || node.text);
279
+ if (!children.length) {
280
+ return;
281
+ }
282
+ let last = {
283
+ type: "pql-field-connection"
284
+ };
285
+ for (let i = 0; i < children.length; i++) {
286
+ const child = children[i];
287
+ if (last.type === "pql-field-connection") {
288
+ if (child.type === "pql-field") {
289
+ last = child;
290
+ } else if (child.type === "pql-field-operator") {
291
+ return {
292
+ msg: "\u9519\u8BEF\u7684\u8868\u8FBE\u5F0F\u3002\u8868\u8FBE\u5F0F\u7F3A\u5931\u5DE6\u503C\u3002",
293
+ child
294
+ };
295
+ } else if (child.type === "pql-field-value" || child.text) {
296
+ return {
297
+ msg: "\u9519\u8BEF\u7684\u8868\u8FBE\u5F0F\u3002\u8868\u8FBE\u5F0F\u7F3A\u5931\u5DE6\u503C\u3002",
298
+ child
299
+ };
300
+ } else if (child.type === "pql-field-connection") {
301
+ return {
302
+ msg: "\u9519\u8BEF\u7684\u8868\u8FBE\u5F0F\u3002\u8FDE\u63A5\u7B26\u7F3A\u5931\u8868\u8FBE\u5F0F",
303
+ child
304
+ };
305
+ }
306
+ } else if (last.type === "pql-field") {
307
+ if (child.type === "pql-field") {
308
+ return {
309
+ msg: "\u9519\u8BEF\u7684\u8868\u8FBE\u5F0F\u3002\u8868\u8FBE\u5F0F\u7F3A\u5931\u64CD\u4F5C\u7B26\u3002",
310
+ child: children[i - 1] || child
311
+ };
312
+ }
313
+ if (child.type === "pql-field-operator") {
314
+ last = child;
315
+ } else if (child.type === "pql-field-value" || child.text) {
316
+ return {
317
+ msg: "\u9519\u8BEF\u7684\u8868\u8FBE\u5F0F\u3002\u8868\u8FBE\u5F0F\u7F3A\u5931\u64CD\u4F5C\u7B26\u3002",
318
+ child
319
+ };
320
+ } else if (child.type === "pql-field-connection") {
321
+ return {
322
+ msg: "\u9519\u8BEF\u7684\u8868\u8FBE\u5F0F\u3002\u8868\u8FBE\u5F0F\u7F3A\u5931\u64CD\u4F5C\u7B26\u3002",
323
+ child: children[i - 1] || child
324
+ };
325
+ }
326
+ } else if (last.type === "pql-field-operator") {
327
+ if (last.value && index.ExcludeOPs.includes(last.value)) {
328
+ if (child.type === "pql-field") {
329
+ return {
330
+ msg: "\u9519\u8BEF\u7684\u8868\u8FBE\u5F0F\u3002\u8868\u8FBE\u5F0F\u7F3A\u5931\u8FDE\u63A5\u7B26\u3002",
331
+ child
332
+ };
333
+ }
334
+ if (child.type === "pql-field-operator") {
335
+ return {
336
+ msg: "\u9519\u8BEF\u7684\u8868\u8FBE\u5F0F\u3002\u8868\u8FBE\u5F0F\u7F3A\u5931\u8FDE\u63A5\u7B26\u3002",
337
+ child
338
+ };
339
+ }
340
+ if (child.type === "pql-field-value" || child.text) {
341
+ return {
342
+ msg: "\u9519\u8BEF\u7684\u8868\u8FBE\u5F0F\u3002\u8868\u8FBE\u5F0F\u7F3A\u5931\u8FDE\u63A5\u7B26\u3002",
343
+ child
344
+ };
345
+ }
346
+ if (child.type === "pql-field-connection") {
347
+ last = child;
348
+ }
349
+ } else if (child.type === "pql-field") {
350
+ return {
351
+ msg: "\u9519\u8BEF\u7684\u8868\u8FBE\u5F0F\u3002\u8868\u8FBE\u5F0F\u7F3A\u5931\u53F3\u503C\u3002",
352
+ child: children[i - 1] || child
353
+ };
354
+ } else if (child.type === "pql-field-operator") {
355
+ return {
356
+ msg: "\u9519\u8BEF\u7684\u8868\u8FBE\u5F0F\u3002\u8868\u8FBE\u5F0F\u7F3A\u5931\u53F3\u503C\u3002",
357
+ child: children[i - 1] || child
358
+ };
359
+ } else if (child.type === "pql-field-value" || child.text) {
360
+ last = child;
361
+ } else if (child.type === "pql-field-connection") {
362
+ return {
363
+ msg: "\u9519\u8BEF\u7684\u8868\u8FBE\u5F0F\u3002\u8868\u8FBE\u5F0F\u7F3A\u5931\u53F3\u503C\u3002",
364
+ child: children[i - 1] || child
365
+ };
366
+ }
367
+ } else if (last.type === "pql-field-value" || last.text) {
368
+ if (child.type === "pql-field") {
369
+ return {
370
+ msg: "\u9519\u8BEF\u7684\u8868\u8FBE\u5F0F\u3002\u8868\u8FBE\u5F0F\u7F3A\u5931\u8FDE\u63A5\u7B26\u3002",
371
+ child
372
+ };
373
+ }
374
+ if (child.type === "pql-field-operator") {
375
+ return {
376
+ msg: "\u9519\u8BEF\u7684\u8868\u8FBE\u5F0F\u3002\u8868\u8FBE\u5F0F\u7F3A\u5931\u8FDE\u63A5\u7B26\u3002",
377
+ child
378
+ };
379
+ }
380
+ if (child.type === "pql-field-value" || child.text) {
381
+ return {
382
+ msg: "\u9519\u8BEF\u7684\u8868\u8FBE\u5F0F\u3002\u8868\u8FBE\u5F0F\u7F3A\u5931\u8FDE\u63A5\u7B26\u3002",
383
+ child
384
+ };
385
+ }
386
+ if (child.type === "pql-field-connection") {
387
+ last = child;
388
+ }
389
+ }
390
+ }
391
+ if (last.type !== "pql-field-value" || !last.text) {
392
+ if (last.type === "pql-field") {
393
+ return {
394
+ msg: "\u9519\u8BEF\u7684\u8868\u8FBE\u5F0F\u3002\u8868\u8FBE\u5F0F\u7F3A\u5931\u64CD\u4F5C\u7B26\u3002",
395
+ child: children[children.length - 1]
396
+ };
397
+ }
398
+ if (last.type === "pql-field-operator") {
399
+ if (last.value && index.ExcludeOPs.includes(last.value)) {
400
+ return;
401
+ }
402
+ return {
403
+ msg: "\u9519\u8BEF\u7684\u8868\u8FBE\u5F0F\u3002\u8868\u8FBE\u5F0F\u7F3A\u5931\u53F3\u503C\u3002",
404
+ child: children[children.length - 1]
405
+ };
406
+ }
407
+ if (last.type === "pql-field-connection") {
408
+ return {
409
+ msg: "\u9519\u8BEF\u7684\u8868\u8FBE\u5F0F\u3002\u8FDE\u63A5\u7B26\u7F3A\u5931\u8868\u8FBE\u5F0F\u3002",
410
+ child: children[children.length - 1]
411
+ };
412
+ }
413
+ }
414
+ };
415
+ const verify = () => {
416
+ if (errorMsg.value) {
417
+ return false;
418
+ }
419
+ return true;
420
+ };
421
+ const currentValue = vue.ref("");
422
+ const htmlText = vue.ref("");
423
+ vue.watch(() => props.value, async () => {
424
+ if (props.value === currentValue.value) {
425
+ return;
426
+ }
427
+ if (!props.value) {
428
+ currentValue.value = "";
429
+ htmlText.value = "";
430
+ editor$1 == null ? void 0 : editor$1.clear();
431
+ return;
432
+ }
433
+ const pqlItems = index.parseCustomCond(props.value);
434
+ if (pqlItems) {
435
+ const nodes = await index.pqlItemsToPqlNodes(pqlItems, props.fields, getCodeListItems);
436
+ if (nodes && nodes.length) {
437
+ const html = index.pqlNodesToHtml(nodes);
438
+ currentValue.value = props.value;
439
+ htmlText.value = html;
440
+ editor$1 == null ? void 0 : editor$1.setHtml(html);
441
+ return;
442
+ }
443
+ }
444
+ currentValue.value = "";
445
+ htmlText.value = "";
446
+ editor$1 == null ? void 0 : editor$1.clear();
447
+ }, {
448
+ immediate: true
449
+ });
450
+ vue.watch(() => props.fields, async () => {
451
+ if (!props.value) {
452
+ currentValue.value = "";
453
+ htmlText.value = "";
454
+ editor$1 == null ? void 0 : editor$1.clear();
455
+ return;
456
+ }
457
+ const pqlItems = index.parseCustomCond(props.value);
458
+ if (pqlItems) {
459
+ const nodes = await index.pqlItemsToPqlNodes(pqlItems, props.fields, getCodeListItems);
460
+ if (nodes && nodes.length) {
461
+ const html = index.pqlNodesToHtml(nodes);
462
+ currentValue.value = props.value;
463
+ htmlText.value = html;
464
+ editor$1 == null ? void 0 : editor$1.setHtml(html);
465
+ return;
466
+ }
467
+ }
468
+ currentValue.value = "";
469
+ htmlText.value = "";
470
+ editor$1 == null ? void 0 : editor$1.clear();
471
+ }, {
472
+ immediate: true
473
+ });
474
+ const handleChange = () => {
475
+ var _a;
476
+ if (!editor$1) {
477
+ return;
478
+ }
479
+ const nodes = ((_a = editor$1.children[0]) == null ? void 0 : _a.children) || [];
480
+ const children = nodes.filter((node) => node.type || node.text);
481
+ setTimeout(() => {
482
+ var _a2;
483
+ if (!editor$1) {
484
+ return;
485
+ }
486
+ const {
487
+ msg,
488
+ child
489
+ } = verifyNode() || {};
490
+ errorMsg.value = msg || "";
491
+ (_a2 = errorMsgEl.value) == null ? void 0 : _a2.classList.remove(ns.b("error-msg"));
492
+ if (child) {
493
+ const el = editor$1.toDOMNode(child);
494
+ if (el) {
495
+ errorMsgEl.value = el;
496
+ el.classList.add(ns.b("error-msg"));
497
+ }
498
+ }
499
+ if (!msg) {
500
+ try {
501
+ const items = index.generateItems(children);
502
+ const customCond = index.generateCustomCond(items, props.fields);
503
+ currentValue.value = customCond;
504
+ emit("change", customCond);
505
+ } catch (err) {
506
+ ibiz.log.error(err == null ? void 0 : err.message);
507
+ }
508
+ }
509
+ }, 10);
510
+ };
511
+ let cleanupKeydown = () => {
512
+ };
513
+ let cleanupClick = () => {
514
+ };
515
+ vue.onMounted(() => {
516
+ if (!editorRef.value) {
517
+ return;
518
+ }
519
+ if (!window.PqlModule) {
520
+ editor.Boot.registerModule(pqlEditor_module.PqlModule);
521
+ window.PqlModule = true;
522
+ }
523
+ const editorConfig = {
524
+ autoFocus: false,
525
+ readOnly: props.readonly,
526
+ placeholder: props.placeholder,
527
+ EXTEND_CONF: {
528
+ pql: {
529
+ showSuggestion
530
+ }
531
+ },
532
+ onFocus: () => {
533
+ setTimeout(() => {
534
+ showSuggestion();
535
+ }, 10);
536
+ },
537
+ onChange: handleChange
538
+ };
539
+ editor$1 = editor.createEditor({
540
+ selector: editorRef.value,
541
+ config: editorConfig,
542
+ mode: "simple"
543
+ });
544
+ editor$1.setHtml(htmlText.value);
545
+ cleanupKeydown = core.listenJSEvent(editorRef.value, "keydown", (event) => {
546
+ setTimeout(() => {
547
+ if ((event.key === "ArrowLeft" || event.key === "ArrowRight") && editor$1) {
548
+ const {
549
+ selection
550
+ } = editor$1;
551
+ if (selection && selection.focus.offset === 0) {
552
+ const node = editor.SlateEditor.node(editor$1, selection)[0];
553
+ if (node) {
554
+ const el = editor$1.toDOMNode(node);
555
+ if (index.isMove(el)) {
556
+ if (event.key === "ArrowLeft") {
557
+ editor$1.moveReverse(1);
558
+ }
559
+ if (event.key === "ArrowRight") {
560
+ editor$1.move(1);
561
+ }
562
+ }
563
+ }
564
+ }
565
+ setTimeout(() => {
566
+ showSuggestion();
567
+ }, 10);
568
+ }
569
+ }, 10);
570
+ if (event.key === "Escape") {
571
+ event.stopPropagation();
572
+ overlayPopover == null ? void 0 : overlayPopover.dismiss();
573
+ }
574
+ });
575
+ if (!props.readonly) {
576
+ cleanupClick = core.listenJSEvent(editorRef.value, "click", () => {
577
+ setTimeout(() => {
578
+ showSuggestion();
579
+ }, 10);
580
+ });
581
+ }
582
+ });
583
+ vue.onUnmounted(() => {
584
+ cleanupKeydown();
585
+ cleanupClick();
586
+ overlayPopover == null ? void 0 : overlayPopover.dismiss();
587
+ });
588
+ return {
589
+ ns,
590
+ editorRef,
591
+ editor: editor$1,
592
+ errorMsg,
593
+ verify
594
+ };
595
+ },
596
+ render() {
597
+ return vue.createVNode("div", {
598
+ "class": this.ns.b()
599
+ }, [vue.createVNode("div", {
600
+ "ref": "editorRef",
601
+ "class": this.ns.b("content")
602
+ }, null), vue.createVNode("div", {
603
+ "class": this.ns.b("footer")
604
+ }, [this.errorMsg])]);
605
+ }
606
+ });
607
+
608
+ exports.IBizPqlEditor = IBizPqlEditor;
@@ -0,0 +1 @@
1
+ .ibiz-pql-editor{display:flex;flex-direction:column;width:100%;height:100%;padding:var(--ibiz-spacing-base-tight);overflow:auto;font-size:var(--ibiz-font-size-regular);border:1px solid var(--ibiz-color-border);border-radius:var(--ibiz-border-radius-small);outline:0}.ibiz-pql-editor [data-slate-node=element][data-slate-void=true]{margin:var(--ibiz-spacing-extra-tight)}.ibiz-pql-editor-content{flex:1 0 0}.ibiz-pql-editor-content .w-e-text-placeholder{top:var(--ibiz-spacing-super-tight);left:0;font-style:normal}.ibiz-pql-editor-content .w-e-text-container [data-slate-editor]{padding:0}.ibiz-pql-editor-content .w-e-text-container [data-slate-editor] p{margin:0}.ibiz-pql-editor-footer{flex:0 0 auto;font-size:var(--ibiz-font-size-small);color:var(--ibiz-color-danger)}.ibiz-pql-editor-error-msg{position:relative}.ibiz-pql-editor-error-msg::after{position:absolute;bottom:-.12rem;left:0;width:100%;height:.25rem;content:"";background:linear-gradient(135deg,transparent,transparent 45%,var(--ibiz-color-danger),transparent 55%,transparent 100%),linear-gradient(45deg,transparent,transparent 45%,var(--ibiz-color-danger),transparent 55%,transparent 100%);background-repeat:repeat-x,repeat-x;background-size:.5rem .5rem}