@faasjs/ant-design 0.0.2-beta.382 → 0.0.2-beta.383
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.d.ts +4 -0
- package/dist/index.js +21 -12
- package/dist/index.mjs +21 -12
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -36,11 +36,15 @@ declare type CalendarProps = CalendarProps$1<Dayjs>;
|
|
|
36
36
|
declare const Calendar: (props: antd_es_calendar_generateCalendar_js.CalendarProps<Dayjs>) => JSX.Element;
|
|
37
37
|
|
|
38
38
|
declare type FaasState = {
|
|
39
|
+
lang: string;
|
|
39
40
|
common: {
|
|
40
41
|
blank: string;
|
|
41
42
|
all: string;
|
|
42
43
|
submit: string;
|
|
43
44
|
pageNotFound: string;
|
|
45
|
+
add: string;
|
|
46
|
+
delete: string;
|
|
47
|
+
required: string;
|
|
44
48
|
};
|
|
45
49
|
Blank: {
|
|
46
50
|
text: string;
|
package/dist/index.js
CHANGED
|
@@ -75,19 +75,28 @@ var import_lodash = require("lodash");
|
|
|
75
75
|
// src/Config.tsx
|
|
76
76
|
var import_react2 = require("react");
|
|
77
77
|
var import_react_use = require("react-use");
|
|
78
|
-
var
|
|
79
|
-
var common =
|
|
78
|
+
var isZH = /^zh/i.test(navigator.language);
|
|
79
|
+
var common = isZH ? {
|
|
80
|
+
lang: "zh",
|
|
80
81
|
blank: "\u7A7A",
|
|
81
82
|
all: "\u5168\u90E8",
|
|
82
83
|
submit: "\u63D0\u4EA4",
|
|
83
|
-
pageNotFound: "\u9875\u9762\u672A\u627E\u5230"
|
|
84
|
+
pageNotFound: "\u9875\u9762\u672A\u627E\u5230",
|
|
85
|
+
add: "\u6DFB\u52A0",
|
|
86
|
+
delete: "\u5220\u9664",
|
|
87
|
+
required: "\u5FC5\u586B"
|
|
84
88
|
} : {
|
|
89
|
+
lang: "en",
|
|
85
90
|
blank: "Empty",
|
|
86
91
|
all: "All",
|
|
87
92
|
submit: "Submit",
|
|
88
|
-
pageNotFound: "Page Not Found"
|
|
93
|
+
pageNotFound: "Page Not Found",
|
|
94
|
+
add: "Add",
|
|
95
|
+
delete: "Delete",
|
|
96
|
+
required: "is required"
|
|
89
97
|
};
|
|
90
98
|
var useFaasState = (0, import_react_use.createGlobalState)({
|
|
99
|
+
lang: "en",
|
|
91
100
|
common,
|
|
92
101
|
Blank: { text: common.blank },
|
|
93
102
|
Form: { submit: { text: common.submit } },
|
|
@@ -283,7 +292,7 @@ var TimePicker = (0, import_react6.forwardRef)((props, ref) => {
|
|
|
283
292
|
TimePicker.displayName = "TimePicker";
|
|
284
293
|
|
|
285
294
|
// src/FormItem.tsx
|
|
286
|
-
function processProps(propsCopy) {
|
|
295
|
+
function processProps(propsCopy, config) {
|
|
287
296
|
if (!propsCopy.title)
|
|
288
297
|
propsCopy.title = (0, import_lodash4.upperFirst)(propsCopy.id);
|
|
289
298
|
if (!propsCopy.label && propsCopy.label !== false)
|
|
@@ -300,13 +309,13 @@ function processProps(propsCopy) {
|
|
|
300
309
|
required: true,
|
|
301
310
|
validator: async (_, values) => {
|
|
302
311
|
if (!values || values.length < 1)
|
|
303
|
-
return Promise.reject(Error(`${propsCopy.label || propsCopy.title}
|
|
312
|
+
return Promise.reject(Error(`${propsCopy.label || propsCopy.title} ${config.common.required}`));
|
|
304
313
|
}
|
|
305
314
|
});
|
|
306
315
|
else
|
|
307
316
|
propsCopy.rules.push({
|
|
308
317
|
required: true,
|
|
309
|
-
message: `${propsCopy.label || propsCopy.title}
|
|
318
|
+
message: `${propsCopy.label || propsCopy.title} ${config.common.required}`
|
|
310
319
|
});
|
|
311
320
|
}
|
|
312
321
|
if (!propsCopy.input)
|
|
@@ -323,7 +332,7 @@ function processProps(propsCopy) {
|
|
|
323
332
|
for (const sub of propsCopy.object) {
|
|
324
333
|
if (!sub.name)
|
|
325
334
|
sub.name = propsCopy.name.concat(sub.id);
|
|
326
|
-
processProps(sub);
|
|
335
|
+
processProps(sub, config);
|
|
327
336
|
}
|
|
328
337
|
break;
|
|
329
338
|
}
|
|
@@ -332,8 +341,9 @@ function processProps(propsCopy) {
|
|
|
332
341
|
function FormItem(props) {
|
|
333
342
|
var _a;
|
|
334
343
|
const [computedProps, setComputedProps] = (0, import_react7.useState)();
|
|
344
|
+
const [config] = useFaasState();
|
|
335
345
|
(0, import_react7.useEffect)(() => {
|
|
336
|
-
setComputedProps(processProps(__spreadValues({}, props)));
|
|
346
|
+
setComputedProps(processProps(__spreadValues({}, props), config));
|
|
337
347
|
}, [props]);
|
|
338
348
|
if (!computedProps)
|
|
339
349
|
return null;
|
|
@@ -464,9 +474,8 @@ function FormItem(props) {
|
|
|
464
474
|
}, /* @__PURE__ */ import_react.default.createElement("label", null, computedProps.label, " ", field.name + 1, !computedProps.disabled && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ import_react.default.createElement(import_antd4.Button, {
|
|
465
475
|
danger: true,
|
|
466
476
|
type: "link",
|
|
467
|
-
icon: /* @__PURE__ */ import_react.default.createElement(import_icons2.MinusCircleOutlined, null),
|
|
468
477
|
onClick: () => remove(field.name)
|
|
469
|
-
}))), /* @__PURE__ */ import_react.default.createElement(import_antd4.Row, {
|
|
478
|
+
}, config.common.delete))), /* @__PURE__ */ import_react.default.createElement(import_antd4.Row, {
|
|
470
479
|
gutter: 24
|
|
471
480
|
}, computedProps.object.map((o) => /* @__PURE__ */ import_react.default.createElement(import_antd4.Col, {
|
|
472
481
|
key: o.id,
|
|
@@ -478,7 +487,7 @@ function FormItem(props) {
|
|
|
478
487
|
block: true,
|
|
479
488
|
onClick: () => add(),
|
|
480
489
|
icon: /* @__PURE__ */ import_react.default.createElement(import_icons2.PlusOutlined, null)
|
|
481
|
-
}, computedProps.label), /* @__PURE__ */ import_react.default.createElement(import_antd4.Form.ErrorList, {
|
|
490
|
+
}, config.common.add, " ", computedProps.label), /* @__PURE__ */ import_react.default.createElement(import_antd4.Form.ErrorList, {
|
|
482
491
|
errors
|
|
483
492
|
}))));
|
|
484
493
|
default:
|
package/dist/index.mjs
CHANGED
|
@@ -28,19 +28,28 @@ import { isNil } from "lodash";
|
|
|
28
28
|
// src/Config.tsx
|
|
29
29
|
import { useEffect } from "react";
|
|
30
30
|
import { createGlobalState } from "react-use";
|
|
31
|
-
var
|
|
32
|
-
var common =
|
|
31
|
+
var isZH = /^zh/i.test(navigator.language);
|
|
32
|
+
var common = isZH ? {
|
|
33
|
+
lang: "zh",
|
|
33
34
|
blank: "\u7A7A",
|
|
34
35
|
all: "\u5168\u90E8",
|
|
35
36
|
submit: "\u63D0\u4EA4",
|
|
36
|
-
pageNotFound: "\u9875\u9762\u672A\u627E\u5230"
|
|
37
|
+
pageNotFound: "\u9875\u9762\u672A\u627E\u5230",
|
|
38
|
+
add: "\u6DFB\u52A0",
|
|
39
|
+
delete: "\u5220\u9664",
|
|
40
|
+
required: "\u5FC5\u586B"
|
|
37
41
|
} : {
|
|
42
|
+
lang: "en",
|
|
38
43
|
blank: "Empty",
|
|
39
44
|
all: "All",
|
|
40
45
|
submit: "Submit",
|
|
41
|
-
pageNotFound: "Page Not Found"
|
|
46
|
+
pageNotFound: "Page Not Found",
|
|
47
|
+
add: "Add",
|
|
48
|
+
delete: "Delete",
|
|
49
|
+
required: "is required"
|
|
42
50
|
};
|
|
43
51
|
var useFaasState = createGlobalState({
|
|
52
|
+
lang: "en",
|
|
44
53
|
common,
|
|
45
54
|
Blank: { text: common.blank },
|
|
46
55
|
Form: { submit: { text: common.submit } },
|
|
@@ -255,7 +264,7 @@ var TimePicker = forwardRef((props, ref) => {
|
|
|
255
264
|
TimePicker.displayName = "TimePicker";
|
|
256
265
|
|
|
257
266
|
// src/FormItem.tsx
|
|
258
|
-
function processProps(propsCopy) {
|
|
267
|
+
function processProps(propsCopy, config) {
|
|
259
268
|
if (!propsCopy.title)
|
|
260
269
|
propsCopy.title = upperFirst3(propsCopy.id);
|
|
261
270
|
if (!propsCopy.label && propsCopy.label !== false)
|
|
@@ -272,13 +281,13 @@ function processProps(propsCopy) {
|
|
|
272
281
|
required: true,
|
|
273
282
|
validator: async (_, values) => {
|
|
274
283
|
if (!values || values.length < 1)
|
|
275
|
-
return Promise.reject(Error(`${propsCopy.label || propsCopy.title}
|
|
284
|
+
return Promise.reject(Error(`${propsCopy.label || propsCopy.title} ${config.common.required}`));
|
|
276
285
|
}
|
|
277
286
|
});
|
|
278
287
|
else
|
|
279
288
|
propsCopy.rules.push({
|
|
280
289
|
required: true,
|
|
281
|
-
message: `${propsCopy.label || propsCopy.title}
|
|
290
|
+
message: `${propsCopy.label || propsCopy.title} ${config.common.required}`
|
|
282
291
|
});
|
|
283
292
|
}
|
|
284
293
|
if (!propsCopy.input)
|
|
@@ -295,7 +304,7 @@ function processProps(propsCopy) {
|
|
|
295
304
|
for (const sub of propsCopy.object) {
|
|
296
305
|
if (!sub.name)
|
|
297
306
|
sub.name = propsCopy.name.concat(sub.id);
|
|
298
|
-
processProps(sub);
|
|
307
|
+
processProps(sub, config);
|
|
299
308
|
}
|
|
300
309
|
break;
|
|
301
310
|
}
|
|
@@ -304,8 +313,9 @@ function processProps(propsCopy) {
|
|
|
304
313
|
function FormItem(props) {
|
|
305
314
|
var _a;
|
|
306
315
|
const [computedProps, setComputedProps] = useState3();
|
|
316
|
+
const [config] = useFaasState();
|
|
307
317
|
useEffect3(() => {
|
|
308
|
-
setComputedProps(processProps(__spreadValues({}, props)));
|
|
318
|
+
setComputedProps(processProps(__spreadValues({}, props), config));
|
|
309
319
|
}, [props]);
|
|
310
320
|
if (!computedProps)
|
|
311
321
|
return null;
|
|
@@ -436,9 +446,8 @@ function FormItem(props) {
|
|
|
436
446
|
}, /* @__PURE__ */ React.createElement("label", null, computedProps.label, " ", field.name + 1, !computedProps.disabled && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ React.createElement(Button, {
|
|
437
447
|
danger: true,
|
|
438
448
|
type: "link",
|
|
439
|
-
icon: /* @__PURE__ */ React.createElement(MinusCircleOutlined, null),
|
|
440
449
|
onClick: () => remove(field.name)
|
|
441
|
-
}))), /* @__PURE__ */ React.createElement(Row, {
|
|
450
|
+
}, config.common.delete))), /* @__PURE__ */ React.createElement(Row, {
|
|
442
451
|
gutter: 24
|
|
443
452
|
}, computedProps.object.map((o) => /* @__PURE__ */ React.createElement(Col, {
|
|
444
453
|
key: o.id,
|
|
@@ -450,7 +459,7 @@ function FormItem(props) {
|
|
|
450
459
|
block: true,
|
|
451
460
|
onClick: () => add(),
|
|
452
461
|
icon: /* @__PURE__ */ React.createElement(PlusOutlined, null)
|
|
453
|
-
}, computedProps.label), /* @__PURE__ */ React.createElement(AntdForm.ErrorList, {
|
|
462
|
+
}, config.common.add, " ", computedProps.label), /* @__PURE__ */ React.createElement(AntdForm.ErrorList, {
|
|
454
463
|
errors
|
|
455
464
|
}))));
|
|
456
465
|
default:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faasjs/ant-design",
|
|
3
|
-
"version": "0.0.2-beta.
|
|
3
|
+
"version": "0.0.2-beta.383",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"lodash": "*",
|
|
29
29
|
"react": "*",
|
|
30
30
|
"react-dom": "*",
|
|
31
|
-
"@faasjs/react": "^0.0.2-beta.
|
|
31
|
+
"@faasjs/react": "^0.0.2-beta.383",
|
|
32
32
|
"react-use": "*",
|
|
33
33
|
"react-router-dom": "*",
|
|
34
34
|
"dayjs": "*"
|