@jetlinks-web/components 2.1.0 → 2.1.2

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.
@@ -21,7 +21,7 @@
21
21
  } */
22
22
  import { defineComponent as _defineComponent } from 'vue';
23
23
  import { unref as _unref, createVNode as _createVNode, withCtx as _withCtx, createTextVNode as _createTextVNode, openBlock as _openBlock, createElementBlock as _createElementBlock, createCommentVNode as _createCommentVNode, createBlock as _createBlock, pushScopeId as _pushScopeId, popScopeId as _popScopeId } from "vue";
24
- const _withScopeId = n => (_pushScopeId("data-v-1722997808659"), n = n(), _popScopeId(), n);
24
+ const _withScopeId = n => (_pushScopeId("data-v-1723098074919"), n = n(), _popScopeId(), n);
25
25
  const _hoisted_1 = {
26
26
  key: 0,
27
27
  style: { "width": "240px" }
package/es/Search/Item.js CHANGED
@@ -78,7 +78,7 @@ function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]
78
78
  } */
79
79
  import { defineComponent as _defineComponent } from 'vue';
80
80
  import { unref as _unref, openBlock as _openBlock, createBlock as _createBlock, createCommentVNode as _createCommentVNode, toDisplayString as _toDisplayString, createElementBlock as _createElementBlock, createVNode as _createVNode, Fragment as _Fragment, normalizeStyle as _normalizeStyle, mergeProps as _mergeProps, resolveDynamicComponent as _resolveDynamicComponent, withCtx as _withCtx, createElementVNode as _createElementVNode, pushScopeId as _pushScopeId, popScopeId as _popScopeId } from "vue";
81
- const _withScopeId = n => (_pushScopeId("data-v-1722997808112"), n = n(), _popScopeId(), n);
81
+ const _withScopeId = n => (_pushScopeId("data-v-1723098072927"), n = n(), _popScopeId(), n);
82
82
  const _hoisted_1 = { class: "JSearch-item" };
83
83
  const _hoisted_2 = {
84
84
  key: 0,
@@ -36,7 +36,7 @@
36
36
  } */
37
37
  import { defineComponent as _defineComponent } from 'vue';
38
38
  import { renderList as _renderList, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock, createVNode as _createVNode, unref as _unref, withCtx as _withCtx, createBlock as _createBlock, renderSlot as _renderSlot, toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, normalizeStyle as _normalizeStyle, createElementVNode as _createElementVNode, normalizeClass as _normalizeClass, pushScopeId as _pushScopeId, popScopeId as _popScopeId } from "vue";
39
- const _withScopeId = n => (_pushScopeId("data-v-1722997808265"), n = n(), _popScopeId(), n);
39
+ const _withScopeId = n => (_pushScopeId("data-v-1723098073260"), n = n(), _popScopeId(), n);
40
40
  const _hoisted_1 = { class: "JSearch-content simple" };
41
41
  const _hoisted_2 = { class: "JSearch-items" };
42
42
  import { Button, Row, Col, Form, FormItemRest, } from 'ant-design-vue';
@@ -28,6 +28,7 @@ function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]
28
28
  "watch": "setup-const",
29
29
  "onMounted": "setup-const",
30
30
  "onBeforeUnmount": "setup-const",
31
+ "nextTick": "setup-const",
31
32
  "handleColumnFixed": "setup-maybe-ref",
32
33
  "props": "setup-reactive-const",
33
34
  "emit": "setup-const",
@@ -66,7 +67,7 @@ import ContextMenu from './components/ContextMenu';
66
67
  import { useRightMenuContext, useTableTool } from "./hooks";
67
68
  import { randomString } from "@jetlinks-web/utils";
68
69
  import { bodyProps, defaultProps } from "./props";
69
- import { ref, reactive, computed, watch, onMounted, onBeforeUnmount } from 'vue';
70
+ import { ref, reactive, computed, watch, onMounted, onBeforeUnmount, nextTick } from 'vue';
70
71
  import { handleColumnFixed } from "./utils";
71
72
  const __sfc_main__ = Object.assign({
72
73
  name: 'JEditTableBody'
@@ -37,6 +37,8 @@ function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]
37
37
  "ref": "setup-const",
38
38
  "reactive": "setup-const",
39
39
  "defineOptions": "setup-const",
40
+ "computed": "setup-const",
41
+ "watch": "setup-const",
40
42
  "bodyProps": "setup-maybe-ref",
41
43
  "defaultProps": "setup-maybe-ref",
42
44
  "findIndex": "setup-maybe-ref",
@@ -55,7 +57,7 @@ function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]
55
57
  "fields": "setup-const",
56
58
  "fieldsErrMap": "setup-ref",
57
59
  "sortData": "setup-reactive-const",
58
- "_dataSource": "setup-maybe-ref",
60
+ "_dataSource": "setup-ref",
59
61
  "isFullscreen": "setup-maybe-ref",
60
62
  "toggle": "setup-maybe-ref",
61
63
  "rules": "setup-maybe-ref",
@@ -67,7 +69,7 @@ function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]
67
69
  "findField": "setup-const",
68
70
  "removeFieldError": "setup-const",
69
71
  "addFieldError": "setup-const",
70
- "scrollWidth": "setup-maybe-ref",
72
+ "scrollWidth": "setup-ref",
71
73
  "onHorizontalScroll": "setup-const",
72
74
  "onResize": "setup-const",
73
75
  "onScrollDown": "setup-const",
@@ -90,7 +92,7 @@ import { tableProps } from 'ant-design-vue/lib/table';
90
92
  import Header from './header.js';
91
93
  import Body from './body.js';
92
94
  import { useFullscreen } from '@vueuse/core';
93
- import { provide, useAttrs, useSlots, ref, reactive, } from 'vue';
95
+ import { provide, useAttrs, useSlots, ref, reactive, computed, watch } from 'vue';
94
96
  import { bodyProps, defaultProps } from "./props";
95
97
  import { findIndex, get, sortBy } from 'lodash-es';
96
98
  const __sfc_main__ = Object.assign({
@@ -343,16 +345,17 @@ const __sfc_main__ = Object.assign({
343
345
  _createElementVNode("div", _hoisted_2, [
344
346
  _createElementVNode("div", {
345
347
  class: "jetlinks-edit-table-header",
346
- style: _normalizeStyle([{ "height": "50px" }, { paddingRight: _unref(scrollWidth) + 'px' }])
348
+ style: _normalizeStyle([{ "height": "50px" }, { paddingRight: scrollWidth.value + 'px' }])
347
349
  }, [
348
350
  _createVNode(Header, {
349
351
  columns: myColumns.value,
350
352
  style: _normalizeStyle({ width: tableStyle.width }),
351
- rowKey: _ctx.rowKey
352
- }, null, 8 /* PROPS */, ["columns", "style", "rowKey"]),
353
+ rowKey: _ctx.rowKey,
354
+ searchColumns: _ctx.searchColumns
355
+ }, null, 8 /* PROPS */, ["columns", "style", "rowKey", "searchColumns"]),
353
356
  _createElementVNode("div", {
354
357
  class: "jetlinks-edit-table-header-scroll-hidden",
355
- style: _normalizeStyle({ width: _unref(scrollWidth) + 'px' })
358
+ style: _normalizeStyle({ width: scrollWidth.value + 'px' })
356
359
  }, null, 4 /* STYLE */)
357
360
  ], 4 /* STYLE */),
358
361
  _createElementVNode("div", {
@@ -362,7 +365,7 @@ const __sfc_main__ = Object.assign({
362
365
  _createVNode(Body, {
363
366
  ref_key: "tableBody",
364
367
  ref: tableBody,
365
- dataSource: _unref(_dataSource),
368
+ dataSource: _dataSource.value,
366
369
  columns: myColumns.value,
367
370
  cellHeight: _ctx.cellHeight,
368
371
  height: _ctx.height,
@@ -400,7 +403,7 @@ const __sfc_main__ = Object.assign({
400
403
  ], 544 /* NEED_HYDRATION, NEED_PATCH */),
401
404
  _createElementVNode("div", {
402
405
  class: "jetlinks-edit-table-horizontal-scroll-hidden",
403
- style: _normalizeStyle({ width: _unref(scrollWidth) + 'px' })
406
+ style: _normalizeStyle({ width: scrollWidth.value + 'px' })
404
407
  }, null, 4 /* STYLE */)
405
408
  ]))
406
409
  : _createCommentVNode("v-if", true)
@@ -0,0 +1,214 @@
1
+ function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) {
2
+ const op = ops[i];
3
+ const fn = ops[i + 1];
4
+ i += 2;
5
+ if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) {
6
+ return undefined;
7
+ }
8
+ if (op === 'access' || op === 'optionalAccess') {
9
+ lastAccessLHS = value;
10
+ value = fn(value);
11
+ }
12
+ else if (op === 'call' || op === 'optionalCall') {
13
+ value = fn((...args) => value.call(lastAccessLHS, ...args));
14
+ lastAccessLHS = undefined;
15
+ }
16
+ } return value; }
17
+ /* Analyzed bindings: {
18
+ "name": "props",
19
+ "required": "props",
20
+ "onBeforeUnmount": "setup-const",
21
+ "computed": "setup-const",
22
+ "reactive": "setup-const",
23
+ "watch": "setup-const",
24
+ "defineOptions": "setup-const",
25
+ "provide": "setup-const",
26
+ "get": "setup-maybe-ref",
27
+ "isArray": "setup-maybe-ref",
28
+ "useProvideFormItemContext": "setup-maybe-ref",
29
+ "useInjectError": "setup-maybe-ref",
30
+ "useInjectForm": "setup-maybe-ref",
31
+ "TABLE_FORM_ITEM_ERROR": "setup-maybe-ref",
32
+ "props": "setup-reactive-const",
33
+ "emit": "setup-const",
34
+ "context": "setup-maybe-ref",
35
+ "globalErrorMessage": "setup-maybe-ref",
36
+ "hideTimer": "setup-let",
37
+ "eventKey": "setup-ref",
38
+ "errorMap": "setup-reactive-const",
39
+ "filedId": "setup-ref",
40
+ "filedName": "setup-ref",
41
+ "filedValue": "setup-ref",
42
+ "popContainer": "setup-const",
43
+ "removeTimer": "setup-const",
44
+ "showErrorTip": "setup-const",
45
+ "hideErrorTip": "setup-const",
46
+ "validateRules": "setup-const",
47
+ "onFieldBlur": "setup-const",
48
+ "onFieldChange": "setup-const"
49
+ } */
50
+ import { toDisplayString as _toDisplayString, createElementVNode as _createElementVNode, openBlock as _openBlock, createElementBlock as _createElementBlock, createCommentVNode as _createCommentVNode, resolveComponent as _resolveComponent, withCtx as _withCtx, createVNode as _createVNode, renderSlot as _renderSlot, normalizeClass as _normalizeClass, Fragment as _Fragment, pushScopeId as _pushScopeId, popScopeId as _popScopeId } from "vue";
51
+ const _withScopeId = n => (_pushScopeId("data-v-1723098069375"), n = n(), _popScopeId(), n);
52
+ const _hoisted_1 = { style: { "color": "#1d2129" } };
53
+ const _hoisted_2 = {
54
+ key: 0,
55
+ class: "table-form-error-target"
56
+ };
57
+ const _hoisted_3 = ["id"];
58
+ import { onBeforeUnmount, computed, reactive, watch, provide } from "vue";
59
+ import { get, isArray } from 'lodash-es';
60
+ import { useProvideFormItemContext } from 'ant-design-vue/es/form/FormItemContext';
61
+ import { useInjectError, useInjectForm } from "./hooks";
62
+ import { TABLE_FORM_ITEM_ERROR } from "./consts";
63
+ const __sfc_main__ = Object.assign({
64
+ name: 'JEditTableFormItem'
65
+ }, {
66
+ props: {
67
+ name: {
68
+ type: [String, Array],
69
+ default: undefined
70
+ },
71
+ required: {
72
+ type: Boolean,
73
+ default: false
74
+ }
75
+ },
76
+ emits: ['change'],
77
+ setup(__props, { emit: __emit }) {
78
+ const props = __props;
79
+ const emit = __emit;
80
+ const context = useInjectForm();
81
+ const globalErrorMessage = useInjectError();
82
+ let hideTimer;
83
+ const eventKey = computed(() => {
84
+ const names = isArray(props.name) ? props.name : [props.name];
85
+ return names.join('-');
86
+ });
87
+ const errorMap = reactive({
88
+ message: '',
89
+ visible: false
90
+ });
91
+ const filedId = computed(() => {
92
+ const names = isArray(props.name) ? props.name : [props.name];
93
+ return names.join('_');
94
+ });
95
+ const filedName = computed(() => {
96
+ const names = isArray(props.name) ? props.name : [props.name];
97
+ const _rules = context.rules.value;
98
+ let tempKey = undefined;
99
+ for (const key of names) {
100
+ if (key in _rules) {
101
+ tempKey = key;
102
+ }
103
+ }
104
+ return tempKey;
105
+ });
106
+ const filedValue = computed(() => {
107
+ return get(context.dataSource.value, props.name);
108
+ });
109
+ provide(TABLE_FORM_ITEM_ERROR, errorMap);
110
+ const popContainer = (e) => {
111
+ return e;
112
+ };
113
+ const removeTimer = () => {
114
+ if (hideTimer) {
115
+ window.clearTimeout(hideTimer);
116
+ hideTimer = null;
117
+ }
118
+ };
119
+ const showErrorTip = (msg) => {
120
+ removeTimer();
121
+ errorMap.message = msg;
122
+ errorMap.visible = true;
123
+ };
124
+ const hideErrorTip = () => {
125
+ errorMap.visible = false;
126
+ removeTimer();
127
+ hideTimer = setTimeout(() => {
128
+ errorMap.message = '';
129
+ }, 300);
130
+ };
131
+ const validateRules = () => {
132
+ let index = 0;
133
+ if (isArray(props.name)) {
134
+ index = props.name[0];
135
+ }
136
+ const promise = context.validateItem({ [filedName.value]: get(context.dataSource.value, props.name) }, index);
137
+ promise.catch(res => {
138
+ const error = _optionalChain([res, 'optionalAccess', _2 => _2.filter, 'call', _3 => _3(item => item.field === filedName.value)]) || [];
139
+ if (error.length === 0) {
140
+ hideErrorTip();
141
+ context.removeFieldError(eventKey.value);
142
+ }
143
+ else {
144
+ removeTimer();
145
+ errorMap.message = _optionalChain([error, 'access', _4 => _4[0], 'optionalAccess', _5 => _5.message]) || errorMap.message;
146
+ errorMap.visible = !!error.length;
147
+ context.addFieldError(eventKey.value, errorMap.message);
148
+ }
149
+ return errorMap.message;
150
+ });
151
+ return promise;
152
+ };
153
+ const onFieldBlur = () => {
154
+ // validateRules()
155
+ };
156
+ const onFieldChange = () => {
157
+ validateRules();
158
+ emit('change');
159
+ };
160
+ watch(() => globalErrorMessage.value, (val) => {
161
+ if (val[eventKey.value]) {
162
+ showErrorTip(val[eventKey.value]);
163
+ }
164
+ else {
165
+ hideErrorTip();
166
+ }
167
+ }, { immediate: true, deep: true });
168
+ useProvideFormItemContext({
169
+ id: filedId,
170
+ onFieldChange,
171
+ onFieldBlur,
172
+ }, computed(() => get(context.dataSource.value, props.name)));
173
+ onBeforeUnmount(() => {
174
+ hideErrorTip();
175
+ });
176
+ watch(() => [filedName.value, props.name], () => {
177
+ context.addField(eventKey.value, {
178
+ filedName: filedName.value,
179
+ eventKey: eventKey.value,
180
+ names: props.name,
181
+ validateRules,
182
+ showErrorTip
183
+ });
184
+ }, { immediate: true });
185
+ return (_ctx, _cache) => {
186
+ const _component_a_tooltip = _resolveComponent("a-tooltip");
187
+ return (_openBlock(), _createElementBlock(_Fragment, null, [
188
+ _createVNode(_component_a_tooltip, {
189
+ color: "#ffffff",
190
+ "get-popup-container": popContainer,
191
+ arrowPointAtCenter: true
192
+ }, {
193
+ title: _withCtx(() => [
194
+ _createElementVNode("span", _hoisted_1, _toDisplayString(errorMap.message), 1 /* TEXT */)
195
+ ]),
196
+ default: _withCtx(() => [
197
+ (errorMap.visible)
198
+ ? (_openBlock(), _createElementBlock("div", _hoisted_2))
199
+ : _createCommentVNode("v-if", true)
200
+ ]),
201
+ _: 1 /* STABLE */
202
+ }),
203
+ _createElementVNode("div", {
204
+ id: eventKey.value,
205
+ style: { "position": "relative" },
206
+ class: _normalizeClass({ 'edit-table-form-has-error': errorMap.message })
207
+ }, [
208
+ _renderSlot(_ctx.$slots, "default")
209
+ ], 10 /* CLASS, PROPS */, _hoisted_3)
210
+ ], 64 /* STABLE_FRAGMENT */));
211
+ };
212
+ }
213
+ });
214
+ export default __sfc_main__;
@@ -78,7 +78,7 @@ const __sfc_main__ = Object.assign({
78
78
  style: {
79
79
  type: Object,
80
80
  default: undefined
81
- }
81
+ },
82
82
  },
83
83
  setup(__props) {
84
84
  const props = __props;
@@ -232,8 +232,9 @@ const __sfc_main__ = Object.assign({
232
232
  key: 0,
233
233
  searchKey: searchData.key,
234
234
  rowKey: _ctx.rowKey,
235
+ columns: _ctx.searchColumns,
235
236
  onClose: _cache[0] || (_cache[0] = $event => (searchData.visible = false))
236
- }, null, 8 /* PROPS */, ["searchKey", "rowKey"]))
237
+ }, null, 8 /* PROPS */, ["searchKey", "rowKey", "columns"]))
237
238
  : _createCommentVNode("v-if", true)
238
239
  ], 64 /* STABLE_FRAGMENT */));
239
240
  };
@@ -17,6 +17,7 @@ function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]
17
17
  /* Analyzed bindings: {
18
18
  "searchKey": "props",
19
19
  "rowKey": "props",
20
+ "columns": "props",
20
21
  "Table": "setup-const",
21
22
  "useTableDataSource": "setup-maybe-ref",
22
23
  "useTableTool": "setup-maybe-ref",
@@ -39,7 +40,6 @@ function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]
39
40
  "tableHeight": "setup-ref",
40
41
  "selectedRowKeys": "setup-ref",
41
42
  "tableRef": "setup-ref",
42
- "columns": "setup-const",
43
43
  "selectedTableRow": "setup-const",
44
44
  "handleFilterArray": "setup-const",
45
45
  "search": "setup-const",
@@ -73,6 +73,10 @@ const __sfc_main__ = Object.assign({
73
73
  rowKey: {
74
74
  type: String,
75
75
  default: 'id'
76
+ },
77
+ columns: {
78
+ type: Array,
79
+ default: () => []
76
80
  }
77
81
  },
78
82
  emits: ['close'],
@@ -89,16 +93,6 @@ const __sfc_main__ = Object.assign({
89
93
  const tableHeight = ref(230);
90
94
  const selectedRowKeys = ref([]);
91
95
  const tableRef = ref();
92
- const columns = [
93
- {
94
- title: '标识',
95
- dataIndex: 'id',
96
- },
97
- {
98
- title: '名称',
99
- dataIndex: 'name',
100
- }
101
- ];
102
96
  const selectedTableRow = (record) => {
103
97
  tableTool.scrollTo({
104
98
  ...record,
@@ -238,7 +232,7 @@ const __sfc_main__ = Object.assign({
238
232
  ref_key: "tableRef",
239
233
  ref: tableRef,
240
234
  "data-source": filterArray.value,
241
- columns: columns,
235
+ columns: __props.columns,
242
236
  height: tableHeight.value,
243
237
  disableMenu: false,
244
238
  cellHeight: 36,
@@ -270,7 +264,7 @@ const __sfc_main__ = Object.assign({
270
264
  }, 1024 /* DYNAMIC_SLOTS */)
271
265
  ]),
272
266
  _: 1 /* STABLE */
273
- }, 8 /* PROPS */, ["data-source", "height", "rowSelection"])
267
+ }, 8 /* PROPS */, ["data-source", "columns", "height", "rowSelection"])
274
268
  ]))
275
269
  : _createCommentVNode("v-if", true),
276
270
  (visible.value)
@@ -8,9 +8,11 @@ exports.default = void 0;
8
8
  var _EditTable = _interopRequireDefault(require("./EditTable.js"));
9
9
  var _Body = _interopRequireDefault(require("./Body.js"));
10
10
  var _Header = _interopRequireDefault(require("./Header.js"));
11
+ var _FormItem = _interopRequireDefault(require("./FormItem.js"));
11
12
  _EditTable.default.install = function (app) {
12
13
  app.component(_EditTable.default.name, _EditTable.default);
13
14
  app.component(_Body.default.name, _Body.default);
14
15
  app.component(_Header.default.name, _Header.default);
16
+ app.component(_FormItem.default.name, _FormItem.default);
15
17
  };
16
18
  var _default = exports.default = _EditTable.default;
@@ -15,6 +15,18 @@ var defaultProps = exports.defaultProps = function defaultProps() {
15
15
  default: function _default() {
16
16
  return [];
17
17
  }
18
+ },
19
+ searchColumns: {
20
+ type: Array,
21
+ default: function _default() {
22
+ return [{
23
+ title: '标识',
24
+ dataIndex: 'id'
25
+ }, {
26
+ title: '名称',
27
+ dataIndex: 'name'
28
+ }];
29
+ }
18
30
  }
19
31
  };
20
32
  };
@@ -6,7 +6,7 @@
6
6
  } */
7
7
  import { defineComponent as _defineComponent } from 'vue';
8
8
  import { unref as _unref, renderSlot as _renderSlot, createElementVNode as _createElementVNode, normalizeStyle as _normalizeStyle, openBlock as _openBlock, createElementBlock as _createElementBlock, pushScopeId as _pushScopeId, popScopeId as _popScopeId } from "vue";
9
- const _withScopeId = n => (_pushScopeId("data-v-1722997806466"), n = n(), _popScopeId(), n);
9
+ const _withScopeId = n => (_pushScopeId("data-v-1723098070855"), n = n(), _popScopeId(), n);
10
10
  const _hoisted_1 = { class: "full-page-warp-content" };
11
11
  import { ref } from 'vue';
12
12
  import { useElementBounding } from '@vueuse/core';
@@ -33,6 +33,7 @@ function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]
33
33
  "nextTick": "setup-const",
34
34
  "monaco": "setup-const",
35
35
  "omit": "setup-maybe-ref",
36
+ "loadGrammars": "setup-maybe-ref",
36
37
  "props": "setup-reactive-const",
37
38
  "emit": "setup-const",
38
39
  "dom": "setup-ref",
@@ -51,6 +52,7 @@ import { openBlock as _openBlock, createElementBlock as _createElementBlock } fr
51
52
  import { ref, onMounted, watch, onUnmounted, toRaw, nextTick } from 'vue';
52
53
  import * as monaco from 'monaco-editor';
53
54
  import { omit } from 'lodash-es';
55
+ import { loadGrammars } from './grammars';
54
56
  const __sfc_main__ = Object.assign({
55
57
  name: 'JMonacoEditor'
56
58
  }, {
@@ -147,6 +149,11 @@ const __sfc_main__ = Object.assign({
147
149
  });
148
150
  onMounted(async () => {
149
151
  const _model = monaco.editor.createModel(props.modelValue, props.language);
152
+ const defaultOptions = Object.assign({
153
+ suggest: {
154
+ preview: true,
155
+ },
156
+ }, omit(props.options, ['readOnly']));
150
157
  instance.value = monaco.editor.create(dom.value, {
151
158
  model: _model,
152
159
  tabSize: 2,
@@ -154,8 +161,9 @@ const __sfc_main__ = Object.assign({
154
161
  scrollBeyondLastLine: false,
155
162
  theme: props.theme,
156
163
  formatOnPaste: true,
157
- ...(omit(props.options, ['readOnly']) || {}),
164
+ ...defaultOptions
158
165
  });
166
+ loadGrammars(monaco, instance.value);
159
167
  instance.value.onDidChangeModelContent(() => {
160
168
  //
161
169
  const value = toRaw(instance.value).getValue();
@@ -0,0 +1,137 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof3 = require("@babel/runtime/helpers/typeof");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.loadGrammars = loadGrammars;
9
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
10
+ var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
11
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
12
+ var _monacoEditorTextmate = require("monaco-editor-textmate");
13
+ var _monacoTextmate = require("monaco-textmate");
14
+ var _typescriptTmLanguage = _interopRequireDefault(require("shiki/languages/typescript.tmLanguage.json"));
15
+ var _javascriptTmLanguage = _interopRequireDefault(require("shiki/languages/javascript.tmLanguage.json"));
16
+ var _htmlTmLanguage = _interopRequireDefault(require("shiki/languages/html.tmLanguage.json"));
17
+ var _cssTmLanguage = _interopRequireDefault(require("shiki/languages/css.tmLanguage.json"));
18
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof3(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof3(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
19
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
20
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != (0, _typeof2.default)(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
21
+ function dispatchGrammars(_x) {
22
+ return _dispatchGrammars.apply(this, arguments);
23
+ }
24
+ function _dispatchGrammars() {
25
+ _dispatchGrammars = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(scopeName) {
26
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
27
+ while (1) switch (_context.prev = _context.next) {
28
+ case 0:
29
+ _context.t0 = scopeName;
30
+ _context.next = _context.t0 === "source.js" ? 3 : _context.t0 === "source.ts" ? 4 : _context.t0 === "source.js" ? 5 : _context.t0 === "text.html.basic" ? 6 : _context.t0 === "source.css" ? 7 : 8;
31
+ break;
32
+ case 3:
33
+ return _context.abrupt("return", {
34
+ format: "json",
35
+ content: Promise.resolve().then(function () {
36
+ return _interopRequireWildcard(require('shiki/languages/vue.tmLanguage.json'));
37
+ })
38
+ });
39
+ case 4:
40
+ return _context.abrupt("return", {
41
+ format: "json",
42
+ content: _typescriptTmLanguage.default
43
+ });
44
+ case 5:
45
+ return _context.abrupt("return", {
46
+ format: "json",
47
+ content: _javascriptTmLanguage.default
48
+ });
49
+ case 6:
50
+ return _context.abrupt("return", {
51
+ format: "json",
52
+ content: _htmlTmLanguage.default
53
+ });
54
+ case 7:
55
+ return _context.abrupt("return", {
56
+ format: "json",
57
+ content: _cssTmLanguage.default
58
+ });
59
+ case 8:
60
+ return _context.abrupt("return", {
61
+ format: "json",
62
+ content: {
63
+ scopeName: "source",
64
+ patterns: []
65
+ }
66
+ });
67
+ case 9:
68
+ case "end":
69
+ return _context.stop();
70
+ }
71
+ }, _callee);
72
+ }));
73
+ return _dispatchGrammars.apply(this, arguments);
74
+ }
75
+ function loadGrammars(_x2, _x3) {
76
+ return _loadGrammars.apply(this, arguments);
77
+ }
78
+ function _loadGrammars() {
79
+ _loadGrammars = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(monaco, editor) {
80
+ var registry, grammars, _iterator, _step, lang;
81
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
82
+ while (1) switch (_context3.prev = _context3.next) {
83
+ case 0:
84
+ registry = new _monacoTextmate.Registry({
85
+ getGrammarDefinition: function () {
86
+ var _getGrammarDefinition = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(scopeName) {
87
+ var dispatch;
88
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
89
+ while (1) switch (_context2.prev = _context2.next) {
90
+ case 0:
91
+ _context2.next = 2;
92
+ return dispatchGrammars(scopeName);
93
+ case 2:
94
+ dispatch = _context2.sent;
95
+ console.log('scopeName', scopeName, dispatch);
96
+ return _context2.abrupt("return", JSON.parse(JSON.stringify(dispatch)));
97
+ case 5:
98
+ case "end":
99
+ return _context2.stop();
100
+ }
101
+ }, _callee2);
102
+ }));
103
+ function getGrammarDefinition(_x4) {
104
+ return _getGrammarDefinition.apply(this, arguments);
105
+ }
106
+ return getGrammarDefinition;
107
+ }()
108
+ });
109
+ grammars = new Map();
110
+ grammars.set("vue", "source.js");
111
+ grammars.set("javascript", "source.js");
112
+ grammars.set("typescript", "source.ts");
113
+ grammars.set("css", "source.css");
114
+ grammars.set("html", "text.html.basic");
115
+ _iterator = (0, _createForOfIteratorHelper2.default)(grammars.keys());
116
+ try {
117
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
118
+ lang = _step.value;
119
+ monaco.languages.register({
120
+ id: lang
121
+ });
122
+ }
123
+ } catch (err) {
124
+ _iterator.e(err);
125
+ } finally {
126
+ _iterator.f();
127
+ }
128
+ _context3.next = 11;
129
+ return (0, _monacoEditorTextmate.wireTmGrammars)(monaco, registry, grammars, editor);
130
+ case 11:
131
+ case "end":
132
+ return _context3.stop();
133
+ }
134
+ }, _callee3);
135
+ }));
136
+ return _loadGrammars.apply(this, arguments);
137
+ }
@@ -0,0 +1 @@
1
+ "use strict";