@tmagic/form 1.8.0-manmanyu.14 → 1.8.0-manmanyu.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,15 +1,15 @@
1
+ import { isGlobalFlat } from "../../utils/config.js";
1
2
  import { display, getDataByPage, sortArray } from "../../utils/form.js";
2
3
  import Container_default from "../Container.js";
3
4
  import ActionsColumn_default from "./ActionsColumn.js";
4
5
  import SortColumn_default from "./SortColumn.js";
5
6
  import { computed, h, inject } from "vue";
6
7
  import { cloneDeep } from "lodash-es";
7
- import { TMagicIcon, TMagicTooltip, isMagicAdminTheme } from "@tmagic/design";
8
+ import { TMagicIcon, TMagicTooltip } from "@tmagic/design";
8
9
  import { WarningFilled } from "@element-plus/icons-vue";
9
10
  //#region packages/form/src/containers/table/useTableColumns.ts
10
11
  var useTableColumns = (props, emit, currentPage, pageSize, modelName) => {
11
12
  const mForm = inject("mForm");
12
- const isMagicAdmin = isMagicAdminTheme();
13
13
  const display$1 = (fuc) => display(mForm, fuc, props);
14
14
  const lastData = computed(() => props.config.pagination ? getDataByPage(props.lastValues[modelName.value], currentPage.value, pageSize.value) : props.lastValues[modelName.value] || []);
15
15
  const itemExtra = (fuc, index) => {
@@ -67,10 +67,10 @@ var useTableColumns = (props, emit, currentPage, pageSize, modelName) => {
67
67
  type: "selection",
68
68
  width: 45
69
69
  } });
70
- const defaultFixed = isMagicAdmin.value ? "right" : "left";
70
+ const defaultFixed = isGlobalFlat.value ? "right" : "left";
71
71
  let actionFixed = props.config.fixed === false ? void 0 : defaultFixed;
72
72
  if (typeof props.config.fixed === "string" && ["left", "right"].includes(props.config.fixed)) actionFixed = props.config.fixed;
73
- const actionFlat = props.config.flat === void 0 && isMagicAdmin.value ? true : props.config.flat;
73
+ const actionFlat = props.config.flat === void 0 && isGlobalFlat.value ? true : props.config.flat;
74
74
  const actionColumn = {
75
75
  props: {
76
76
  label: "操作",
@@ -1,7 +1,8 @@
1
1
  import { useAddField } from "../utils/useAddField.js";
2
+ import { isGlobalFlat } from "../utils/config.js";
2
3
  import FormDialog_default from "../FormDialog.js";
3
4
  import { computed, createElementBlock, createTextVNode, createVNode, defineComponent, inject, normalizeStyle, openBlock, readonly, ref, toDisplayString, unref, withCtx } from "vue";
4
- import { TMagicButton, TMagicIcon, isMagicAdminTheme } from "@tmagic/design";
5
+ import { TMagicButton, TMagicIcon } from "@tmagic/design";
5
6
  import { Notebook } from "@element-plus/icons-vue";
6
7
  //#region packages/form/src/fields/Link.vue?vue&type=script&setup=true&lang.ts
7
8
  var _hoisted_1 = ["href"];
@@ -33,7 +34,6 @@ var Link_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineCompo
33
34
  setup(__props, { emit: __emit }) {
34
35
  const props = __props;
35
36
  const emit = __emit;
36
- const isMagicAdmin = isMagicAdminTheme(props);
37
37
  useAddField(props.prop);
38
38
  const formValue = ref({});
39
39
  const editor = ref();
@@ -71,7 +71,7 @@ var Link_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineCompo
71
71
  editor.value && (editor.value.dialogVisible = false);
72
72
  };
73
73
  return (_ctx, _cache) => {
74
- return unref(isMagicAdmin) && __props.config.href && !__props.disabled ? (openBlock(), createElementBlock("a", {
74
+ return unref(isGlobalFlat) && __props.config.href && !__props.disabled ? (openBlock(), createElementBlock("a", {
75
75
  key: 0,
76
76
  target: "_blank",
77
77
  href: href.value,
@@ -1,6 +1,7 @@
1
1
  import { useAddField } from "../utils/useAddField.js";
2
+ import { isGlobalFlat } from "../utils/config.js";
2
3
  import { createBlock, createCommentVNode, defineComponent, inject, openBlock, ref, unref, watch } from "vue";
3
- import { TMagicInputNumber, isMagicAdminTheme } from "@tmagic/design";
4
+ import { TMagicInputNumber } from "@tmagic/design";
4
5
  //#region packages/form/src/fields/Number.vue?vue&type=script&setup=true&lang.ts
5
6
  var Number_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
6
7
  name: "MFormNumber",
@@ -24,7 +25,6 @@ var Number_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineCom
24
25
  setup(__props, { emit: __emit }) {
25
26
  const props = __props;
26
27
  const emit = __emit;
27
- const isMagicAdmin = isMagicAdminTheme();
28
28
  const value = ref();
29
29
  watch(() => props.model[props.name], (v) => {
30
30
  value.value = v;
@@ -44,7 +44,7 @@ var Number_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineCom
44
44
  modelValue: value.value,
45
45
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => value.value = $event),
46
46
  clearable: "",
47
- "controls-position": unref(isMagicAdmin) ? "" : "right",
47
+ "controls-position": unref(isGlobalFlat) ? "" : "right",
48
48
  size: __props.size,
49
49
  max: __props.config.max,
50
50
  min: __props.config.min,
@@ -1,7 +1,10 @@
1
+ import { ref } from "vue";
1
2
  //#region packages/form/src/utils/config.ts
2
3
  var $MAGIC_FORM = {};
4
+ var isGlobalFlat = ref(false);
3
5
  var setConfig = (option) => {
4
6
  $MAGIC_FORM = option;
7
+ isGlobalFlat.value = option.flat ?? false;
5
8
  };
6
9
  var getConfig = (key) => $MAGIC_FORM[key];
7
10
  var fieldRegistry = /* @__PURE__ */ new Map();
@@ -12,4 +15,4 @@ var registerField = (tagName, component) => {
12
15
  var getField = (tagName) => fieldRegistry.get(tagName);
13
16
  var deleteField = (tagName) => fieldRegistry.delete(tagName);
14
17
  //#endregion
15
- export { deleteField, getConfig, getField, registerField, setConfig };
18
+ export { deleteField, getConfig, getField, isGlobalFlat, registerField, setConfig };
@@ -2654,8 +2654,10 @@
2654
2654
  //#endregion
2655
2655
  //#region packages/form/src/utils/config.ts
2656
2656
  var $MAGIC_FORM = {};
2657
+ var isGlobalFlat = (0, vue.ref)(false);
2657
2658
  var setConfig = (option) => {
2658
2659
  $MAGIC_FORM = option;
2660
+ isGlobalFlat.value = option.flat ?? false;
2659
2661
  };
2660
2662
  var getConfig = (key) => $MAGIC_FORM[key];
2661
2663
  var fieldRegistry = /* @__PURE__ */ new Map();
@@ -5854,7 +5856,6 @@
5854
5856
  //#region packages/form/src/containers/table/useTableColumns.ts
5855
5857
  var useTableColumns = (props, emit, currentPage, pageSize, modelName) => {
5856
5858
  const mForm = (0, vue.inject)("mForm");
5857
- const isMagicAdmin = (0, _tmagic_design.isMagicAdminTheme)();
5858
5859
  const display$1 = (fuc) => display(mForm, fuc, props);
5859
5860
  const lastData = (0, vue.computed)(() => props.config.pagination ? getDataByPage(props.lastValues[modelName.value], currentPage.value, pageSize.value) : props.lastValues[modelName.value] || []);
5860
5861
  const itemExtra = (fuc, index) => {
@@ -5912,10 +5913,10 @@
5912
5913
  type: "selection",
5913
5914
  width: 45
5914
5915
  } });
5915
- const defaultFixed = isMagicAdmin.value ? "right" : "left";
5916
+ const defaultFixed = isGlobalFlat.value ? "right" : "left";
5916
5917
  let actionFixed = props.config.fixed === false ? void 0 : defaultFixed;
5917
5918
  if (typeof props.config.fixed === "string" && ["left", "right"].includes(props.config.fixed)) actionFixed = props.config.fixed;
5918
- const actionFlat = props.config.flat === void 0 && isMagicAdmin.value ? true : props.config.flat;
5919
+ const actionFlat = props.config.flat === void 0 && isGlobalFlat.value ? true : props.config.flat;
5919
5920
  const actionColumn = {
5920
5921
  props: {
5921
5922
  label: "操作",
@@ -6676,7 +6677,6 @@
6676
6677
  setup(__props, { emit: __emit }) {
6677
6678
  const props = __props;
6678
6679
  const emit = __emit;
6679
- const isMagicAdmin = (0, _tmagic_design.isMagicAdminTheme)();
6680
6680
  const value = (0, vue.ref)();
6681
6681
  (0, vue.watch)(() => props.model[props.name], (v) => {
6682
6682
  value.value = v;
@@ -6696,7 +6696,7 @@
6696
6696
  modelValue: value.value,
6697
6697
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => value.value = $event),
6698
6698
  clearable: "",
6699
- "controls-position": (0, vue.unref)(isMagicAdmin) ? "" : "right",
6699
+ "controls-position": (0, vue.unref)(isGlobalFlat) ? "" : "right",
6700
6700
  size: __props.size,
6701
6701
  max: __props.config.max,
6702
6702
  min: __props.config.min,
@@ -7572,7 +7572,6 @@
7572
7572
  setup(__props, { emit: __emit }) {
7573
7573
  const props = __props;
7574
7574
  const emit = __emit;
7575
- const isMagicAdmin = (0, _tmagic_design.isMagicAdminTheme)(props);
7576
7575
  useAddField(props.prop);
7577
7576
  const formValue = (0, vue.ref)({});
7578
7577
  const editor = (0, vue.ref)();
@@ -7610,7 +7609,7 @@
7610
7609
  editor.value && (editor.value.dialogVisible = false);
7611
7610
  };
7612
7611
  return (_ctx, _cache) => {
7613
- return (0, vue.unref)(isMagicAdmin) && __props.config.href && !__props.disabled ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("a", {
7612
+ return (0, vue.unref)(isGlobalFlat) && __props.config.href && !__props.disabled ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("a", {
7614
7613
  key: 0,
7615
7614
  target: "_blank",
7616
7615
  href: href.value,
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.8.0-manmanyu.14",
2
+ "version": "1.8.0-manmanyu.15",
3
3
  "name": "@tmagic/form",
4
4
  "type": "module",
5
5
  "sideEffects": [
@@ -52,9 +52,9 @@
52
52
  "peerDependencies": {
53
53
  "vue": "^3.5.38",
54
54
  "typescript": "^6.0.3",
55
- "@tmagic/design": "1.8.0-manmanyu.14",
56
- "@tmagic/form-schema": "1.8.0-manmanyu.14",
57
- "@tmagic/utils": "1.8.0-manmanyu.14"
55
+ "@tmagic/utils": "1.8.0-manmanyu.15",
56
+ "@tmagic/form-schema": "1.8.0-manmanyu.15",
57
+ "@tmagic/design": "1.8.0-manmanyu.15"
58
58
  },
59
59
  "peerDependenciesMeta": {
60
60
  "typescript": {
@@ -2,10 +2,11 @@ import { computed, h, inject, type Ref } from 'vue';
2
2
  import { WarningFilled } from '@element-plus/icons-vue';
3
3
  import { cloneDeep } from 'lodash-es';
4
4
 
5
- import { isMagicAdminTheme, type TableColumnOptions, TMagicIcon, TMagicTooltip } from '@tmagic/design';
5
+ import { type TableColumnOptions, TMagicIcon, TMagicTooltip } from '@tmagic/design';
6
6
  import type { FormItemConfig, FormState, TableColumnConfig } from '@tmagic/form-schema';
7
7
 
8
8
  import type { ContainerChangeEventData } from '../../schema';
9
+ import { isGlobalFlat } from '../../utils/config';
9
10
  import { display as displayFunc, getDataByPage, sortArray } from '../../utils/form';
10
11
  import Container from '../Container.vue';
11
12
 
@@ -21,9 +22,6 @@ export const useTableColumns = (
21
22
  modelName: Ref<string | number>,
22
23
  ) => {
23
24
  const mForm = inject<FormState | undefined>('mForm');
24
- // magic-admin 主题下「操作列」默认固定在右侧;其它主题保持原默认「左侧」。
25
- // 调用方仍可通过 `config.fixed`('left' | 'right' | false)显式覆盖。
26
- const isMagicAdmin = isMagicAdminTheme();
27
25
 
28
26
  const display = (fuc: any) => displayFunc(mForm, fuc, props);
29
27
 
@@ -114,13 +112,13 @@ export const useTableColumns = (
114
112
  },
115
113
  });
116
114
  }
117
- const defaultFixed: 'left' | 'right' = isMagicAdmin.value ? 'right' : 'left';
115
+ const defaultFixed: 'left' | 'right' = isGlobalFlat.value ? 'right' : 'left';
118
116
  let actionFixed: 'left' | 'right' | undefined = props.config.fixed === false ? undefined : defaultFixed;
119
117
  if (typeof props.config.fixed === 'string' && ['left', 'right'].includes(props.config.fixed)) {
120
118
  actionFixed = props.config.fixed;
121
119
  }
122
120
 
123
- const actionFlat = props.config.flat === undefined && isMagicAdmin.value ? true : props.config.flat;
121
+ const actionFlat = props.config.flat === undefined && isGlobalFlat.value ? true : props.config.flat;
124
122
 
125
123
  const actionColumn = {
126
124
  props: {
@@ -2,7 +2,7 @@
2
2
  <a
3
3
  target="_blank"
4
4
  :href="href"
5
- v-if="isMagicAdmin && config.href && !disabled"
5
+ v-if="isGlobalFlat && config.href && !disabled"
6
6
  class="magic-admin-link"
7
7
  :style="config.css || {}"
8
8
  >
@@ -31,10 +31,11 @@
31
31
  import { computed, inject, readonly, ref } from 'vue';
32
32
  import { Notebook } from '@element-plus/icons-vue';
33
33
 
34
- import { isMagicAdminTheme, TMagicButton, TMagicIcon } from '@tmagic/design';
34
+ import { TMagicButton, TMagicIcon } from '@tmagic/design';
35
35
 
36
36
  import FormDialog from '../FormDialog.vue';
37
37
  import type { FieldProps, FormState, LinkConfig } from '../schema';
38
+ import { isGlobalFlat } from '../utils/config';
38
39
  import { useAddField } from '../utils/useAddField';
39
40
 
40
41
  defineOptions({
@@ -45,8 +46,6 @@ const props = defineProps<FieldProps<LinkConfig> & { theme?: string }>();
45
46
 
46
47
  const emit = defineEmits(['change']);
47
48
 
48
- const isMagicAdmin = isMagicAdminTheme(props);
49
-
50
49
  useAddField(props.prop);
51
50
 
52
51
  const formValue = ref({});
@@ -3,7 +3,7 @@
3
3
  v-if="model"
4
4
  v-model="value"
5
5
  clearable
6
- :controls-position="isMagicAdmin ? '' : 'right'"
6
+ :controls-position="isGlobalFlat ? '' : 'right'"
7
7
  :size="size"
8
8
  :max="config.max"
9
9
  :min="config.min"
@@ -18,9 +18,10 @@
18
18
  <script lang="ts" setup>
19
19
  import { inject, ref, watch } from 'vue';
20
20
 
21
- import { isMagicAdminTheme, TMagicInputNumber } from '@tmagic/design';
21
+ import { TMagicInputNumber } from '@tmagic/design';
22
22
 
23
23
  import type { FieldProps, FormState, NumberConfig } from '../schema';
24
+ import { isGlobalFlat } from '../utils/config';
24
25
  import { useAddField } from '../utils/useAddField';
25
26
 
26
27
  defineOptions({
@@ -34,9 +35,6 @@ const emit = defineEmits<{
34
35
  input: [values: number];
35
36
  }>();
36
37
 
37
- // magic-admin 主题下输入框走"无右侧上下箭头"的极简样式(控件位置置空回到 ElInputNumber 默认两侧布局)
38
- const isMagicAdmin = isMagicAdminTheme();
39
-
40
38
  const value = ref<number>();
41
39
 
42
40
  watch(
package/src/plugin.ts CHANGED
@@ -54,6 +54,7 @@ import FormDrawer from './FormDrawer.vue';
54
54
  import './theme/index.scss';
55
55
 
56
56
  export interface FormInstallOptions {
57
+ flat?: boolean;
57
58
  [key: string]: any;
58
59
  }
59
60
 
@@ -17,11 +17,17 @@
17
17
  */
18
18
 
19
19
  import type { Component } from 'vue';
20
+ import { ref } from 'vue';
20
21
 
21
22
  let $MAGIC_FORM = {} as any;
23
+ // 用 ref 持有 flat 全局开关:const 引用本身不可变,符合 `import/no-mutable-exports`;
24
+ // 通过 `.value` 改值仍保持模块级响应式语义,与 editor/plugin.ts、design/index.ts 里
25
+ // 的同名变量写法对齐。
26
+ const isGlobalFlat = ref(false);
22
27
 
23
28
  const setConfig = (option: any): void => {
24
29
  $MAGIC_FORM = option;
30
+ isGlobalFlat.value = option.flat ?? false;
25
31
  };
26
32
 
27
33
  const getConfig = <T = unknown>(key: string): T => $MAGIC_FORM[key];
@@ -39,4 +45,4 @@ const getField = (tagName: string): Component | undefined => fieldRegistry.get(t
39
45
 
40
46
  const deleteField = (tagName: string): boolean => fieldRegistry.delete(tagName);
41
47
 
42
- export { deleteField, getConfig, getField, registerField, setConfig };
48
+ export { deleteField, getConfig, getField, isGlobalFlat, registerField, setConfig };
package/types/index.d.ts CHANGED
@@ -2022,6 +2022,7 @@ declare const deleteField: (tagName: string) => boolean;
2022
2022
  //#endregion
2023
2023
  //#region temp/packages/form/src/plugin.d.ts
2024
2024
  interface FormInstallOptions {
2025
+ flat?: boolean;
2025
2026
  [key: string]: any;
2026
2027
  }
2027
2028
  declare const _default$31: {