@tmagic/form 1.2.13 → 1.2.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.
Files changed (45) hide show
  1. package/dist/style.css +2 -2
  2. package/dist/tmagic-form.js +103 -108
  3. package/dist/tmagic-form.js.map +1 -1
  4. package/dist/tmagic-form.umd.cjs +103 -113
  5. package/dist/tmagic-form.umd.cjs.map +1 -1
  6. package/package.json +7 -7
  7. package/src/containers/Fieldset.vue +2 -9
  8. package/src/containers/Table.vue +1 -1
  9. package/src/containers/Tabs.vue +65 -60
  10. package/src/fields/Select.vue +2 -2
  11. package/src/fields/Text.vue +3 -3
  12. package/src/schema.ts +1 -0
  13. package/types/Form.vue.d.ts +5 -5
  14. package/types/FormDialog.vue.d.ts +41 -743
  15. package/types/containers/Col.vue.d.ts +2 -2
  16. package/types/containers/Container.vue.d.ts +3 -3
  17. package/types/containers/Fieldset.vue.d.ts +3 -3
  18. package/types/containers/GroupList.vue.d.ts +2 -2
  19. package/types/containers/GroupListItem.vue.d.ts +2 -2
  20. package/types/containers/Panel.vue.d.ts +22 -90
  21. package/types/containers/Row.vue.d.ts +2 -2
  22. package/types/containers/Step.vue.d.ts +3 -3
  23. package/types/containers/Table.vue.d.ts +42 -155
  24. package/types/containers/Tabs.vue.d.ts +3 -3
  25. package/types/fields/Cascader.vue.d.ts +4 -4
  26. package/types/fields/Checkbox.vue.d.ts +4 -4
  27. package/types/fields/CheckboxGroup.vue.d.ts +4 -4
  28. package/types/fields/ColorPicker.vue.d.ts +4 -4
  29. package/types/fields/Date.vue.d.ts +4 -4
  30. package/types/fields/DateTime.vue.d.ts +4 -4
  31. package/types/fields/Daterange.vue.d.ts +4 -4
  32. package/types/fields/Display.vue.d.ts +2 -2
  33. package/types/fields/DynamicField.vue.d.ts +4 -4
  34. package/types/fields/Hidden.vue.d.ts +2 -2
  35. package/types/fields/Link.vue.d.ts +4 -4
  36. package/types/fields/Number.vue.d.ts +4 -4
  37. package/types/fields/RadioGroup.vue.d.ts +4 -4
  38. package/types/fields/Select.vue.d.ts +4 -4
  39. package/types/fields/SelectOptionGroups.vue.d.ts +2 -2
  40. package/types/fields/SelectOptions.vue.d.ts +2 -2
  41. package/types/fields/Switch.vue.d.ts +4 -4
  42. package/types/fields/Text.vue.d.ts +4 -4
  43. package/types/fields/Textarea.vue.d.ts +4 -4
  44. package/types/fields/Time.vue.d.ts +4 -4
  45. package/types/schema.d.ts +15 -14
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.2.13",
2
+ "version": "1.2.15",
3
3
  "name": "@tmagic/form",
4
4
  "type": "module",
5
5
  "sideEffects": [
@@ -36,8 +36,8 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@element-plus/icons-vue": "^2.0.9",
39
- "@tmagic/design": "1.2.13",
40
- "@tmagic/utils": "1.2.13",
39
+ "@tmagic/design": "1.2.15",
40
+ "@tmagic/utils": "1.2.15",
41
41
  "lodash-es": "^4.17.21",
42
42
  "sortablejs": "^1.14.0",
43
43
  "vue": "^3.2.37"
@@ -50,14 +50,14 @@
50
50
  "@types/lodash-es": "^4.17.4",
51
51
  "@types/node": "^15.12.4",
52
52
  "@types/sortablejs": "^1.10.7",
53
- "@vitejs/plugin-vue": "^3.1.0",
53
+ "@vitejs/plugin-vue": "^4.1.0",
54
54
  "@vue/compiler-sfc": "^3.2.37",
55
55
  "@vue/test-utils": "^2.0.0",
56
56
  "rimraf": "^3.0.2",
57
57
  "sass": "^1.35.1",
58
- "typescript": "^4.7.4",
59
- "vite": "^3.1.3",
58
+ "typescript": "^5.0.4",
59
+ "vite": "^4.2.1",
60
60
  "vite-plugin-vue-setup-extend": "^0.4.0",
61
- "vue-tsc": "^1.0.11"
61
+ "vue-tsc": "^1.2.0"
62
62
  }
63
63
  }
@@ -10,6 +10,7 @@
10
10
  :prop="`${prop}${prop ? '.' : ''}${config.name}.value`"
11
11
  :true-label="1"
12
12
  :false-label="0"
13
+ @update:modelValue="change"
13
14
  ><span v-html="config.legend"></span><span v-if="config.extra" v-html="config.extra" class="m-form-tip"></span
14
15
  ></TMagicCheckbox>
15
16
  </component>
@@ -61,7 +62,7 @@
61
62
  </template>
62
63
 
63
64
  <script lang="ts" setup name="MFormFieldset">
64
- import { computed, inject, watch } from 'vue';
65
+ import { computed, inject } from 'vue';
65
66
 
66
67
  import { TMagicCheckbox } from '@tmagic/design';
67
68
 
@@ -115,13 +116,5 @@ const change = () => {
115
116
 
116
117
  const key = (item: any, index: number) => item[mForm?.keyProp || '__key'] ?? index;
117
118
 
118
- if (props.config.checkbox && name.value) {
119
- watch(
120
- () => props.model[name.value]?.value,
121
- () => {
122
- emit('change', props.model);
123
- },
124
- );
125
- }
126
119
  const onAddDiffCount = () => emit('addDiffCount');
127
120
  </script>
@@ -534,7 +534,7 @@ const clearHandler = () => {
534
534
  };
535
535
 
536
536
  const excelHandler = (file: any) => {
537
- if (!file || !file.raw) {
537
+ if (!file?.raw) {
538
538
  return false;
539
539
  }
540
540
  const reader = new FileReader();
@@ -1,71 +1,77 @@
1
1
  <template>
2
- <TMagicTabs
2
+ <component
3
3
  v-model="activeTabName"
4
- :class="config.dynamic ? 'magic-form-dynamic-tab' : 'magic-form-tab'"
5
- :type="config.tabType"
6
- :editable="config.editable || false"
7
- :tab-position="config.tabPosition || 'top'"
4
+ v-bind="
5
+ tabsComponent.props({
6
+ type: config.tabType,
7
+ editable: config.editable || false,
8
+ tabPosition: config.tabPosition || 'top',
9
+ })
10
+ "
11
+ :is="tabsComponent.component"
12
+ :class="`tmagic-design-tabs ${config.dynamic ? 'magic-form-dynamic-tab' : 'magic-form-tab'}`"
8
13
  @tab-click="tabClickHandler"
9
14
  @tab-add="onTabAdd"
10
15
  @tab-remove="onTabRemove"
11
16
  >
12
- <template v-for="(tab, tabIndex) in tabs">
13
- <component
14
- v-if="display(tab.display) && tabItems(tab).length"
15
- :is="uiComponent.component"
16
- :key="tab[mForm?.keyProp || '__key'] ?? tabIndex"
17
- :name="filter(tab.status) || tabIndex.toString()"
18
- :lazy="tab.lazy || false"
19
- >
20
- <template #label>
21
- <span>
22
- {{ filter(tab.title)
23
- }}<el-badge :hidden="!diffCount[tabIndex]" :value="diffCount[tabIndex]" class="diff-count-badge"></el-badge>
24
- </span>
25
- </template>
26
- <Container
27
- v-for="item in tabItems(tab)"
28
- :key="item[mForm?.keyProp || '__key']"
29
- :config="item"
30
- :disabled="disabled"
31
- :model="
32
- config.dynamic
33
- ? (name ? model[name] : model)[tabIndex]
34
- : tab.name
35
- ? (name ? model[name] : model)[tab.name]
36
- : name
37
- ? model[name]
38
- : model
39
- "
40
- :last-values="
41
- isEmpty(lastValues)
42
- ? {}
43
- : config.dynamic
44
- ? (name ? lastValues[name] : lastValues)[tabIndex]
45
- : tab.name
46
- ? (name ? lastValues[name] : lastValues)[tab.name]
47
- : name
48
- ? lastValues[name]
49
- : lastValues
50
- "
51
- :is-compare="isCompare"
52
- :prop="config.dynamic ? `${prop}${prop ? '.' : ''}${String(tabIndex)}` : prop"
53
- :size="size"
54
- :label-width="tab.labelWidth || labelWidth"
55
- :expand-more="expandMore"
56
- @change="changeHandler"
57
- @addDiffCount="onAddDiffCount(tabIndex)"
58
- ></Container>
59
- </component>
60
- </template>
61
- </TMagicTabs>
17
+ <component
18
+ v-for="(tab, tabIndex) in tabs"
19
+ :is="tabPaneComponent.component"
20
+ :key="tab[mForm?.keyProp || '__key'] ?? tabIndex"
21
+ v-bind="tabPaneComponent.props({ name: filter(tab.status) || tabIndex.toString(), lazy: tab.lazy || false })"
22
+ >
23
+ <template #label>
24
+ <span>
25
+ {{ filter(tab.title)
26
+ }}<TMagicBadge
27
+ :hidden="!diffCount[tabIndex]"
28
+ :value="diffCount[tabIndex]"
29
+ class="diff-count-badge"
30
+ ></TMagicBadge>
31
+ </span>
32
+ </template>
33
+ <Container
34
+ v-for="item in tabItems(tab)"
35
+ :key="item[mForm?.keyProp || '__key']"
36
+ :config="item"
37
+ :disabled="disabled"
38
+ :model="
39
+ config.dynamic
40
+ ? (name ? model[name] : model)[tabIndex]
41
+ : tab.name
42
+ ? (name ? model[name] : model)[tab.name]
43
+ : name
44
+ ? model[name]
45
+ : model
46
+ "
47
+ :last-values="
48
+ isEmpty(lastValues)
49
+ ? {}
50
+ : config.dynamic
51
+ ? (name ? lastValues[name] : lastValues)[tabIndex]
52
+ : tab.name
53
+ ? (name ? lastValues[name] : lastValues)[tab.name]
54
+ : name
55
+ ? lastValues[name]
56
+ : lastValues
57
+ "
58
+ :is-compare="isCompare"
59
+ :prop="config.dynamic ? `${prop}${prop ? '.' : ''}${String(tabIndex)}` : prop"
60
+ :size="size"
61
+ :label-width="tab.labelWidth || labelWidth"
62
+ :expand-more="expandMore"
63
+ @change="changeHandler"
64
+ @addDiffCount="onAddDiffCount(tabIndex)"
65
+ ></Container>
66
+ </component>
67
+ </component>
62
68
  </template>
63
69
 
64
70
  <script setup lang="ts" name="MFormTabs">
65
71
  import { computed, inject, ref, watchEffect } from 'vue';
66
72
  import { cloneDeep, isEmpty } from 'lodash-es';
67
73
 
68
- import { getConfig, TMagicTabs } from '@tmagic/design';
74
+ import { getConfig, TMagicBadge } from '@tmagic/design';
69
75
 
70
76
  import { FormState, TabConfig, TabPaneConfig } from '../schema';
71
77
  import { display as displayFunc, filterFunction } from '../utils/form';
@@ -76,7 +82,8 @@ type DiffCount = {
76
82
  [tabIndex: number]: number;
77
83
  };
78
84
 
79
- const uiComponent = getConfig('components').tabPane;
85
+ const tabPaneComponent = getConfig('components').tabPane;
86
+ const tabsComponent = getConfig('components').tabs;
80
87
 
81
88
  const getActive = (mForm: FormState | undefined, props: any, activeTabName: string) => {
82
89
  const { config, model, prop } = props;
@@ -135,7 +142,7 @@ const tabs = computed(() => {
135
142
  if (!props.config.name) throw new Error('dynamic tab 必须配置name');
136
143
  return props.model[props.config.name] || [];
137
144
  }
138
- return props.config.items;
145
+ return props.config.items.filter((item) => displayFunc(mForm, item.display, props));
139
146
  });
140
147
 
141
148
  const filter = (config: any) => filterFunction(mForm, config, props);
@@ -193,8 +200,6 @@ const onTabRemove = (tabName: string) => {
193
200
  mForm?.$emit('field-change', props.prop, props.model[props.config.name]);
194
201
  };
195
202
 
196
- const display = (displayConfig: any) => displayFunc(mForm, displayConfig, props);
197
-
198
203
  const changeHandler = () => {
199
204
  emit('change', props.model);
200
205
  if (typeof props.config.onChange === 'function') {
@@ -5,8 +5,8 @@
5
5
  v-loading="loading"
6
6
  class="m-select"
7
7
  ref="tMagicSelect"
8
- clearable
9
- filterable
8
+ :clearable="typeof config.clearable !== 'undefined' ? config.clearable : true"
9
+ :filterable="typeof config.filterable !== 'undefined' ? config.filterable : true"
10
10
  :popper-class="`m-select-popper ${popperClass}`"
11
11
  :size="size"
12
12
  :remote="remote"
@@ -11,14 +11,14 @@
11
11
  >
12
12
  <template #append v-if="config.append">
13
13
  <span v-if="typeof config.append === 'string'">{{ config.append }}</span>
14
- <el-button
14
+ <TMagicButton
15
15
  v-if="typeof config.append === 'object' && config.append.type === 'button'"
16
16
  style="color: #409eff"
17
17
  :size="size"
18
18
  @click.prevent="buttonClickHandler"
19
19
  >
20
20
  {{ config.append.text }}
21
- </el-button>
21
+ </TMagicButton>
22
22
  </template>
23
23
  </TMagicInput>
24
24
  </template>
@@ -26,7 +26,7 @@
26
26
  <script lang="ts" setup name="MFormText">
27
27
  import { inject } from 'vue';
28
28
 
29
- import { TMagicInput } from '@tmagic/design';
29
+ import { TMagicButton, TMagicInput } from '@tmagic/design';
30
30
  import { isNumber } from '@tmagic/utils';
31
31
 
32
32
  import { FormState, TextConfig } from '../schema';
package/src/schema.ts CHANGED
@@ -432,6 +432,7 @@ export interface SelectConfig extends FormItem, Input {
432
432
  multiple?: boolean;
433
433
  valueKey?: string;
434
434
  allowCreate?: boolean;
435
+ filterable?: boolean;
435
436
  group?: boolean;
436
437
  options: SelectConfigOption[] | SelectConfigGroupOption[] | SelectOptionFunction;
437
438
  remote: true;
@@ -13,7 +13,7 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
13
13
  disabled?: boolean | undefined;
14
14
  height?: string | undefined;
15
15
  stepActive?: string | number | undefined;
16
- size?: "small" | "default" | "large" | undefined;
16
+ size?: "default" | "small" | "large" | undefined;
17
17
  inline?: boolean | undefined;
18
18
  labelPosition?: string | undefined;
19
19
  keyProp?: string | undefined;
@@ -53,7 +53,7 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
53
53
  disabled?: boolean | undefined;
54
54
  height?: string | undefined;
55
55
  stepActive?: string | number | undefined;
56
- size?: "small" | "default" | "large" | undefined;
56
+ size?: "default" | "small" | "large" | undefined;
57
57
  inline?: boolean | undefined;
58
58
  labelPosition?: string | undefined;
59
59
  keyProp?: string | undefined;
@@ -90,8 +90,8 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
90
90
  labelPosition: string;
91
91
  }>;
92
92
  export default _default;
93
- declare type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
94
- declare type __VLS_TypePropsToRuntimeProps<T> = {
93
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
94
+ type __VLS_TypePropsToRuntimeProps<T> = {
95
95
  [K in keyof T]-?: {} extends Pick<T, K> ? {
96
96
  type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
97
97
  } : {
@@ -99,7 +99,7 @@ declare type __VLS_TypePropsToRuntimeProps<T> = {
99
99
  required: true;
100
100
  };
101
101
  };
102
- declare type __VLS_WithDefaults<P, D> = {
102
+ type __VLS_WithDefaults<P, D> = {
103
103
  [K in keyof Pick<P, keyof P>]: K extends keyof D ? P[K] & {
104
104
  default: D[K];
105
105
  } : P[K];