@tmagic/form 1.3.0-alpha.7 → 1.3.0-alpha.9

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/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.3.0-alpha.7",
2
+ "version": "1.3.0-alpha.9",
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.3.0-alpha.7",
40
- "@tmagic/utils": "1.3.0-alpha.7",
39
+ "@tmagic/design": "1.3.0-alpha.9",
40
+ "@tmagic/utils": "1.3.0-alpha.9",
41
41
  "lodash-es": "^4.17.21",
42
42
  "sortablejs": "^1.14.0",
43
43
  "vue": "^3.3.4"
@@ -82,13 +82,17 @@ const equalValue = (value: any, v: any): boolean => {
82
82
  };
83
83
 
84
84
  const mapOptions = (data: any[]) => {
85
- const { option } = props.config;
86
- const { text } = option;
87
- const { value } = option;
85
+ const {
86
+ option = {
87
+ text: 'text',
88
+ value: 'value',
89
+ },
90
+ } = props.config;
91
+ const { text = 'text', value = 'value' } = option;
88
92
 
89
93
  return data.map((item) => ({
90
- text: typeof text === 'function' ? text(item) : item[text || 'text'],
91
- value: typeof value === 'function' ? value(item) : item[value || 'value'],
94
+ text: typeof text === 'function' ? text(item) : item[text],
95
+ value: typeof value === 'function' ? value(item) : item[value],
92
96
  }));
93
97
  };
94
98
 
@@ -103,8 +107,10 @@ const getOptions = async () => {
103
107
 
104
108
  let items: SelectOption[] | SelectGroupOption[] = [];
105
109
 
106
- const { config } = props;
107
- const { option } = config;
110
+ const { option } = props.config;
111
+
112
+ if (!option) return [];
113
+
108
114
  const { root = '', totalKey = 'total' } = option;
109
115
  let { body = {}, url } = option;
110
116
 
@@ -224,8 +230,10 @@ const getInitLocalOption = async () => {
224
230
  const getInitOption = async () => {
225
231
  if (!props.model) return [];
226
232
 
227
- const { config } = props;
228
- const { option } = config;
233
+ const { option } = props.config;
234
+
235
+ if (!option) return [];
236
+
229
237
  const { root = '', initRoot = '' } = option;
230
238
  let { initBody = {} } = option;
231
239
 
package/src/schema.ts CHANGED
@@ -435,9 +435,9 @@ export interface SelectConfig extends FormItem, Input {
435
435
  allowCreate?: boolean;
436
436
  filterable?: boolean;
437
437
  group?: boolean;
438
- options: SelectConfigOption[] | SelectConfigGroupOption[] | SelectOptionFunction;
439
- remote: true;
440
- option: {
438
+ options?: SelectConfigOption[] | SelectConfigGroupOption[] | SelectOptionFunction;
439
+ remote?: true;
440
+ option?: {
441
441
  url: string | ((mForm: FormState | undefined, data: { model: any; formValue: any }) => string);
442
442
  initUrl?: string | ((mForm: FormState | undefined, data: { model: any; formValue: any }) => string);
443
443
  method?: 'jsonp' | string;
package/types/schema.d.ts CHANGED
@@ -347,9 +347,9 @@ export interface SelectConfig extends FormItem, Input {
347
347
  allowCreate?: boolean;
348
348
  filterable?: boolean;
349
349
  group?: boolean;
350
- options: SelectConfigOption[] | SelectConfigGroupOption[] | SelectOptionFunction;
351
- remote: true;
352
- option: {
350
+ options?: SelectConfigOption[] | SelectConfigGroupOption[] | SelectOptionFunction;
351
+ remote?: true;
352
+ option?: {
353
353
  url: string | ((mForm: FormState | undefined, data: {
354
354
  model: any;
355
355
  formValue: any;