@veltra/desktop 1.7.2 → 1.7.4
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/auto-complete/style2.css +7 -6
- package/dist/components/batch-edit/use-features.js +1 -1
- package/dist/components/batch-edit/use-features.js.map +1 -1
- package/dist/components/batch-edit/use-handlers.js +2 -2
- package/dist/components/batch-edit/use-handlers.js.map +1 -1
- package/dist/components/breadcrumb/style2.css +1 -1
- package/dist/components/card/style2.css +2 -2
- package/dist/components/check-tag/check-tag.js +2 -2
- package/dist/components/check-tag/check-tag.js.map +1 -1
- package/dist/components/condition-editor/style2.css +4 -4
- package/dist/components/contextmenu/style2.css +7 -7
- package/dist/components/dual-nav/style2.css +1 -1
- package/dist/components/expression-editor/style2.css +1 -1
- package/dist/components/form/use-form-fields.js +3 -14
- package/dist/components/form/use-form-fields.js.map +1 -1
- package/dist/components/number-range-input/style2.css +1 -1
- package/dist/components/progress-nodes/style2.css +2 -2
- package/dist/components/rich-text-editor/style2.css +12 -12
- package/dist/components/select/style2.css +4 -4
- package/dist/components/table/use-check.js +2 -2
- package/dist/components/table/use-check.js.map +1 -1
- package/dist/components/tabs/style2.css +1 -1
- package/dist/components/tree/style2.css +1 -1
- package/package.json +9 -9
- package/src/components/auto-complete/style.scss +31 -6
- package/src/components/batch-edit/use-features.ts +1 -1
- package/src/components/batch-edit/use-handlers.ts +2 -2
- package/src/components/breadcrumb/style.scss +1 -1
- package/src/components/card/style.scss +2 -2
- package/src/components/check-tag/check-tag.vue +2 -2
- package/src/components/condition-editor/style.scss +4 -4
- package/src/components/contextmenu/style.scss +25 -5
- package/src/components/dual-nav/style.scss +1 -1
- package/src/components/expression-editor/style.scss +1 -1
- package/src/components/form/use-form-fields.ts +3 -28
- package/src/components/number-range-input/style.scss +1 -1
- package/src/components/progress-nodes/style.scss +3 -3
- package/src/components/rich-text-editor/style.scss +12 -12
- package/src/components/select/style.scss +20 -4
- package/src/components/table/use-check.ts +2 -2
- package/src/components/tabs/style.scss +1 -1
- package/src/components/tree/style.scss +1 -1
|
@@ -36,21 +36,22 @@
|
|
|
36
36
|
cursor: pointer;
|
|
37
37
|
margin: 2px 0;
|
|
38
38
|
user-select: none;
|
|
39
|
+
color: var(--u-text-color-main);
|
|
39
40
|
overflow: hidden;
|
|
40
41
|
text-overflow: ellipsis;
|
|
41
42
|
white-space: nowrap;
|
|
42
43
|
}
|
|
43
44
|
.u-auto-complete__option:hover {
|
|
44
|
-
background-color: var(--u-
|
|
45
|
-
color: var(--u-
|
|
45
|
+
background-color: var(--u-auto-complete-option-hover-bg, var(--u-bg-color-hover));
|
|
46
|
+
color: var(--u-auto-complete-option-hover-color, var(--u-text-color-title));
|
|
46
47
|
}
|
|
47
48
|
.u-auto-complete__option.is-active {
|
|
48
|
-
background-color: var(--u-
|
|
49
|
-
color: var(--u-
|
|
49
|
+
background-color: var(--u-auto-complete-option-hover-bg, var(--u-bg-color-hover));
|
|
50
|
+
color: var(--u-auto-complete-option-hover-color, var(--u-text-color-title));
|
|
50
51
|
}
|
|
51
52
|
.u-auto-complete__option.is-selected {
|
|
52
|
-
background-color: var(--u-
|
|
53
|
-
color: var(--u-
|
|
53
|
+
background-color: var(--u-auto-complete-option-selected-bg, var(--u-color-primary-light-9));
|
|
54
|
+
color: var(--u-auto-complete-option-selected-color, var(--u-color-primary));
|
|
54
55
|
}
|
|
55
56
|
.u-auto-complete__ripple {
|
|
56
57
|
background-color: var(--u-color-primary-light-7);
|
|
@@ -22,7 +22,7 @@ function useFeatures(options) {
|
|
|
22
22
|
}),
|
|
23
23
|
dynamicFeatures: computed(() => {
|
|
24
24
|
const { features } = props;
|
|
25
|
-
if (!Array.isArray(features) && typeof features === "object") return Object.entries(features).filter(([
|
|
25
|
+
if (!Array.isArray(features) && typeof features === "object") return Object.entries(features).filter(([, value]) => {
|
|
26
26
|
return typeof value === "function";
|
|
27
27
|
}).reduce((acc, [key, value]) => {
|
|
28
28
|
acc[key] = value;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-features.js","names":[],"sources":["../../../src/components/batch-edit/use-features.ts"],"sourcesContent":["import { computed } from 'vue'\n\nimport type { BatchEditFeature, BatchEditProps, TableRow } from '../../types'\n\ninterface Options {\n props: BatchEditProps\n}\nexport function useFeatures(options: Options) {\n const { props } = options\n const staticFeatures = computed(() => {\n const { features } = props\n\n if (Array.isArray(features)) {\n return new Set(features)\n }\n\n const defaultFeatures = new Set<BatchEditFeature>(['create', 'delete', 'update', 'createChild'])\n\n if (!features) {\n return defaultFeatures\n }\n\n // 函数与 false 的特性视为关闭;显式 true 视为开启(即便不在默认集合内)\n Object.entries(features).forEach(([key, value]) => {\n const k = key as BatchEditFeature\n if (typeof value === 'function' || value === false) {\n defaultFeatures.delete(k)\n } else if (value === true) {\n defaultFeatures.add(k)\n }\n })\n return defaultFeatures\n })\n\n const dynamicFeatures = computed<\n Record<BatchEditFeature, ((row?: TableRow) => boolean) | undefined>\n >(() => {\n const { features } = props\n if (!Array.isArray(features) && typeof features === 'object') {\n const ret = Object.entries(features)\n .filter(([
|
|
1
|
+
{"version":3,"file":"use-features.js","names":[],"sources":["../../../src/components/batch-edit/use-features.ts"],"sourcesContent":["import { computed } from 'vue'\n\nimport type { BatchEditFeature, BatchEditProps, TableRow } from '../../types'\n\ninterface Options {\n props: BatchEditProps\n}\nexport function useFeatures(options: Options) {\n const { props } = options\n const staticFeatures = computed(() => {\n const { features } = props\n\n if (Array.isArray(features)) {\n return new Set(features)\n }\n\n const defaultFeatures = new Set<BatchEditFeature>(['create', 'delete', 'update', 'createChild'])\n\n if (!features) {\n return defaultFeatures\n }\n\n // 函数与 false 的特性视为关闭;显式 true 视为开启(即便不在默认集合内)\n Object.entries(features).forEach(([key, value]) => {\n const k = key as BatchEditFeature\n if (typeof value === 'function' || value === false) {\n defaultFeatures.delete(k)\n } else if (value === true) {\n defaultFeatures.add(k)\n }\n })\n return defaultFeatures\n })\n\n const dynamicFeatures = computed<\n Record<BatchEditFeature, ((row?: TableRow) => boolean) | undefined>\n >(() => {\n const { features } = props\n if (!Array.isArray(features) && typeof features === 'object') {\n const ret = Object.entries(features)\n .filter(([, value]) => {\n return typeof value === 'function'\n })\n .reduce(\n (acc, [key, value]) => {\n acc[key] = value\n return acc\n },\n {} as Record<BatchEditFeature, (row?: TableRow) => boolean>\n )\n return ret\n }\n\n return {} as Record<BatchEditFeature, ((row?: TableRow) => boolean) | undefined>\n })\n\n return { staticFeatures, dynamicFeatures }\n}\n"],"mappings":";;AAOA,SAAgB,YAAY,SAAkB;CAC5C,MAAM,EAAE,UAAU;CAgDlB,OAAO;EAAE,gBA/Cc,eAAe;GACpC,MAAM,EAAE,aAAa;GAErB,IAAI,MAAM,QAAQ,QAAQ,GACxB,OAAO,IAAI,IAAI,QAAQ;GAGzB,MAAM,kCAAkB,IAAI,IAAsB;IAAC;IAAU;IAAU;IAAU;GAAa,CAAC;GAE/F,IAAI,CAAC,UACH,OAAO;GAIT,OAAO,QAAQ,QAAQ,CAAC,CAAC,SAAS,CAAC,KAAK,WAAW;IACjD,MAAM,IAAI;IACV,IAAI,OAAO,UAAU,cAAc,UAAU,OAC3C,gBAAgB,OAAO,CAAC;SACnB,IAAI,UAAU,MACnB,gBAAgB,IAAI,CAAC;GAEzB,CAAC;GACD,OAAO;EACT,CAwBsB;EAAG,iBAtBD,eAEhB;GACN,MAAM,EAAE,aAAa;GACrB,IAAI,CAAC,MAAM,QAAQ,QAAQ,KAAK,OAAO,aAAa,UAYlD,OAXY,OAAO,QAAQ,QAAQ,CAAC,CACjC,QAAQ,GAAG,WAAW;IACrB,OAAO,OAAO,UAAU;GAC1B,CAAC,CAAC,CACD,QACE,KAAK,CAAC,KAAK,WAAW;IACrB,IAAI,OAAO;IACX,OAAO;GACT,GACA,CAAC,CAEI;GAGX,OAAO,CAAC;EACV,CAEuC;CAAE;AAC3C"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { computed, nextTick } from "vue";
|
|
2
|
-
import { last, o } from "@cat-kit/core";
|
|
2
|
+
import { copy, last, o } from "@cat-kit/core";
|
|
3
3
|
//#region src/components/batch-edit/use-handlers.ts
|
|
4
4
|
/** 按索引路径在原始数据树中定位节点(等价于历史 Forest.visit 路径访问) */
|
|
5
5
|
function visitDataByIndexPath(roots, indexPath, childrenKey) {
|
|
@@ -24,7 +24,7 @@ function useHandlers(options) {
|
|
|
24
24
|
return typeof props.tree === "string" ? props.tree : "children";
|
|
25
25
|
});
|
|
26
26
|
function getInsertData() {
|
|
27
|
-
return
|
|
27
|
+
return copy(props.model ?? {});
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
30
|
* 插入数据
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-handlers.js","names":[],"sources":["../../../src/components/batch-edit/use-handlers.ts"],"sourcesContent":["import { last, o } from '@cat-kit/core'\nimport { computed, nextTick, type ShallowRef } from 'vue'\n\nimport type {\n TableRow,\n BatchEditEmits,\n BatchEditProps,\n BatchEditStates,\n FormExposed\n} from '../../types'\n\n/** 按索引路径在原始数据树中定位节点(等价于历史 Forest.visit 路径访问) */\nfunction visitDataByIndexPath<T extends Record<string, unknown>>(\n roots: T[],\n indexPath: number[],\n childrenKey: string\n): T | undefined {\n if (!indexPath.length) return undefined\n let currentList: T[] | undefined = roots\n let node: T | undefined\n for (let i = 0; i < indexPath.length; i++) {\n const idx = indexPath[i]!\n if (!currentList) return undefined\n node = currentList[idx]\n if (node === undefined) return undefined\n if (i < indexPath.length - 1) {\n const next = node[childrenKey]\n currentList = Array.isArray(next) ? (next as T[]) : undefined\n }\n }\n return node\n}\n\ninterface Options {\n props: BatchEditProps\n emit: BatchEditEmits\n state: BatchEditStates\n formRef: ShallowRef<FormExposed | null>\n resetState: () => void\n}\n\nexport interface EditReturned {\n handleSave: () => Promise<void>\n handleClose: () => void\n handleCreate: () => void\n handleDelete: (row: TableRow) => Promise<void>\n handleInsertToNext: (row: TableRow) => void\n handleInsertToPrev: (row: TableRow) => void\n handleInsertChild: (row: TableRow) => void\n}\n\nexport function useHandlers(options: Options): EditReturned {\n const { props, emit, state, resetState, formRef } = options\n\n const childrenKey = computed(() => {\n return typeof props.tree === 'string' ? props.tree : 'children'\n })\n\n function getInsertData(): Record<string, any> {\n return
|
|
1
|
+
{"version":3,"file":"use-handlers.js","names":[],"sources":["../../../src/components/batch-edit/use-handlers.ts"],"sourcesContent":["import { copy, last, o } from '@cat-kit/core'\nimport { computed, nextTick, type ShallowRef } from 'vue'\n\nimport type {\n TableRow,\n BatchEditEmits,\n BatchEditProps,\n BatchEditStates,\n FormExposed\n} from '../../types'\n\n/** 按索引路径在原始数据树中定位节点(等价于历史 Forest.visit 路径访问) */\nfunction visitDataByIndexPath<T extends Record<string, unknown>>(\n roots: T[],\n indexPath: number[],\n childrenKey: string\n): T | undefined {\n if (!indexPath.length) return undefined\n let currentList: T[] | undefined = roots\n let node: T | undefined\n for (let i = 0; i < indexPath.length; i++) {\n const idx = indexPath[i]!\n if (!currentList) return undefined\n node = currentList[idx]\n if (node === undefined) return undefined\n if (i < indexPath.length - 1) {\n const next = node[childrenKey]\n currentList = Array.isArray(next) ? (next as T[]) : undefined\n }\n }\n return node\n}\n\ninterface Options {\n props: BatchEditProps\n emit: BatchEditEmits\n state: BatchEditStates\n formRef: ShallowRef<FormExposed | null>\n resetState: () => void\n}\n\nexport interface EditReturned {\n handleSave: () => Promise<void>\n handleClose: () => void\n handleCreate: () => void\n handleDelete: (row: TableRow) => Promise<void>\n handleInsertToNext: (row: TableRow) => void\n handleInsertToPrev: (row: TableRow) => void\n handleInsertChild: (row: TableRow) => void\n}\n\nexport function useHandlers(options: Options): EditReturned {\n const { props, emit, state, resetState, formRef } = options\n\n const childrenKey = computed(() => {\n return typeof props.tree === 'string' ? props.tree : 'children'\n })\n\n function getInsertData(): Record<string, any> {\n return copy(props.model ?? {})\n }\n\n /**\n * 插入数据\n * @param item 数据\n */\n function insert(item: Record<string, any>) {\n const data = [...(props.data ?? [])]\n\n const parent = visitDataByIndexPath(data ?? [], state.indexPath.slice(0, -1), childrenKey.value)\n\n if (parent) {\n const children = parent[childrenKey.value]\n if (!children) {\n parent[childrenKey.value] = [item]\n } else {\n children.splice(last(state.indexPath), 0, item)\n }\n } else {\n data.splice(last(state.indexPath), 0, item)\n }\n\n emit('update:data', data)\n\n return item\n }\n\n /**\n * 点击新增按钮\n */\n function handleCreate() {\n const { data } = props\n\n resetState()\n\n nextTick(() => {\n state.formActionType = 'create'\n state.formVisible = true\n state.depth = 1\n state.indexPath = [data?.length ?? 0]\n emit('create')\n })\n }\n\n function handleInsertToPrev(row: TableRow) {\n resetState()\n state.formActionType = 'create'\n state.formVisible = true\n state.parentRow = row.parent\n state.depth = row.depth\n state.indexPath = [...row.indexes]\n emit('create-prev', row)\n }\n\n function handleInsertToNext(row: TableRow) {\n resetState()\n state.formActionType = 'create'\n state.formVisible = true\n state.parentRow = row.parent\n state.depth = row.depth\n state.indexPath = [...row.indexes.slice(0, -1), row.index + 1]\n emit('create-next', row)\n }\n\n function handleInsertChild(row: TableRow) {\n resetState()\n state.formActionType = 'createChild'\n state.formVisible = true\n state.parentRow = row\n state.depth = row.depth + 1\n row.expanded = true\n state.indexPath = [...row.indexes, row.children?.length ?? 0]\n emit('create-child', row)\n }\n\n function runWithLoading<Arg extends any[]>(fn: (...args: Arg) => Promise<void> | void) {\n return async (...args: Arg) => {\n state.loading = true\n if (state.row) {\n state.row.operating = true\n }\n try {\n await fn.apply(null, args)\n } catch (error) {\n console.error(error)\n }\n state.loading = false\n if (state.row) {\n state.row.operating = false\n }\n }\n }\n\n /** 保存 */\n const handleSave = runWithLoading(async () => {\n const { model, saveMethod } = props\n const valid = await formRef.value?.validate()\n if (!model || !valid) return\n\n let item = getInsertData()\n\n // 新增\n if (state.formActionType === 'create' || state.formActionType === 'createChild') {\n await props.beforeCreate?.(item, state.parentRow?.data)\n if (saveMethod) {\n const result = await saveMethod(item, state.formActionType, state.parentRow?.data)\n if (result) {\n item = result\n }\n }\n insert(item)\n\n // 推进插入点,便于连续新增;并重置表单到初始默认值\n const next = last(state.indexPath) + 1\n state.indexPath = [...state.indexPath.slice(0, -1), next]\n formRef.value?.reset()\n return\n }\n\n // 普通模式下的编辑\n if (saveMethod) {\n const result = await saveMethod(item, state.formActionType, state.parentRow?.data)\n if (result) {\n item = result\n }\n }\n\n const { row } = state\n row &&\n Object.keys(item).forEach((key) => {\n o(row.data).set(key, o(item).get(key))\n })\n })\n\n const handleDelete = runWithLoading(async (row: TableRow) => {\n const { deleteMethod } = props\n\n if (deleteMethod) {\n const result = await deleteMethod([row.data])\n if (result === false) {\n return\n }\n }\n\n const data = [...(props.data ?? [])]\n\n const parent = visitDataByIndexPath(data, row.indexes.slice(0, -1), childrenKey.value)\n\n if (parent) {\n const children = parent[childrenKey.value]\n if (children) {\n children.splice(row.index, 1)\n } else {\n console.error('行路径不正确')\n }\n } else {\n data.splice(row.index, 1)\n }\n\n if (state.row === row) {\n resetState()\n }\n\n emit('update:data', data)\n })\n\n function handleClose() {\n resetState()\n }\n\n return {\n handleDelete,\n handleInsertChild,\n handleInsertToNext,\n handleInsertToPrev,\n handleCreate,\n handleClose,\n handleSave\n }\n}\n"],"mappings":";;;;AAYA,SAAS,qBACP,OACA,WACA,aACe;CACf,IAAI,CAAC,UAAU,QAAQ,OAAO,KAAA;CAC9B,IAAI,cAA+B;CACnC,IAAI;CACJ,KAAK,IAAI,IAAI,GAAG,IAAI,UAAU,QAAQ,KAAK;EACzC,MAAM,MAAM,UAAU;EACtB,IAAI,CAAC,aAAa,OAAO,KAAA;EACzB,OAAO,YAAY;EACnB,IAAI,SAAS,KAAA,GAAW,OAAO,KAAA;EAC/B,IAAI,IAAI,UAAU,SAAS,GAAG;GAC5B,MAAM,OAAO,KAAK;GAClB,cAAc,MAAM,QAAQ,IAAI,IAAK,OAAe,KAAA;EACtD;CACF;CACA,OAAO;AACT;AAoBA,SAAgB,YAAY,SAAgC;CAC1D,MAAM,EAA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AEX;EAEA,MAAM,EAAE,QAAQ;EAChB,OACE,OAAO,KAAK,IAAI,CAAC,CAAC,SAAS,QAAQ;GACjC,EAAE,IAAI,IAAI,CAAC,CAAC,IAAI,KAAK,EAAE,IAAI,CAAC,CAAC,IAAI,GAAG,CAAC;EACvC,CAAC;CACL,CAAC;CAED,MAAM,eAAe,eAAe,OAAO,QAAkB;EAC3D,MAAM,EAAE,iBAAiB;EAEzB,IAAI,cAEE;OAAA,MADiB,aAAa,CAAC,IAAI,IAAI,CAAC,MAC7B,OACb;EAAA;EAIJ,MAAM,OAAO,CAAC,GAAI,MAAM,QAAQ,CAAC,CAAE;EAEnC,MAAM,SAAS,qBAAqB,MAAM,IAAI,QAAQ,MAAM,GAAG,EAAE,GAAG,YAAY,KAAK;EAErF,IAAI,QAAQ;GACV,MAAM,WAAW,OAAO,YAAY;GACpC,IAAI,UACF,SAAS,OAAO,IAAI,OAAO,CAAC;QAE5B,QAAQ,MAAM,QAAQ;EAE1B,OACE,KAAK,OAAO,IAAI,OAAO,CAAC;EAG1B,IAAI,MAAM,QAAQ,KAChB,WAAW;EAGb,KAAK,eAAe,IAAI;CAC1B,CAAC;CAED,SAAS,cAAc;EACrB,WAAW;CACb;CAEA,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
font-weight: bold;
|
|
83
83
|
}
|
|
84
84
|
.u-card__header {
|
|
85
|
-
background-color: var(--u-header-bg
|
|
85
|
+
background-color: var(--u-card-header-bg, transparent);
|
|
86
86
|
color: var(--u-text-color-title);
|
|
87
87
|
}
|
|
88
88
|
.u-card__cover {
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
transform: translateY(-50%);
|
|
102
102
|
}
|
|
103
103
|
.u-card__action {
|
|
104
|
-
background-color: var(--u-action-bg
|
|
104
|
+
background-color: var(--u-card-action-bg, transparent);
|
|
105
105
|
}
|
|
106
106
|
.u-card__action .u-button + .u-button {
|
|
107
107
|
margin-left: var(--u-gap-default);
|
|
@@ -14,10 +14,10 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
14
14
|
const props = __props;
|
|
15
15
|
const emits = __emit;
|
|
16
16
|
const classList = computed(() => {
|
|
17
|
-
return [cls.b, bem.is("checked", props.checked)];
|
|
17
|
+
return [cls.b, bem.is("checked", props.modelValue ?? props.checked)];
|
|
18
18
|
});
|
|
19
19
|
const handleChange = () => {
|
|
20
|
-
emits("update:modelValue", props.checked);
|
|
20
|
+
emits("update:modelValue", !(props.modelValue ?? props.checked));
|
|
21
21
|
};
|
|
22
22
|
return (_ctx, _cache) => {
|
|
23
23
|
return openBlock(), createElementBlock("div", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check-tag.js","names":[],"sources":["../../../src/components/check-tag/check-tag.vue"],"sourcesContent":["<template>\n <div :class=\"classList\" @click=\"handleChange\">\n <slot />\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport { bem } from '@veltra/utils'\nimport { computed } from 'vue'\n\nimport type { CheckTagEmits, CheckTagProps } from '../../types'\n\ndefineOptions({ name: 'UCheckTag' })\n\nconst cls = bem('check-tag')\n\nconst props = withDefaults(defineProps<CheckTagProps>(), {})\n\nconst emits = defineEmits<CheckTagEmits>()\n\nconst classList = computed(() => {\n return [cls.b, bem.is('checked', props.checked)]\n})\n\nconst handleChange = () => {\n emits('update:modelValue', props.checked)\n}\n</script>\n"],"mappings":";;;;;;;;;;;;EAcA,MAAM,MAAM,IAAI,WAAW;EAE3B,MAAM,QAAQ;EAEd,MAAM,QAAQ;EAEd,MAAM,YAAY,eAAe;GAC/B,OAAO,CAAC,IAAI,GAAG,IAAI,GAAG,WAAW,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"check-tag.js","names":[],"sources":["../../../src/components/check-tag/check-tag.vue"],"sourcesContent":["<template>\n <div :class=\"classList\" @click=\"handleChange\">\n <slot />\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport { bem } from '@veltra/utils'\nimport { computed } from 'vue'\n\nimport type { CheckTagEmits, CheckTagProps } from '../../types'\n\ndefineOptions({ name: 'UCheckTag' })\n\nconst cls = bem('check-tag')\n\nconst props = withDefaults(defineProps<CheckTagProps>(), {})\n\nconst emits = defineEmits<CheckTagEmits>()\n\nconst classList = computed(() => {\n return [cls.b, bem.is('checked', props.modelValue ?? props.checked)]\n})\n\nconst handleChange = () => {\n emits('update:modelValue', !(props.modelValue ?? props.checked))\n}\n</script>\n"],"mappings":";;;;;;;;;;;;EAcA,MAAM,MAAM,IAAI,WAAW;EAE3B,MAAM,QAAQ;EAEd,MAAM,QAAQ;EAEd,MAAM,YAAY,eAAe;GAC/B,OAAO,CAAC,IAAI,GAAG,IAAI,GAAG,WAAW,MAAM,cAAc,MAAM,OAAO,CAAC;EACrE,CAAC;EAED,MAAM,qBAAqB;GACzB,MAAM,qBAAqB,EAAE,MAAM,cAAc,MAAM,QAAQ;EACjE;;GAzBE,OAAA,UAAA,GAAA,mBAEM,OAAA;IAFA,OAAK,eAAE,UAAA,KAAS;IAAG,SAAO;GAC9B,GAAA,CAAA,WAAQ,KAAA,QAAA,SAAA,CAAA,GAAA,CAAA"}
|
|
@@ -82,14 +82,14 @@
|
|
|
82
82
|
background-color: var(--u-color-primary-light-9);
|
|
83
83
|
}
|
|
84
84
|
.u-condition-editor__connector--and:hover {
|
|
85
|
-
background-color: var(--u-color-primary-light-
|
|
85
|
+
background-color: var(--u-color-primary-light-7);
|
|
86
86
|
}
|
|
87
87
|
.u-condition-editor__connector--or {
|
|
88
|
-
color: var(--u-color-warning-dark-
|
|
88
|
+
color: var(--u-color-warning-dark-1);
|
|
89
89
|
background-color: var(--u-color-warning-light-9);
|
|
90
90
|
}
|
|
91
91
|
.u-condition-editor__connector--or:hover {
|
|
92
|
-
background-color: var(--u-color-warning-light-
|
|
92
|
+
background-color: var(--u-color-warning-light-7);
|
|
93
93
|
}
|
|
94
94
|
.u-condition-editor__connector:focus-visible {
|
|
95
95
|
box-shadow: var(--u-focus-ring);
|
|
@@ -210,7 +210,7 @@
|
|
|
210
210
|
transition: background-color 0.15s ease, border-color 0.15s ease;
|
|
211
211
|
}
|
|
212
212
|
.u-condition-editor__value-chip:hover {
|
|
213
|
-
background-color: var(--u-color-primary-light-
|
|
213
|
+
background-color: var(--u-color-primary-light-7);
|
|
214
214
|
border-color: var(--u-color-primary-light-5);
|
|
215
215
|
}
|
|
216
216
|
.u-condition-editor__value-chip:focus-visible {
|
|
@@ -92,12 +92,12 @@
|
|
|
92
92
|
flex-wrap: nowrap;
|
|
93
93
|
}
|
|
94
94
|
.u-contextmenu__item:not(.is-disabled):not(.is-loading) > .u-contextmenu__item-content:hover {
|
|
95
|
-
background-color: var(--u-
|
|
96
|
-
color: var(--u-
|
|
95
|
+
background-color: var(--u-contextmenu-item-hover-bg, var(--u-bg-color-hover));
|
|
96
|
+
color: var(--u-contextmenu-item-hover-color, var(--u-text-color-title));
|
|
97
97
|
}
|
|
98
98
|
.u-contextmenu .u-contextmenu__item.is-open:not(.is-disabled) > .u-contextmenu__item-content {
|
|
99
|
-
background-color: var(--u-
|
|
100
|
-
color: var(--u-
|
|
99
|
+
background-color: var(--u-contextmenu-item-hover-bg, var(--u-bg-color-hover));
|
|
100
|
+
color: var(--u-contextmenu-item-hover-color, var(--u-text-color-title));
|
|
101
101
|
}
|
|
102
102
|
.u-contextmenu__icon-place {
|
|
103
103
|
width: 1em;
|
|
@@ -146,7 +146,7 @@
|
|
|
146
146
|
}
|
|
147
147
|
.u-contextmenu--small__item-content {
|
|
148
148
|
padding: 0 var(--u-gap-small);
|
|
149
|
-
min-height: calc(var(--u-
|
|
149
|
+
min-height: var(--u-contextmenu-item-height-small, calc(var(--u-form-component-height-small) - 4px));
|
|
150
150
|
border-radius: calc(var(--u-radius-small) + 1px);
|
|
151
151
|
}
|
|
152
152
|
.u-contextmenu--default {
|
|
@@ -154,7 +154,7 @@
|
|
|
154
154
|
}
|
|
155
155
|
.u-contextmenu--default__item-content {
|
|
156
156
|
padding: 0 var(--u-gap-default);
|
|
157
|
-
min-height: calc(var(--u-
|
|
157
|
+
min-height: var(--u-contextmenu-item-height-default, calc(var(--u-form-component-height-default) - 4px));
|
|
158
158
|
border-radius: calc(var(--u-radius-default) + 1px);
|
|
159
159
|
}
|
|
160
160
|
.u-contextmenu--large {
|
|
@@ -162,6 +162,6 @@
|
|
|
162
162
|
}
|
|
163
163
|
.u-contextmenu--large__item-content {
|
|
164
164
|
padding: 0 var(--u-gap-large);
|
|
165
|
-
min-height: calc(var(--u-
|
|
165
|
+
min-height: var(--u-contextmenu-item-height-large, calc(var(--u-form-component-height-large) - 4px));
|
|
166
166
|
border-radius: calc(var(--u-radius-large) + 1px);
|
|
167
167
|
}
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
}
|
|
91
91
|
.u-expression-editor__chip:hover {
|
|
92
92
|
color: var(--u-expression-editor-chip-color, var(--u-color-primary));
|
|
93
|
-
background-color: var(--u-expression-editor-chip-bg, var(--u-color-primary-light-
|
|
93
|
+
background-color: var(--u-expression-editor-chip-bg, var(--u-color-primary-light-7));
|
|
94
94
|
box-shadow: 0 1px 4px var(--u-shadow-color);
|
|
95
95
|
}
|
|
96
96
|
.u-expression-editor__chip:hover .u-expression-editor__chip-close {
|
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
import { nextTick, watch } from "vue";
|
|
2
|
-
import { o } from "@cat-kit/core";
|
|
2
|
+
import { copy, o } from "@cat-kit/core";
|
|
3
3
|
//#region src/components/form/use-form-fields.ts
|
|
4
|
-
/** 深拷贝 model,保留 undefined 等 o().copy() 会丢弃的值 */
|
|
5
|
-
function snapshotModel(model) {
|
|
6
|
-
const result = {};
|
|
7
|
-
for (const key of Object.keys(model)) {
|
|
8
|
-
const value = model[key];
|
|
9
|
-
if (Array.isArray(value)) result[key] = value.map((item) => item !== null && typeof item === "object" ? snapshotModel(item) : item);
|
|
10
|
-
else if (value !== null && typeof value === "object") result[key] = snapshotModel(value);
|
|
11
|
-
else result[key] = value;
|
|
12
|
-
}
|
|
13
|
-
return result;
|
|
14
|
-
}
|
|
15
4
|
/** 按快照逐字段写回 model,支持 undefined 与嵌套对象 */
|
|
16
5
|
function applySnapshot(target, source) {
|
|
17
6
|
for (const key of Object.keys(source)) {
|
|
@@ -22,7 +11,7 @@ function applySnapshot(target, source) {
|
|
|
22
11
|
continue;
|
|
23
12
|
}
|
|
24
13
|
if (Array.isArray(sourceValue)) {
|
|
25
|
-
o(target).set(key, sourceValue
|
|
14
|
+
o(target).set(key, copy(sourceValue));
|
|
26
15
|
continue;
|
|
27
16
|
}
|
|
28
17
|
o(target).set(key, sourceValue);
|
|
@@ -45,7 +34,7 @@ function useFormFields(options) {
|
|
|
45
34
|
return willValidate;
|
|
46
35
|
}
|
|
47
36
|
watch(() => props.model, (model) => {
|
|
48
|
-
initialSnapshot = model ?
|
|
37
|
+
initialSnapshot = model ? copy(model) : void 0;
|
|
49
38
|
}, {
|
|
50
39
|
immediate: true,
|
|
51
40
|
deep: false
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-form-fields.js","names":[],"sources":["../../../src/components/form/use-form-fields.ts"],"sourcesContent":["import { o } from '@cat-kit/core'\nimport type { FormFieldItem } from '@veltra/utils'\nimport { nextTick, watch } from 'vue'\n\nimport type { FormProps } from '../../types/form'\n\ninterface Options {\n props: FormProps\n}\n\n/**
|
|
1
|
+
{"version":3,"file":"use-form-fields.js","names":[],"sources":["../../../src/components/form/use-form-fields.ts"],"sourcesContent":["import { copy, o } from '@cat-kit/core'\nimport type { FormFieldItem } from '@veltra/utils'\nimport { nextTick, watch } from 'vue'\n\nimport type { FormProps } from '../../types/form'\n\ninterface Options {\n props: FormProps\n}\n\n/** 按快照逐字段写回 model,支持 undefined 与嵌套对象 */\nfunction applySnapshot(target: Record<string, any>, source: Record<string, any>) {\n for (const key of Object.keys(source)) {\n const sourceValue = source[key]\n const targetValue = target[key]\n\n if (\n sourceValue !== null &&\n typeof sourceValue === 'object' &&\n !Array.isArray(sourceValue) &&\n targetValue !== null &&\n typeof targetValue === 'object' &&\n !Array.isArray(targetValue)\n ) {\n applySnapshot(targetValue, sourceValue)\n continue\n }\n\n if (Array.isArray(sourceValue)) {\n o(target).set(key, copy(sourceValue))\n continue\n }\n\n o(target).set(key, sourceValue)\n }\n}\n\nexport function useFormFields(options: Options) {\n const { props } = options\n const fields: Record<string, FormFieldItem> = {}\n\n let willValidate = true\n\n /** model 初始快照,供 reset 恢复 */\n let initialSnapshot: Record<string, any> | undefined\n\n function runWithoutChangeValidate(fn: () => void) {\n willValidate = false\n fn()\n nextTick(() => {\n willValidate = true\n })\n }\n\n function shouldValidate() {\n return willValidate\n }\n\n watch(\n () => props.model,\n (model) => {\n initialSnapshot = model ? copy(model) : undefined\n },\n { immediate: true, deep: false }\n )\n\n function registerField(field: string, item: FormFieldItem) {\n fields[field] = item\n }\n\n function unregisterField(field: string) {\n delete fields[field]\n }\n\n function clearValidate() {\n Object.values(fields).forEach((item) => item.clearValidate?.())\n }\n\n async function validate(keys?: string[]) {\n let validList: boolean[]\n if (keys) {\n validList = await Promise.all(\n keys.map((key) => fields[key]?.validate() ?? Promise.resolve(true))\n )\n } else {\n validList = await Promise.all(Object.values(fields).map((field) => field.validate()))\n }\n return validList.every((valid) => valid)\n }\n\n function reset() {\n if (!props.model || !initialSnapshot) return\n\n runWithoutChangeValidate(() => {\n applySnapshot(props.model!, initialSnapshot!)\n Object.values(fields).forEach((item) => item.clearValidate?.())\n })\n }\n\n return { fields, registerField, validate, unregisterField, clearValidate, reset, shouldValidate }\n}\n"],"mappings":";;;;AAWA,SAAS,cAAc,QAA6B,QAA6B;CAC/E,KAAK,MAAM,OAAO,OAAO,KAAK,MAAM,GAAG;EACrC,MAAM,cAAc,OAAO;EAC3B,MAAM,cAAc,OAAO;EAE3B,IACE,gBAAgB,QAChB,OAAO,gBAAgB,YACvB,CAAC,MAAM,QAAQ,WAAW,KAC1B,g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Q,eAAgB;GAC5C,OAAO,OAAO,MAAM,CAAC,CAAC,SAAS,SAAS,KAAK,gBAAgB,CAAC;EAChE,CAAC;CACH;CAEA,OAAO;EAAE;EAAQ;EAAe;EAAU;EAAiB;EAAe;EAAO;CAAe;AAClG"}
|
|
@@ -42,13 +42,13 @@
|
|
|
42
42
|
color: inherit;
|
|
43
43
|
flex: 0 0 auto;
|
|
44
44
|
transition: background-color 0.2s, color 0.2s;
|
|
45
|
-
border-radius: var(--u-radius-
|
|
45
|
+
border-radius: var(--u-radius-default);
|
|
46
46
|
}
|
|
47
47
|
.u-progress-nodes__item:hover .u-progress-nodes__dot {
|
|
48
48
|
border-color: var(--u-text-color-second);
|
|
49
49
|
}
|
|
50
50
|
.u-progress-nodes__item:hover .u-progress-nodes__label {
|
|
51
|
-
color: var(--u-
|
|
51
|
+
color: var(--u-color-primary);
|
|
52
52
|
}
|
|
53
53
|
.u-progress-nodes__node {
|
|
54
54
|
position: relative;
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
width: 100%;
|
|
20
20
|
border: 1px solid var(--u-border-muted-color);
|
|
21
21
|
border-radius: var(--u-radius-default);
|
|
22
|
-
background-color: var(--u-color-
|
|
22
|
+
background-color: var(--u-bg-color-top);
|
|
23
23
|
transition: border-color 0.25s ease;
|
|
24
24
|
display: flex;
|
|
25
25
|
flex-direction: column;
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
gap: 2px;
|
|
49
49
|
padding: 6px 8px;
|
|
50
50
|
border-bottom: 1px solid var(--u-border-color);
|
|
51
|
-
background-color: var(--u-color-
|
|
51
|
+
background-color: var(--u-bg-color-middle);
|
|
52
52
|
}
|
|
53
53
|
.u-rich-text-editor__toolbar-btn {
|
|
54
54
|
display: inline-flex;
|
|
@@ -59,16 +59,16 @@
|
|
|
59
59
|
border: none;
|
|
60
60
|
border-radius: 4px;
|
|
61
61
|
background: transparent;
|
|
62
|
-
color: var(--u-text-color);
|
|
62
|
+
color: var(--u-text-color-main);
|
|
63
63
|
cursor: pointer;
|
|
64
64
|
transition: all 0.15s ease;
|
|
65
65
|
padding: 0;
|
|
66
66
|
}
|
|
67
67
|
.u-rich-text-editor__toolbar-btn:not(.is-disabled):hover {
|
|
68
|
-
background-color: var(--u-color-hover);
|
|
68
|
+
background-color: var(--u-bg-color-hover);
|
|
69
69
|
}
|
|
70
70
|
.u-rich-text-editor__toolbar-btn.is-active {
|
|
71
|
-
background-color: var(--u-color-primary-light);
|
|
71
|
+
background-color: var(--u-color-primary-light-9);
|
|
72
72
|
color: var(--u-color-primary);
|
|
73
73
|
}
|
|
74
74
|
.u-rich-text-editor__toolbar-btn.is-disabled {
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
border: 1px solid var(--u-border-muted-color);
|
|
104
104
|
border-radius: 4px;
|
|
105
105
|
background-color: transparent;
|
|
106
|
-
color: var(--u-text-color);
|
|
106
|
+
color: var(--u-text-color-main);
|
|
107
107
|
font-size: 13px;
|
|
108
108
|
cursor: pointer;
|
|
109
109
|
outline: none;
|
|
@@ -133,7 +133,7 @@
|
|
|
133
133
|
outline: none;
|
|
134
134
|
font-size: 14px;
|
|
135
135
|
line-height: 1.6;
|
|
136
|
-
color: var(--u-text-color);
|
|
136
|
+
color: var(--u-text-color-main);
|
|
137
137
|
word-break: break-word;
|
|
138
138
|
}
|
|
139
139
|
.u-rich-text-editor__editable:focus {
|
|
@@ -223,7 +223,7 @@
|
|
|
223
223
|
font-weight: 600;
|
|
224
224
|
line-height: 1.4;
|
|
225
225
|
margin: 10px 0 4px 0;
|
|
226
|
-
color: var(--u-text-color-
|
|
226
|
+
color: var(--u-text-color-second);
|
|
227
227
|
}
|
|
228
228
|
.u-rte-h6:first-child {
|
|
229
229
|
margin-top: 0;
|
|
@@ -248,7 +248,7 @@
|
|
|
248
248
|
.u-rte-code {
|
|
249
249
|
font-family: "Menlo", "Consolas", "Monaco", monospace;
|
|
250
250
|
font-size: 0.9em;
|
|
251
|
-
background-color: var(--u-color-
|
|
251
|
+
background-color: var(--u-bg-color-middle);
|
|
252
252
|
padding: 2px 6px;
|
|
253
253
|
border-radius: 3px;
|
|
254
254
|
border: 1px solid var(--u-border-color);
|
|
@@ -277,8 +277,8 @@
|
|
|
277
277
|
margin: 8px 0;
|
|
278
278
|
padding: 8px 16px;
|
|
279
279
|
border-left: 3px solid var(--u-color-primary);
|
|
280
|
-
background-color: var(--u-color-
|
|
281
|
-
color: var(--u-text-color-
|
|
280
|
+
background-color: var(--u-bg-color-middle);
|
|
281
|
+
color: var(--u-text-color-second);
|
|
282
282
|
font-style: italic;
|
|
283
283
|
}
|
|
284
284
|
|
|
@@ -286,7 +286,7 @@
|
|
|
286
286
|
font-family: "Menlo", "Consolas", "Monaco", monospace;
|
|
287
287
|
font-size: 13px;
|
|
288
288
|
line-height: 1.6;
|
|
289
|
-
background-color: var(--u-color-
|
|
289
|
+
background-color: var(--u-bg-color-middle);
|
|
290
290
|
border: 1px solid var(--u-border-color);
|
|
291
291
|
border-radius: 6px;
|
|
292
292
|
padding: 12px 16px;
|
|
@@ -63,13 +63,13 @@
|
|
|
63
63
|
white-space: nowrap;
|
|
64
64
|
}
|
|
65
65
|
.u-select__option:hover {
|
|
66
|
-
background-color: var(--u-
|
|
67
|
-
color: var(--u-
|
|
66
|
+
background-color: var(--u-select-option-hover-bg, var(--u-bg-color-hover));
|
|
67
|
+
color: var(--u-select-option-hover-color, var(--u-text-color-title));
|
|
68
68
|
}
|
|
69
69
|
.u-select__option.is-selected {
|
|
70
70
|
position: relative;
|
|
71
|
-
background-color: var(--u-
|
|
72
|
-
color: var(--u-
|
|
71
|
+
background-color: var(--u-select-option-selected-bg, var(--u-color-primary-light-9));
|
|
72
|
+
color: var(--u-select-option-selected-color, var(--u-color-primary));
|
|
73
73
|
font-weight: 600;
|
|
74
74
|
}
|
|
75
75
|
.u-select__option.is-selected::before {
|
|
@@ -69,7 +69,7 @@ function useCheck(options) {
|
|
|
69
69
|
() => props.rowKey,
|
|
70
70
|
() => props.checkable,
|
|
71
71
|
rows
|
|
72
|
-
], ([checked, rowKey, checkable, rows], [
|
|
72
|
+
], ([checked, rowKey, checkable, rows], [, , , oRows]) => {
|
|
73
73
|
if (changedByEvent || !checkable || !rowKey) return;
|
|
74
74
|
changedByModel = true;
|
|
75
75
|
rows !== oRows && setDicts();
|
|
@@ -92,7 +92,7 @@ function useCheck(options) {
|
|
|
92
92
|
() => props.rowKey,
|
|
93
93
|
() => props.selectable,
|
|
94
94
|
rows
|
|
95
|
-
], ([selected, rowKey, selectable, rows], [
|
|
95
|
+
], ([selected, rowKey, selectable, rows], [, , , oRows]) => {
|
|
96
96
|
if (changedByEvent || !selectable || !rowKey) return;
|
|
97
97
|
changedByModel = true;
|
|
98
98
|
rows !== oRows && setDicts();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-check.js","names":["UCheckbox"],"sources":["../../../src/components/table/use-check.ts"],"sourcesContent":["import { dfs, o, type Forest } from '@cat-kit/core'\nimport type { BEM } from '@veltra/utils'\nimport {\n computed,\n createTextVNode,\n createVNode,\n nextTick,\n shallowRef,\n toRaw,\n triggerRef,\n watch,\n type ComputedRef,\n type ShallowRef\n} from 'vue'\n\nimport type { TableRow, TableColumn, TableEmits, TableProps, ComponentSize } from '../../types'\nimport { UCheckbox } from '../checkbox'\n\ninterface Options {\n rows: ShallowRef<TableRow[] | undefined>\n rowForest: ShallowRef<Forest<Record<string, unknown>, any> | undefined>\n props: TableProps\n emit: TableEmits<any>\n size: ComputedRef<ComponentSize>\n cls: BEM<'table'>\n}\n\ninterface UseCheckReturned {\n checkedRows: ShallowRef<Set<TableRow>>\n clearChecked: () => void\n clearSelected: () => void\n createCheckColumn: () => TableColumn\n createSelectColumn: () => TableColumn\n}\n\nexport function useCheck(options: Options): UseCheckReturned {\n const { rows, rowForest, props, emit, size, cls } = options\n\n const checkedRows = shallowRef(new Set<TableRow>())\n const selectedRow = shallowRef<TableRow>()\n\n /** 触发checkedRows的更新 */\n function triggerCheckedRows() {\n triggerRef(checkedRows)\n }\n\n function clearChecked() {\n checkedRows.value.forEach((row) => {\n row.checked = false\n })\n checkedRows.value.clear()\n triggerCheckedRows()\n }\n\n function clearSelected() {\n if (selectedRow.value) {\n selectedRow.value.checked = false\n selectedRow.value = undefined\n }\n }\n\n watch([() => props.checkable, () => props.selectable, () => rows.value], () => {\n clearChecked()\n clearSelected()\n })\n\n watch(selectedRow, (selectedRow) => {\n if (changedByModel) return\n changedByEvent = true\n emit('update:selected', selectedRow?.data ? toRaw(selectedRow.data) : undefined)\n nextTick(() => {\n changedByEvent = false\n })\n })\n\n let changedByEvent = false\n let changedByModel = false\n watch(checkedRows, (checkedRows) => {\n if (changedByModel) return\n changedByEvent = true\n emit(\n 'update:checked',\n Array.from(checkedRows).map((row) => toRaw(row.data))\n )\n nextTick(() => {\n changedByEvent = false\n })\n })\n\n let dicts: Map<string | number, TableRow> | undefined = undefined\n\n // 设置uid -> row 字典,以便于数据重复使用\n function setDicts() {\n if (dicts || !rows.value || !props.rowKey) return\n\n let mapEntries: [string | number, TableRow][] = []\n let i = 0\n while (i < rows.value.length) {\n const row = rows.value[i]!\n\n mapEntries.push([row.uid, row])\n i++\n }\n dicts = new Map(mapEntries)\n }\n\n watch(rows, () => {\n dicts = undefined\n })\n\n watch(\n [() => props.checked, () => props.rowKey, () => props.checkable, rows],\n ([checked, rowKey, checkable, rows], [_, __, ___, oRows]) => {\n if (changedByEvent || !checkable || !rowKey) return\n\n changedByModel = true\n\n // 如果没有字典,先建立字典\n rows !== oRows && setDicts()\n\n clearChecked()\n\n checked?.forEach((item) => {\n const uid = o(item).get(rowKey)\n if (uid === undefined || uid === null) return\n const row = dicts?.get(uid as string | number)\n if (!row) return\n\n row.checked = true\n checkedRows.value.add(row)\n })\n triggerCheckedRows()\n\n nextTick(() => {\n changedByModel = false\n })\n },\n { immediate: true }\n )\n\n watch(\n [() => props.selected, () => props.rowKey, () => props.selectable, rows],\n ([selected, rowKey, selectable, rows], [_, __, ___, oRows]) => {\n if (changedByEvent || !selectable || !rowKey) return\n\n changedByModel = true\n\n // 如果没有字典,先建立字典(懒建立)\n rows !== oRows && setDicts()\n\n if (selected) {\n const uid = o(selected).get(rowKey)\n const row =\n uid === undefined || uid === null ? undefined : dicts?.get(uid as string | number)\n if (row) {\n row.checked = true\n selectedRow.value = row\n }\n } else {\n clearSelected()\n }\n\n nextTick(() => {\n changedByModel = false\n })\n },\n { immediate: true }\n )\n\n const allChecked = computed(() => {\n const rowSize = props.tree ? rowForest.value?.size : rows.value?.length\n return !!rowSize && rowSize === checkedRows.value.size\n })\n\n function handleCheckAllTree(check: boolean) {\n if (check) {\n rowForest.value?.dfs((row) => {\n row.checked = true\n checkedRows.value.add(row)\n })\n } else {\n rowForest.value?.dfs((row) => {\n row.checked = false\n })\n checkedRows.value.clear()\n }\n triggerCheckedRows()\n }\n\n function handleCheckAllRows(check: boolean) {\n if (check) {\n rows.value?.forEach((row) => {\n row.checked = true\n checkedRows.value.add(row)\n })\n } else {\n rows.value?.forEach((row) => {\n row.checked = false\n })\n checkedRows.value.clear()\n }\n triggerCheckedRows()\n }\n\n function handleCheckAll(check: boolean) {\n if (props.tree) {\n handleCheckAllTree(check as boolean)\n } else {\n handleCheckAllRows(check as boolean)\n }\n }\n\n function handleCheckRow(row: TableRow, check: boolean) {\n const cb = check\n ? (row: TableRow) => checkedRows.value.add(row)\n : (row: TableRow) => checkedRows.value.delete(row)\n\n const childrenKey = typeof props.tree === 'string' ? props.tree : 'children'\n dfs(\n row as unknown as Record<string, unknown>,\n (node) => {\n const r = node as unknown as TableRow\n r.checked = check\n cb(r)\n },\n childrenKey\n )\n\n triggerCheckedRows()\n }\n\n const getCheckboxColumnWidth = () => {\n return size.value === 'large' ? 80 : 60\n }\n\n const checkboxClass = cls.e('checkbox')\n const checkboxClick = (e: Event) => e.stopPropagation()\n\n function createCheckColumn(): TableColumn {\n const width = getCheckboxColumnWidth()\n return {\n key: '__is_check_column__',\n name: '',\n width,\n minWidth: width,\n align: 'center',\n fixed: 'left',\n resizable: false,\n nameRender() {\n const checkboxNode = createVNode(UCheckbox, {\n modelValue: allChecked.value,\n 'onUpdate:modelValue': handleCheckAll\n })\n if (!props.tree) {\n return checkboxNode\n }\n\n // const expandNode = createVNode('i', {\n // text: true,\n // class: cls.e('expand-space')\n // })\n return [checkboxNode]\n },\n render(ctx) {\n const { row } = ctx\n\n // @ts-ignore\n return createVNode(UCheckbox, {\n class: checkboxClass,\n modelValue: row.checked,\n 'onUpdate:modelValue': (val: boolean) => {\n handleCheckRow(row, val)\n },\n onClick: checkboxClick\n })\n }\n }\n }\n\n function handleSelect(row: TableRow, check: boolean) {\n row.checked = check\n if (check) {\n if (selectedRow.value) {\n selectedRow.value.checked = false\n }\n selectedRow.value = row\n } else {\n selectedRow.value = undefined\n }\n }\n\n function createSelectColumn(): TableColumn {\n const width = getCheckboxColumnWidth()\n return {\n key: '__is_select_column__',\n name: '单选',\n minWidth: width,\n resizable: false,\n width,\n align: 'center',\n fixed: 'left',\n nameRender(_ctx) {\n if (!props.tree) {\n return '单选'\n }\n\n // const expandNode = createVNode('i', {\n // text: true,\n // class: cls.e('expand-space')\n // })\n return [createTextVNode('单选')]\n },\n\n render({ row }) {\n // @ts-ignore\n return createVNode(UCheckbox, {\n class: checkboxClass,\n modelValue: row.checked,\n 'onUpdate:modelValue': (val: boolean) => {\n handleSelect(row, val)\n },\n onClick: checkboxClick\n })\n }\n }\n }\n\n return { checkedRows, createCheckColumn, createSelectColumn, clearChecked, clearSelected }\n}\n"],"mappings":";;;;AAmCA,SAAgB,SAAS,SAAoC;CAC3D,MAAM,EAAE,MAAM,WAAW,OAAO,MAAM,MAAM,QAAQ;CAEpD,MAAM,cAAc,2BAAW,IAAI,IAAc,CAAC;CAClD,MAAM,cAAc,WAAqB;;CAGzC,SAAS,qBAAqB;EAC5B,WAAW,WAAW;CACxB;CAEA,SAAS,eAAe;EACtB,YAAY,MAAM,SAAS,QAAQ;GACjC,IAAI,UAAU;EACh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zB;KACA,SAAS;IACX,CAAC;GACH;EACF;CACF;CAEA,SAAS,aAAa,KAAe,OAAgB;EACnD,IAAI,UAAU;EACd,IAAI,OAAO;GACT,IAAI,YAAY,OACd,YAAY,MAAM,UAAU;GAE9B,YAAY,QAAQ;EACtB,OACE,YAAY,QAAQ,KAAA;CAExB;CAEA,SAAS,qBAAkC;EACzC,MAAM,QAAQ,uBAAuB;EACrC,OAAO;GACL,KAAK;GACL,MAAM;GACN,UAAU;GACV,WAAW;GACX;GACA,OAAO;GACP,OAAO;GACP,WAAW,MAAM;IACf,IAAI,CAAC,MAAM,MACT,OAAO;IAOT,OAAO,CAAC,gBAAgB,IAAI,CAAC;GAC/B;GAEA,OAAO,EAAE,OAAO;IAEd,OAAO,YAAYA,WAAW;KAC5B,OAAO;KACP,YAAY,IAAI;KAChB,wBAAwB,QAAiB;MACvC,aAAa,KAAK,GAAG;KACvB;KACA,SAAS;IACX,CAAC;GACH;EACF;CACF;CAEA,OAAO;EAAE;EAAa;EAAmB;EAAoB;EAAc;CAAc;AAC3F"}
|
|
1
|
+
{"version":3,"file":"use-check.js","names":["UCheckbox"],"sources":["../../../src/components/table/use-check.ts"],"sourcesContent":["import { dfs, o, type Forest } from '@cat-kit/core'\nimport type { BEM } from '@veltra/utils'\nimport {\n computed,\n createTextVNode,\n createVNode,\n nextTick,\n shallowRef,\n toRaw,\n triggerRef,\n watch,\n type ComputedRef,\n type ShallowRef\n} from 'vue'\n\nimport type { TableRow, TableColumn, TableEmits, TableProps, ComponentSize } from '../../types'\nimport { UCheckbox } from '../checkbox'\n\ninterface Options {\n rows: ShallowRef<TableRow[] | undefined>\n rowForest: ShallowRef<Forest<Record<string, unknown>, any> | undefined>\n props: TableProps\n emit: TableEmits<any>\n size: ComputedRef<ComponentSize>\n cls: BEM<'table'>\n}\n\ninterface UseCheckReturned {\n checkedRows: ShallowRef<Set<TableRow>>\n clearChecked: () => void\n clearSelected: () => void\n createCheckColumn: () => TableColumn\n createSelectColumn: () => TableColumn\n}\n\nexport function useCheck(options: Options): UseCheckReturned {\n const { rows, rowForest, props, emit, size, cls } = options\n\n const checkedRows = shallowRef(new Set<TableRow>())\n const selectedRow = shallowRef<TableRow>()\n\n /** 触发checkedRows的更新 */\n function triggerCheckedRows() {\n triggerRef(checkedRows)\n }\n\n function clearChecked() {\n checkedRows.value.forEach((row) => {\n row.checked = false\n })\n checkedRows.value.clear()\n triggerCheckedRows()\n }\n\n function clearSelected() {\n if (selectedRow.value) {\n selectedRow.value.checked = false\n selectedRow.value = undefined\n }\n }\n\n watch([() => props.checkable, () => props.selectable, () => rows.value], () => {\n clearChecked()\n clearSelected()\n })\n\n watch(selectedRow, (selectedRow) => {\n if (changedByModel) return\n changedByEvent = true\n emit('update:selected', selectedRow?.data ? toRaw(selectedRow.data) : undefined)\n nextTick(() => {\n changedByEvent = false\n })\n })\n\n let changedByEvent = false\n let changedByModel = false\n watch(checkedRows, (checkedRows) => {\n if (changedByModel) return\n changedByEvent = true\n emit(\n 'update:checked',\n Array.from(checkedRows).map((row) => toRaw(row.data))\n )\n nextTick(() => {\n changedByEvent = false\n })\n })\n\n let dicts: Map<string | number, TableRow> | undefined = undefined\n\n // 设置uid -> row 字典,以便于数据重复使用\n function setDicts() {\n if (dicts || !rows.value || !props.rowKey) return\n\n let mapEntries: [string | number, TableRow][] = []\n let i = 0\n while (i < rows.value.length) {\n const row = rows.value[i]!\n\n mapEntries.push([row.uid, row])\n i++\n }\n dicts = new Map(mapEntries)\n }\n\n watch(rows, () => {\n dicts = undefined\n })\n\n watch(\n [() => props.checked, () => props.rowKey, () => props.checkable, rows],\n ([checked, rowKey, checkable, rows], [, , , oRows]) => {\n if (changedByEvent || !checkable || !rowKey) return\n\n changedByModel = true\n\n // 如果没有字典,先建立字典\n rows !== oRows && setDicts()\n\n clearChecked()\n\n checked?.forEach((item) => {\n const uid = o(item).get(rowKey)\n if (uid === undefined || uid === null) return\n const row = dicts?.get(uid as string | number)\n if (!row) return\n\n row.checked = true\n checkedRows.value.add(row)\n })\n triggerCheckedRows()\n\n nextTick(() => {\n changedByModel = false\n })\n },\n { immediate: true }\n )\n\n watch(\n [() => props.selected, () => props.rowKey, () => props.selectable, rows],\n ([selected, rowKey, selectable, rows], [, , , oRows]) => {\n if (changedByEvent || !selectable || !rowKey) return\n\n changedByModel = true\n\n // 如果没有字典,先建立字典(懒建立)\n rows !== oRows && setDicts()\n\n if (selected) {\n const uid = o(selected).get(rowKey)\n const row =\n uid === undefined || uid === null ? undefined : dicts?.get(uid as string | number)\n if (row) {\n row.checked = true\n selectedRow.value = row\n }\n } else {\n clearSelected()\n }\n\n nextTick(() => {\n changedByModel = false\n })\n },\n { immediate: true }\n )\n\n const allChecked = computed(() => {\n const rowSize = props.tree ? rowForest.value?.size : rows.value?.length\n return !!rowSize && rowSize === checkedRows.value.size\n })\n\n function handleCheckAllTree(check: boolean) {\n if (check) {\n rowForest.value?.dfs((row) => {\n row.checked = true\n checkedRows.value.add(row)\n })\n } else {\n rowForest.value?.dfs((row) => {\n row.checked = false\n })\n checkedRows.value.clear()\n }\n triggerCheckedRows()\n }\n\n function handleCheckAllRows(check: boolean) {\n if (check) {\n rows.value?.forEach((row) => {\n row.checked = true\n checkedRows.value.add(row)\n })\n } else {\n rows.value?.forEach((row) => {\n row.checked = false\n })\n checkedRows.value.clear()\n }\n triggerCheckedRows()\n }\n\n function handleCheckAll(check: boolean) {\n if (props.tree) {\n handleCheckAllTree(check as boolean)\n } else {\n handleCheckAllRows(check as boolean)\n }\n }\n\n function handleCheckRow(row: TableRow, check: boolean) {\n const cb = check\n ? (row: TableRow) => checkedRows.value.add(row)\n : (row: TableRow) => checkedRows.value.delete(row)\n\n const childrenKey = typeof props.tree === 'string' ? props.tree : 'children'\n dfs(\n row as unknown as Record<string, unknown>,\n (node) => {\n const r = node as unknown as TableRow\n r.checked = check\n cb(r)\n },\n childrenKey\n )\n\n triggerCheckedRows()\n }\n\n const getCheckboxColumnWidth = () => {\n return size.value === 'large' ? 80 : 60\n }\n\n const checkboxClass = cls.e('checkbox')\n const checkboxClick = (e: Event) => e.stopPropagation()\n\n function createCheckColumn(): TableColumn {\n const width = getCheckboxColumnWidth()\n return {\n key: '__is_check_column__',\n name: '',\n width,\n minWidth: width,\n align: 'center',\n fixed: 'left',\n resizable: false,\n nameRender() {\n const checkboxNode = createVNode(UCheckbox, {\n modelValue: allChecked.value,\n 'onUpdate:modelValue': handleCheckAll\n })\n if (!props.tree) {\n return checkboxNode\n }\n\n // const expandNode = createVNode('i', {\n // text: true,\n // class: cls.e('expand-space')\n // })\n return [checkboxNode]\n },\n render(ctx) {\n const { row } = ctx\n\n // @ts-ignore\n return createVNode(UCheckbox, {\n class: checkboxClass,\n modelValue: row.checked,\n 'onUpdate:modelValue': (val: boolean) => {\n handleCheckRow(row, val)\n },\n onClick: checkboxClick\n })\n }\n }\n }\n\n function handleSelect(row: TableRow, check: boolean) {\n row.checked = check\n if (check) {\n if (selectedRow.value) {\n selectedRow.value.checked = false\n }\n selectedRow.value = row\n } else {\n selectedRow.value = undefined\n }\n }\n\n function createSelectColumn(): TableColumn {\n const width = getCheckboxColumnWidth()\n return {\n key: '__is_select_column__',\n name: '单选',\n minWidth: width,\n resizable: false,\n width,\n align: 'center',\n fixed: 'left',\n nameRender(_ctx) {\n if (!props.tree) {\n return '单选'\n }\n\n // const expandNode = createVNode('i', {\n // text: true,\n // class: cls.e('expand-space')\n // })\n return [createTextVNode('单选')]\n },\n\n render({ row }) {\n // @ts-ignore\n return createVNode(UCheckbox, {\n class: checkboxClass,\n modelValue: row.checked,\n 'onUpdate:modelValue': (val: boolean) => {\n handleSelect(row, val)\n },\n onClick: checkboxClick\n })\n }\n }\n }\n\n return { checkedRows, createCheckColumn, createSelectColumn, clearChecked, clearSelected }\n}\n"],"mappings":";;;;AAmCA,SAAgB,SAAS,SAAoC;CAC3D,MAAM,EAAE,MAAM,WAAW,OAAO,MAAM,MAAM,QAAQ;CAEpD,MAAM,cAAc,2BAAW,IAAI,IAAc,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QAAQ;IAGhB,OAAO,YAAYA,WAAW;KAC5B,OAAO;KACP,YAAY,IAAI;KAChB,wBAAwB,QAAiB;MACvC,eAAe,KAAK,GAAG;KACzB;KACA,SAAS;IACX,CAAC;GACH;EACF;CACF;CAEA,SAAS,aAAa,KAAe,OAAgB;EACnD,IAAI,UAAU;EACd,IAAI,OAAO;GACT,IAAI,YAAY,OACd,YAAY,MAAM,UAAU;GAE9B,YAAY,QAAQ;EACtB,OACE,YAAY,QAAQ,KAAA;CAExB;CAEA,SAAS,qBAAkC;EACzC,MAAM,QAAQ,uBAAuB;EACrC,OAAO;GACL,KAAK;GACL,MAAM;GACN,UAAU;GACV,WAAW;GACX;GACA,OAAO;GACP,OAAO;GACP,WAAW,MAAM;IACf,IAAI,CAAC,MAAM,MACT,OAAO;IAOT,OAAO,CAAC,gBAAgB,IAAI,CAAC;GAC/B;GAEA,OAAO,EAAE,OAAO;IAEd,OAAO,YAAYA,WAAW;KAC5B,OAAO;KACP,YAAY,IAAI;KAChB,wBAAwB,QAAiB;MACvC,aAAa,KAAK,GAAG;KACvB;KACA,SAAS;IACX,CAAC;GACH;EACF;CACF;CAEA,OAAO;EAAE;EAAa;EAAmB;EAAoB;EAAc;CAAc;AAC3F"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veltra/desktop",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.4",
|
|
4
4
|
"homepage": "https://github.com/cabinet-fe/ultra-ui#readme",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/cabinet-fe/ultra-ui/issues"
|
|
@@ -78,15 +78,15 @@
|
|
|
78
78
|
"@codemirror/view": "6.43.9"
|
|
79
79
|
},
|
|
80
80
|
"peerDependencies": {
|
|
81
|
-
"@cat-kit/core": ">=1.1
|
|
82
|
-
"@cat-kit/fe": ">=1.1
|
|
83
|
-
"@veltra/compositions": "^1.7.
|
|
84
|
-
"@veltra/directives": "^1.7.
|
|
81
|
+
"@cat-kit/core": ">=1.2.1",
|
|
82
|
+
"@cat-kit/fe": ">=1.2.1",
|
|
83
|
+
"@veltra/compositions": "^1.7.4",
|
|
84
|
+
"@veltra/directives": "^1.7.4",
|
|
85
85
|
"@veltra/icons": "^1.5.0",
|
|
86
|
-
"@veltra/sheet-core": "^2.5.
|
|
87
|
-
"@veltra/styles": "^1.7.
|
|
88
|
-
"@veltra/utils": "^1.7.
|
|
89
|
-
"vue": ">=3.5.
|
|
86
|
+
"@veltra/sheet-core": "^2.5.4",
|
|
87
|
+
"@veltra/styles": "^1.7.4",
|
|
88
|
+
"@veltra/utils": "^1.7.4",
|
|
89
|
+
"vue": ">=3.5.42"
|
|
90
90
|
},
|
|
91
91
|
"peerDependenciesMeta": {
|
|
92
92
|
"@veltra/sheet-core": {
|
|
@@ -29,21 +29,46 @@ $root-name: auto-complete;
|
|
|
29
29
|
cursor: pointer;
|
|
30
30
|
margin: 2px 0;
|
|
31
31
|
user-select: none;
|
|
32
|
+
color: fn.use-var(text-color, main);
|
|
32
33
|
@include m.ellipsis;
|
|
33
34
|
|
|
34
35
|
&:hover {
|
|
35
|
-
background-color: var(
|
|
36
|
-
|
|
36
|
+
background-color: fn.component-var(
|
|
37
|
+
auto-complete,
|
|
38
|
+
option-hover-bg,
|
|
39
|
+
fn.use-var(bg-color, hover)
|
|
40
|
+
);
|
|
41
|
+
color: fn.component-var(
|
|
42
|
+
auto-complete,
|
|
43
|
+
option-hover-color,
|
|
44
|
+
fn.use-var(text-color, title)
|
|
45
|
+
);
|
|
37
46
|
}
|
|
38
47
|
|
|
39
48
|
@include m.is(active) {
|
|
40
|
-
background-color: var(
|
|
41
|
-
|
|
49
|
+
background-color: fn.component-var(
|
|
50
|
+
auto-complete,
|
|
51
|
+
option-hover-bg,
|
|
52
|
+
fn.use-var(bg-color, hover)
|
|
53
|
+
);
|
|
54
|
+
color: fn.component-var(
|
|
55
|
+
auto-complete,
|
|
56
|
+
option-hover-color,
|
|
57
|
+
fn.use-var(text-color, title)
|
|
58
|
+
);
|
|
42
59
|
}
|
|
43
60
|
|
|
44
61
|
@include m.is(selected) {
|
|
45
|
-
background-color: var(
|
|
46
|
-
|
|
62
|
+
background-color: fn.component-var(
|
|
63
|
+
auto-complete,
|
|
64
|
+
option-selected-bg,
|
|
65
|
+
fn.use-var(color, primary, light-9)
|
|
66
|
+
);
|
|
67
|
+
color: fn.component-var(
|
|
68
|
+
auto-complete,
|
|
69
|
+
option-selected-color,
|
|
70
|
+
fn.use-var(color, primary)
|
|
71
|
+
);
|
|
47
72
|
}
|
|
48
73
|
}
|
|
49
74
|
|
|
@@ -38,7 +38,7 @@ export function useFeatures(options: Options) {
|
|
|
38
38
|
const { features } = props
|
|
39
39
|
if (!Array.isArray(features) && typeof features === 'object') {
|
|
40
40
|
const ret = Object.entries(features)
|
|
41
|
-
.filter(([
|
|
41
|
+
.filter(([, value]) => {
|
|
42
42
|
return typeof value === 'function'
|
|
43
43
|
})
|
|
44
44
|
.reduce(
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { last, o } from '@cat-kit/core'
|
|
1
|
+
import { copy, last, o } from '@cat-kit/core'
|
|
2
2
|
import { computed, nextTick, type ShallowRef } from 'vue'
|
|
3
3
|
|
|
4
4
|
import type {
|
|
@@ -57,7 +57,7 @@ export function useHandlers(options: Options): EditReturned {
|
|
|
57
57
|
})
|
|
58
58
|
|
|
59
59
|
function getInsertData(): Record<string, any> {
|
|
60
|
-
return
|
|
60
|
+
return copy(props.model ?? {})
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
/**
|
|
@@ -39,7 +39,7 @@ $root-name: card;
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
@include m.e(header) {
|
|
42
|
-
background-color: fn.
|
|
42
|
+
background-color: fn.component-var(card, header-bg, transparent);
|
|
43
43
|
color: fn.use-var(text-color, title);
|
|
44
44
|
}
|
|
45
45
|
|
|
@@ -65,7 +65,7 @@ $root-name: card;
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
@include m.e(action) {
|
|
68
|
-
background-color: fn.
|
|
68
|
+
background-color: fn.component-var(card, action-bg, transparent);
|
|
69
69
|
|
|
70
70
|
#{fn.bem(button)} + #{fn.bem(button)} {
|
|
71
71
|
margin-left: fn.use-var(gap, default);
|
|
@@ -19,10 +19,10 @@ const props = withDefaults(defineProps<CheckTagProps>(), {})
|
|
|
19
19
|
const emits = defineEmits<CheckTagEmits>()
|
|
20
20
|
|
|
21
21
|
const classList = computed(() => {
|
|
22
|
-
return [cls.b, bem.is('checked', props.checked)]
|
|
22
|
+
return [cls.b, bem.is('checked', props.modelValue ?? props.checked)]
|
|
23
23
|
})
|
|
24
24
|
|
|
25
25
|
const handleChange = () => {
|
|
26
|
-
emits('update:modelValue', props.checked)
|
|
26
|
+
emits('update:modelValue', !(props.modelValue ?? props.checked))
|
|
27
27
|
}
|
|
28
28
|
</script>
|
|
@@ -84,16 +84,16 @@ $connector-width: 56px;
|
|
|
84
84
|
background-color: fn.use-var(color, primary, light-9);
|
|
85
85
|
|
|
86
86
|
&:hover {
|
|
87
|
-
background-color: fn.use-var(color, primary, light-
|
|
87
|
+
background-color: fn.use-var(color, primary, light-7);
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
@include m.m(or) {
|
|
92
|
-
color: fn.use-var(color, warning, dark-
|
|
92
|
+
color: fn.use-var(color, warning, dark-1);
|
|
93
93
|
background-color: fn.use-var(color, warning, light-9);
|
|
94
94
|
|
|
95
95
|
&:hover {
|
|
96
|
-
background-color: fn.use-var(color, warning, light-
|
|
96
|
+
background-color: fn.use-var(color, warning, light-7);
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
|
|
@@ -243,7 +243,7 @@ $connector-width: 56px;
|
|
|
243
243
|
border-color 0.15s ease;
|
|
244
244
|
|
|
245
245
|
&:hover {
|
|
246
|
-
background-color: fn.use-var(color, primary, light-
|
|
246
|
+
background-color: fn.use-var(color, primary, light-7);
|
|
247
247
|
border-color: fn.use-var(color, primary, light-5);
|
|
248
248
|
}
|
|
249
249
|
|
|
@@ -92,15 +92,31 @@ $arrow-size: 12px;
|
|
|
92
92
|
|
|
93
93
|
#{$b}__item:not(.is-disabled):not(.is-loading) > & {
|
|
94
94
|
&:hover {
|
|
95
|
-
background-color: var(
|
|
96
|
-
|
|
95
|
+
background-color: fn.component-var(
|
|
96
|
+
contextmenu,
|
|
97
|
+
item-hover-bg,
|
|
98
|
+
fn.use-var(bg-color, hover)
|
|
99
|
+
);
|
|
100
|
+
color: fn.component-var(
|
|
101
|
+
contextmenu,
|
|
102
|
+
item-hover-color,
|
|
103
|
+
fn.use-var(text-color, title)
|
|
104
|
+
);
|
|
97
105
|
}
|
|
98
106
|
}
|
|
99
107
|
}
|
|
100
108
|
|
|
101
109
|
#{$b}__item.is-open:not(.is-disabled) > #{$b}__item-content {
|
|
102
|
-
background-color: var(
|
|
103
|
-
|
|
110
|
+
background-color: fn.component-var(
|
|
111
|
+
contextmenu,
|
|
112
|
+
item-hover-bg,
|
|
113
|
+
fn.use-var(bg-color, hover)
|
|
114
|
+
);
|
|
115
|
+
color: fn.component-var(
|
|
116
|
+
contextmenu,
|
|
117
|
+
item-hover-color,
|
|
118
|
+
fn.use-var(text-color, title)
|
|
119
|
+
);
|
|
104
120
|
}
|
|
105
121
|
|
|
106
122
|
@include m.e(icon-place) {
|
|
@@ -142,7 +158,11 @@ $arrow-size: 12px;
|
|
|
142
158
|
|
|
143
159
|
@include m.e(item-content) {
|
|
144
160
|
padding: 0 fn.use-var(gap, $size);
|
|
145
|
-
min-height:
|
|
161
|
+
min-height: fn.component-var(
|
|
162
|
+
contextmenu,
|
|
163
|
+
item-height-#{$size},
|
|
164
|
+
calc(fn.use-var(form-component-height, $size) - 4px)
|
|
165
|
+
);
|
|
146
166
|
border-radius: calc(fn.use-var(radius, $size) + 1px);
|
|
147
167
|
}
|
|
148
168
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o } from '@cat-kit/core'
|
|
1
|
+
import { copy, o } from '@cat-kit/core'
|
|
2
2
|
import type { FormFieldItem } from '@veltra/utils'
|
|
3
3
|
import { nextTick, watch } from 'vue'
|
|
4
4
|
|
|
@@ -8,26 +8,6 @@ interface Options {
|
|
|
8
8
|
props: FormProps
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
/** 深拷贝 model,保留 undefined 等 o().copy() 会丢弃的值 */
|
|
12
|
-
function snapshotModel(model: Record<string, any>): Record<string, any> {
|
|
13
|
-
const result: Record<string, any> = {}
|
|
14
|
-
|
|
15
|
-
for (const key of Object.keys(model)) {
|
|
16
|
-
const value = model[key]
|
|
17
|
-
if (Array.isArray(value)) {
|
|
18
|
-
result[key] = value.map((item) =>
|
|
19
|
-
item !== null && typeof item === 'object' ? snapshotModel(item) : item
|
|
20
|
-
)
|
|
21
|
-
} else if (value !== null && typeof value === 'object') {
|
|
22
|
-
result[key] = snapshotModel(value)
|
|
23
|
-
} else {
|
|
24
|
-
result[key] = value
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return result
|
|
29
|
-
}
|
|
30
|
-
|
|
31
11
|
/** 按快照逐字段写回 model,支持 undefined 与嵌套对象 */
|
|
32
12
|
function applySnapshot(target: Record<string, any>, source: Record<string, any>) {
|
|
33
13
|
for (const key of Object.keys(source)) {
|
|
@@ -47,12 +27,7 @@ function applySnapshot(target: Record<string, any>, source: Record<string, any>)
|
|
|
47
27
|
}
|
|
48
28
|
|
|
49
29
|
if (Array.isArray(sourceValue)) {
|
|
50
|
-
o(target).set(
|
|
51
|
-
key,
|
|
52
|
-
sourceValue.map((item) =>
|
|
53
|
-
item !== null && typeof item === 'object' ? snapshotModel(item) : item
|
|
54
|
-
)
|
|
55
|
-
)
|
|
30
|
+
o(target).set(key, copy(sourceValue))
|
|
56
31
|
continue
|
|
57
32
|
}
|
|
58
33
|
|
|
@@ -84,7 +59,7 @@ export function useFormFields(options: Options) {
|
|
|
84
59
|
watch(
|
|
85
60
|
() => props.model,
|
|
86
61
|
(model) => {
|
|
87
|
-
initialSnapshot = model ?
|
|
62
|
+
initialSnapshot = model ? copy(model) : undefined
|
|
88
63
|
},
|
|
89
64
|
{ immediate: true, deep: false }
|
|
90
65
|
)
|
|
@@ -39,7 +39,7 @@ $root-name: progress-nodes;
|
|
|
39
39
|
transition:
|
|
40
40
|
background-color 0.2s,
|
|
41
41
|
color 0.2s;
|
|
42
|
-
border-radius: fn.use-var(radius,
|
|
42
|
+
border-radius: fn.use-var(radius, default);
|
|
43
43
|
|
|
44
44
|
&:hover {
|
|
45
45
|
@include m.bem($root-name, dot) {
|
|
@@ -47,7 +47,7 @@ $root-name: progress-nodes;
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
@include m.bem($root-name, label) {
|
|
50
|
-
color: fn.use-var(
|
|
50
|
+
color: fn.use-var(color, primary);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
}
|
|
@@ -64,7 +64,7 @@ $root-name: progress-nodes;
|
|
|
64
64
|
@include m.e(link) {
|
|
65
65
|
position: absolute;
|
|
66
66
|
border-style: dashed;
|
|
67
|
-
border-color: fn.use-var(text
|
|
67
|
+
border-color: fn.use-var(text-color, placeholder);
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
// 节点圆点
|
|
@@ -8,7 +8,7 @@ $root-name: rich-text-editor;
|
|
|
8
8
|
width: 100%;
|
|
9
9
|
border: 1px solid fn.use-var(border, muted-color);
|
|
10
10
|
border-radius: fn.use-var(radius, default);
|
|
11
|
-
background-color: fn.use-var(color,
|
|
11
|
+
background-color: fn.use-var(bg-color, top);
|
|
12
12
|
transition: border-color 0.25s ease;
|
|
13
13
|
display: flex;
|
|
14
14
|
flex-direction: column;
|
|
@@ -38,7 +38,7 @@ $root-name: rich-text-editor;
|
|
|
38
38
|
gap: 2px;
|
|
39
39
|
padding: 6px 8px;
|
|
40
40
|
border-bottom: 1px solid fn.use-var(border-color);
|
|
41
|
-
background-color: fn.use-var(color,
|
|
41
|
+
background-color: fn.use-var(bg-color, middle);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
@include m.e(toolbar-btn) {
|
|
@@ -50,19 +50,19 @@ $root-name: rich-text-editor;
|
|
|
50
50
|
border: none;
|
|
51
51
|
border-radius: 4px;
|
|
52
52
|
background: transparent;
|
|
53
|
-
color: fn.use-var(text-color);
|
|
53
|
+
color: fn.use-var(text-color, main);
|
|
54
54
|
cursor: pointer;
|
|
55
55
|
transition: all 0.15s ease;
|
|
56
56
|
padding: 0;
|
|
57
57
|
|
|
58
58
|
@include m.is-not(disabled) {
|
|
59
59
|
&:hover {
|
|
60
|
-
background-color: fn.use-var(color, hover);
|
|
60
|
+
background-color: fn.use-var(bg-color, hover);
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
&.is-active {
|
|
65
|
-
background-color: fn.use-var(color, primary, light);
|
|
65
|
+
background-color: fn.use-var(color, primary, light-9);
|
|
66
66
|
color: fn.use-var(color, primary);
|
|
67
67
|
}
|
|
68
68
|
|
|
@@ -104,7 +104,7 @@ $root-name: rich-text-editor;
|
|
|
104
104
|
border: 1px solid fn.use-var(border, muted-color);
|
|
105
105
|
border-radius: 4px;
|
|
106
106
|
background-color: transparent;
|
|
107
|
-
color: fn.use-var(text-color);
|
|
107
|
+
color: fn.use-var(text-color, main);
|
|
108
108
|
font-size: 13px;
|
|
109
109
|
cursor: pointer;
|
|
110
110
|
outline: none;
|
|
@@ -146,7 +146,7 @@ $root-name: rich-text-editor;
|
|
|
146
146
|
outline: none;
|
|
147
147
|
font-size: 14px;
|
|
148
148
|
line-height: 1.6;
|
|
149
|
-
color: fn.use-var(text-color);
|
|
149
|
+
color: fn.use-var(text-color, main);
|
|
150
150
|
word-break: break-word;
|
|
151
151
|
|
|
152
152
|
&:focus {
|
|
@@ -259,7 +259,7 @@ $root-name: rich-text-editor;
|
|
|
259
259
|
font-weight: 600;
|
|
260
260
|
line-height: 1.4;
|
|
261
261
|
margin: 10px 0 4px 0;
|
|
262
|
-
color: fn.use-var(text-color,
|
|
262
|
+
color: fn.use-var(text-color, second);
|
|
263
263
|
|
|
264
264
|
&:first-child {
|
|
265
265
|
margin-top: 0;
|
|
@@ -286,7 +286,7 @@ $root-name: rich-text-editor;
|
|
|
286
286
|
.u-rte-code {
|
|
287
287
|
font-family: 'Menlo', 'Consolas', 'Monaco', monospace;
|
|
288
288
|
font-size: 0.9em;
|
|
289
|
-
background-color: fn.use-var(color,
|
|
289
|
+
background-color: fn.use-var(bg-color, middle);
|
|
290
290
|
padding: 2px 6px;
|
|
291
291
|
border-radius: 3px;
|
|
292
292
|
border: 1px solid fn.use-var(border-color);
|
|
@@ -318,8 +318,8 @@ $root-name: rich-text-editor;
|
|
|
318
318
|
margin: 8px 0;
|
|
319
319
|
padding: 8px 16px;
|
|
320
320
|
border-left: 3px solid fn.use-var(color, primary);
|
|
321
|
-
background-color: fn.use-var(color,
|
|
322
|
-
color: fn.use-var(text-color,
|
|
321
|
+
background-color: fn.use-var(bg-color, middle);
|
|
322
|
+
color: fn.use-var(text-color, second);
|
|
323
323
|
font-style: italic;
|
|
324
324
|
}
|
|
325
325
|
|
|
@@ -328,7 +328,7 @@ $root-name: rich-text-editor;
|
|
|
328
328
|
font-family: 'Menlo', 'Consolas', 'Monaco', monospace;
|
|
329
329
|
font-size: 13px;
|
|
330
330
|
line-height: 1.6;
|
|
331
|
-
background-color: fn.use-var(color,
|
|
331
|
+
background-color: fn.use-var(bg-color, middle);
|
|
332
332
|
border: 1px solid fn.use-var(border-color);
|
|
333
333
|
border-radius: 6px;
|
|
334
334
|
padding: 12px 16px;
|
|
@@ -63,14 +63,30 @@ $root-name: select;
|
|
|
63
63
|
@include m.ellipsis;
|
|
64
64
|
|
|
65
65
|
&:hover {
|
|
66
|
-
background-color: var(
|
|
67
|
-
|
|
66
|
+
background-color: fn.component-var(
|
|
67
|
+
select,
|
|
68
|
+
option-hover-bg,
|
|
69
|
+
fn.use-var(bg-color, hover)
|
|
70
|
+
);
|
|
71
|
+
color: fn.component-var(
|
|
72
|
+
select,
|
|
73
|
+
option-hover-color,
|
|
74
|
+
fn.use-var(text-color, title)
|
|
75
|
+
);
|
|
68
76
|
}
|
|
69
77
|
|
|
70
78
|
@include m.is(selected) {
|
|
71
79
|
position: relative;
|
|
72
|
-
background-color: var(
|
|
73
|
-
|
|
80
|
+
background-color: fn.component-var(
|
|
81
|
+
select,
|
|
82
|
+
option-selected-bg,
|
|
83
|
+
fn.use-var(color, primary, light-9)
|
|
84
|
+
);
|
|
85
|
+
color: fn.component-var(
|
|
86
|
+
select,
|
|
87
|
+
option-selected-color,
|
|
88
|
+
fn.use-var(color, primary)
|
|
89
|
+
);
|
|
74
90
|
font-weight: 600;
|
|
75
91
|
|
|
76
92
|
&::before {
|
|
@@ -110,7 +110,7 @@ export function useCheck(options: Options): UseCheckReturned {
|
|
|
110
110
|
|
|
111
111
|
watch(
|
|
112
112
|
[() => props.checked, () => props.rowKey, () => props.checkable, rows],
|
|
113
|
-
([checked, rowKey, checkable, rows], [
|
|
113
|
+
([checked, rowKey, checkable, rows], [, , , oRows]) => {
|
|
114
114
|
if (changedByEvent || !checkable || !rowKey) return
|
|
115
115
|
|
|
116
116
|
changedByModel = true
|
|
@@ -140,7 +140,7 @@ export function useCheck(options: Options): UseCheckReturned {
|
|
|
140
140
|
|
|
141
141
|
watch(
|
|
142
142
|
[() => props.selected, () => props.rowKey, () => props.selectable, rows],
|
|
143
|
-
([selected, rowKey, selectable, rows], [
|
|
143
|
+
([selected, rowKey, selectable, rows], [, , , oRows]) => {
|
|
144
144
|
if (changedByEvent || !selectable || !rowKey) return
|
|
145
145
|
|
|
146
146
|
changedByModel = true
|
|
@@ -159,7 +159,7 @@ $active-shadow: fn.use-var(shadow, sm);
|
|
|
159
159
|
padding: 0;
|
|
160
160
|
border: none;
|
|
161
161
|
background: transparent;
|
|
162
|
-
color: fn.use-var(text-color,
|
|
162
|
+
color: fn.use-var(text-color, second);
|
|
163
163
|
cursor: pointer;
|
|
164
164
|
border-radius: fn.use-var(radius, default);
|
|
165
165
|
font-size: 12px;
|