@faasjs/ant-design 1.1.0 → 1.2.0

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/index.js CHANGED
@@ -212,17 +212,37 @@ function transferOptions(options) {
212
212
  );
213
213
  }
214
214
  function transferValue(type, value) {
215
- if (typeof value === "undefined" || value === null || value === "" || value === "null" || value === "undefined")
216
- return null;
217
215
  if (!type)
218
216
  type = "string";
219
- if (type.endsWith("[]") && typeof value === "string")
220
- value = value.split(",").filter(Boolean);
221
- if (["date", "time"].includes(type)) {
222
- if (typeof value === "number" && value.toString().length === 10)
223
- value = value * 1e3;
224
- if (!dayjs2__default.default.isDayjs(value))
225
- value = dayjs2__default.default(value);
217
+ if (!type.endsWith("[]") && (typeof value === "undefined" || value === null || value === "" || value === "null" || value === "undefined"))
218
+ return null;
219
+ if (type.endsWith("[]")) {
220
+ if (!value)
221
+ value = [];
222
+ if (typeof value === "string")
223
+ value = value.split(",").filter(Boolean);
224
+ if (!Array.isArray(value))
225
+ value = [value];
226
+ value = value.map(
227
+ (item) => transferValue(type.replace("[]", ""), item)
228
+ );
229
+ }
230
+ switch (type) {
231
+ case "boolean":
232
+ if (typeof value === "string")
233
+ value = value === "true";
234
+ break;
235
+ case "number":
236
+ if (typeof value === "string")
237
+ value = Number(value);
238
+ break;
239
+ case "date":
240
+ case "time":
241
+ if (typeof value === "number" && value.toString().length === 10)
242
+ value = value * 1e3;
243
+ if (!dayjs2__default.default.isDayjs(value))
244
+ value = dayjs2__default.default(value);
245
+ break;
226
246
  }
227
247
  return value;
228
248
  }
package/dist/index.mjs CHANGED
@@ -209,17 +209,37 @@ function transferOptions(options) {
209
209
  );
210
210
  }
211
211
  function transferValue(type, value) {
212
- if (typeof value === "undefined" || value === null || value === "" || value === "null" || value === "undefined")
213
- return null;
214
212
  if (!type)
215
213
  type = "string";
216
- if (type.endsWith("[]") && typeof value === "string")
217
- value = value.split(",").filter(Boolean);
218
- if (["date", "time"].includes(type)) {
219
- if (typeof value === "number" && value.toString().length === 10)
220
- value = value * 1e3;
221
- if (!dayjs2.isDayjs(value))
222
- value = dayjs2(value);
214
+ if (!type.endsWith("[]") && (typeof value === "undefined" || value === null || value === "" || value === "null" || value === "undefined"))
215
+ return null;
216
+ if (type.endsWith("[]")) {
217
+ if (!value)
218
+ value = [];
219
+ if (typeof value === "string")
220
+ value = value.split(",").filter(Boolean);
221
+ if (!Array.isArray(value))
222
+ value = [value];
223
+ value = value.map(
224
+ (item) => transferValue(type.replace("[]", ""), item)
225
+ );
226
+ }
227
+ switch (type) {
228
+ case "boolean":
229
+ if (typeof value === "string")
230
+ value = value === "true";
231
+ break;
232
+ case "number":
233
+ if (typeof value === "string")
234
+ value = Number(value);
235
+ break;
236
+ case "date":
237
+ case "time":
238
+ if (typeof value === "number" && value.toString().length === 10)
239
+ value = value * 1e3;
240
+ if (!dayjs2.isDayjs(value))
241
+ value = dayjs2(value);
242
+ break;
223
243
  }
224
244
  return value;
225
245
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faasjs/ant-design",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -26,7 +26,7 @@
26
26
  "lodash-es": "*"
27
27
  },
28
28
  "peerDependencies": {
29
- "@faasjs/react": "1.1.0",
29
+ "@faasjs/react": "1.2.0",
30
30
  "antd": "*",
31
31
  "react": "*",
32
32
  "react-dom": "*",
@@ -37,7 +37,7 @@
37
37
  "@testing-library/jest-dom": "*",
38
38
  "@testing-library/react": "*",
39
39
  "@testing-library/user-event": "*",
40
- "@faasjs/react": "1.1.0",
40
+ "@faasjs/react": "1.2.0",
41
41
  "antd": "*",
42
42
  "react": "*",
43
43
  "react-dom": "*",