@veltra/desktop 1.7.4 → 1.7.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/calendar/utils.js +5 -5
- package/dist/components/calendar/utils.js.map +1 -1
- package/dist/components/code-editor/code-editor.js +94 -15
- package/dist/components/code-editor/code-editor.js.map +1 -1
- package/dist/components/code-editor/style.js +1 -0
- package/dist/components/code-editor/style2.css +61 -13
- package/dist/components/date-picker/date-picker.js +27 -4
- package/dist/components/date-picker/date-picker.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/types/code-editor.d.ts +3 -1
- package/dist/types/date-panel.d.ts +1 -1
- package/dist/types/date-picker.d.ts +10 -2
- package/dist/types/date-range-picker.d.ts +1 -1
- package/dist/types/index.d.ts +2 -2
- package/package.json +5 -5
- package/src/components/calendar/utils.ts +8 -8
- package/src/components/code-editor/code-editor.vue +109 -18
- package/src/components/code-editor/style.scss +71 -14
- package/src/components/code-editor/style.ts +1 -0
- package/src/components/date-picker/__test__/date-picker.test.ts +235 -0
- package/src/components/date-picker/date-picker.vue +33 -3
- package/src/types/code-editor.ts +3 -1
- package/src/types/date-panel.ts +1 -1
- package/src/types/date-picker.ts +10 -1
- package/src/types/date-range-picker.ts +1 -1
|
@@ -25,7 +25,7 @@ function getMonthDays(d, disabledDate) {
|
|
|
25
25
|
type: "current"
|
|
26
26
|
};
|
|
27
27
|
day.isToday = day.date.format() === todayStr;
|
|
28
|
-
day.disabled = disabledDate?.(day.date);
|
|
28
|
+
day.disabled = disabledDate?.(day.date, day.date.raw);
|
|
29
29
|
return day;
|
|
30
30
|
});
|
|
31
31
|
const preMonthDays = [];
|
|
@@ -39,7 +39,7 @@ function getMonthDays(d, disabledDate) {
|
|
|
39
39
|
date: d.calc(-i, "days"),
|
|
40
40
|
type: "pre"
|
|
41
41
|
};
|
|
42
|
-
day.disabled = disabledDate?.(day.date);
|
|
42
|
+
day.disabled = disabledDate?.(day.date, day.date.raw);
|
|
43
43
|
preMonthDays.unshift(day);
|
|
44
44
|
i++;
|
|
45
45
|
}
|
|
@@ -52,7 +52,7 @@ function getMonthDays(d, disabledDate) {
|
|
|
52
52
|
date: d.calc(j++, "days"),
|
|
53
53
|
type: "next"
|
|
54
54
|
};
|
|
55
|
-
day.disabled = disabledDate?.(day.date);
|
|
55
|
+
day.disabled = disabledDate?.(day.date, day.date.raw);
|
|
56
56
|
nextMonthDays.push(day);
|
|
57
57
|
}
|
|
58
58
|
return [
|
|
@@ -80,7 +80,7 @@ function getYearMonths(d, disabledDate) {
|
|
|
80
80
|
key: ym,
|
|
81
81
|
month,
|
|
82
82
|
date: monthDate,
|
|
83
|
-
disabled: disabledDate?.(monthDate)
|
|
83
|
+
disabled: disabledDate?.(monthDate, monthDate.raw)
|
|
84
84
|
};
|
|
85
85
|
});
|
|
86
86
|
}
|
|
@@ -99,7 +99,7 @@ function getTenYears(d, disabledDate) {
|
|
|
99
99
|
return {
|
|
100
100
|
year,
|
|
101
101
|
date: yearDate,
|
|
102
|
-
disabled: disabledDate?.(yearDate)
|
|
102
|
+
disabled: disabledDate?.(yearDate, yearDate.raw)
|
|
103
103
|
};
|
|
104
104
|
});
|
|
105
105
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":[],"sources":["../../../src/components/calendar/utils.ts"],"sourcesContent":["import { type Dater, date } from '@cat-kit/core'\n\nimport type { CalendarDay, CalendarMonth, CalendarYear } from '../../types'\n\nexport const weekDays: string[] = ['日', '一', '二', '三', '四', '五', '六']\n\n/**\n * 获取一个月的天数\n * @param d 日期\n * @param disabledDate 禁用日期\n * @returns\n */\nexport function getMonthDays(\n d: Date | string | number | Dater,\n disabledDate?: (d: Dater) => boolean\n): CalendarDay[] {\n const todayStr = date().format()\n if (d instanceof Date || typeof d === 'string' || typeof d === 'number') {\n d = date(d)\n }\n\n // 本月天数\n d.setDay(1)\n const currentMonthDays: CalendarDay[] = Array.from({ length: d.getDays() }).map((_, i) => {\n const day: CalendarDay = { date: d.calc(i, 'days'), type: 'current' }\n day.isToday = day.date.format() === todayStr\n day.disabled = disabledDate?.(day.date)\n return day\n })\n\n const preMonthDays: CalendarDay[] = []\n\n const nextMonthDays: CalendarDay[] = []\n\n // 上月天数\n const firstDayWeek = d.weekDay\n\n if (firstDayWeek !== 0) {\n // 上个月最后一天\n d.setDay(0)\n let i = 0\n while (i < firstDayWeek) {\n const day: CalendarDay = { date: d.calc(-i, 'days'), type: 'pre' }\n day.disabled = disabledDate?.(day.date)\n preMonthDays.unshift(day)\n i++\n }\n }\n\n // 下个月的天数\n const nextMonthDaysAmount = 42 - currentMonthDays.length - preMonthDays.length\n\n let j = 0\n d.setMonth(d.month + 2).setDay(1)\n\n while (j < nextMonthDaysAmount) {\n const day: CalendarDay = { date: d.calc(j++, 'days'), type: 'next' }\n day.disabled = disabledDate?.(day.date)\n nextMonthDays.push(day)\n }\n\n return [...preMonthDays, ...currentMonthDays, ...nextMonthDays]\n}\n\n/**\n * 获取一年的月份\n * @param d 日期\n * @param disabledDate 禁用的日期\n * @returns\n */\nexport function getYearMonths(\n d: Date | string | number | Dater,\n disabledDate?: (d: Dater) => boolean\n): CalendarMonth[] {\n if (d instanceof Date || typeof d === 'string' || typeof d === 'number') {\n d = date(d)\n }\n\n const year = d.year\n\n return Array.from({ length: 12 }).map((_, i) => {\n const month = i + 1\n\n const ym = `${year}-${month}`\n\n const monthDate = date(ym).toEndOfMonth().setHours(23)\n\n monthDate.setMinutes(59)\n monthDate.setSeconds(59)\n\n return { key: ym, month, date: monthDate, disabled: disabledDate?.(monthDate) }\n })\n}\n\n/**\n * 获取当前年份所处的10年\n * @param d 日期\n * @param disabledDate 禁用的日期\n * @returns\n */\nexport function getTenYears(\n d: Date | string | number | Dater,\n disabledDate?: (d: Dater) => boolean\n): CalendarYear[] {\n if (d instanceof Date || typeof d === 'string' || typeof d === 'number') {\n d = date(d)\n }\n\n const startYear = d.year - (d.year % 10) + 1\n\n return Array.from({ length: 10 }).map((_, i) => {\n const year = startYear + i\n\n const yearDate = date(`${year}-12-31 23:59:59`)\n\n return { year, date: yearDate, disabled: disabledDate?.(yearDate) }\n })\n}\n"],"mappings":";;AAIA,MAAa,WAAqB;CAAC;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;AAAG;;;;;;;AAQpE,SAAgB,aACd,GACA,cACe;CACf,MAAM,WAAW,KAAK,CAAC,CAAC,OAAO;CAC/B,IAAI,aAAa,QAAQ,OAAO,MAAM,YAAY,OAAO,MAAM,UAC7D,IAAI,KAAK,CAAC;CAIZ,EAAE,OAAO,CAAC;CACV,MAAM,mBAAkC,MAAM,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,MAAM;EACxF,MAAM,MAAmB;GAAE,MAAM,EAAE,KAAK,GAAG,MAAM;GAAG,MAAM;EAAU;EACpE,IAAI,UAAU,IAAI,KAAK,OAAO,MAAM;EACpC,IAAI,WAAW,eAAe,IAAI,IAAI;
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["../../../src/components/calendar/utils.ts"],"sourcesContent":["import { type Dater, date } from '@cat-kit/core'\n\nimport type { CalendarDay, CalendarMonth, CalendarYear } from '../../types'\n\nexport const weekDays: string[] = ['日', '一', '二', '三', '四', '五', '六']\n\n/**\n * 获取一个月的天数\n * @param d 日期\n * @param disabledDate 禁用日期\n * @returns\n */\nexport function getMonthDays(\n d: Date | string | number | Dater,\n disabledDate?: (d: Dater, raw: Date) => boolean\n): CalendarDay[] {\n const todayStr = date().format()\n if (d instanceof Date || typeof d === 'string' || typeof d === 'number') {\n d = date(d)\n }\n\n // 本月天数\n d.setDay(1)\n const currentMonthDays: CalendarDay[] = Array.from({ length: d.getDays() }).map((_, i) => {\n const day: CalendarDay = { date: d.calc(i, 'days'), type: 'current' }\n day.isToday = day.date.format() === todayStr\n day.disabled = disabledDate?.(day.date, day.date.raw)\n return day\n })\n\n const preMonthDays: CalendarDay[] = []\n\n const nextMonthDays: CalendarDay[] = []\n\n // 上月天数\n const firstDayWeek = d.weekDay\n\n if (firstDayWeek !== 0) {\n // 上个月最后一天\n d.setDay(0)\n let i = 0\n while (i < firstDayWeek) {\n const day: CalendarDay = { date: d.calc(-i, 'days'), type: 'pre' }\n day.disabled = disabledDate?.(day.date, day.date.raw)\n preMonthDays.unshift(day)\n i++\n }\n }\n\n // 下个月的天数\n const nextMonthDaysAmount = 42 - currentMonthDays.length - preMonthDays.length\n\n let j = 0\n d.setMonth(d.month + 2).setDay(1)\n\n while (j < nextMonthDaysAmount) {\n const day: CalendarDay = { date: d.calc(j++, 'days'), type: 'next' }\n day.disabled = disabledDate?.(day.date, day.date.raw)\n nextMonthDays.push(day)\n }\n\n return [...preMonthDays, ...currentMonthDays, ...nextMonthDays]\n}\n\n/**\n * 获取一年的月份\n * @param d 日期\n * @param disabledDate 禁用的日期\n * @returns\n */\nexport function getYearMonths(\n d: Date | string | number | Dater,\n disabledDate?: (d: Dater, raw: Date) => boolean\n): CalendarMonth[] {\n if (d instanceof Date || typeof d === 'string' || typeof d === 'number') {\n d = date(d)\n }\n\n const year = d.year\n\n return Array.from({ length: 12 }).map((_, i) => {\n const month = i + 1\n\n const ym = `${year}-${month}`\n\n const monthDate = date(ym).toEndOfMonth().setHours(23)\n\n monthDate.setMinutes(59)\n monthDate.setSeconds(59)\n\n return { key: ym, month, date: monthDate, disabled: disabledDate?.(monthDate, monthDate.raw) }\n })\n}\n\n/**\n * 获取当前年份所处的10年\n * @param d 日期\n * @param disabledDate 禁用的日期\n * @returns\n */\nexport function getTenYears(\n d: Date | string | number | Dater,\n disabledDate?: (d: Dater, raw: Date) => boolean\n): CalendarYear[] {\n if (d instanceof Date || typeof d === 'string' || typeof d === 'number') {\n d = date(d)\n }\n\n const startYear = d.year - (d.year % 10) + 1\n\n return Array.from({ length: 10 }).map((_, i) => {\n const year = startYear + i\n\n const yearDate = date(`${year}-12-31 23:59:59`)\n\n return { year, date: yearDate, disabled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K,GAAG;CACxB;CAEA,OAAO;EAAC,GAAG;EAAc,GAAG;EAAkB,GAAG;CAAa;AAChE;;;;;;;AAQA,SAAgB,cACd,GACA,cACiB;CACjB,IAAI,aAAa,QAAQ,OAAO,MAAM,YAAY,OAAO,MAAM,UAC7D,IAAI,KAAK,CAAC;CAGZ,MAAM,OAAO,EAAE;CAEf,OAAO,MAAM,KAAK,EAAE,QAAQ,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,MAAM;EAC9C,MAAM,QAAQ,IAAI;EAElB,MAAM,KAAK,GAAG,KAAK,GAAG;EAEtB,MAAM,YAAY,KAAK,EAAE,CAAC,CAAC,aAAa,CAAC,CAAC,SAAS,EAAE;EAErD,UAAU,WAAW,EAAE;EACvB,UAAU,WAAW,EAAE;EAEvB,OAAO;GAAE,KAAK;GAAI;GAAO,MAAM;GAAW,UAAU,eAAe,WAAW,UAAU,GAAG;EAAE;CAC/F,CAAC;AACH;;;;;;;AAQA,SAAgB,YACd,GACA,cACgB;CAChB,IAAI,aAAa,QAAQ,OAAO,MAAM,YAAY,OAAO,MAAM,UAC7D,IAAI,KAAK,CAAC;CAGZ,MAAM,YAAY,EAAE,OAAQ,EAAE,OAAO,KAAM;CAE3C,OAAO,MAAM,KAAK,EAAE,QAAQ,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,MAAM;EAC9C,MAAM,OAAO,YAAY;EAEzB,MAAM,WAAW,KAAK,GAAG,KAAK,gBAAgB;EAE9C,OAAO;GAAE;GAAM,MAAM;GAAU,UAAU,eAAe,UAAU,SAAS,GAAG;EAAE;CAClF,CAAC;AACH"}
|
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
import _sfc_main$1 from "../
|
|
2
|
-
import _sfc_main$2 from "../
|
|
1
|
+
import _sfc_main$1 from "../icon/icon.js";
|
|
2
|
+
import _sfc_main$2 from "../scroll/scroll.js";
|
|
3
|
+
import _sfc_main$3 from "../select/select.js";
|
|
3
4
|
import { Compartment, EditorState } from "../../node_modules/.bun/@codemirror_state@6.7.1/node_modules/@codemirror/state/dist/index.js";
|
|
4
5
|
import { EditorView, tooltips } from "../../node_modules/.bun/@codemirror_view@6.43.9/node_modules/@codemirror/view/dist/index.js";
|
|
5
6
|
import { oneDark } from "../../node_modules/.bun/@codemirror_theme-one-dark@6.1.3/node_modules/@codemirror/theme-one-dark/dist/index.js";
|
|
6
7
|
import { basicSetup } from "./basic-setup.js";
|
|
7
8
|
import { loadLanguage } from "./lang-loaders.js";
|
|
8
9
|
import { buildFullDoc, extractBodyFromText, getShellRanges, mapSelectionToBody, shellExtension, textEqualsShellDoc } from "./shell-extension.js";
|
|
9
|
-
import { computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, defineComponent, mergeModels, normalizeClass, normalizeStyle, onBeforeUnmount, openBlock, shallowRef, toDisplayString, unref, useModel, useTemplateRef, watch, withCtx, withKeys, withModifiers } from "vue";
|
|
10
|
+
import { Fragment, Teleport, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, mergeModels, mergeProps, nextTick, normalizeClass, normalizeStyle, onBeforeUnmount, openBlock, shallowRef, toDisplayString, unref, useModel, useTemplateRef, watch, withCtx, withKeys, withModifiers } from "vue";
|
|
10
11
|
import { useFormFallbackProps } from "@veltra/compositions";
|
|
11
12
|
import { bem, injectFormContext, zIndex } from "@veltra/utils";
|
|
13
|
+
import { Close, ZoomIn } from "@veltra/icons/normal";
|
|
12
14
|
//#region src/components/code-editor/code-editor.vue
|
|
13
15
|
const _hoisted_1 = { ref: "container" };
|
|
14
16
|
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
15
17
|
name: "UCodeEditor",
|
|
18
|
+
inheritAttrs: false,
|
|
16
19
|
__name: "code-editor",
|
|
17
20
|
props: /*@__PURE__*/ mergeModels({
|
|
18
21
|
modelValue: {},
|
|
@@ -24,6 +27,10 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
24
27
|
type: Boolean,
|
|
25
28
|
default: false
|
|
26
29
|
},
|
|
30
|
+
zoomable: {
|
|
31
|
+
type: Boolean,
|
|
32
|
+
default: true
|
|
33
|
+
},
|
|
27
34
|
defaultLines: { default: 8 },
|
|
28
35
|
tips: {},
|
|
29
36
|
span: {},
|
|
@@ -60,11 +67,20 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
60
67
|
disabled: false,
|
|
61
68
|
readonly: false
|
|
62
69
|
});
|
|
70
|
+
/** 放大状态:复用同一组件根 DOM / 同一 EditorView 实例,Teleport 移入 body 全屏遮罩 */
|
|
71
|
+
const zoomed = shallowRef(false);
|
|
72
|
+
/** 放大期间原位置占位的高度(取放大前组件根高度) */
|
|
73
|
+
const placeholderHeight = shallowRef("");
|
|
74
|
+
/** 放大遮罩的 z 轴层级,进入放大时取一次,避免渲染期反复自增 */
|
|
75
|
+
const zoomZIndex = shallowRef();
|
|
76
|
+
const rootRef = useTemplateRef("root");
|
|
77
|
+
const zoomWrapRef = useTemplateRef("zoomWrap");
|
|
63
78
|
const className = computed(() => [
|
|
64
79
|
cls.b,
|
|
65
80
|
bem.is("disabled", disabled.value),
|
|
66
81
|
bem.is("readonly", readonly.value),
|
|
67
|
-
bem.is("dark", props.dark)
|
|
82
|
+
bem.is("dark", props.dark),
|
|
83
|
+
bem.is("zoomed", zoomed.value)
|
|
68
84
|
]);
|
|
69
85
|
const rootStyle = computed(() => ({ "--u-code-editor-default-lines": Math.max(1, props.defaultLines) }));
|
|
70
86
|
const langs = computed(() => props.langs ?? []);
|
|
@@ -77,6 +93,29 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
77
93
|
const activeLang = computed(() => lang.value ?? langs.value[0]);
|
|
78
94
|
/** 仅一种语言时,在选择器位置展示名称 */
|
|
79
95
|
const langLabel = computed(() => langs.value.length === 1 && activeLang.value ? activeLang.value.toUpperCase() : void 0);
|
|
96
|
+
/** 语言标识或放大/关闭按钮任一存在时才渲染工具栏 */
|
|
97
|
+
const hasToolbar = computed(() => showLangSelect.value || !!langLabel.value || props.zoomable || zoomed.value);
|
|
98
|
+
function enterZoom() {
|
|
99
|
+
if (disabled.value || zoomed.value) return;
|
|
100
|
+
const root = rootRef.value;
|
|
101
|
+
if (root) placeholderHeight.value = `${root.offsetHeight}px`;
|
|
102
|
+
zoomZIndex.value = zIndex();
|
|
103
|
+
zoomed.value = true;
|
|
104
|
+
editor.value?.dispatch({ effects: tooltipThemeCompartment.reconfigure(EditorView.theme({ ".cm-tooltip": { zIndex: zIndex() } })) });
|
|
105
|
+
nextTick(() => zoomWrapRef.value?.focus());
|
|
106
|
+
}
|
|
107
|
+
function exitZoom() {
|
|
108
|
+
if (!zoomed.value) return;
|
|
109
|
+
zoomed.value = false;
|
|
110
|
+
}
|
|
111
|
+
/** 放大期间锁定 body 滚动,退出后恢复原值 */
|
|
112
|
+
let prevBodyOverflow = "";
|
|
113
|
+
watch(zoomed, (v) => {
|
|
114
|
+
if (v) {
|
|
115
|
+
prevBodyOverflow = document.body.style.overflow;
|
|
116
|
+
document.body.style.overflow = "hidden";
|
|
117
|
+
} else document.body.style.overflow = prevBodyOverflow;
|
|
118
|
+
});
|
|
80
119
|
const shellConfig = computed(() => ({
|
|
81
120
|
prefix: props.prefix ?? "",
|
|
82
121
|
suffix: props.suffix ?? ""
|
|
@@ -88,6 +127,7 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
88
127
|
const readOnlyCompartment = new Compartment();
|
|
89
128
|
const langCompartment = new Compartment();
|
|
90
129
|
const shellCompartment = new Compartment();
|
|
130
|
+
const tooltipThemeCompartment = new Compartment();
|
|
91
131
|
/** 聚焦时的正文快照,用于失焦时判断是否触发 change */
|
|
92
132
|
let focusSnapshot = "";
|
|
93
133
|
/**
|
|
@@ -108,7 +148,7 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
108
148
|
return [
|
|
109
149
|
basicSetup,
|
|
110
150
|
tooltips({ parent: document.body }),
|
|
111
|
-
EditorView.theme({ ".cm-tooltip": { zIndex: zIndex() } }),
|
|
151
|
+
tooltipThemeCompartment.of(EditorView.theme({ ".cm-tooltip": { zIndex: zIndex() } })),
|
|
112
152
|
themeCompartment.of(props.dark ? oneDark : []),
|
|
113
153
|
editableCompartment.of(EditorView.editable.of(!disabled.value)),
|
|
114
154
|
readOnlyCompartment.of(EditorState.readOnly.of(readonly.value)),
|
|
@@ -246,14 +286,35 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
246
286
|
});
|
|
247
287
|
lastEditorBody = body;
|
|
248
288
|
}, { immediate: true });
|
|
249
|
-
onBeforeUnmount(
|
|
289
|
+
onBeforeUnmount(() => {
|
|
290
|
+
destroyEditor();
|
|
291
|
+
if (zoomed.value) document.body.style.overflow = prevBodyOverflow;
|
|
292
|
+
});
|
|
250
293
|
return (_ctx, _cache) => {
|
|
251
|
-
return openBlock(),
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
294
|
+
return openBlock(), createElementBlock(Fragment, null, [
|
|
295
|
+
createCommentVNode(" 放大时原位置的等高占位,避免页面布局位移 "),
|
|
296
|
+
zoomed.value ? (openBlock(), createElementBlock("div", {
|
|
297
|
+
key: 0,
|
|
298
|
+
class: normalizeClass(unref(cls).e("placeholder")),
|
|
299
|
+
style: normalizeStyle({ height: placeholderHeight.value })
|
|
300
|
+
}, null, 6)) : createCommentVNode("v-if", true),
|
|
301
|
+
(openBlock(), createBlock(Teleport, {
|
|
302
|
+
to: "body",
|
|
303
|
+
disabled: !zoomed.value
|
|
304
|
+
}, [createElementVNode("div", {
|
|
305
|
+
ref: "zoomWrap",
|
|
306
|
+
class: normalizeClass([unref(cls).e("zoom-wrap"), unref(bem).is("zoomed", zoomed.value)]),
|
|
307
|
+
style: normalizeStyle(zoomed.value ? { zIndex: zoomZIndex.value } : void 0),
|
|
308
|
+
tabindex: "-1",
|
|
309
|
+
onKeyup: withKeys(exitZoom, ["esc"])
|
|
310
|
+
}, [createElementVNode("div", mergeProps({ ref: "root" }, _ctx.$attrs, {
|
|
311
|
+
class: className.value,
|
|
312
|
+
style: rootStyle.value,
|
|
313
|
+
onKeyup: _cache[1] || (_cache[1] = withKeys(withModifiers(() => {}, ["stop"]), ["enter"]))
|
|
314
|
+
}), [hasToolbar.value ? (openBlock(), createElementBlock("div", {
|
|
315
|
+
key: 0,
|
|
316
|
+
class: normalizeClass(unref(cls).e("toolbar"))
|
|
317
|
+
}, [showLangSelect.value ? (openBlock(), createBlock(unref(_sfc_main$3), {
|
|
257
318
|
key: 0,
|
|
258
319
|
class: normalizeClass(unref(cls).e("lang-select")),
|
|
259
320
|
modelValue: lang.value,
|
|
@@ -270,9 +331,27 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
270
331
|
])) : langLabel.value ? (openBlock(), createElementBlock("span", {
|
|
271
332
|
key: 1,
|
|
272
333
|
class: normalizeClass(unref(cls).e("lang-label"))
|
|
273
|
-
}, toDisplayString(langLabel.value), 3)) : createCommentVNode("v-if", true)
|
|
274
|
-
|
|
275
|
-
|
|
334
|
+
}, toDisplayString(langLabel.value), 3)) : createCommentVNode("v-if", true), createElementVNode("div", { class: normalizeClass(unref(cls).e("toolbar-actions")) }, [zoomed.value ? (openBlock(), createBlock(unref(_sfc_main$1), {
|
|
335
|
+
key: 0,
|
|
336
|
+
class: normalizeClass(unref(cls).e("btn-close")),
|
|
337
|
+
title: "关闭",
|
|
338
|
+
onClick: exitZoom
|
|
339
|
+
}, {
|
|
340
|
+
default: withCtx(() => [createVNode(unref(Close))]),
|
|
341
|
+
_: 1
|
|
342
|
+
}, 8, ["class"])) : __props.zoomable ? (openBlock(), createBlock(unref(_sfc_main$1), {
|
|
343
|
+
key: 1,
|
|
344
|
+
class: normalizeClass([unref(cls).e("btn-zoom"), unref(bem).is("disabled", unref(disabled))]),
|
|
345
|
+
title: "放大",
|
|
346
|
+
onClick: enterZoom
|
|
347
|
+
}, {
|
|
348
|
+
default: withCtx(() => [createVNode(unref(ZoomIn))]),
|
|
349
|
+
_: 1
|
|
350
|
+
}, 8, ["class"])) : createCommentVNode("v-if", true)], 2)], 2)) : createCommentVNode("v-if", true), createVNode(unref(_sfc_main$2), { class: normalizeClass(unref(cls).e("scroll")) }, {
|
|
351
|
+
default: withCtx(() => [createElementVNode("div", _hoisted_1, null, 512)]),
|
|
352
|
+
_: 1
|
|
353
|
+
}, 8, ["class"])], 16)], 38)], 8, ["disabled"]))
|
|
354
|
+
], 64);
|
|
276
355
|
};
|
|
277
356
|
}
|
|
278
357
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-editor.js","names":[],"sources":["../../../src/components/code-editor/code-editor.vue"],"sourcesContent":["<template>\n <u-scroll :class=\"className\" :style=\"rootStyle\" @keyup.enter.stop>\n <div ref=\"container\"></div>\n\n <u-select\n v-if=\"showLangSelect\"\n :class=\"cls.e('lang-select')\"\n v-model=\"lang\"\n size=\"small\"\n :options=\"langOptions\"\n :clearable=\"false\"\n :disabled=\"disabled\"\n />\n <span v-else-if=\"langLabel\" :class=\"cls.e('lang-label')\">{{ langLabel }}</span>\n </u-scroll>\n</template>\n\n<script lang=\"ts\" setup>\nimport { Compartment, EditorState, type Extension, type Text } from '@codemirror/state'\nimport { oneDark } from '@codemirror/theme-one-dark'\nimport { EditorView, tooltips } from '@codemirror/view'\nimport { useFormFallbackProps } from '@veltra/compositions'\nimport { bem, injectFormContext, zIndex } from '@veltra/utils'\nimport {\n computed,\n onBeforeUnmount,\n shallowRef,\n useTemplateRef,\n watch,\n type CSSProperties\n} from 'vue'\n\nimport type { CodeEditorEmits, CodeEditorLang, CodeEditorProps } from '../../types'\nimport { UScroll } from '../scroll'\nimport { USelect } from '../select'\nimport { basicSetup } from './basic-setup'\nimport { loadLanguage } from './lang-loaders'\nimport {\n buildFullDoc,\n extractBodyFromText,\n getShellRanges,\n mapSelectionToBody,\n shellExtension,\n textEqualsShellDoc,\n type ShellConfig\n} from './shell-extension'\n\ndefineOptions({ name: 'UCodeEditor' })\n\nconst props = withDefaults(defineProps<CodeEditorProps>(), {\n disabled: undefined,\n readonly: undefined,\n dark: false,\n defaultLines: 8\n})\n\nconst emit = defineEmits<CodeEditorEmits>()\n\nconst model = defineModel<string>()\nconst lang = defineModel<CodeEditorLang>('lang')\n\nconst cls = bem('code-editor')\n\nconst { formProps } = injectFormContext()\n\nconst { disabled, readonly } = useFormFallbackProps([formProps ?? {}, props], {\n disabled: false,\n readonly: false\n})\n\nconst className = computed<string[]>(() => [\n cls.b,\n bem.is('disabled', disabled.value),\n bem.is('readonly', readonly.value),\n bem.is('dark', props.dark)\n])\n\nconst rootStyle = computed<CSSProperties>(() => ({\n '--u-code-editor-default-lines': Math.max(1, props.defaultLines)\n}))\n\nconst langs = computed(() => props.langs ?? [])\n\nconst showLangSelect = computed(() => langs.value.length > 1)\n\nconst langOptions = computed(() =>\n langs.value.map((value) => ({ label: value.toUpperCase(), value }))\n)\n\n/** 实际生效的语言:优先 lang model,否则回落 langs[0] */\nconst activeLang = computed<CodeEditorLang | undefined>(() => lang.value ?? langs.value[0])\n\n/** 仅一种语言时,在选择器位置展示名称 */\nconst langLabel = computed(() =>\n langs.value.length === 1 && activeLang.value ? activeLang.value.toUpperCase() : undefined\n)\n\nconst shellConfig = computed<ShellConfig>(() => ({\n prefix: props.prefix ?? '',\n suffix: props.suffix ?? ''\n}))\n\nconst containerRef = useTemplateRef('container')\nconst editor = shallowRef<EditorView | null>(null)\n\nconst themeCompartment = new Compartment()\nconst editableCompartment = new Compartment()\nconst readOnlyCompartment = new Compartment()\nconst langCompartment = new Compartment()\nconst shellCompartment = new Compartment()\n\n/** 聚焦时的正文快照,用于失焦时判断是否触发 change */\nlet focusSnapshot = ''\n\n/**\n * 编辑器最近一次写出的正文引用。\n * 用于短路 model → doc 同步,避免每次按键对整篇文档做 O(n) 相等比较。\n */\nlet lastEditorBody: string | undefined\n\n/** 上一帧是否处于 IME composition,用于在 composition 结束时补一次 model 同步 */\nlet wasComposing = false\n\n/** 将编辑器正文写回 v-model(跳过与上次相同的值,避免多余更新) */\nfunction writeModelFromDoc(doc: Text) {\n const nextBody = extractBodyFromText(doc, shellConfig.value)\n if (nextBody === lastEditorBody && nextBody === model.value) return\n lastEditorBody = nextBody\n model.value = nextBody\n}\n\nfunction buildExtensions(): Extension[] {\n return [\n basicSetup,\n tooltips({ parent: document.body }),\n EditorView.theme({ '.cm-tooltip': { zIndex: zIndex() } }),\n themeCompartment.of(props.dark ? oneDark : []),\n editableCompartment.of(EditorView.editable.of(!disabled.value)),\n readOnlyCompartment.of(EditorState.readOnly.of(readonly.value)),\n langCompartment.of([]),\n shellCompartment.of(shellExtension(shellConfig.value)),\n EditorView.updateListener.of((update) => {\n const composing = update.view.composing\n\n // IME 进行中不写回,避免中间态触发父级重渲染;结束后再统一同步\n if (update.docChanged && !composing) {\n writeModelFromDoc(update.state.doc)\n } else if (wasComposing && !composing) {\n writeModelFromDoc(update.state.doc)\n }\n wasComposing = composing\n\n if (!update.focusChanged) return\n if (update.view.hasFocus) {\n focusSnapshot = extractBodyFromText(update.state.doc, shellConfig.value)\n return\n }\n const current = extractBodyFromText(update.state.doc, shellConfig.value)\n if (current !== focusSnapshot) {\n emit('change', current)\n }\n })\n ]\n}\n\nlet editorToken = 0\nlet langToken = 0\n\nasync function applyLanguage() {\n const view = editor.value\n if (!view) return\n const myToken = ++langToken\n const language = activeLang.value\n\n if (!language) {\n if (myToken !== langToken || editor.value !== view) return\n view.dispatch({ effects: langCompartment.reconfigure([]) })\n return\n }\n\n const ext = await loadLanguage(language)\n if (myToken !== langToken || editor.value !== view) return\n view.dispatch({ effects: langCompartment.reconfigure(ext) })\n}\n\nfunction destroyEditor() {\n ++editorToken\n ++langToken\n editor.value?.destroy()\n editor.value = null\n lastEditorBody = undefined\n wasComposing = false\n}\n\nfunction createEditor() {\n destroyEditor()\n const myToken = ++editorToken\n const parent = containerRef.value\n if (!parent) return\n\n const config = shellConfig.value\n const body = model.value ?? ''\n const doc = buildFullDoc(body, config)\n const { bodyStart } = getShellRanges(doc.length, config)\n lastEditorBody = body\n\n const view = new EditorView({\n doc,\n selection: { anchor: bodyStart, head: bodyStart },\n extensions: buildExtensions(),\n parent\n })\n\n if (myToken !== editorToken) {\n view.destroy()\n return\n }\n\n editor.value = view\n applyLanguage()\n}\n\n/**\n * 将 model 正文同步为完整文档;可选同时 reconfigure shell,\n * 避免 prefix/suffix 变更时「先改扩展、后改文档」导致选区越界。\n */\nfunction syncDocFromModel(\n view: EditorView,\n body: string,\n config: ShellConfig,\n options?: { reconfigureShell?: boolean; prevShell?: ShellConfig }\n) {\n const current = view.state.doc\n const docChanged = !textEqualsShellDoc(current, body, config)\n const reconfigureShell = options?.reconfigureShell ?? false\n\n if (!docChanged && !reconfigureShell) return\n\n const nextDoc = buildFullDoc(body, config)\n const prevShell = options?.prevShell ?? config\n const prevRanges = getShellRanges(current.length, prevShell)\n const nextRanges = getShellRanges(nextDoc.length, config)\n const selection = mapSelectionToBody(view.state.selection, prevRanges, nextRanges, nextDoc.length)\n\n view.dispatch({\n ...(docChanged\n ? {\n changes: { from: 0, to: current.length, insert: nextDoc },\n selection,\n // 仅外壳变更时滚入视口;外部 model 回写不应打断用户滚动位置\n ...(reconfigureShell ? { scrollIntoView: true } : {})\n }\n : { selection }),\n ...(reconfigureShell ? { effects: shellCompartment.reconfigure(shellExtension(config)) } : {}),\n // 绕过 shell 的 change/transactionFilter,避免全量替换被拦截或选区被错误钳制\n filter: false\n })\n}\n\nwatch(\n containerRef,\n (el) => {\n if (el) createEditor()\n else destroyEditor()\n },\n { immediate: true, flush: 'post' }\n)\n\nwatch(activeLang, applyLanguage)\n\n/** langs 变化时,若当前 lang 未设或不在列表中则纠正为 langs[0] */\nwatch(\n langs,\n (list) => {\n if (!list.length) return\n if (!lang.value || !list.includes(lang.value)) {\n lang.value = list[0]\n }\n },\n { immediate: true }\n)\n\nwatch(\n () => props.dark,\n (dark) => {\n editor.value?.dispatch({ effects: themeCompartment.reconfigure(dark ? oneDark : []) })\n }\n)\n\nwatch(disabled, (v) => {\n editor.value?.dispatch({ effects: editableCompartment.reconfigure(EditorView.editable.of(!v)) })\n})\n\nwatch(readonly, (v) => {\n editor.value?.dispatch({ effects: readOnlyCompartment.reconfigure(EditorState.readOnly.of(v)) })\n})\n\nwatch(\n [model, editor, shellConfig],\n ([v, e], [, , prevShell]) => {\n if (!e) return\n // IME 组字中不接受外部回写,避免打断输入\n if (e.composing) return\n const config = shellConfig.value\n const shellChanged =\n !prevShell || prevShell.prefix !== config.prefix || prevShell.suffix !== config.suffix\n // 编辑器自身写出的 model 无需回写文档\n if (!shellChanged && v === lastEditorBody) return\n const body = v ?? ''\n syncDocFromModel(e, body, config, {\n reconfigureShell: shellChanged,\n prevShell: prevShell ?? config\n })\n lastEditorBody = body\n },\n { immediate: true }\n)\n\nonBeforeUnmount(destroyEditor)\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiDA,MAAM,QAAQ;EAOd,MAAM,OAAO;EAEb,MAAM,QAAQ,SAAmB,SAAA,YAAC;EAClC,MAAM,OAAO,SAA2B,SAAC,MAAM;EAE/C,MAAM,MAAM,IAAI,aAAa;EAE7B,MAAM,EAAE,cAAc,kBAAkB;EAExC,MAAM,EAAE,UAAU,aAAa,qBAAqB,CAAC,aAAa,CAAC,GAAG,KAAK,GAAG;GAC5E,UAAU;GACV,UAAU;EACZ,CAAC;EAED,MAAM,YAAY,eAAyB;GACzC,IAAI;GACJ,IAAI,GAAG,YAAY,SAAS,KAAK;GACjC,IAAI,GAAG,YAAY,SAAS,KAAK;GACjC,IAAI,GAAG,QAAQ,MAAM,IAAI;EAC3B,CAAC;EAED,MAAM,YAAY,gBAA+B,EAC/C,iCAAiC,KAAK,IAAI,GAAG,MAAM,YAAY,EACjE,EAAE;EAEF,MAAM,QAAQ,eAAe,MAAM,SAAS,CAAC,CAAC;EAE9C,MAAM,iBAAiB,eAAe,MAAM,MAAM,SAAS,CAAC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,KAAA;KAAA,uBAAA,OAAA,OAAA,OAAA,MAAA,WAAA,KAAI,QAAA;KACb,MAAK;KACJ,SAAS,YAAA;KACT,WAAW;KACX,UAAU,MAAA,QAAA;;;;;;IAEI,CAAA,KAAA,UAAA,SAAjB,UAAA,GAAA,mBAA+E,QAAA;;KAAlD,OAAK,eAAE,MAAA,GAAA,CAAG,CAAC,EAAC,YAAA,CAAA;IAAmB,GAAA,gBAAA,UAAA,KAAS,GAAA,CAAA,KAAA,mBAAA,QAAA,IAAA,CAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"code-editor.js","names":["$attrs"],"sources":["../../../src/components/code-editor/code-editor.vue"],"sourcesContent":["<template>\n <!-- 放大时原位置的等高占位,避免页面布局位移 -->\n <div v-if=\"zoomed\" :class=\"cls.e('placeholder')\" :style=\"{ height: placeholderHeight }\" />\n\n <Teleport to=\"body\" :disabled=\"!zoomed\">\n <div\n ref=\"zoomWrap\"\n :class=\"[cls.e('zoom-wrap'), bem.is('zoomed', zoomed)]\"\n :style=\"zoomed ? { zIndex: zoomZIndex } : undefined\"\n tabindex=\"-1\"\n @keyup.esc=\"exitZoom\"\n >\n <div ref=\"root\" v-bind=\"$attrs\" :class=\"className\" :style=\"rootStyle\" @keyup.enter.stop>\n <div v-if=\"hasToolbar\" :class=\"cls.e('toolbar')\">\n <u-select\n v-if=\"showLangSelect\"\n :class=\"cls.e('lang-select')\"\n v-model=\"lang\"\n size=\"small\"\n :options=\"langOptions\"\n :clearable=\"false\"\n :disabled=\"disabled\"\n />\n <span v-else-if=\"langLabel\" :class=\"cls.e('lang-label')\">{{ langLabel }}</span>\n\n <div :class=\"cls.e('toolbar-actions')\">\n <u-icon v-if=\"zoomed\" :class=\"cls.e('btn-close')\" title=\"关闭\" @click=\"exitZoom\">\n <Close />\n </u-icon>\n <u-icon\n v-else-if=\"zoomable\"\n :class=\"[cls.e('btn-zoom'), bem.is('disabled', disabled)]\"\n title=\"放大\"\n @click=\"enterZoom\"\n >\n <ZoomIn />\n </u-icon>\n </div>\n </div>\n\n <u-scroll :class=\"cls.e('scroll')\">\n <div ref=\"container\"></div>\n </u-scroll>\n </div>\n </div>\n </Teleport>\n</template>\n\n<script lang=\"ts\" setup>\nimport { Compartment, EditorState, type Extension, type Text } from '@codemirror/state'\nimport { oneDark } from '@codemirror/theme-one-dark'\nimport { EditorView, tooltips } from '@codemirror/view'\nimport { useFormFallbackProps } from '@veltra/compositions'\nimport { ZoomIn, Close } from '@veltra/icons/normal'\nimport { bem, injectFormContext, zIndex } from '@veltra/utils'\nimport {\n computed,\n nextTick,\n onBeforeUnmount,\n shallowRef,\n useTemplateRef,\n watch,\n type CSSProperties\n} from 'vue'\n\nimport type { CodeEditorEmits, CodeEditorLang, CodeEditorProps } from '../../types'\nimport { UIcon } from '../icon'\nimport { UScroll } from '../scroll'\nimport { USelect } from '../select'\nimport { basicSetup } from './basic-setup'\nimport { loadLanguage } from './lang-loaders'\nimport {\n buildFullDoc,\n extractBodyFromText,\n getShellRanges,\n mapSelectionToBody,\n shellExtension,\n textEqualsShellDoc,\n type ShellConfig\n} from './shell-extension'\n\ndefineOptions({ name: 'UCodeEditor', inheritAttrs: false })\n\nconst props = withDefaults(defineProps<CodeEditorProps>(), {\n disabled: undefined,\n readonly: undefined,\n dark: false,\n zoomable: true,\n defaultLines: 8\n})\n\nconst emit = defineEmits<CodeEditorEmits>()\n\nconst model = defineModel<string>()\nconst lang = defineModel<CodeEditorLang>('lang')\n\nconst cls = bem('code-editor')\n\nconst { formProps } = injectFormContext()\n\nconst { disabled, readonly } = useFormFallbackProps([formProps ?? {}, props], {\n disabled: false,\n readonly: false\n})\n\n/** 放大状态:复用同一组件根 DOM / 同一 EditorView 实例,Teleport 移入 body 全屏遮罩 */\nconst zoomed = shallowRef(false)\n\n/** 放大期间原位置占位的高度(取放大前组件根高度) */\nconst placeholderHeight = shallowRef('')\n\n/** 放大遮罩的 z 轴层级,进入放大时取一次,避免渲染期反复自增 */\nconst zoomZIndex = shallowRef<number>()\n\nconst rootRef = useTemplateRef<HTMLElement>('root')\nconst zoomWrapRef = useTemplateRef<HTMLElement>('zoomWrap')\n\nconst className = computed<string[]>(() => [\n cls.b,\n bem.is('disabled', disabled.value),\n bem.is('readonly', readonly.value),\n bem.is('dark', props.dark),\n bem.is('zoomed', zoomed.value)\n])\n\nconst rootStyle = computed<CSSProperties>(() => ({\n '--u-code-editor-default-lines': Math.max(1, props.defaultLines)\n}))\n\nconst langs = computed(() => props.langs ?? [])\n\nconst showLangSelect = computed(() => langs.value.length > 1)\n\nconst langOptions = computed(() =>\n langs.value.map((value) => ({ label: value.toUpperCase(), value }))\n)\n\n/** 实际生效的语言:优先 lang model,否则回落 langs[0] */\nconst activeLang = computed<CodeEditorLang | undefined>(() => lang.value ?? langs.value[0])\n\n/** 仅一种语言时,在选择器位置展示名称 */\nconst langLabel = computed(() =>\n langs.value.length === 1 && activeLang.value ? activeLang.value.toUpperCase() : undefined\n)\n\n/** 语言标识或放大/关闭按钮任一存在时才渲染工具栏 */\nconst hasToolbar = computed(\n () => showLangSelect.value || !!langLabel.value || props.zoomable || zoomed.value\n)\n\nfunction enterZoom() {\n if (disabled.value || zoomed.value) return\n const root = rootRef.value\n if (root) placeholderHeight.value = `${root.offsetHeight}px`\n zoomZIndex.value = zIndex()\n zoomed.value = true\n // 遮罩层级高于创建编辑器时写入的 tooltip 层级,同步抬升避免补全提示被遮罩盖住\n editor.value?.dispatch({\n effects: tooltipThemeCompartment.reconfigure(\n EditorView.theme({ '.cm-tooltip': { zIndex: zIndex() } })\n )\n })\n // 对齐 dialog 先例:放大按钮(u-icon)不可聚焦,点击后焦点在 body 上,\n // keyup 不会向下经过遮罩,需主动聚焦遮罩,Esc 才能冒泡到 keyup.esc\n nextTick(() => zoomWrapRef.value?.focus())\n}\n\nfunction exitZoom() {\n if (!zoomed.value) return\n zoomed.value = false\n}\n\n/** 放大期间锁定 body 滚动,退出后恢复原值 */\nlet prevBodyOverflow = ''\n\nwatch(zoomed, (v) => {\n if (v) {\n prevBodyOverflow = document.body.style.overflow\n document.body.style.overflow = 'hidden'\n } else {\n document.body.style.overflow = prevBodyOverflow\n }\n})\n\nconst shellConfig = computed<ShellConfig>(() => ({\n prefix: props.prefix ?? '',\n suffix: props.suffix ?? ''\n}))\n\nconst containerRef = useTemplateRef('container')\nconst editor = shallowRef<EditorView | null>(null)\n\nconst themeCompartment = new Compartment()\nconst editableCompartment = new Compartment()\nconst readOnlyCompartment = new Compartment()\nconst langCompartment = new Compartment()\nconst shellCompartment = new Compartment()\nconst tooltipThemeCompartment = new Compartment()\n\n/** 聚焦时的正文快照,用于失焦时判断是否触发 change */\nlet focusSnapshot = ''\n\n/**\n * 编辑器最近一次写出的正文引用。\n * 用于短路 model → doc 同步,避免每次按键对整篇文档做 O(n) 相等比较。\n */\nlet lastEditorBody: string | undefined\n\n/** 上一帧是否处于 IME composition,用于在 composition 结束时补一次 model 同步 */\nlet wasComposing = false\n\n/** 将编辑器正文写回 v-model(跳过与上次相同的值,避免多余更新) */\nfunction writeModelFromDoc(doc: Text) {\n const nextBody = extractBodyFromText(doc, shellConfig.value)\n if (nextBody === lastEditorBody && nextBody === model.value) return\n lastEditorBody = nextBody\n model.value = nextBody\n}\n\nfunction buildExtensions(): Extension[] {\n return [\n basicSetup,\n tooltips({ parent: document.body }),\n tooltipThemeCompartment.of(EditorView.theme({ '.cm-tooltip': { zIndex: zIndex() } })),\n themeCompartment.of(props.dark ? oneDark : []),\n editableCompartment.of(EditorView.editable.of(!disabled.value)),\n readOnlyCompartment.of(EditorState.readOnly.of(readonly.value)),\n langCompartment.of([]),\n shellCompartment.of(shellExtension(shellConfig.value)),\n EditorView.updateListener.of((update) => {\n const composing = update.view.composing\n\n // IME 进行中不写回,避免中间态触发父级重渲染;结束后再统一同步\n if (update.docChanged && !composing) {\n writeModelFromDoc(update.state.doc)\n } else if (wasComposing && !composing) {\n writeModelFromDoc(update.state.doc)\n }\n wasComposing = composing\n\n if (!update.focusChanged) return\n if (update.view.hasFocus) {\n focusSnapshot = extractBodyFromText(update.state.doc, shellConfig.value)\n return\n }\n const current = extractBodyFromText(update.state.doc, shellConfig.value)\n if (current !== focusSnapshot) {\n emit('change', current)\n }\n })\n ]\n}\n\nlet editorToken = 0\nlet langToken = 0\n\nasync function applyLanguage() {\n const view = editor.value\n if (!view) return\n const myToken = ++langToken\n const language = activeLang.value\n\n if (!language) {\n if (myToken !== langToken || editor.value !== view) return\n view.dispatch({ effects: langCompartment.reconfigure([]) })\n return\n }\n\n const ext = await loadLanguage(language)\n if (myToken !== langToken || editor.value !== view) return\n view.dispatch({ effects: langCompartment.reconfigure(ext) })\n}\n\nfunction destroyEditor() {\n ++editorToken\n ++langToken\n editor.value?.destroy()\n editor.value = null\n lastEditorBody = undefined\n wasComposing = false\n}\n\nfunction createEditor() {\n destroyEditor()\n const myToken = ++editorToken\n const parent = containerRef.value\n if (!parent) return\n\n const config = shellConfig.value\n const body = model.value ?? ''\n const doc = buildFullDoc(body, config)\n const { bodyStart } = getShellRanges(doc.length, config)\n lastEditorBody = body\n\n const view = new EditorView({\n doc,\n selection: { anchor: bodyStart, head: bodyStart },\n extensions: buildExtensions(),\n parent\n })\n\n if (myToken !== editorToken) {\n view.destroy()\n return\n }\n\n editor.value = view\n applyLanguage()\n}\n\n/**\n * 将 model 正文同步为完整文档;可选同时 reconfigure shell,\n * 避免 prefix/suffix 变更时「先改扩展、后改文档」导致选区越界。\n */\nfunction syncDocFromModel(\n view: EditorView,\n body: string,\n config: ShellConfig,\n options?: { reconfigureShell?: boolean; prevShell?: ShellConfig }\n) {\n const current = view.state.doc\n const docChanged = !textEqualsShellDoc(current, body, config)\n const reconfigureShell = options?.reconfigureShell ?? false\n\n if (!docChanged && !reconfigureShell) return\n\n const nextDoc = buildFullDoc(body, config)\n const prevShell = options?.prevShell ?? config\n const prevRanges = getShellRanges(current.length, prevShell)\n const nextRanges = getShellRanges(nextDoc.length, config)\n const selection = mapSelectionToBody(view.state.selection, prevRanges, nextRanges, nextDoc.length)\n\n view.dispatch({\n ...(docChanged\n ? {\n changes: { from: 0, to: current.length, insert: nextDoc },\n selection,\n // 仅外壳变更时滚入视口;外部 model 回写不应打断用户滚动位置\n ...(reconfigureShell ? { scrollIntoView: true } : {})\n }\n : { selection }),\n ...(reconfigureShell ? { effects: shellCompartment.reconfigure(shellExtension(config)) } : {}),\n // 绕过 shell 的 change/transactionFilter,避免全量替换被拦截或选区被错误钳制\n filter: false\n })\n}\n\nwatch(\n containerRef,\n (el) => {\n if (el) createEditor()\n else destroyEditor()\n },\n { immediate: true, flush: 'post' }\n)\n\nwatch(activeLang, applyLanguage)\n\n/** langs 变化时,若当前 lang 未设或不在列表中则纠正为 langs[0] */\nwatch(\n langs,\n (list) => {\n if (!list.length) return\n if (!lang.value || !list.includes(lang.value)) {\n lang.value = list[0]\n }\n },\n { immediate: true }\n)\n\nwatch(\n () => props.dark,\n (dark) => {\n editor.value?.dispatch({ effects: themeCompartment.reconfigure(dark ? oneDark : []) })\n }\n)\n\nwatch(disabled, (v) => {\n editor.value?.dispatch({ effects: editableCompartment.reconfigure(EditorView.editable.of(!v)) })\n})\n\nwatch(readonly, (v) => {\n editor.value?.dispatch({ effects: readOnlyCompartment.reconfigure(EditorState.readOnly.of(v)) })\n})\n\nwatch(\n [model, editor, shellConfig],\n ([v, e], [, , prevShell]) => {\n if (!e) return\n // IME 组字中不接受外部回写,避免打断输入\n if (e.composing) return\n const config = shellConfig.value\n const shellChanged =\n !prevShell || prevShell.prefix !== config.prefix || prevShell.suffix !== config.suffix\n // 编辑器自身写出的 model 无需回写文档\n if (!shellChanged && v === lastEditorBody) return\n const body = v ?? ''\n syncDocFromModel(e, body, config, {\n reconfigureShell: shellChanged,\n prevShell: prevShell ?? config\n })\n lastEditorBody = body\n },\n { immediate: true }\n)\n\nonBeforeUnmount(() => {\n destroyEditor()\n if (zoomed.value) document.body.style.overflow = prevBodyOverflow\n})\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;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
flex-direction: column;
|
|
30
32
|
width: 100%;
|
|
31
33
|
max-height: 480px;
|
|
32
34
|
border-radius: var(--u-radius-default);
|
|
@@ -39,28 +41,67 @@
|
|
|
39
41
|
.u-code-editor:hover, .u-code-editor:focus-within {
|
|
40
42
|
border-color: var(--u-color-primary);
|
|
41
43
|
}
|
|
44
|
+
.u-code-editor__toolbar {
|
|
45
|
+
flex-shrink: 0;
|
|
46
|
+
padding: 4px var(--u-gap-small);
|
|
47
|
+
border-bottom: 1px solid var(--u-code-editor-border);
|
|
48
|
+
display: flex;
|
|
49
|
+
justify-content: space-between;
|
|
50
|
+
align-items: center;
|
|
51
|
+
flex-wrap: nowrap;
|
|
52
|
+
}
|
|
53
|
+
.u-code-editor__toolbar-actions {
|
|
54
|
+
margin-left: auto;
|
|
55
|
+
gap: var(--u-gap-small);
|
|
56
|
+
display: flex;
|
|
57
|
+
justify-content: flex-start;
|
|
58
|
+
align-items: center;
|
|
59
|
+
flex-wrap: nowrap;
|
|
60
|
+
}
|
|
42
61
|
.u-code-editor__lang-select {
|
|
43
|
-
position: absolute;
|
|
44
|
-
top: 2px;
|
|
45
|
-
right: 2px;
|
|
46
|
-
z-index: 2;
|
|
47
62
|
width: 88px;
|
|
48
63
|
border: none;
|
|
49
64
|
}
|
|
50
|
-
.u-code-editor__lang-select input {
|
|
51
|
-
text-align: right;
|
|
52
|
-
}
|
|
53
65
|
.u-code-editor__lang-label {
|
|
54
|
-
position: absolute;
|
|
55
|
-
top: 2px;
|
|
56
|
-
right: 8px;
|
|
57
|
-
z-index: 2;
|
|
58
66
|
font-size: 12px;
|
|
59
|
-
line-height: 24px;
|
|
60
67
|
color: var(--u-code-editor-gutter-fg);
|
|
61
|
-
pointer-events: none;
|
|
62
68
|
user-select: none;
|
|
63
69
|
}
|
|
70
|
+
.u-code-editor__btn-zoom, .u-code-editor__btn-close {
|
|
71
|
+
cursor: pointer;
|
|
72
|
+
font-size: 14px;
|
|
73
|
+
color: var(--u-code-editor-gutter-fg);
|
|
74
|
+
transition: color var(--u-transition-fast) var(--u-transition-ease);
|
|
75
|
+
}
|
|
76
|
+
.u-code-editor__btn-zoom:hover, .u-code-editor__btn-close:hover {
|
|
77
|
+
color: var(--u-color-primary);
|
|
78
|
+
}
|
|
79
|
+
.u-code-editor__btn-zoom.is-disabled, .u-code-editor__btn-close.is-disabled {
|
|
80
|
+
cursor: not-allowed;
|
|
81
|
+
}
|
|
82
|
+
.u-code-editor__btn-zoom.is-disabled:hover, .u-code-editor__btn-close.is-disabled:hover {
|
|
83
|
+
color: var(--u-code-editor-gutter-fg);
|
|
84
|
+
}
|
|
85
|
+
.u-code-editor__scroll {
|
|
86
|
+
flex: 1;
|
|
87
|
+
min-height: 0;
|
|
88
|
+
}
|
|
89
|
+
.u-code-editor__placeholder {
|
|
90
|
+
box-sizing: border-box;
|
|
91
|
+
width: 100%;
|
|
92
|
+
}
|
|
93
|
+
.u-code-editor__zoom-wrap {
|
|
94
|
+
display: contents;
|
|
95
|
+
}
|
|
96
|
+
.u-code-editor__zoom-wrap.is-zoomed {
|
|
97
|
+
position: fixed;
|
|
98
|
+
inset: 0;
|
|
99
|
+
display: flex;
|
|
100
|
+
align-items: center;
|
|
101
|
+
justify-content: center;
|
|
102
|
+
background-color: rgba(0, 0, 0, 0.32);
|
|
103
|
+
outline: none;
|
|
104
|
+
}
|
|
64
105
|
.u-code-editor .cm-editor {
|
|
65
106
|
background: transparent;
|
|
66
107
|
color: var(--u-code-editor-fg);
|
|
@@ -113,6 +154,13 @@
|
|
|
113
154
|
--u-code-editor-active-bg: rgba(255, 255, 255, 0.04);
|
|
114
155
|
--u-code-editor-selection-bg: rgba(99, 162, 255, 0.25);
|
|
115
156
|
}
|
|
157
|
+
.u-code-editor.is-zoomed {
|
|
158
|
+
width: 80vw;
|
|
159
|
+
height: 80vh;
|
|
160
|
+
max-height: none;
|
|
161
|
+
border-radius: var(--u-radius-large);
|
|
162
|
+
box-shadow: var(--u-shadow-lg);
|
|
163
|
+
}
|
|
116
164
|
.u-code-editor.is-disabled {
|
|
117
165
|
background-color: var(--u-color-disabled);
|
|
118
166
|
box-shadow: none;
|
|
@@ -6,7 +6,7 @@ import { Fragment, computed, createBlock, createElementBlock, createTextVNode, c
|
|
|
6
6
|
import { useFormFallbackProps, useUserAction } from "@veltra/compositions";
|
|
7
7
|
import { FORM_EMPTY_CONTENT, bem, injectFormContext } from "@veltra/utils";
|
|
8
8
|
import { Calendar } from "@veltra/icons/normal";
|
|
9
|
-
import { date } from "@cat-kit/core";
|
|
9
|
+
import { Dater, date } from "@cat-kit/core";
|
|
10
10
|
//#region src/components/date-picker/date-picker.vue
|
|
11
11
|
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
12
12
|
name: "UDatePicker",
|
|
@@ -18,6 +18,7 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
18
18
|
type: { default: "date" },
|
|
19
19
|
format: {},
|
|
20
20
|
valueFormat: {},
|
|
21
|
+
dataType: { default: "string" },
|
|
21
22
|
disabledDate: {},
|
|
22
23
|
clearable: {
|
|
23
24
|
type: Boolean,
|
|
@@ -38,7 +39,7 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
38
39
|
rules: {},
|
|
39
40
|
size: {}
|
|
40
41
|
},
|
|
41
|
-
emits: ["update:modelValue"],
|
|
42
|
+
emits: ["update:modelValue", "change"],
|
|
42
43
|
setup(__props, { emit: __emit }) {
|
|
43
44
|
const props = __props;
|
|
44
45
|
const emit = __emit;
|
|
@@ -63,16 +64,37 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
63
64
|
});
|
|
64
65
|
const currentDate = shallowRef();
|
|
65
66
|
const { userAction, isUserActive } = useUserAction();
|
|
67
|
+
function parseModelValue(val) {
|
|
68
|
+
if (val == null || val === "") return void 0;
|
|
69
|
+
if (val instanceof Date || typeof val === "number") {
|
|
70
|
+
const d = date(val);
|
|
71
|
+
return isNaN(d.timestamp) ? void 0 : d;
|
|
72
|
+
}
|
|
73
|
+
if (typeof val === "string") {
|
|
74
|
+
if (props.dataType === "string" && props.valueFormat) {
|
|
75
|
+
const parsed = Dater.parse(val, props.valueFormat);
|
|
76
|
+
if (!isNaN(parsed.timestamp)) return parsed;
|
|
77
|
+
}
|
|
78
|
+
const fallback = date(val);
|
|
79
|
+
return isNaN(fallback.timestamp) ? void 0 : fallback;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
66
82
|
watch(() => props.modelValue, (modelValue) => {
|
|
67
83
|
if (isUserActive()) return;
|
|
68
|
-
currentDate.value =
|
|
84
|
+
currentDate.value = parseModelValue(modelValue);
|
|
69
85
|
}, { immediate: true });
|
|
70
86
|
const displayedValue = computed(() => {
|
|
71
87
|
return currentDate.value?.format(formatStr.value) ?? "";
|
|
72
88
|
});
|
|
89
|
+
function formatModelValue(d) {
|
|
90
|
+
if (props.dataType === "date") return d.raw;
|
|
91
|
+
if (props.dataType === "timestamp") return d.timestamp;
|
|
92
|
+
return d.format(props.valueFormat ?? formatStr.value);
|
|
93
|
+
}
|
|
73
94
|
const commitSelectedDate = userAction((date) => {
|
|
74
95
|
currentDate.value = date;
|
|
75
|
-
emit("update:modelValue", date
|
|
96
|
+
emit("update:modelValue", formatModelValue(date));
|
|
97
|
+
emit("change", date.raw);
|
|
76
98
|
});
|
|
77
99
|
async function handleSelectDate(date) {
|
|
78
100
|
await commitSelectedDate(date);
|
|
@@ -81,6 +103,7 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
81
103
|
function handleClear() {
|
|
82
104
|
currentDate.value = void 0;
|
|
83
105
|
emit("update:modelValue", void 0);
|
|
106
|
+
emit("change", void 0);
|
|
84
107
|
}
|
|
85
108
|
return (_ctx, _cache) => {
|
|
86
109
|
return !unref(readonly) ? (openBlock(), createBlock(unref(_sfc_main$2), mergeProps({ key: 0 }, _ctx.$attrs, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-picker.js","names":["$attrs"],"sources":["../../../src/components/date-picker/date-picker.vue"],"sourcesContent":["<template>\n <u-dropdown\n v-if=\"!readonly\"\n v-bind=\"$attrs\"\n :class=\"className\"\n trigger=\"click\"\n width=\"auto\"\n ref=\"dropdownRef\"\n @update:visible=\"\"\n :disabled=\"disabled\"\n >\n <template #trigger>\n <u-input\n :size=\"size\"\n native-readonly\n :clearable=\"clearable\"\n :placeholder=\"placeholder\"\n :model-value=\"displayedValue\"\n :disabled=\"disabled\"\n @clear=\"handleClear\"\n >\n <template #suffix>\n <u-icon :class=\"cls.e('icon')\"><Calendar /></u-icon>\n </template>\n </u-input>\n </template>\n\n <template #content>\n <UDatePanel :size :type :disabled-date :date=\"currentDate\" @select:date=\"handleSelectDate\" />\n </template>\n </u-dropdown>\n\n <template v-else>\n {{ displayedValue || FORM_EMPTY_CONTENT }}\n </template>\n</template>\n\n<script lang=\"ts\" setup>\nimport { date,
|
|
1
|
+
{"version":3,"file":"date-picker.js","names":["$attrs"],"sources":["../../../src/components/date-picker/date-picker.vue"],"sourcesContent":["<template>\n <u-dropdown\n v-if=\"!readonly\"\n v-bind=\"$attrs\"\n :class=\"className\"\n trigger=\"click\"\n width=\"auto\"\n ref=\"dropdownRef\"\n @update:visible=\"\"\n :disabled=\"disabled\"\n >\n <template #trigger>\n <u-input\n :size=\"size\"\n native-readonly\n :clearable=\"clearable\"\n :placeholder=\"placeholder\"\n :model-value=\"displayedValue\"\n :disabled=\"disabled\"\n @clear=\"handleClear\"\n >\n <template #suffix>\n <u-icon :class=\"cls.e('icon')\"><Calendar /></u-icon>\n </template>\n </u-input>\n </template>\n\n <template #content>\n <UDatePanel :size :type :disabled-date :date=\"currentDate\" @select:date=\"handleSelectDate\" />\n </template>\n </u-dropdown>\n\n <template v-else>\n {{ displayedValue || FORM_EMPTY_CONTENT }}\n </template>\n</template>\n\n<script lang=\"ts\" setup>\nimport { date, Dater } from '@cat-kit/core'\nimport { useFormFallbackProps, useUserAction } from '@veltra/compositions'\nimport { Calendar } from '@veltra/icons/normal'\nimport { bem, FORM_EMPTY_CONTENT } from '@veltra/utils'\nimport { injectFormContext } from '@veltra/utils'\nimport { computed, shallowRef, watch } from 'vue'\n\nimport type { DatePickerEmits, DatePickerProps } from '../../types'\nimport type { DropdownExposed } from '../../types'\nimport { UDatePanel } from '../date-panel'\nimport { UDropdown } from '../dropdown'\nimport { UIcon } from '../icon'\nimport { UInput } from '../input'\n\ndefineOptions({ name: 'UDatePicker', inheritAttrs: false })\n\nconst props = withDefaults(defineProps<DatePickerProps>(), {\n placeholder: '选择日期',\n type: 'date',\n dataType: 'string',\n disabled: undefined,\n readonly: undefined,\n clearable: true\n})\n\nconst emit = defineEmits<DatePickerEmits>()\n\nconst cls = bem('date-picker')\n\nconst { formProps } = injectFormContext()\n\nconst { size, disabled, readonly } = useFormFallbackProps([formProps ?? {}, props], {\n size: 'default',\n disabled: false,\n readonly: false\n})\n\nconst className = computed(() => {\n return [cls.b, cls.m(size.value)]\n})\n\nconst dropdownRef = shallowRef<DropdownExposed>()\n\nconst formatStr = computed(() => {\n const { format, type } = props\n if (format) return format\n if (type === 'date') return 'yyyy-MM-dd'\n if (type === 'month') return 'yyyy-MM'\n if (type === 'year') return 'yyyy'\n return 'yyyy-MM-dd'\n})\n\nconst currentDate = shallowRef<Dater>()\n\nconst { userAction, isUserActive } = useUserAction()\n\nfunction parseModelValue(val?: string | number | Date): Dater | undefined {\n if (val == null || val === '') return undefined\n if (val instanceof Date || typeof val === 'number') {\n const d = date(val)\n return isNaN(d.timestamp) ? undefined : d\n }\n if (typeof val === 'string') {\n if (props.dataType === 'string' && props.valueFormat) {\n const parsed = Dater.parse(val, props.valueFormat)\n if (!isNaN(parsed.timestamp)) return parsed\n }\n const fallback = date(val)\n return isNaN(fallback.timestamp) ? undefined : fallback\n }\n return undefined\n}\n\nwatch(\n () => props.modelValue,\n (modelValue) => {\n if (isUserActive()) return\n currentDate.value = parseModelValue(modelValue)\n },\n { immediate: true }\n)\n\nconst displayedValue = computed(() => {\n return currentDate.value?.format(formatStr.value) ?? ''\n})\n\nfunction formatModelValue(d: Dater) {\n if (props.dataType === 'date') {\n return d.raw\n }\n if (props.dataType === 'timestamp') {\n return d.timestamp\n }\n return d.format(props.valueFormat ?? formatStr.value)\n}\n\nconst commitSelectedDate = userAction((date: Dater) => {\n currentDate.value = date\n emit('update:modelValue', formatModelValue(date))\n emit('change', date.raw)\n})\n\nasync function handleSelectDate(date: Dater) {\n await commitSelectedDate(date)\n dropdownRef.value?.close()\n}\n\nfunction handleClear() {\n currentDate.value = undefined\n emit('update:modelValue', undefined)\n emit('change', undefined)\n}\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsDA,MAAM,QAAQ;EASd,MAAM,OAAO;EAEb,MAAM,MAAM,IAAI,aAAa;EAE7B,MAAM,EAAE,cAAc,kBAAkB;EAExC,MAAM,EAAE,MAAM,UAAU,aAAa,qBAAqB,CAAC,aAAa,CAAC,GAAG,KAAK,GAAG;GAClF,MAAM;GACN,UAAU;GACV,UAAU;EACZ,CAAC;EAED,MAAM,YAAY,eAAe;GAC/B,OAAO,CAAC,IAAI,GAAG,IAAI,EAAE,KAAK,KAAK,CAAC;EAClC,CAAC;EAED,MAAM,cAAc,WAA4B;EAEhD,MAAM,YAAY,eAAe;GAC/B,MAAM,EAAE,QAAQ,SAAS;GACzB,IAAI,QAAQ,OAAO;GACnB,IAAI,SAAS,QAAQ,OAAO;GAC5B,IAAI,SAAS,SAAS,OAAO;GAC7B,IAAI,SAAS,QAAQ,OAAO;GAC5B,OAAO;EACT,CAAC;EAED,MAAM,cAAc,WAAkB;EAEtC,MAAM,EAAE,YAAY,iBAAiB,cAAc;EAEnD,SAAS,gBAAgB,KAAiD;GACxE,IAAI,OAAO,QAAQ,QAAQ,IAAI,OAAO,KAAA;GACtC,IAAI,eAAe,QAAQ,OAAO,QAAQ,UAAU;IAClD,MAAM,IAAI,KAAK,GAAG;IAClB,OAAO,MAAM,EAAE,SAAS,IAAI,KAAA,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QAAA;;IAEA,SAAO,cAaN,CAZV,YAYU,MAAA,aAAA,GAAA;KAXP,MAAM,MAAA,IAAA;KACP,mBAAA;KACC,WAAW,QAAA;KACX,aAAa,QAAA;KACb,eAAa,eAAA;KACb,UAAU,MAAA,QAAA;KACV,SAAO;;KAEG,QAAM,cACqC,CAApD,YAAoD,MAAA,WAAA,GAAA,EAA3C,OAAK,eAAE,MAAA,GAAA,CAAG,CAAC,EAAC,MAAA,CAAA,EAAA,GAAA;MAAU,SAAA,cAAY,CAAZ,YAAY,MAAA,QAAA,CAAA,CAAA,CAAA;;;;;;;;;;;IAKtC,SAAO,cAC6E,CAA7F,YAA6F,MAAA,WAAA,GAAA;KAAhF,MAAA,MAAA,IAAA;KAAM,MAAA,QAAA;KAAM,iBAAA,QAAA;KAAe,MAAM,YAAA;KAAc,iBAAa;;;;;;;;GAI7E,GAAA,IAAA,CAAA,SAAA,UAAA,CAAA,MAAA,UAAA,GAAA,mBAEW,UAAA,EAAA,KAAA,EAAA,GAAA,CADN,gBAAA,gBAAA,eAAA,SAAkB,MAAA,kBAAA,CAAkB,GAAA,CAAA,CAAA,GAAA,EAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -140,7 +140,7 @@ import { NavEmits, NavExposed, NavItem, NavProps, _NavExposed } from "./types/na
|
|
|
140
140
|
import { DualNavEmits, DualNavExposed, DualNavProps, DualNavRailVariant, DualNavRootItem, _DualNavExposed } from "./types/dual-nav.js";
|
|
141
141
|
import { GroupNavEmits, GroupNavGroup, GroupNavProps } from "./types/group-nav.js";
|
|
142
142
|
import { PasswordInputEmits, PasswordInputExposed, PasswordInputProps, _PasswordInputExposed } from "./types/password-input.js";
|
|
143
|
-
import { DatePickerEmits, DatePickerExposed, DatePickerProps, _DatePickerExposed } from "./types/date-picker.js";
|
|
143
|
+
import { DatePickerDataType, DatePickerEmits, DatePickerExposed, DatePickerProps, _DatePickerExposed } from "./types/date-picker.js";
|
|
144
144
|
import { DropdownEmits, DropdownExposed, DropdownProps, _DropdownExposed } from "./types/dropdown.js";
|
|
145
145
|
import { ContextmenuEmits, ContextmenuExposed, ContextmenuItem, ContextmenuProps, _ContextmenuExposed } from "./types/contextmenu.js";
|
|
146
146
|
import { SelectEmits, SelectExposed, SelectProps, _SelectExposed } from "./types/select.js";
|
|
@@ -183,4 +183,4 @@ import { defineBatchEditColumns } from "./components/batch-edit/helper.js";
|
|
|
183
183
|
import { defineTableColumns } from "./components/table/use-columns.js";
|
|
184
184
|
import "./components/index.js";
|
|
185
185
|
export * from "@veltra/utils";
|
|
186
|
-
export { type ActionEmits, type ActionExposed, type ActionGroupExposed, type ActionGroupProps, type ActionProps, type AnimationEmits, type AnimationExposed, type AnimationProps, type AutoCompleteEmits, type AutoCompleteExposed, type AutoCompleteProps, type BadgeEmits, type BadgeExposed, type BadgeProps, type BarType, type BatchEditColumn, type BatchEditEmits, type BatchEditExposed, type BatchEditFeature, type BatchEditFormStatus, type BatchEditProps, type BatchEditSlots, type BatchEditStates, type BreadcrumbEmits, type BreadcrumbExposed, type BreadcrumbItem, type BreadcrumbProps, type BreadcrumbSlotScope, type BreakCols, type Breakpoint, type ButtonEmits, type ButtonExposed, type ButtonProps, type ButtonType, type CalendarDay, type CalendarEmits, type CalendarExposed, type CalendarMonth, type CalendarProps, type CalendarYear, type CardActionProps, type CardContentProps, type CardCoverProps, type CardEmits, type CardExposed, type CardProps, type CascadeEmits, type CascadeExposed, type CascadeNode, type CascadeProps, type CheckTagEmits, type CheckTagExposed, type CheckTagProps, type CheckboxButtonEmits, type CheckboxButtonProps, type CheckboxEmits, type CheckboxExposed, type CheckboxGroupEmits, type CheckboxGroupExposed, type CheckboxGroupProps, type CheckboxProps, type CodeEditorEmits, type CodeEditorExposed, type CodeEditorLang, type CodeEditorProps, type CollapseEmits, type CollapseItemEmits, type CollapseItemProps, type CollapseModelValue, type CollapseProps, type CollapseValue, type ConditionConnector, type ConditionEditorEmits, type ConditionEditorExposed, type ConditionEditorProps, type EvaluateOptions as ConditionEvaluateOptions, type ConditionExpression, type ConditionField, type ConditionGroup, type ConditionLeaf, type ConditionNode, type ConditionValue, type ContextmenuEmits, type ContextmenuExposed, type ContextmenuItem, ContextmenuPanelDIKey, type ContextmenuProps, ContextmenuRootDIKey, type CssTransitionEmits, type CssTransitionExposed, type CssTransitionProps, type DatePanelEmits, type DatePanelProps, type DatePickerEmits, type DatePickerExposed, type DatePickerProps, type DateRangePickerEmits, type DateRangePickerExposed, type DateRangePickerProps, type DialogEmits, type DialogExposed, type DialogProps, type DialogTransition, type DrawerDirection, type DrawerEmits, type DrawerExposed, type DrawerMode, type DrawerProps, type DropdownEmits, type DropdownExposed, type DropdownProps, type DualNavEmits, type DualNavExposed, type DualNavProps, type DualNavRailVariant, type DualNavRootItem, type EmptyEmits, type EmptyExposed, type EmptyProps, type ExpressionEditorEmits, type ExpressionEditorExposed, type ExpressionEditorProps, type ExpressionSelectableLevels, type FileViewerEmits, type FileViewerExposed, type FileViewerItem, type FileViewerKind, type FileViewerProps, type FloatButtonEmits, type FloatButtonExposed, type FloatButtonItem, type FloatButtonProps, type FormEmits, type FormExposed, type FormItemEmits, type FormItemExposed, type FormItemProps, type FormProps, type GanttChartEmits, type GanttChartExposed, type GanttChartProps, type GridEmits, type GridExposed, type GridInputEmits, type GridInputExposed, type GridInputProps, type GridItemProps, type GridProps, type GroupInputEmits, type GroupInputExposed, type GroupInputProps, type GroupNavEmits, type GroupNavGroup, type GroupNavProps, type IconEmits, type IconExposed, type IconProps, type InputEmits, type InputExposed, type InputProps, type LayoutEmits, type LayoutExposed, type LayoutProps, type ListEmits, type ListExposed, type ListProps, type LoadingEmits, type LoadingExposed, type LoadingProps, type LoadingType, type Message, type MessageConfirm, type MessageConfirmAction, type MessageConfirmEmits, type MessageConfirmExposed, type MessageConfirmInstance, type MessageConfirmOptions, type MessageConfirmProps, type MessageEmits, type MessageExposed, type MessageInstance, type MessageOptions, type MessageProps, type MessageType, type MultiAutoCompleteEmits, type MultiAutoCompleteExposed, type MultiAutoCompleteProps, type MultiSelectEmits, type MultiSelectExposed, type MultiSelectProps, type MultiTreeSelectEmits, type MultiTreeSelectExposed, type MultiTreeSelectProps, type NavEmits, type NavExposed, type NavItem, type NavProps, type NodeRenderExposed, type NodeRenderProps, type Notification, type NotificationEmits, type NotificationExposed, type NotificationInstance, type NotificationOptions, type NotificationPosition, type NotificationProps, type NumberEmits, type NumberExposed, type NumberInputEmits, type NumberInputExposed, type NumberInputProps, type NumberProps, type NumberRangeInputEmits, type NumberRangeInputExposed, type NumberRangeInputProps, type NumberRangeTuple, type PaginatorEmits, type PaginatorExposed, type PaginatorProps, type PaletteColorType, type PaletteEmits, type PaletteExposed, type PaletteHSV, type PaletteProps, type PaletteRGB, type PanelItem, type PanelType, type PasswordInputEmits, type PasswordInputExposed, type PasswordInputProps, type PopConfirmEmits, type PopConfirmExposed, type PopConfirmProps, type PopEmits, type PopExposed, type PopProps, type ProgressEmits, type ProgressExposed, type ProgressNodesEmits, type ProgressNodesExposed, type ProgressNodesProps, type ProgressProps, type QuickBatchEditEmits, type QuickBatchEditExposed, type QuickBatchEditProps, type RadioEmits, type RadioExposed, type RadioGroupEmits, type RadioGroupExposed, type RadioGroupProps, type RadioProps, type RichTextEditorEmits, type RichTextEditorExposed, type RichTextEditorProps, type RichTextFormat, type ScrollEmits, type ScrollExposed, type ScrollPosition, type ScrollProps, type SegmentEmits, type SegmentExposed, type SegmentItem, type SegmentProps, type SelectEmits, type SelectExposed, type SelectProps, type SliderEmits, type SliderExposed, type SliderProps, type StepsEmits, type StepsExposed, type StepsProps, type StepsSlotScope, type SwitchEmits, type SwitchExposed, type SwitchProps, type TabItem, type TableColumn, type TableColumnAlign, type TableColumnNode, type TableColumnRenderContext, type TableColumnSlotsScope, type TableEditorEmits, type TableEditorExposed, type TableEditorProps, type TableEmits, type TableExposed, type TableProps, type TableRow, type TableRowSlotsScope, type TableSummaryContext, type TabsEmits, type TabsExposed, type TabsHorizontalEmits, type TabsHorizontalExposed, type TabsHorizontalProps, type TabsProps, type TabsVerticalEmits, type TabsVerticalExposed, type TabsVerticalProps, type TagEmits, type TagExposed, type TagProps, type TextEditorEmits, type TextEditorExposed, type TextEditorProps, type TextEmits, type TextExposed, type TextProps, type TextareaEmits, type TextareaExposed, type TextareaProps, type ThemeExposed, type ThemeProps, type TipAlign, type TipDirection, type TipEmits, type TipExposed, type TipProps, type ToolbarItem, type TreeEmit, type TreeExposed, type TreeNode, type TreeNodeProps, type TreeProps, type TreeSelectEmits, type TreeSelectExposed, type TreeSelectProps, _sfc_main as UAction, action_group_default as UActionGroup, _sfc_main$1 as UAutoComplete, _sfc_main$2 as UBadge, _sfc_main$3 as UBatchEdit, _sfc_main$4 as UBreadcrumb, _sfc_main$5 as UButton, _sfc_main$6 as UButtonGroup, _sfc_main$7 as UCalendar, _sfc_main$8 as UCard, _sfc_main$9 as UCardAction, _sfc_main$10 as UCardContent, _sfc_main$11 as UCardCover, _sfc_main$12 as UCardHeader, _sfc_main$13 as UCascade, _sfc_main$14 as UCheckTag, _sfc_main$15 as UCheckbox, _sfc_main$16 as UCheckboxButton, _sfc_main$17 as UCheckboxGroup, _sfc_main$18 as UCodeEditor, _sfc_main$19 as UCollapse, _sfc_main$20 as UCollapseItem, _sfc_main$21 as UConditionEditor, _sfc_main$22 as UContextmenu, _sfc_main$23 as UDatePanel, _sfc_main$24 as UDatePicker, _sfc_main$25 as UDateRangePicker, _sfc_main$26 as UDialog, _sfc_main$27 as UDrawer, _sfc_main$28 as UDropdown, _sfc_main$29 as UDualNav, _sfc_main$30 as UEmpty, _sfc_main$31 as UExpressionEditor, _sfc_main$32 as UFilePicker, _sfc_main$33 as UFileViewer, _sfc_main$34 as UFloatButton, form_default as UForm, form_item_default as UFormItem, _sfc_main$35 as UGanttChart, _sfc_main$36 as UGrid, _sfc_main$37 as UGridInput, _sfc_main$38 as UGridItem, _sfc_main$39 as UGroupInput, _sfc_main$40 as UGroupNav, _sfc_main$41 as UIcon, input_default as UInput, _sfc_main$42 as UKbd, _sfc_main$43 as ULayout, _sfc_main$44 as UList, _sfc_main$45 as UListItem, _sfc_main$46 as ULoading, _sfc_main$47 as UMessage, _sfc_main$48 as UMessageConfirm, _sfc_main$49 as UMultiSelect, _sfc_main$50 as UMultiTreeSelect, _sfc_main$51 as UNav, _sfc_main$52 as UNavItem, _sfc_main$53 as UNavSub, NodeRender as UNodeRender, _sfc_main$54 as UNotification, _sfc_main$55 as UNumber, _sfc_main$56 as UNumberInput, _sfc_main$57 as UNumberRangeInput, _sfc_main$58 as UPaginator, _sfc_main$59 as UPalette, _sfc_main$60 as UPasswordInput, _sfc_main$61 as UPopConfirm, _sfc_main$62 as UProgress, _sfc_main$63 as UProgressNodes, _sfc_main$64 as URadio, _sfc_main$65 as URadioGroup, _sfc_main$66 as URichTextEditor, _sfc_main$67 as UScroll, _sfc_main$68 as USegment, _sfc_main$69 as USelect, _sfc_main$70 as USlider, _sfc_main$71 as USteps, _sfc_main$72 as USwitch, _sfc_main$73 as UTable, _sfc_main$74 as UTableEditor, _sfc_main$75 as UTabs, _sfc_main$76 as UTabsHorizontal, _sfc_main$77 as UTabsVertical, _sfc_main$78 as UTag, _sfc_main$79 as UText, _sfc_main$80 as UTextarea, _sfc_main$81 as UTheme, _sfc_main$82 as UTip, _sfc_main$83 as UTree, _sfc_main$84 as UTreeSelect, _sfc_main$85 as UWatermark, type UploaderEmits, type UploaderExposed, type UploaderProps, type VariableItem, type WatermarkEmits, type WatermarkExposed, type WatermarkProps, type _ActionExposed, type _ActionGroupExposed, type _AnimationExposed, type _AutoCompleteExposed, type _BadgeExposed, type _BatchEditExposed, type _BreadcrumbExposed, type _ButtonExposed, type _CalendarExposed, type _CardExposed, type _CascadeExposed, type _CheckTagExposed, type _CodeEditorExposed, type _ConditionEditorExposed, type _ContextmenuExposed, type _CssTransitionExposed, type _DatePickerExposed, type _DateRangePickerExposed, type _DialogExposed, type _DrawerExposed, type _DropdownExposed, type _DualNavExposed, type _EmptyExposed, type _ExpressionEditorExposed, type _FileViewerExposed, type _FloatButtonExposed, type _FormExposed, type _GanttChartExposed, type _GridExposed, type _GridInputExposed, type _GroupInputExposed, type _InputExposed, type _LayoutExposed, type _ListExposed, type _LoadingExposed, type _MessageConfirmExposed, type _MessageExposed, type _MultiAutoCompleteExposed, type _MultiSelectExposed, type _MultiTreeSelectExposed, type _NavExposed, type _NotificationExposed, type _PaginatorExposed, type _PaletteExposed, type _PasswordInputExposed, type _PopConfirmExposed, type _PopExposed, type _ProgressExposed, type _ProgressNodesExposed, type _QuickBatchEditExposed, type _RadioExposed, type _RadioGroupExposed, type _RichTextEditorExposed, type _ScrollExposed, type _SegmentExposed, type _SelectExposed, type _SliderExposed, type _StepsExposed, type _SwitchExposed, type _TableEditorExposed, type _TableExposed, type _TabsExposed, type _TabsHorizontalExposed, type _TabsVerticalExposed, type _TextEditorExposed, type _TextExposed, type _TextareaExposed, type _ThemeExposed, type _TipExposed, type _TreeExposed, type _TreeSelectExposed, type _UploaderExposed, type _WatermarkExposed, contextmenu, createEmptyGroup, createEmptyLeaf, defineBatchEditColumns, defineTableColumns, evaluate as evaluateConditionExpression, message, messageConfirm, notification, vLoading };
|
|
186
|
+
export { type ActionEmits, type ActionExposed, type ActionGroupExposed, type ActionGroupProps, type ActionProps, type AnimationEmits, type AnimationExposed, type AnimationProps, type AutoCompleteEmits, type AutoCompleteExposed, type AutoCompleteProps, type BadgeEmits, type BadgeExposed, type BadgeProps, type BarType, type BatchEditColumn, type BatchEditEmits, type BatchEditExposed, type BatchEditFeature, type BatchEditFormStatus, type BatchEditProps, type BatchEditSlots, type BatchEditStates, type BreadcrumbEmits, type BreadcrumbExposed, type BreadcrumbItem, type BreadcrumbProps, type BreadcrumbSlotScope, type BreakCols, type Breakpoint, type ButtonEmits, type ButtonExposed, type ButtonProps, type ButtonType, type CalendarDay, type CalendarEmits, type CalendarExposed, type CalendarMonth, type CalendarProps, type CalendarYear, type CardActionProps, type CardContentProps, type CardCoverProps, type CardEmits, type CardExposed, type CardProps, type CascadeEmits, type CascadeExposed, type CascadeNode, type CascadeProps, type CheckTagEmits, type CheckTagExposed, type CheckTagProps, type CheckboxButtonEmits, type CheckboxButtonProps, type CheckboxEmits, type CheckboxExposed, type CheckboxGroupEmits, type CheckboxGroupExposed, type CheckboxGroupProps, type CheckboxProps, type CodeEditorEmits, type CodeEditorExposed, type CodeEditorLang, type CodeEditorProps, type CollapseEmits, type CollapseItemEmits, type CollapseItemProps, type CollapseModelValue, type CollapseProps, type CollapseValue, type ConditionConnector, type ConditionEditorEmits, type ConditionEditorExposed, type ConditionEditorProps, type EvaluateOptions as ConditionEvaluateOptions, type ConditionExpression, type ConditionField, type ConditionGroup, type ConditionLeaf, type ConditionNode, type ConditionValue, type ContextmenuEmits, type ContextmenuExposed, type ContextmenuItem, ContextmenuPanelDIKey, type ContextmenuProps, ContextmenuRootDIKey, type CssTransitionEmits, type CssTransitionExposed, type CssTransitionProps, type DatePanelEmits, type DatePanelProps, type DatePickerDataType, type DatePickerEmits, type DatePickerExposed, type DatePickerProps, type DateRangePickerEmits, type DateRangePickerExposed, type DateRangePickerProps, type DialogEmits, type DialogExposed, type DialogProps, type DialogTransition, type DrawerDirection, type DrawerEmits, type DrawerExposed, type DrawerMode, type DrawerProps, type DropdownEmits, type DropdownExposed, type DropdownProps, type DualNavEmits, type DualNavExposed, type DualNavProps, type DualNavRailVariant, type DualNavRootItem, type EmptyEmits, type EmptyExposed, type EmptyProps, type ExpressionEditorEmits, type ExpressionEditorExposed, type ExpressionEditorProps, type ExpressionSelectableLevels, type FileViewerEmits, type FileViewerExposed, type FileViewerItem, type FileViewerKind, type FileViewerProps, type FloatButtonEmits, type FloatButtonExposed, type FloatButtonItem, type FloatButtonProps, type FormEmits, type FormExposed, type FormItemEmits, type FormItemExposed, type FormItemProps, type FormProps, type GanttChartEmits, type GanttChartExposed, type GanttChartProps, type GridEmits, type GridExposed, type GridInputEmits, type GridInputExposed, type GridInputProps, type GridItemProps, type GridProps, type GroupInputEmits, type GroupInputExposed, type GroupInputProps, type GroupNavEmits, type GroupNavGroup, type GroupNavProps, type IconEmits, type IconExposed, type IconProps, type InputEmits, type InputExposed, type InputProps, type LayoutEmits, type LayoutExposed, type LayoutProps, type ListEmits, type ListExposed, type ListProps, type LoadingEmits, type LoadingExposed, type LoadingProps, type LoadingType, type Message, type MessageConfirm, type MessageConfirmAction, type MessageConfirmEmits, type MessageConfirmExposed, type MessageConfirmInstance, type MessageConfirmOptions, type MessageConfirmProps, type MessageEmits, type MessageExposed, type MessageInstance, type MessageOptions, type MessageProps, type MessageType, type MultiAutoCompleteEmits, type MultiAutoCompleteExposed, type MultiAutoCompleteProps, type MultiSelectEmits, type MultiSelectExposed, type MultiSelectProps, type MultiTreeSelectEmits, type MultiTreeSelectExposed, type MultiTreeSelectProps, type NavEmits, type NavExposed, type NavItem, type NavProps, type NodeRenderExposed, type NodeRenderProps, type Notification, type NotificationEmits, type NotificationExposed, type NotificationInstance, type NotificationOptions, type NotificationPosition, type NotificationProps, type NumberEmits, type NumberExposed, type NumberInputEmits, type NumberInputExposed, type NumberInputProps, type NumberProps, type NumberRangeInputEmits, type NumberRangeInputExposed, type NumberRangeInputProps, type NumberRangeTuple, type PaginatorEmits, type PaginatorExposed, type PaginatorProps, type PaletteColorType, type PaletteEmits, type PaletteExposed, type PaletteHSV, type PaletteProps, type PaletteRGB, type PanelItem, type PanelType, type PasswordInputEmits, type PasswordInputExposed, type PasswordInputProps, type PopConfirmEmits, type PopConfirmExposed, type PopConfirmProps, type PopEmits, type PopExposed, type PopProps, type ProgressEmits, type ProgressExposed, type ProgressNodesEmits, type ProgressNodesExposed, type ProgressNodesProps, type ProgressProps, type QuickBatchEditEmits, type QuickBatchEditExposed, type QuickBatchEditProps, type RadioEmits, type RadioExposed, type RadioGroupEmits, type RadioGroupExposed, type RadioGroupProps, type RadioProps, type RichTextEditorEmits, type RichTextEditorExposed, type RichTextEditorProps, type RichTextFormat, type ScrollEmits, type ScrollExposed, type ScrollPosition, type ScrollProps, type SegmentEmits, type SegmentExposed, type SegmentItem, type SegmentProps, type SelectEmits, type SelectExposed, type SelectProps, type SliderEmits, type SliderExposed, type SliderProps, type StepsEmits, type StepsExposed, type StepsProps, type StepsSlotScope, type SwitchEmits, type SwitchExposed, type SwitchProps, type TabItem, type TableColumn, type TableColumnAlign, type TableColumnNode, type TableColumnRenderContext, type TableColumnSlotsScope, type TableEditorEmits, type TableEditorExposed, type TableEditorProps, type TableEmits, type TableExposed, type TableProps, type TableRow, type TableRowSlotsScope, type TableSummaryContext, type TabsEmits, type TabsExposed, type TabsHorizontalEmits, type TabsHorizontalExposed, type TabsHorizontalProps, type TabsProps, type TabsVerticalEmits, type TabsVerticalExposed, type TabsVerticalProps, type TagEmits, type TagExposed, type TagProps, type TextEditorEmits, type TextEditorExposed, type TextEditorProps, type TextEmits, type TextExposed, type TextProps, type TextareaEmits, type TextareaExposed, type TextareaProps, type ThemeExposed, type ThemeProps, type TipAlign, type TipDirection, type TipEmits, type TipExposed, type TipProps, type ToolbarItem, type TreeEmit, type TreeExposed, type TreeNode, type TreeNodeProps, type TreeProps, type TreeSelectEmits, type TreeSelectExposed, type TreeSelectProps, _sfc_main as UAction, action_group_default as UActionGroup, _sfc_main$1 as UAutoComplete, _sfc_main$2 as UBadge, _sfc_main$3 as UBatchEdit, _sfc_main$4 as UBreadcrumb, _sfc_main$5 as UButton, _sfc_main$6 as UButtonGroup, _sfc_main$7 as UCalendar, _sfc_main$8 as UCard, _sfc_main$9 as UCardAction, _sfc_main$10 as UCardContent, _sfc_main$11 as UCardCover, _sfc_main$12 as UCardHeader, _sfc_main$13 as UCascade, _sfc_main$14 as UCheckTag, _sfc_main$15 as UCheckbox, _sfc_main$16 as UCheckboxButton, _sfc_main$17 as UCheckboxGroup, _sfc_main$18 as UCodeEditor, _sfc_main$19 as UCollapse, _sfc_main$20 as UCollapseItem, _sfc_main$21 as UConditionEditor, _sfc_main$22 as UContextmenu, _sfc_main$23 as UDatePanel, _sfc_main$24 as UDatePicker, _sfc_main$25 as UDateRangePicker, _sfc_main$26 as UDialog, _sfc_main$27 as UDrawer, _sfc_main$28 as UDropdown, _sfc_main$29 as UDualNav, _sfc_main$30 as UEmpty, _sfc_main$31 as UExpressionEditor, _sfc_main$32 as UFilePicker, _sfc_main$33 as UFileViewer, _sfc_main$34 as UFloatButton, form_default as UForm, form_item_default as UFormItem, _sfc_main$35 as UGanttChart, _sfc_main$36 as UGrid, _sfc_main$37 as UGridInput, _sfc_main$38 as UGridItem, _sfc_main$39 as UGroupInput, _sfc_main$40 as UGroupNav, _sfc_main$41 as UIcon, input_default as UInput, _sfc_main$42 as UKbd, _sfc_main$43 as ULayout, _sfc_main$44 as UList, _sfc_main$45 as UListItem, _sfc_main$46 as ULoading, _sfc_main$47 as UMessage, _sfc_main$48 as UMessageConfirm, _sfc_main$49 as UMultiSelect, _sfc_main$50 as UMultiTreeSelect, _sfc_main$51 as UNav, _sfc_main$52 as UNavItem, _sfc_main$53 as UNavSub, NodeRender as UNodeRender, _sfc_main$54 as UNotification, _sfc_main$55 as UNumber, _sfc_main$56 as UNumberInput, _sfc_main$57 as UNumberRangeInput, _sfc_main$58 as UPaginator, _sfc_main$59 as UPalette, _sfc_main$60 as UPasswordInput, _sfc_main$61 as UPopConfirm, _sfc_main$62 as UProgress, _sfc_main$63 as UProgressNodes, _sfc_main$64 as URadio, _sfc_main$65 as URadioGroup, _sfc_main$66 as URichTextEditor, _sfc_main$67 as UScroll, _sfc_main$68 as USegment, _sfc_main$69 as USelect, _sfc_main$70 as USlider, _sfc_main$71 as USteps, _sfc_main$72 as USwitch, _sfc_main$73 as UTable, _sfc_main$74 as UTableEditor, _sfc_main$75 as UTabs, _sfc_main$76 as UTabsHorizontal, _sfc_main$77 as UTabsVertical, _sfc_main$78 as UTag, _sfc_main$79 as UText, _sfc_main$80 as UTextarea, _sfc_main$81 as UTheme, _sfc_main$82 as UTip, _sfc_main$83 as UTree, _sfc_main$84 as UTreeSelect, _sfc_main$85 as UWatermark, type UploaderEmits, type UploaderExposed, type UploaderProps, type VariableItem, type WatermarkEmits, type WatermarkExposed, type WatermarkProps, type _ActionExposed, type _ActionGroupExposed, type _AnimationExposed, type _AutoCompleteExposed, type _BadgeExposed, type _BatchEditExposed, type _BreadcrumbExposed, type _ButtonExposed, type _CalendarExposed, type _CardExposed, type _CascadeExposed, type _CheckTagExposed, type _CodeEditorExposed, type _ConditionEditorExposed, type _ContextmenuExposed, type _CssTransitionExposed, type _DatePickerExposed, type _DateRangePickerExposed, type _DialogExposed, type _DrawerExposed, type _DropdownExposed, type _DualNavExposed, type _EmptyExposed, type _ExpressionEditorExposed, type _FileViewerExposed, type _FloatButtonExposed, type _FormExposed, type _GanttChartExposed, type _GridExposed, type _GridInputExposed, type _GroupInputExposed, type _InputExposed, type _LayoutExposed, type _ListExposed, type _LoadingExposed, type _MessageConfirmExposed, type _MessageExposed, type _MultiAutoCompleteExposed, type _MultiSelectExposed, type _MultiTreeSelectExposed, type _NavExposed, type _NotificationExposed, type _PaginatorExposed, type _PaletteExposed, type _PasswordInputExposed, type _PopConfirmExposed, type _PopExposed, type _ProgressExposed, type _ProgressNodesExposed, type _QuickBatchEditExposed, type _RadioExposed, type _RadioGroupExposed, type _RichTextEditorExposed, type _ScrollExposed, type _SegmentExposed, type _SelectExposed, type _SliderExposed, type _StepsExposed, type _SwitchExposed, type _TableEditorExposed, type _TableExposed, type _TabsExposed, type _TabsHorizontalExposed, type _TabsVerticalExposed, type _TextEditorExposed, type _TextExposed, type _TextareaExposed, type _ThemeExposed, type _TipExposed, type _TreeExposed, type _TreeSelectExposed, type _UploaderExposed, type _WatermarkExposed, contextmenu, createEmptyGroup, createEmptyLeaf, defineBatchEditColumns, defineTableColumns, evaluate as evaluateConditionExpression, message, messageConfirm, notification, vLoading };
|
|
@@ -5,7 +5,7 @@ type CodeEditorLang = 'js' | 'sql' | 'java' | 'json' | 'markdown' | 'spel' | 'ba
|
|
|
5
5
|
interface CodeEditorProps extends Omit<FormComponentProps, 'size'> {
|
|
6
6
|
modelValue?: string;
|
|
7
7
|
/**
|
|
8
|
-
* 可选语言列表。长度大于 1
|
|
8
|
+
* 可选语言列表。长度大于 1 时在顶部工具栏显示内置语言选择器;
|
|
9
9
|
* 仅一种语言时显示语言名称标签
|
|
10
10
|
*/
|
|
11
11
|
langs?: CodeEditorLang[];
|
|
@@ -17,6 +17,8 @@ interface CodeEditorProps extends Omit<FormComponentProps, 'size'> {
|
|
|
17
17
|
suffix?: string;
|
|
18
18
|
/** 是否使用暗色主题 */
|
|
19
19
|
dark?: boolean;
|
|
20
|
+
/** 是否显示放大按钮,默认 true;false 时不渲染放大按钮 */
|
|
21
|
+
zoomable?: boolean;
|
|
20
22
|
/**
|
|
21
23
|
* 默认显示的行数,用于撑起编辑器最小高度,超出后滚动
|
|
22
24
|
* @default 8
|