@faasjs/ant-design 0.0.2-beta.357 → 0.0.2-beta.358

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 CHANGED
@@ -18,6 +18,7 @@ declare type FaasState = {
18
18
  blank: string;
19
19
  all: string;
20
20
  submit: string;
21
+ pageNotFound: string;
21
22
  };
22
23
  Blank: {
23
24
  text: string;
@@ -158,6 +159,7 @@ declare type RoutesProps = {
158
159
  routes: (RouteProps & {
159
160
  page?: LazyExoticComponent<ComponentType<any>>;
160
161
  })[];
162
+ fallback?: JSX.Element;
161
163
  notFound?: JSX.Element;
162
164
  };
163
165
  declare function Routes(props: RoutesProps): JSX.Element;
package/dist/index.js CHANGED
@@ -70,11 +70,17 @@ var import_lodash = require("lodash");
70
70
  // src/Config.tsx
71
71
  var import_react2 = require("react");
72
72
  var import_react_use = require("react-use");
73
- var _a, _b, _c;
74
- var common = {
75
- blank: ((_a = navigator.language) == null ? void 0 : _a.includes("CN")) ? "\u7A7A" : "Empty",
76
- all: ((_b = navigator.language) == null ? void 0 : _b.includes("CN")) ? "\u5168\u90E8" : "All",
77
- submit: ((_c = navigator.language) == null ? void 0 : _c.includes("CN")) ? "\u63D0\u4EA4" : "Submit"
73
+ var isCN = /^zh/i.test(navigator.language);
74
+ var common = isCN ? {
75
+ blank: "\u7A7A",
76
+ all: "\u5168\u90E8",
77
+ submit: "\u63D0\u4EA4",
78
+ pageNotFound: "\u9875\u9762\u672A\u627E\u5230"
79
+ } : {
80
+ blank: "Empty",
81
+ all: "All",
82
+ submit: "Submit",
83
+ pageNotFound: "Page Not Found"
78
84
  };
79
85
  var useFaasState = (0, import_react_use.createGlobalState)({
80
86
  common,
@@ -121,23 +127,23 @@ var import_react4 = require("@faasjs/react");
121
127
  function DescriptionItemContent(props) {
122
128
  const [computedProps, setComputedProps] = (0, import_react3.useState)();
123
129
  (0, import_react3.useEffect)(() => {
124
- var _a2, _b2;
130
+ var _a, _b;
125
131
  const propsCopy = __spreadValues({}, props);
126
132
  if (!propsCopy.item.title)
127
133
  propsCopy.item.title = (0, import_lodash3.upperFirst)(propsCopy.item.id);
128
134
  if (!propsCopy.item.type)
129
135
  propsCopy.item.type = "string";
130
- if ((_a2 = propsCopy.item.options) == null ? void 0 : _a2.length) {
136
+ if ((_a = propsCopy.item.options) == null ? void 0 : _a.length) {
131
137
  propsCopy.item.options = transferOptions(propsCopy.item.options);
132
138
  }
133
139
  if (propsCopy.item.options && typeof propsCopy.value !== "undefined" && propsCopy.value !== null) {
134
140
  if (propsCopy.item.type.endsWith("[]"))
135
141
  propsCopy.value = propsCopy.value.map((v) => {
136
- var _a3;
137
- return ((_a3 = propsCopy.item.options.find((option) => option.value === v)) == null ? void 0 : _a3.label) || v;
142
+ var _a2;
143
+ return ((_a2 = propsCopy.item.options.find((option) => option.value === v)) == null ? void 0 : _a2.label) || v;
138
144
  });
139
145
  else
140
- propsCopy.value = ((_b2 = props.item.options.find((option) => option.value === props.value)) == null ? void 0 : _b2.label) || props.value;
146
+ propsCopy.value = ((_b = props.item.options.find((option) => option.value === props.value)) == null ? void 0 : _b.label) || props.value;
141
147
  }
142
148
  setComputedProps(propsCopy);
143
149
  }, [props]);
@@ -334,11 +340,11 @@ function FormItem(props) {
334
340
  name: computedProps.name,
335
341
  rules: computedProps.rules
336
342
  }, (fields, { add, remove }, { errors }) => {
337
- var _a2;
343
+ var _a;
338
344
  return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, computedProps.label && /* @__PURE__ */ import_react.default.createElement("div", {
339
345
  className: "ant-form-item-label"
340
346
  }, /* @__PURE__ */ import_react.default.createElement("label", {
341
- className: ((_a2 = computedProps.rules) == null ? void 0 : _a2.find((r) => r.required)) && "ant-form-item-required"
347
+ className: ((_a = computedProps.rules) == null ? void 0 : _a.find((r) => r.required)) && "ant-form-item-required"
342
348
  }, computedProps.label)), fields.map((field) => /* @__PURE__ */ import_react.default.createElement(import_antd4.Form.Item, {
343
349
  key: field.key
344
350
  }, /* @__PURE__ */ import_react.default.createElement(import_antd4.Row, {
@@ -375,7 +381,7 @@ function FormItem(props) {
375
381
 
376
382
  // src/Form.tsx
377
383
  function Form(props) {
378
- var _a2, _b2;
384
+ var _a, _b;
379
385
  const [loading, setLoading] = (0, import_react7.useState)(false);
380
386
  const [computedProps, setComputedProps] = (0, import_react7.useState)();
381
387
  const [config] = useFaasState();
@@ -396,7 +402,7 @@ function Form(props) {
396
402
  }, []);
397
403
  if (!computedProps)
398
404
  return null;
399
- return /* @__PURE__ */ import_react.default.createElement(import_antd5.Form, __spreadValues({}, computedProps), (_a2 = props.items) == null ? void 0 : _a2.map((item) => /* @__PURE__ */ import_react.default.createElement(FormItem, __spreadProps(__spreadValues({
405
+ return /* @__PURE__ */ import_react.default.createElement(import_antd5.Form, __spreadValues({}, computedProps), (_a = props.items) == null ? void 0 : _a.map((item) => /* @__PURE__ */ import_react.default.createElement(FormItem, __spreadProps(__spreadValues({
400
406
  key: item.id
401
407
  }, item), {
402
408
  extendTypes: props.extendTypes
@@ -404,7 +410,7 @@ function Form(props) {
404
410
  htmlType: "submit",
405
411
  type: "primary",
406
412
  loading
407
- }, ((_b2 = props.submit) == null ? void 0 : _b2.text) || config.Form.submit.text));
413
+ }, ((_b = props.submit) == null ? void 0 : _b.text) || config.Form.submit.text));
408
414
  }
409
415
  Form.useForm = import_antd5.Form.useForm;
410
416
  Form.Item = FormItem;
@@ -413,11 +419,11 @@ Form.Item = FormItem;
413
419
  var import_antd6 = require("antd");
414
420
  var import_react8 = require("react");
415
421
  var import_react_router_dom = require("react-router-dom");
416
- function NoMatch() {
422
+ function NotFound() {
423
+ const [config] = useFaasState();
417
424
  return /* @__PURE__ */ import_react.default.createElement(import_antd6.Result, {
418
425
  status: "404",
419
- title: "404",
420
- subTitle: "Page not found"
426
+ title: config.common.pageNotFound
421
427
  });
422
428
  }
423
429
  function Routes(props) {
@@ -425,14 +431,15 @@ function Routes(props) {
425
431
  key: r.path
426
432
  }, r), {
427
433
  element: r.element || /* @__PURE__ */ import_react.default.createElement(import_react8.Suspense, {
428
- fallback: /* @__PURE__ */ import_react.default.createElement(import_antd6.Skeleton, {
429
- active: true
434
+ fallback: props.fallback || /* @__PURE__ */ import_react.default.createElement(import_antd6.Skeleton, {
435
+ active: true,
436
+ style: { padding: "24px" }
430
437
  })
431
438
  }, /* @__PURE__ */ import_react.default.createElement(r.page, null))
432
439
  }))), /* @__PURE__ */ import_react.default.createElement(import_react_router_dom.Route, {
433
440
  key: "*",
434
441
  path: "*",
435
- element: props.notFound || /* @__PURE__ */ import_react.default.createElement(NoMatch, null)
442
+ element: props.notFound || /* @__PURE__ */ import_react.default.createElement(NotFound, null)
436
443
  }));
437
444
  }
438
445
 
@@ -443,15 +450,15 @@ var import_icons3 = require("@ant-design/icons");
443
450
  var import_lodash5 = require("lodash");
444
451
  var import_react10 = require("@faasjs/react");
445
452
  function processValue(item, value) {
446
- var _a2;
453
+ var _a;
447
454
  if (item.options && typeof value !== "undefined" && value !== null) {
448
455
  if (item.type.endsWith("[]"))
449
456
  return value.map((v) => {
450
- var _a3;
451
- return ((_a3 = item.options.find((option) => option.value === v)) == null ? void 0 : _a3.label) || v;
457
+ var _a2;
458
+ return ((_a2 = item.options.find((option) => option.value === v)) == null ? void 0 : _a2.label) || v;
452
459
  });
453
460
  else
454
- return ((_a2 = item.options.find((option) => option.value === value)) == null ? void 0 : _a2.label) || value;
461
+ return ((_a = item.options.find((option) => option.value === value)) == null ? void 0 : _a.label) || value;
455
462
  }
456
463
  return value;
457
464
  }
@@ -459,7 +466,7 @@ function Table(props) {
459
466
  const [columns, setColumns] = (0, import_react9.useState)();
460
467
  const [config] = useFaasState();
461
468
  (0, import_react9.useEffect)(() => {
462
- var _a2;
469
+ var _a;
463
470
  for (const item of props.items) {
464
471
  if (!item.key)
465
472
  item.key = item.id;
@@ -469,7 +476,7 @@ function Table(props) {
469
476
  item.title = (0, import_lodash5.upperFirst)(item.id);
470
477
  if (!item.type)
471
478
  item.type = "string";
472
- if ((_a2 = item.options) == null ? void 0 : _a2.length) {
479
+ if ((_a = item.options) == null ? void 0 : _a.length) {
473
480
  item.options = transferOptions(item.options);
474
481
  item.filters = item.options.map((o) => ({
475
482
  text: o.label,
@@ -605,7 +612,7 @@ function Table(props) {
605
612
  rowKey: props.rowKey || "id",
606
613
  columns,
607
614
  dataSource: data.rows,
608
- pagination: data.pagination,
615
+ pagination: __spreadValues(__spreadValues({}, props.pagination), data.pagination),
609
616
  onChange: (pagination, filters, sorter) => {
610
617
  reload(__spreadProps(__spreadValues({}, params), {
611
618
  pagination,
package/dist/index.mjs CHANGED
@@ -28,11 +28,17 @@ import { isNil } from "lodash";
28
28
  // src/Config.tsx
29
29
  import { useEffect } from "react";
30
30
  import { createGlobalState } from "react-use";
31
- var _a, _b, _c;
32
- var common = {
33
- blank: ((_a = navigator.language) == null ? void 0 : _a.includes("CN")) ? "\u7A7A" : "Empty",
34
- all: ((_b = navigator.language) == null ? void 0 : _b.includes("CN")) ? "\u5168\u90E8" : "All",
35
- submit: ((_c = navigator.language) == null ? void 0 : _c.includes("CN")) ? "\u63D0\u4EA4" : "Submit"
31
+ var isCN = /^zh/i.test(navigator.language);
32
+ var common = isCN ? {
33
+ blank: "\u7A7A",
34
+ all: "\u5168\u90E8",
35
+ submit: "\u63D0\u4EA4",
36
+ pageNotFound: "\u9875\u9762\u672A\u627E\u5230"
37
+ } : {
38
+ blank: "Empty",
39
+ all: "All",
40
+ submit: "Submit",
41
+ pageNotFound: "Page Not Found"
36
42
  };
37
43
  var useFaasState = createGlobalState({
38
44
  common,
@@ -83,23 +89,23 @@ import { FaasDataWrapper } from "@faasjs/react";
83
89
  function DescriptionItemContent(props) {
84
90
  const [computedProps, setComputedProps] = useState();
85
91
  useEffect2(() => {
86
- var _a2, _b2;
92
+ var _a, _b;
87
93
  const propsCopy = __spreadValues({}, props);
88
94
  if (!propsCopy.item.title)
89
95
  propsCopy.item.title = upperFirst2(propsCopy.item.id);
90
96
  if (!propsCopy.item.type)
91
97
  propsCopy.item.type = "string";
92
- if ((_a2 = propsCopy.item.options) == null ? void 0 : _a2.length) {
98
+ if ((_a = propsCopy.item.options) == null ? void 0 : _a.length) {
93
99
  propsCopy.item.options = transferOptions(propsCopy.item.options);
94
100
  }
95
101
  if (propsCopy.item.options && typeof propsCopy.value !== "undefined" && propsCopy.value !== null) {
96
102
  if (propsCopy.item.type.endsWith("[]"))
97
103
  propsCopy.value = propsCopy.value.map((v) => {
98
- var _a3;
99
- return ((_a3 = propsCopy.item.options.find((option) => option.value === v)) == null ? void 0 : _a3.label) || v;
104
+ var _a2;
105
+ return ((_a2 = propsCopy.item.options.find((option) => option.value === v)) == null ? void 0 : _a2.label) || v;
100
106
  });
101
107
  else
102
- propsCopy.value = ((_b2 = props.item.options.find((option) => option.value === props.value)) == null ? void 0 : _b2.label) || props.value;
108
+ propsCopy.value = ((_b = props.item.options.find((option) => option.value === props.value)) == null ? void 0 : _b.label) || props.value;
103
109
  }
104
110
  setComputedProps(propsCopy);
105
111
  }, [props]);
@@ -308,11 +314,11 @@ function FormItem(props) {
308
314
  name: computedProps.name,
309
315
  rules: computedProps.rules
310
316
  }, (fields, { add, remove }, { errors }) => {
311
- var _a2;
317
+ var _a;
312
318
  return /* @__PURE__ */ React.createElement(React.Fragment, null, computedProps.label && /* @__PURE__ */ React.createElement("div", {
313
319
  className: "ant-form-item-label"
314
320
  }, /* @__PURE__ */ React.createElement("label", {
315
- className: ((_a2 = computedProps.rules) == null ? void 0 : _a2.find((r) => r.required)) && "ant-form-item-required"
321
+ className: ((_a = computedProps.rules) == null ? void 0 : _a.find((r) => r.required)) && "ant-form-item-required"
316
322
  }, computedProps.label)), fields.map((field) => /* @__PURE__ */ React.createElement(AntdForm.Item, {
317
323
  key: field.key
318
324
  }, /* @__PURE__ */ React.createElement(Row, {
@@ -349,7 +355,7 @@ function FormItem(props) {
349
355
 
350
356
  // src/Form.tsx
351
357
  function Form(props) {
352
- var _a2, _b2;
358
+ var _a, _b;
353
359
  const [loading, setLoading] = useState4(false);
354
360
  const [computedProps, setComputedProps] = useState4();
355
361
  const [config] = useFaasState();
@@ -370,7 +376,7 @@ function Form(props) {
370
376
  }, []);
371
377
  if (!computedProps)
372
378
  return null;
373
- return /* @__PURE__ */ React.createElement(AntdForm2, __spreadValues({}, computedProps), (_a2 = props.items) == null ? void 0 : _a2.map((item) => /* @__PURE__ */ React.createElement(FormItem, __spreadProps(__spreadValues({
379
+ return /* @__PURE__ */ React.createElement(AntdForm2, __spreadValues({}, computedProps), (_a = props.items) == null ? void 0 : _a.map((item) => /* @__PURE__ */ React.createElement(FormItem, __spreadProps(__spreadValues({
374
380
  key: item.id
375
381
  }, item), {
376
382
  extendTypes: props.extendTypes
@@ -378,7 +384,7 @@ function Form(props) {
378
384
  htmlType: "submit",
379
385
  type: "primary",
380
386
  loading
381
- }, ((_b2 = props.submit) == null ? void 0 : _b2.text) || config.Form.submit.text));
387
+ }, ((_b = props.submit) == null ? void 0 : _b.text) || config.Form.submit.text));
382
388
  }
383
389
  Form.useForm = AntdForm2.useForm;
384
390
  Form.Item = FormItem;
@@ -392,11 +398,11 @@ import {
392
398
  Routes as OriginRoutes,
393
399
  Route
394
400
  } from "react-router-dom";
395
- function NoMatch() {
401
+ function NotFound() {
402
+ const [config] = useFaasState();
396
403
  return /* @__PURE__ */ React.createElement(Result, {
397
404
  status: "404",
398
- title: "404",
399
- subTitle: "Page not found"
405
+ title: config.common.pageNotFound
400
406
  });
401
407
  }
402
408
  function Routes(props) {
@@ -404,14 +410,15 @@ function Routes(props) {
404
410
  key: r.path
405
411
  }, r), {
406
412
  element: r.element || /* @__PURE__ */ React.createElement(Suspense, {
407
- fallback: /* @__PURE__ */ React.createElement(Skeleton, {
408
- active: true
413
+ fallback: props.fallback || /* @__PURE__ */ React.createElement(Skeleton, {
414
+ active: true,
415
+ style: { padding: "24px" }
409
416
  })
410
417
  }, /* @__PURE__ */ React.createElement(r.page, null))
411
418
  }))), /* @__PURE__ */ React.createElement(Route, {
412
419
  key: "*",
413
420
  path: "*",
414
- element: props.notFound || /* @__PURE__ */ React.createElement(NoMatch, null)
421
+ element: props.notFound || /* @__PURE__ */ React.createElement(NotFound, null)
415
422
  }));
416
423
  }
417
424
 
@@ -429,15 +436,15 @@ import { CheckOutlined as CheckOutlined2, CloseOutlined as CloseOutlined2 } from
429
436
  import { isNil as isNil2, upperFirst as upperFirst4 } from "lodash";
430
437
  import { FaasDataWrapper as FaasDataWrapper2 } from "@faasjs/react";
431
438
  function processValue(item, value) {
432
- var _a2;
439
+ var _a;
433
440
  if (item.options && typeof value !== "undefined" && value !== null) {
434
441
  if (item.type.endsWith("[]"))
435
442
  return value.map((v) => {
436
- var _a3;
437
- return ((_a3 = item.options.find((option) => option.value === v)) == null ? void 0 : _a3.label) || v;
443
+ var _a2;
444
+ return ((_a2 = item.options.find((option) => option.value === v)) == null ? void 0 : _a2.label) || v;
438
445
  });
439
446
  else
440
- return ((_a2 = item.options.find((option) => option.value === value)) == null ? void 0 : _a2.label) || value;
447
+ return ((_a = item.options.find((option) => option.value === value)) == null ? void 0 : _a.label) || value;
441
448
  }
442
449
  return value;
443
450
  }
@@ -445,7 +452,7 @@ function Table(props) {
445
452
  const [columns, setColumns] = useState5();
446
453
  const [config] = useFaasState();
447
454
  useEffect5(() => {
448
- var _a2;
455
+ var _a;
449
456
  for (const item of props.items) {
450
457
  if (!item.key)
451
458
  item.key = item.id;
@@ -455,7 +462,7 @@ function Table(props) {
455
462
  item.title = upperFirst4(item.id);
456
463
  if (!item.type)
457
464
  item.type = "string";
458
- if ((_a2 = item.options) == null ? void 0 : _a2.length) {
465
+ if ((_a = item.options) == null ? void 0 : _a.length) {
459
466
  item.options = transferOptions(item.options);
460
467
  item.filters = item.options.map((o) => ({
461
468
  text: o.label,
@@ -591,7 +598,7 @@ function Table(props) {
591
598
  rowKey: props.rowKey || "id",
592
599
  columns,
593
600
  dataSource: data.rows,
594
- pagination: data.pagination,
601
+ pagination: __spreadValues(__spreadValues({}, props.pagination), data.pagination),
595
602
  onChange: (pagination, filters, sorter) => {
596
603
  reload(__spreadProps(__spreadValues({}, params), {
597
604
  pagination,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faasjs/ant-design",
3
- "version": "0.0.2-beta.357",
3
+ "version": "0.0.2-beta.358",
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.357",
31
+ "@faasjs/react": "^0.0.2-beta.358",
32
32
  "react-use": "*",
33
33
  "react-router-dom": "*"
34
34
  },