@sheinx/hooks 3.8.0-beta.32 → 3.8.0-beta.34

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 +1 @@
1
- {"version":3,"file":"use-check.d.ts","sourceRoot":"","sources":["use-check.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI5D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,QAAA,MAAM,QAAQ,UAAW,cAAc;;;;;qBAuDpB,gBAAgB,CAAC,gBAAgB,CAAC;0BArBT,MAAM,WAAW,CAAC,gBAAgB,CAAC;;;;;;;;;;;yBAnBa,gBAAgB;;;;CAiE3G,CAAC;AAEF,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"use-check.d.ts","sourceRoot":"","sources":["use-check.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI5D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,QAAA,MAAM,QAAQ,UAAW,cAAc;;;;;qBAgEpB,gBAAgB,CAAC,gBAAgB,CAAC;0BArBT,MAAM,WAAW,CAAC,gBAAgB,CAAC;;;;;;;;;;;yBA5Ba,gBAAgB;;;;CA0E3G,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -46,11 +46,19 @@ var useCheck = function useCheck(props) {
46
46
  var handleInputRef = (0, _useForkRef.default)(inputRef, inputRefPo);
47
47
  var handleClick = function handleClick(otherHandlers, needStopPropagation) {
48
48
  return function (event) {
49
- var _inputRef$current, _otherHandlers$onClic;
49
+ var _otherHandlers$onClic;
50
50
  if (needStopPropagation) {
51
51
  event.stopPropagation();
52
52
  }
53
- (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 || _inputRef$current.click();
53
+
54
+ // 检查是否被 label 元素包裹,如果是则不需要手动触发 input.click()
55
+ // 因为 label 会自动将点击事件传递给内部的 input 元素
56
+ var target = event.currentTarget;
57
+ var isInsideLabel = target.closest('label') !== null;
58
+ if (!isInsideLabel) {
59
+ var _inputRef$current;
60
+ (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 || _inputRef$current.click();
61
+ }
54
62
  otherHandlers === null || otherHandlers === void 0 || (_otherHandlers$onClic = otherHandlers.onClick) === null || _otherHandlers$onClic === void 0 || _otherHandlers$onClic.call(otherHandlers, event);
55
63
  };
56
64
  };
@@ -5,7 +5,8 @@ interface SchemaMeta {
5
5
  format?: string;
6
6
  items?: any;
7
7
  enum?: any[] | {
8
- anyOf: any[];
8
+ anyOf?: any[];
9
+ oneOf?: any[];
9
10
  };
10
11
  description?: string;
11
12
  [key: string]: any;
@@ -1 +1 @@
1
- {"version":3,"file":"form-schema-builder.d.ts","sourceRoot":"","sources":["form-schema-builder.ts"],"names":[],"mappings":"AAAA,UAAU,UAAU;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,IAAI,CAAC,EAAE,GAAG,EAAE,GAAG;QAAE,KAAK,EAAE,GAAG,EAAE,CAAA;KAAE,CAAC;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC5C,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAA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E,MAAM,CAAC;QACf,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GAAG,UAAU;IAmLd,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI;IAuCzC,WAAW,CAAC,aAAa,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,UAAU,GAAG,IAAI;IAkB1F,kBAAkB,CAAC,aAAa,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,UAAU,GAAG,IAAI;IAatG,oBAAoB,CAAC,aAAa,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,UAAU,GAAG,IAAI;IA0B9H,cAAc,CAAC,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,GAAG,IAAI;IAwB7F,aAAa,IAAI,cAAc;CAGhC"}
@@ -74,6 +74,7 @@ var SchemaBuilder = exports.SchemaBuilder = /*#__PURE__*/function () {
74
74
  var itemType;
75
75
  if (typeof componentElement.type === 'function') {
76
76
  var componentName = componentElement.type.displayName || componentElement.type.name;
77
+ var format = componentElement.props.format || componentElement.props.keygen;
77
78
  switch (componentName) {
78
79
  case 'ShineoutInput':
79
80
  case 'ShineoutEditableArea':
@@ -88,10 +89,10 @@ var SchemaBuilder = exports.SchemaBuilder = /*#__PURE__*/function () {
88
89
  case 'ShineoutTextarea':
89
90
  fieldSchemaInfo.type = 'string';
90
91
  break;
92
+ case 'ShineoutCascader':
91
93
  case 'ShineoutSelect':
92
94
  case 'ShineoutTreeSelect':
93
95
  {
94
- var format = componentElement.props.format || componentElement.props.keygen;
95
96
  if (typeof componentElement.props.keygen !== 'boolean') {
96
97
  if (typeof format === 'string') {
97
98
  var _data$;
@@ -112,31 +113,28 @@ var SchemaBuilder = exports.SchemaBuilder = /*#__PURE__*/function () {
112
113
  } else {
113
114
  fieldSchemaInfo.type = itemType;
114
115
  }
115
- // props.data格式: [
116
- // { "value": 1, "title": "年假" },
117
- // { "value": 2, "title": "调休" },
118
- // { "value": 3, "title": "事假" },
119
- // { "value": 4, "title": "病假" },
120
- // { "value": 5, "title": "其他" }
121
- // ]
122
- // 转换为jsonschema中的enum格式:
123
- // "enum": {
124
- // "anyOf": [
125
- // { "const": 1, "title": "年假" },
126
- // { "const": 2, "title": "调休" },
127
- // { "const": 3, "title": "事假" },
128
- // { "const": 4, "title": "病假" },
129
- // { "const": 5, "title": "其他" }
130
- // ]
131
- // }
132
- fieldSchemaInfo.enum = {
133
- anyOf: componentElement.props.data.map(function (item) {
134
- return {
135
- const: (item === null || item === void 0 ? void 0 : item[format]) || item,
136
- title: (item === null || item === void 0 ? void 0 : item.title) || item
137
- };
138
- })
139
- };
116
+ if (itemType === 'object') {
117
+ // 对于对象类型,使用 oneOf 而不是 enum
118
+ if (componentElement.props.multiple) {
119
+ fieldSchemaInfo.items.oneOf = componentElement.props.data.map(function (item) {
120
+ return {
121
+ const: item,
122
+ title: (item === null || item === void 0 ? void 0 : item.title) || JSON.stringify(item)
123
+ };
124
+ });
125
+ } else {
126
+ fieldSchemaInfo.oneOf = componentElement.props.data.map(function (item) {
127
+ return {
128
+ const: item,
129
+ title: (item === null || item === void 0 ? void 0 : item.title) || JSON.stringify(item)
130
+ };
131
+ });
132
+ }
133
+ } else {
134
+ fieldSchemaInfo.enum = componentElement.props.data.map(function (item) {
135
+ return (item === null || item === void 0 ? void 0 : item[format]) || item;
136
+ });
137
+ }
140
138
  break;
141
139
  }
142
140
  case 'ShineoutDatePicker':
@@ -159,15 +157,71 @@ var SchemaBuilder = exports.SchemaBuilder = /*#__PURE__*/function () {
159
157
  break;
160
158
  case 'ShineoutCheckbox':
161
159
  case 'ShineoutCheckboxGroup':
162
- fieldSchemaInfo.type = 'array';
163
- fieldSchemaInfo.items = {
164
- type: 'string'
165
- };
166
- break;
160
+ {
161
+ if (typeof componentElement.props.keygen !== 'boolean') {
162
+ if (typeof format === 'string') {
163
+ var _data$2;
164
+ itemType = _typeof(data === null || data === void 0 ? void 0 : data[0]) === 'object' ? _typeof(data === null || data === void 0 || (_data$2 = data[0]) === null || _data$2 === void 0 ? void 0 : _data$2[format]) : _typeof(data === null || data === void 0 ? void 0 : data[0]);
165
+ } else if (typeof format === 'function') {
166
+ itemType = _typeof(format(data === null || data === void 0 ? void 0 : data[0]));
167
+ } else {
168
+ itemType = _typeof(data === null || data === void 0 ? void 0 : data[0]);
169
+ }
170
+ } else {
171
+ itemType = _typeof(data === null || data === void 0 ? void 0 : data[0]);
172
+ }
173
+ fieldSchemaInfo.type = 'array';
174
+ fieldSchemaInfo.items = {
175
+ type: itemType
176
+ };
177
+
178
+ // ShineoutCheckboxGroup 有 data 时(多选的)
179
+ if (itemType === 'object') {
180
+ fieldSchemaInfo.items.oneOf = componentElement.props.data.map(function (item) {
181
+ return {
182
+ const: item,
183
+ title: (item === null || item === void 0 ? void 0 : item.title) || JSON.stringify(item)
184
+ };
185
+ });
186
+ } else {
187
+ fieldSchemaInfo.items.enum = componentElement.props.data.map(function (item) {
188
+ return (item === null || item === void 0 ? void 0 : item[format]) || item;
189
+ });
190
+ }
191
+ break;
192
+ }
167
193
  case 'ShineoutRadio':
168
194
  case 'ShineoutRadioGroup':
169
- fieldSchemaInfo.type = 'string';
170
- break;
195
+ {
196
+ if (typeof componentElement.props.keygen !== 'boolean') {
197
+ if (typeof format === 'string') {
198
+ var _data$3;
199
+ itemType = _typeof(data === null || data === void 0 ? void 0 : data[0]) === 'object' ? _typeof(data === null || data === void 0 || (_data$3 = data[0]) === null || _data$3 === void 0 ? void 0 : _data$3[format]) : _typeof(data === null || data === void 0 ? void 0 : data[0]);
200
+ } else if (typeof format === 'function') {
201
+ itemType = _typeof(format(data === null || data === void 0 ? void 0 : data[0]));
202
+ } else {
203
+ itemType = _typeof(data === null || data === void 0 ? void 0 : data[0]);
204
+ }
205
+ } else {
206
+ itemType = _typeof(data === null || data === void 0 ? void 0 : data[0]);
207
+ }
208
+ fieldSchemaInfo.type = itemType;
209
+
210
+ // ShineoutRadioGroup 有 data 时(单选的)
211
+ if (itemType === 'object') {
212
+ fieldSchemaInfo.oneOf = componentElement.props.data.map(function (item) {
213
+ return {
214
+ const: item,
215
+ title: (item === null || item === void 0 ? void 0 : item.title) || JSON.stringify(item)
216
+ };
217
+ });
218
+ } else {
219
+ fieldSchemaInfo.enum = componentElement.props.data.map(function (item) {
220
+ return (item === null || item === void 0 ? void 0 : item[format]) || item;
221
+ });
222
+ }
223
+ break;
224
+ }
171
225
  case 'ShineoutSwitch':
172
226
  fieldSchemaInfo.type = 'boolean';
173
227
  break;
@@ -1 +1 @@
1
- {"version":3,"file":"use-check.d.ts","sourceRoot":"","sources":["use-check.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI5D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,QAAA,MAAM,QAAQ,UAAW,cAAc;;;;;qBAuDpB,gBAAgB,CAAC,gBAAgB,CAAC;0BArBT,MAAM,WAAW,CAAC,gBAAgB,CAAC;;;;;;;;;;;yBAnBa,gBAAgB;;;;CAiE3G,CAAC;AAEF,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"use-check.d.ts","sourceRoot":"","sources":["use-check.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI5D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,QAAA,MAAM,QAAQ,UAAW,cAAc;;;;;qBAgEpB,gBAAgB,CAAC,gBAAgB,CAAC;0BArBT,MAAM,WAAW,CAAC,gBAAgB,CAAC;;;;;;;;;;;yBA5Ba,gBAAgB;;;;CA0E3G,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -40,11 +40,19 @@ var useCheck = function useCheck(props) {
40
40
  var handleInputRef = useForkRef(inputRef, inputRefPo);
41
41
  var handleClick = function handleClick(otherHandlers, needStopPropagation) {
42
42
  return function (event) {
43
- var _inputRef$current, _otherHandlers$onClic;
43
+ var _otherHandlers$onClic;
44
44
  if (needStopPropagation) {
45
45
  event.stopPropagation();
46
46
  }
47
- (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 || _inputRef$current.click();
47
+
48
+ // 检查是否被 label 元素包裹,如果是则不需要手动触发 input.click()
49
+ // 因为 label 会自动将点击事件传递给内部的 input 元素
50
+ var target = event.currentTarget;
51
+ var isInsideLabel = target.closest('label') !== null;
52
+ if (!isInsideLabel) {
53
+ var _inputRef$current;
54
+ (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 || _inputRef$current.click();
55
+ }
48
56
  otherHandlers === null || otherHandlers === void 0 || (_otherHandlers$onClic = otherHandlers.onClick) === null || _otherHandlers$onClic === void 0 || _otherHandlers$onClic.call(otherHandlers, event);
49
57
  };
50
58
  };
@@ -5,7 +5,8 @@ interface SchemaMeta {
5
5
  format?: string;
6
6
  items?: any;
7
7
  enum?: any[] | {
8
- anyOf: any[];
8
+ anyOf?: any[];
9
+ oneOf?: any[];
9
10
  };
10
11
  description?: string;
11
12
  [key: string]: any;
@@ -1 +1 @@
1
- {"version":3,"file":"form-schema-builder.d.ts","sourceRoot":"","sources":["form-schema-builder.ts"],"names":[],"mappings":"AAAA,UAAU,UAAU;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,IAAI,CAAC,EAAE,GAAG,EAAE,GAAG;QAA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Aa;IACxB,OAAO,CAAC,MAAM,CAAiB;gBACnB,QAAQ,EAAE,MAAM;IAQ5B,YAAY,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,UAAU,CAAA;KAAE,GAAG,IAAI;IAMtE;;OAEG;IACH,wBAAwB,CAAC,MAAM,EAAE;QAC/B,gBAAgB,EAAE,GAAG,CAAC;QACtB,KAAK,CAAC,EAAE,GAAG,EAAE,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GAAG,UAAU;IAmLd,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI;IAuCzC,WAAW,CAAC,aAAa,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,UAAU,GAAG,IAAI;IAkB1F,kBAAkB,CAAC,aAAa,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,UAAU,GAAG,IAAI;IAatG,oBAAoB,CAAC,aAAa,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,UAAU,GAAG,IAAI;IA0B9H,cAAc,CAAC,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,GAAG,IAAI;IAwB7F,aAAa,IAAI,cAAc;CAGhC"}
@@ -68,6 +68,7 @@ export var SchemaBuilder = /*#__PURE__*/function () {
68
68
  var itemType;
69
69
  if (typeof componentElement.type === 'function') {
70
70
  var componentName = componentElement.type.displayName || componentElement.type.name;
71
+ var format = componentElement.props.format || componentElement.props.keygen;
71
72
  switch (componentName) {
72
73
  case 'ShineoutInput':
73
74
  case 'ShineoutEditableArea':
@@ -82,10 +83,10 @@ export var SchemaBuilder = /*#__PURE__*/function () {
82
83
  case 'ShineoutTextarea':
83
84
  fieldSchemaInfo.type = 'string';
84
85
  break;
86
+ case 'ShineoutCascader':
85
87
  case 'ShineoutSelect':
86
88
  case 'ShineoutTreeSelect':
87
89
  {
88
- var format = componentElement.props.format || componentElement.props.keygen;
89
90
  if (typeof componentElement.props.keygen !== 'boolean') {
90
91
  if (typeof format === 'string') {
91
92
  var _data$;
@@ -106,31 +107,28 @@ export var SchemaBuilder = /*#__PURE__*/function () {
106
107
  } else {
107
108
  fieldSchemaInfo.type = itemType;
108
109
  }
109
- // props.data格式: [
110
- // { "value": 1, "title": "年假" },
111
- // { "value": 2, "title": "调休" },
112
- // { "value": 3, "title": "事假" },
113
- // { "value": 4, "title": "病假" },
114
- // { "value": 5, "title": "其他" }
115
- // ]
116
- // 转换为jsonschema中的enum格式:
117
- // "enum": {
118
- // "anyOf": [
119
- // { "const": 1, "title": "年假" },
120
- // { "const": 2, "title": "调休" },
121
- // { "const": 3, "title": "事假" },
122
- // { "const": 4, "title": "病假" },
123
- // { "const": 5, "title": "其他" }
124
- // ]
125
- // }
126
- fieldSchemaInfo.enum = {
127
- anyOf: componentElement.props.data.map(function (item) {
128
- return {
129
- const: (item === null || item === void 0 ? void 0 : item[format]) || item,
130
- title: (item === null || item === void 0 ? void 0 : item.title) || item
131
- };
132
- })
133
- };
110
+ if (itemType === 'object') {
111
+ // 对于对象类型,使用 oneOf 而不是 enum
112
+ if (componentElement.props.multiple) {
113
+ fieldSchemaInfo.items.oneOf = componentElement.props.data.map(function (item) {
114
+ return {
115
+ const: item,
116
+ title: (item === null || item === void 0 ? void 0 : item.title) || JSON.stringify(item)
117
+ };
118
+ });
119
+ } else {
120
+ fieldSchemaInfo.oneOf = componentElement.props.data.map(function (item) {
121
+ return {
122
+ const: item,
123
+ title: (item === null || item === void 0 ? void 0 : item.title) || JSON.stringify(item)
124
+ };
125
+ });
126
+ }
127
+ } else {
128
+ fieldSchemaInfo.enum = componentElement.props.data.map(function (item) {
129
+ return (item === null || item === void 0 ? void 0 : item[format]) || item;
130
+ });
131
+ }
134
132
  break;
135
133
  }
136
134
  case 'ShineoutDatePicker':
@@ -153,15 +151,71 @@ export var SchemaBuilder = /*#__PURE__*/function () {
153
151
  break;
154
152
  case 'ShineoutCheckbox':
155
153
  case 'ShineoutCheckboxGroup':
156
- fieldSchemaInfo.type = 'array';
157
- fieldSchemaInfo.items = {
158
- type: 'string'
159
- };
160
- break;
154
+ {
155
+ if (typeof componentElement.props.keygen !== 'boolean') {
156
+ if (typeof format === 'string') {
157
+ var _data$2;
158
+ itemType = _typeof(data === null || data === void 0 ? void 0 : data[0]) === 'object' ? _typeof(data === null || data === void 0 || (_data$2 = data[0]) === null || _data$2 === void 0 ? void 0 : _data$2[format]) : _typeof(data === null || data === void 0 ? void 0 : data[0]);
159
+ } else if (typeof format === 'function') {
160
+ itemType = _typeof(format(data === null || data === void 0 ? void 0 : data[0]));
161
+ } else {
162
+ itemType = _typeof(data === null || data === void 0 ? void 0 : data[0]);
163
+ }
164
+ } else {
165
+ itemType = _typeof(data === null || data === void 0 ? void 0 : data[0]);
166
+ }
167
+ fieldSchemaInfo.type = 'array';
168
+ fieldSchemaInfo.items = {
169
+ type: itemType
170
+ };
171
+
172
+ // ShineoutCheckboxGroup 有 data 时(多选的)
173
+ if (itemType === 'object') {
174
+ fieldSchemaInfo.items.oneOf = componentElement.props.data.map(function (item) {
175
+ return {
176
+ const: item,
177
+ title: (item === null || item === void 0 ? void 0 : item.title) || JSON.stringify(item)
178
+ };
179
+ });
180
+ } else {
181
+ fieldSchemaInfo.items.enum = componentElement.props.data.map(function (item) {
182
+ return (item === null || item === void 0 ? void 0 : item[format]) || item;
183
+ });
184
+ }
185
+ break;
186
+ }
161
187
  case 'ShineoutRadio':
162
188
  case 'ShineoutRadioGroup':
163
- fieldSchemaInfo.type = 'string';
164
- break;
189
+ {
190
+ if (typeof componentElement.props.keygen !== 'boolean') {
191
+ if (typeof format === 'string') {
192
+ var _data$3;
193
+ itemType = _typeof(data === null || data === void 0 ? void 0 : data[0]) === 'object' ? _typeof(data === null || data === void 0 || (_data$3 = data[0]) === null || _data$3 === void 0 ? void 0 : _data$3[format]) : _typeof(data === null || data === void 0 ? void 0 : data[0]);
194
+ } else if (typeof format === 'function') {
195
+ itemType = _typeof(format(data === null || data === void 0 ? void 0 : data[0]));
196
+ } else {
197
+ itemType = _typeof(data === null || data === void 0 ? void 0 : data[0]);
198
+ }
199
+ } else {
200
+ itemType = _typeof(data === null || data === void 0 ? void 0 : data[0]);
201
+ }
202
+ fieldSchemaInfo.type = itemType;
203
+
204
+ // ShineoutRadioGroup 有 data 时(单选的)
205
+ if (itemType === 'object') {
206
+ fieldSchemaInfo.oneOf = componentElement.props.data.map(function (item) {
207
+ return {
208
+ const: item,
209
+ title: (item === null || item === void 0 ? void 0 : item.title) || JSON.stringify(item)
210
+ };
211
+ });
212
+ } else {
213
+ fieldSchemaInfo.enum = componentElement.props.data.map(function (item) {
214
+ return (item === null || item === void 0 ? void 0 : item[format]) || item;
215
+ });
216
+ }
217
+ break;
218
+ }
165
219
  case 'ShineoutSwitch':
166
220
  fieldSchemaInfo.type = 'boolean';
167
221
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sheinx/hooks",
3
- "version": "3.8.0-beta.32",
3
+ "version": "3.8.0-beta.34",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "MIT",