@arim-aisdc/public-components 2.3.1 → 2.3.2

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,69 +1,69 @@
1
- @font-face {
2
- font-family: "iconfont-public"; /* Project id 4386651 */
3
- src: url('./iconfont.ttf?t=1730099749830') format('truetype');
4
- }
5
-
6
- .iconfont-public {
7
- font-family: "iconfont-public" !important;
8
- font-size: 16px;
9
- font-style: normal;
10
- -webkit-font-smoothing: antialiased;
11
- -moz-osx-font-smoothing: grayscale;
12
- }
13
-
14
- .icon-public-guanbiqita:before {
15
- content: "\e6db";
16
- }
17
-
18
- .icon-public-shuaxinbiaoqian:before {
19
- content: "\e6dc";
20
- }
21
-
22
- .icon-public-guanbibiaoqian:before {
23
- content: "\e6dd";
24
- }
25
-
26
- .icon-public-upload:before {
27
- content: "\e877";
28
- }
29
-
30
- .icon-public-download:before {
31
- content: "\e878";
32
- }
33
-
34
- .icon-public-refresh:before {
35
- content: "\e7c1";
36
- }
37
-
38
- .icon-public-edit:before {
39
- content: "\e7c2";
40
- }
41
-
42
- .icon-public-calendar:before {
43
- content: "\e7c3";
44
- }
45
-
46
- .icon-public-reduce:before {
47
- content: "\e7c4";
48
- }
49
-
50
- .icon-public-setting:before {
51
- content: "\e7bc";
52
- }
53
-
54
- .icon-public-delete:before {
55
- content: "\e7bd";
56
- }
57
-
58
- .icon-public-drag:before {
59
- content: "\e7be";
60
- }
61
-
62
- .icon-public-down:before {
63
- content: "\e7bf";
64
- }
65
-
66
- .icon-public-pin:before {
67
- content: "\e7c0";
68
- }
69
-
1
+ @font-face {
2
+ font-family: "iconfont-public"; /* Project id 4386651 */
3
+ src: url('./iconfont.ttf?t=1730099749830') format('truetype');
4
+ }
5
+
6
+ .iconfont-public {
7
+ font-family: "iconfont-public" !important;
8
+ font-size: 16px;
9
+ font-style: normal;
10
+ -webkit-font-smoothing: antialiased;
11
+ -moz-osx-font-smoothing: grayscale;
12
+ }
13
+
14
+ .icon-public-guanbiqita:before {
15
+ content: "\e6db";
16
+ }
17
+
18
+ .icon-public-shuaxinbiaoqian:before {
19
+ content: "\e6dc";
20
+ }
21
+
22
+ .icon-public-guanbibiaoqian:before {
23
+ content: "\e6dd";
24
+ }
25
+
26
+ .icon-public-upload:before {
27
+ content: "\e877";
28
+ }
29
+
30
+ .icon-public-download:before {
31
+ content: "\e878";
32
+ }
33
+
34
+ .icon-public-refresh:before {
35
+ content: "\e7c1";
36
+ }
37
+
38
+ .icon-public-edit:before {
39
+ content: "\e7c2";
40
+ }
41
+
42
+ .icon-public-calendar:before {
43
+ content: "\e7c3";
44
+ }
45
+
46
+ .icon-public-reduce:before {
47
+ content: "\e7c4";
48
+ }
49
+
50
+ .icon-public-setting:before {
51
+ content: "\e7bc";
52
+ }
53
+
54
+ .icon-public-delete:before {
55
+ content: "\e7bd";
56
+ }
57
+
58
+ .icon-public-drag:before {
59
+ content: "\e7be";
60
+ }
61
+
62
+ .icon-public-down:before {
63
+ content: "\e7bf";
64
+ }
65
+
66
+ .icon-public-pin:before {
67
+ content: "\e7c0";
68
+ }
69
+
@@ -17,7 +17,7 @@ export declare const foramtBaseInfoField: (data: any, dataField: BaseInfoFieldTy
17
17
  value: any;
18
18
  field: string;
19
19
  label?: string;
20
- text: string | Element | JSX.Element;
20
+ text: string | JSX.Element | Element;
21
21
  units?: string;
22
22
  width?: string;
23
23
  labelWidth?: string;
@@ -1,6 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { ThemeType } from "../../../dist/components/ThemeProvider";
3
3
  import type { VariablesJsonType } from './type';
4
+ import { Locale } from '../../locales';
4
5
  export interface ConfigConsumerProps {
5
6
  userId?: string;
6
7
  tableKeyPrefixCls?: string;
@@ -20,11 +21,14 @@ export interface ConfigConsumerProps {
20
21
  request?: (...params: any[]) => Promise<Blob>;
21
22
  /** 主题包名称 */
22
23
  themePackageName?: 'DefaultThemePackage' | 'DyImsBlueThemePackage';
24
+ /**语言 */
25
+ locale?: Locale;
23
26
  }
24
27
  export declare const DEFAULT_CONTEXT: {
25
28
  theme: string;
26
29
  userId: string;
27
30
  tableKeyPrefixCls: string;
31
+ locale: Locale;
28
32
  };
29
33
  declare const ConfigContext: import("react").Context<ConfigConsumerProps>;
30
34
  export default ConfigContext;
@@ -1,11 +1,14 @@
1
1
  import { createContext } from 'react';
2
+ import public_zhCN from "../../locales/zh_CN";
2
3
 
3
4
  // context data 类型
4
5
 
5
6
  export var DEFAULT_CONTEXT = {
6
7
  theme: 'light',
7
8
  userId: '',
8
- tableKeyPrefixCls: 'TableMax'
9
+ tableKeyPrefixCls: 'TableMax',
10
+ locale: public_zhCN
11
+ // locale: public_enUS
9
12
  };
10
13
  var ConfigContext = /*#__PURE__*/createContext(DEFAULT_CONTEXT);
11
14
  export default ConfigContext;
@@ -1,3 +1,9 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
1
7
  import React from 'react';
2
8
  import { useConfig } from "../ConfigProvider";
3
9
  // @ts-ignore
@@ -5,6 +11,7 @@ import defaultEmptyDarkImage from "../../assets/images/data-empty-dark.svg";
5
11
  // @ts-ignore
6
12
  import defaultEmptyLightImage from "../../assets/images/data-empty-light.svg";
7
13
  import "./index.less";
14
+ import { useTranslation } from "../../hooks/useTranslation";
8
15
  import { jsx as _jsx } from "react/jsx-runtime";
9
16
  import { jsxs as _jsxs } from "react/jsx-runtime";
10
17
  import { Fragment as _Fragment } from "react/jsx-runtime";
@@ -23,13 +30,15 @@ var emptyDataRender = function emptyDataRender(dynamicTheme, darkImage, lightIma
23
30
  var Empty = function Empty(_ref) {
24
31
  var emptyDarkImage = _ref.emptyDarkImage,
25
32
  emptyLightImage = _ref.emptyLightImage,
26
- _ref$text = _ref.text,
27
- text = _ref$text === void 0 ? "暂无数据" : _ref$text;
33
+ text = _ref.text;
28
34
  var _useConfig = useConfig(),
29
35
  theme = _useConfig.theme,
30
36
  renderEmpty = _useConfig.renderEmpty;
37
+ var _useTranslation = useTranslation(),
38
+ _useTranslation2 = _slicedToArray(_useTranslation, 1),
39
+ t = _useTranslation2[0];
31
40
  return /*#__PURE__*/_jsx(_Fragment, {
32
- children: emptyDarkImage && emptyLightImage ? emptyDataRender(theme, emptyDarkImage, emptyLightImage, text) : renderEmpty ? renderEmpty === null || renderEmpty === void 0 ? void 0 : renderEmpty(theme) : emptyDataRender(theme, defaultEmptyDarkImage, defaultEmptyLightImage, text)
41
+ children: emptyDarkImage && emptyLightImage ? emptyDataRender(theme, emptyDarkImage, emptyLightImage, t('global.text.emptyText')) : renderEmpty ? renderEmpty === null || renderEmpty === void 0 ? void 0 : renderEmpty(theme) : emptyDataRender(theme, defaultEmptyDarkImage, defaultEmptyLightImage, t('global.text.emptyText'))
33
42
  });
34
43
  };
35
44
  export default Empty;
@@ -2,6 +2,12 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
2
2
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
3
3
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4
4
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
5
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
6
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
7
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
8
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
9
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
10
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
5
11
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
12
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
13
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
@@ -11,6 +17,7 @@ import { Modal } from 'antd';
11
17
  import MessageTip from "../MessageTip";
12
18
  import "./index.less";
13
19
  import { themeStyle } from "./utils";
20
+ import { useTranslation } from "../../../hooks/useTranslation";
14
21
  import { jsx as _jsx } from "react/jsx-runtime";
15
22
  var modal = null;
16
23
  var config = function config(_ref) {
@@ -104,11 +111,16 @@ var confirmModal = function confirmModal(_ref4) {
104
111
  cancelText = _ref4.cancelText,
105
112
  centered = _ref4.centered,
106
113
  deleteActionName = _ref4.deleteActionName;
114
+ var _useTranslation = useTranslation(),
115
+ _useTranslation2 = _slicedToArray(_useTranslation, 1),
116
+ t = _useTranslation2[0];
107
117
  Modal.confirm({
108
- title: title ? title : '确认删除这条信息吗?',
109
- content: content || content === '' ? content : '删除后可能无法恢复,请谨慎操作!',
110
- okText: okText ? okText : '确认',
111
- cancelText: cancelText ? cancelText : '取消',
118
+ title: title ? title : t('global.message.confirmDeleteTitle'),
119
+ // '确认删除这条信息吗?',
120
+ // content: content || content === '' ? content : '删除后可能无法恢复,请谨慎操作!',
121
+ content: content || content === '' ? content : t('global.message.confirmDeleteSubTitle'),
122
+ okText: okText ? okText : t('global.button.confirm'),
123
+ cancelText: cancelText ? cancelText : t('global.button.cancel'),
112
124
  styles: {
113
125
  body: themeStyle('bodyStyle'),
114
126
  // 背景颜色
@@ -132,7 +144,8 @@ var confirmModal = function confirmModal(_ref4) {
132
144
  case 0:
133
145
  MessageTip.loading({
134
146
  key: 'delete',
135
- content: deleteActionName ? "".concat(deleteActionName, "\u4E2D") : '删除中'
147
+ // content: deleteActionName ? `${deleteActionName}中` : '删除中',
148
+ content: deleteActionName ? t('global.message.actioning', deleteActionName) : t('global.message.deleting')
136
149
  });
137
150
  _context.next = 3;
138
151
  return handlerConfirm();
@@ -141,7 +154,7 @@ var confirmModal = function confirmModal(_ref4) {
141
154
  if (!(resp !== null && resp !== void 0 && resp[0])) {
142
155
  MessageTip.success({
143
156
  key: 'delete',
144
- content: deleteActionName ? "".concat(deleteActionName, "\u6210\u529F") : '删除成功'
157
+ content: deleteActionName ? t('global.message.successAction', deleteActionName) : t('global.message.deleteSuccess')
145
158
  });
146
159
  }
147
160
  case 5:
@@ -28,6 +28,7 @@ import RemoteCascader from "./RemoteCascader";
28
28
  import RemoteSelect from "./RemoteSelectCom";
29
29
  import "./index.less";
30
30
  import { FormItemType, TimeFormatType } from "./type";
31
+ import { useTranslation } from "../../hooks/useTranslation";
31
32
  import { jsx as _jsx } from "react/jsx-runtime";
32
33
  import { jsxs as _jsxs } from "react/jsx-runtime";
33
34
  export var typeList = {
@@ -39,10 +40,8 @@ export var typeList = {
39
40
  var QueryFilter = function QueryFilter(_ref, ref) {
40
41
  var data = _ref.data,
41
42
  initialValues = _ref.initialValues,
42
- _ref$isOkText = _ref.isOkText,
43
- isOkText = _ref$isOkText === void 0 ? '确定' : _ref$isOkText,
44
- _ref$cancelText = _ref.cancelText,
45
- cancelText = _ref$cancelText === void 0 ? '重置' : _ref$cancelText,
43
+ isOkText = _ref.isOkText,
44
+ cancelText = _ref.cancelText,
46
45
  handleSubmit = _ref.handleSubmit,
47
46
  handleCancel = _ref.handleCancel,
48
47
  _ref$showButton = _ref.showButton,
@@ -53,6 +52,9 @@ var QueryFilter = function QueryFilter(_ref, ref) {
53
52
  _ref$renderButton = _ref.renderButton,
54
53
  renderButton = _ref$renderButton === void 0 ? null : _ref$renderButton,
55
54
  rest = _objectWithoutProperties(_ref, _excluded);
55
+ var _useTranslation = useTranslation(),
56
+ _useTranslation2 = _slicedToArray(_useTranslation, 1),
57
+ t = _useTranslation2[0];
56
58
  var _Form$useForm = Form.useForm(),
57
59
  _Form$useForm2 = _slicedToArray(_Form$useForm, 1),
58
60
  form = _Form$useForm2[0];
@@ -336,7 +338,7 @@ var QueryFilter = function QueryFilter(_ref, ref) {
336
338
  break;
337
339
  case FormItemType.DateTime:
338
340
  element = /*#__PURE__*/_jsx(DatePicker, {
339
- showTime: true,
341
+ showTime: item.showTimeFormat,
340
342
  style: {
341
343
  width: item !== null && item !== void 0 && item.wapperWidth ? item === null || item === void 0 ? void 0 : item.wapperWidth : '100%'
342
344
  },
@@ -657,7 +659,7 @@ var QueryFilter = function QueryFilter(_ref, ref) {
657
659
  form.resetFields();
658
660
  }, 200);
659
661
  },
660
- children: cancelText
662
+ children: cancelText || t('global.button.reset')
661
663
  }), /*#__PURE__*/_jsx(Button, {
662
664
  type: "primary",
663
665
  className: "xmTtn",
@@ -665,7 +667,7 @@ var QueryFilter = function QueryFilter(_ref, ref) {
665
667
  onClick: function onClick() {
666
668
  return form.submit();
667
669
  },
668
- children: isOkText
670
+ children: isOkText || t('global.button.confirm')
669
671
  })]
670
672
  })
671
673
  }), renderButton ? /*#__PURE__*/_jsx(Form.Item, {
@@ -140,6 +140,8 @@ export type searchFieldType = {
140
140
  multiple?: boolean;
141
141
  /**预设常用的日期范围 { label: React.ReactNode, value: Dayjs | (() => Dayjs) | Dayjs[] }[]*/
142
142
  presets?: TimeRangePickerProps['presets'] | TimePickerProps['presets'];
143
+ /**是否显示时间或时间格式 */
144
+ showTimeFormat?: any;
143
145
  };
144
146
  export interface QueryFilterProps extends FormProps {
145
147
  data: searchFieldType[];
@@ -37,6 +37,7 @@ import PaginationV2 from "./components/PaginationV2";
37
37
  import { useColumnWidth } from "./hooks/useColumnWidth";
38
38
  import "./tableMax.less";
39
39
  import { downloadExcel, getFormatFilters, getFormatFiltersV2, getFormatSorting, operationColumnNoTooltips } from "./utils";
40
+ import { useTranslation } from "../../hooks/useTranslation";
40
41
  import { jsx as _jsx } from "react/jsx-runtime";
41
42
  import { jsxs as _jsxs } from "react/jsx-runtime";
42
43
  export var ColumnType = /*#__PURE__*/function (ColumnType) {
@@ -186,6 +187,9 @@ var TableMax = function TableMax(_ref) {
186
187
  request = _ref.request,
187
188
  onEditValueChange = _ref.onEditValueChange;
188
189
  var tableMaxRef = useRef(null);
190
+ var _useTranslation = useTranslation(),
191
+ _useTranslation2 = _slicedToArray(_useTranslation, 1),
192
+ t = _useTranslation2[0];
189
193
  var columns = useMemo(function () {
190
194
  // 给columns配置默认的过滤函数,排序函数,操作列取消tooltip
191
195
  return operationColumnNoTooltips(setDefaultSortFn(setDefaultFilterFn(cloneDeep(originColumns))));
@@ -1221,7 +1225,7 @@ var TableMax = function TableMax(_ref) {
1221
1225
  current: (skipCount || skipCount === 0) && pageSize ? skipCount / pageSize + 1 : 0,
1222
1226
  showSizeChanger: showSizeChanger,
1223
1227
  showTotal: function showTotal(total) {
1224
- return "\u5171 ".concat(total, " \u6761");
1228
+ return t('global.pagination.total', total);
1225
1229
  },
1226
1230
  size: 'small',
1227
1231
  onChange: function onChange(index, size) {
@@ -16,6 +16,7 @@ import { createPortal } from 'react-dom';
16
16
  import { useConfig } from "../../../ConfigProvider";
17
17
  import { ColumnType } from "../../index";
18
18
  import "./index.less";
19
+ import { useTranslation } from "../../../../hooks/useTranslation";
19
20
  import { jsx as _jsx } from "react/jsx-runtime";
20
21
  import { jsxs as _jsxs } from "react/jsx-runtime";
21
22
  var reorderColumn = function reorderColumn(draggedColumnId, targetColumnId, columnOrder) {
@@ -24,17 +25,21 @@ var reorderColumn = function reorderColumn(draggedColumnId, targetColumnId, colu
24
25
  };
25
26
  var headerRowNumOptions = [{
26
27
  value: 1,
27
- label: '1行'
28
+ label: '1行',
29
+ code: 'oneRow'
28
30
  }, {
29
31
  value: 2,
30
- label: '2行'
32
+ label: '2行',
33
+ code: 'twoRow'
31
34
  }, {
32
35
  value: 3,
33
- label: '3行'
36
+ label: '3行',
37
+ code: 'threeRow'
34
38
  }];
35
39
  var SettingItem = function SettingItem(_ref) {
36
40
  var _column$columnDef, _column$columnDef2;
37
- var table = _ref.table,
41
+ var t = _ref.t,
42
+ table = _ref.table,
38
43
  column = _ref.column,
39
44
  canSelection = _ref.canSelection,
40
45
  selectionWithoutChecked = _ref.selectionWithoutChecked,
@@ -74,31 +79,31 @@ var SettingItem = function SettingItem(_ref) {
74
79
  return [{
75
80
  icon: 'gudingliewei',
76
81
  value: 'right',
77
- tooltip: '固定列尾'
82
+ tooltip: t('global.setting.pinToTail')
78
83
  }, {
79
84
  icon: 'buguding',
80
85
  value: false,
81
- tooltip: '不固定'
86
+ tooltip: t('global.setting.unpin')
82
87
  }];
83
88
  case 'right':
84
89
  return [{
85
90
  icon: 'gudinglieshou',
86
91
  value: 'left',
87
- tooltip: '固定列首'
92
+ tooltip: t('global.setting.pinToHead')
88
93
  }, {
89
94
  icon: 'buguding',
90
95
  value: false,
91
- tooltip: '不固定'
96
+ tooltip: t('global.setting.unpin')
92
97
  }];
93
98
  case false:
94
99
  return [{
95
100
  icon: 'gudinglieshou',
96
101
  value: 'left',
97
- tooltip: '固定列首'
102
+ tooltip: t('global.setting.pinToHead')
98
103
  }, {
99
104
  icon: 'gudingliewei',
100
105
  value: 'right',
101
- tooltip: '固定列尾'
106
+ tooltip: t('global.setting.pinToTail')
102
107
  }];
103
108
  default:
104
109
  return [];
@@ -239,6 +244,9 @@ var ColumnSetting = function ColumnSetting(_ref3) {
239
244
  headerRowNum = _ref3.headerRowNum,
240
245
  onHeaderRowNumChange = _ref3.onHeaderRowNumChange,
241
246
  getRowCanExpand = _ref3.getRowCanExpand;
247
+ var _useTranslation = useTranslation(),
248
+ _useTranslation2 = _slicedToArray(_useTranslation, 1),
249
+ t = _useTranslation2[0];
242
250
  var _useConfig = useConfig(),
243
251
  root = _useConfig.root;
244
252
  var _useState = useState(false),
@@ -309,19 +317,19 @@ var ColumnSetting = function ColumnSetting(_ref3) {
309
317
  // canSelection && leftLength++;
310
318
  // eslint-disable-next-line @typescript-eslint/no-unused-expressions
311
319
  table.getLeftLeafColumns().length > leftLength && arr.push({
312
- groupName: '固定列首',
320
+ groupName: t('global.setting.pinToHead'),
313
321
  groupList: table.getLeftLeafColumns(),
314
322
  draggable: false
315
323
  });
316
324
  // eslint-disable-next-line @typescript-eslint/no-unused-expressions
317
325
  table.getCenterLeafColumns().length > 0 && arr.push({
318
- groupName: table.getLeftLeafColumns().length > leftLength || table.getRightLeafColumns().length > 0 ? '不固定' : '',
326
+ groupName: table.getLeftLeafColumns().length > leftLength || table.getRightLeafColumns().length > 0 ? t('global.setting.unpin') : '',
319
327
  groupList: table.getCenterLeafColumns(),
320
328
  draggable: true
321
329
  });
322
330
  // eslint-disable-next-line @typescript-eslint/no-unused-expressions
323
331
  table.getRightLeafColumns().length > 0 && arr.push({
324
- groupName: '固定列尾',
332
+ groupName: t('global.setting.pinToTail'),
325
333
  groupList: table.getRightLeafColumns(),
326
334
  draggable: false
327
335
  });
@@ -347,9 +355,13 @@ var ColumnSetting = function ColumnSetting(_ref3) {
347
355
  children: /*#__PURE__*/_jsxs("div", {
348
356
  className: "header-row-num-setting",
349
357
  children: [/*#__PURE__*/_jsx("span", {
350
- children: "\u6807\u9898\u884C\u6570"
358
+ children: t('global.setting.headerRowNum')
351
359
  }), /*#__PURE__*/_jsx(Segmented, {
352
- options: headerRowNumOptions,
360
+ options: t.tA(headerRowNumOptions, {
361
+ labelKey: 'label',
362
+ fieldKey: 'code',
363
+ groupPrefix: 'global.setting'
364
+ }),
353
365
  value: headerRowNum,
354
366
  onChange: onHeaderRowNumChange,
355
367
  style: {
@@ -364,14 +376,14 @@ var ColumnSetting = function ColumnSetting(_ref3) {
364
376
  children: [/*#__PURE__*/_jsx(Checkbox, {
365
377
  checked: table.getIsAllColumnsVisible(),
366
378
  onChange: table.getToggleAllColumnsVisibilityHandler(),
367
- children: "\u5168\u9009"
379
+ children: t('global.setting.selectAll')
368
380
  }), /*#__PURE__*/_jsx("span", {
369
381
  className: "reset",
370
382
  onClick: resetSetting,
371
383
  style: {
372
384
  cursor: 'pointer'
373
385
  },
374
- children: "\u91CD\u7F6E"
386
+ children: t('global.setting.reset')
375
387
  })]
376
388
  }), /*#__PURE__*/_jsx("div", {
377
389
  className: "column-setting-body",
@@ -384,6 +396,7 @@ var ColumnSetting = function ColumnSetting(_ref3) {
384
396
  }), item === null || item === void 0 || (_item$groupList = item.groupList) === null || _item$groupList === void 0 ? void 0 : _item$groupList.map(function (column) {
385
397
  // TODO: 待优化
386
398
  return column.id === ColumnType.Darg || column.id === ColumnType.Selection || column.id === ColumnType.Expander || column.parent || column.id === ColumnType.PlaceHolder ? null : /*#__PURE__*/_jsx(SettingItem, {
399
+ t: t,
387
400
  column: column,
388
401
  table: table,
389
402
  canSelection: canSelection,
@@ -1,13 +1,13 @@
1
1
  import { TableMaxColumnType } from "../../type";
2
- export declare const numberSortFn: (rowA: any, rowB: any, columnId: string) => 1 | -1 | 0;
3
- export declare const stringSortFn: (rowA: any, rowB: any, columnId: string) => 1 | -1 | 0;
4
- export declare const numberOrStringSortFn: (rowA: any, rowB: any, columnId: string) => 1 | -1 | 0;
5
- export declare const timeSortFn: (rowA: any, rowB: any, columnId: string) => 1 | -1 | 0;
2
+ export declare const numberSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
3
+ export declare const stringSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
4
+ export declare const numberOrStringSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
5
+ export declare const timeSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
6
6
  declare const customSortFns: {
7
- numberSortFn: (rowA: any, rowB: any, columnId: string) => 1 | -1 | 0;
8
- stringSortFn: (rowA: any, rowB: any, columnId: string) => 1 | -1 | 0;
9
- timeSortFn: (rowA: any, rowB: any, columnId: string) => 1 | -1 | 0;
10
- numberOrStringSortFn: (rowA: any, rowB: any, columnId: string) => 1 | -1 | 0;
7
+ numberSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
8
+ stringSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
9
+ timeSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
10
+ numberOrStringSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
11
11
  };
12
12
  export default customSortFns;
13
13
  export type SortFnType = keyof typeof customSortFns | undefined;
@@ -7,8 +7,15 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
7
7
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
8
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
9
9
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
10
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
11
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
12
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
13
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
14
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
15
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
10
16
  import { Pagination, Select } from 'antd';
11
17
  import "./index.less";
18
+ import { useTranslation } from "../../../../hooks/useTranslation";
12
19
  import { jsx as _jsx } from "react/jsx-runtime";
13
20
  import { jsxs as _jsxs } from "react/jsx-runtime";
14
21
  var defaultPageSizeOptions = [10, 20, 50, 100];
@@ -19,6 +26,9 @@ var pageSizeOptions = defaultPageSizeOptions.map(function (size) {
19
26
  };
20
27
  });
21
28
  var PaginationV2 = function PaginationV2(props) {
29
+ var _useTranslation = useTranslation(),
30
+ _useTranslation2 = _slicedToArray(_useTranslation, 1),
31
+ t = _useTranslation2[0];
22
32
  var showSizeChanger = props.showSizeChanger,
23
33
  curPageDataNum = props.curPageDataNum,
24
34
  rest = _objectWithoutProperties(props, _excluded);
@@ -30,11 +40,11 @@ var PaginationV2 = function PaginationV2(props) {
30
40
  className: "table-max-pagination-wrapper",
31
41
  children: [/*#__PURE__*/_jsx("div", {
32
42
  className: "total-info",
33
- children: "".concat(curPageDataNum, "\u6761/\u5171").concat(rest.total, "\u6761")
43
+ children: t('global.pagination.totalInfo', curPageDataNum, rest.total)
34
44
  }), showSizeChanger && /*#__PURE__*/_jsxs("div", {
35
45
  className: "size-changer-wrapper",
36
46
  children: [/*#__PURE__*/_jsx("span", {
37
- children: "\u6BCF\u9875"
47
+ children: t('global.pagination.perPage')
38
48
  }), /*#__PURE__*/_jsx(Select, {
39
49
  className: "size-changer",
40
50
  options: pageSizeOptions,
@@ -42,7 +52,7 @@ var PaginationV2 = function PaginationV2(props) {
42
52
  onChange: handleChangePageSize,
43
53
  value: rest.pageSize
44
54
  }), /*#__PURE__*/_jsx("span", {
45
- children: "\u6761"
55
+ children: t('global.pagination.pieces')
46
56
  })]
47
57
  }), /*#__PURE__*/_jsx(Pagination, _objectSpread(_objectSpread({
48
58
  className: "table-max-pagination"
@@ -0,0 +1,16 @@
1
+ import { Locale } from '../locales';
2
+ export type LocaleComponentName = Exclude<keyof Locale, 'locale'>;
3
+ type LocaleFunction = ((...rest: any) => string) & {
4
+ tA: (data: any[], options: TranslateOptions) => any[];
5
+ tT: (data: any[]) => any[];
6
+ tQ: (data: any[]) => any[];
7
+ tF: (data: any[]) => any[];
8
+ tB: (data: any[]) => any[];
9
+ };
10
+ type TranslateOptions = {
11
+ fieldKey: string;
12
+ labelKey: string;
13
+ groupPrefix?: string;
14
+ };
15
+ export declare const useTranslation: (locales?: Record<string, Omit<Locale, 'locale' extends keyof Locale ? never : 'locale'>>) => [LocaleFunction, getLocaleCode: string, switchLocale: (lang: string) => void];
16
+ export {};
@@ -0,0 +1,195 @@
1
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
2
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
3
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
4
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
5
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
9
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
10
+ import * as React from 'react';
11
+ import { FormItemType } from "../components/QueryFilter";
12
+ import { useConfig } from "../components/ConfigProvider";
13
+ function deepMerge(obj1, obj2) {
14
+ // 创建一个新对象,避免直接修改原始对象
15
+ var result = _objectSpread({}, obj1);
16
+
17
+ // 遍历 obj2 的所有属性
18
+ for (var key in obj2) {
19
+ if (obj2.hasOwnProperty(key)) {
20
+ // 如果 obj2 的属性值是一个对象,且 obj1 中也有这个属性且是对象,则递归合并
21
+ if (_typeof(obj2[key]) === "object" && obj2[key] !== null && _typeof(obj1[key]) === "object") {
22
+ result[key] = deepMerge(obj1[key], obj2[key]);
23
+ } else {
24
+ // 否则直接覆盖 obj1 的属性值
25
+ result[key] = obj2[key];
26
+ }
27
+ }
28
+ }
29
+ return result;
30
+ }
31
+
32
+ // 自定义 Hook useTranslation
33
+ export var useTranslation = function useTranslation(locales) {
34
+ // const topLocales = React.useContext<LocaleContextProps>(LocaleContext);
35
+ var _useConfig = useConfig(),
36
+ topLocales = _useConfig.locale;
37
+ var fullLocale = locales && locales[topLocales.locale] ? deepMerge(topLocales, locales[topLocales.locale]) : topLocales;
38
+ // 获取本地化文本的函数
39
+ var getLocalText = function getLocalText() {
40
+ for (var _len = arguments.length, rest = new Array(_len), _key = 0; _key < _len; _key++) {
41
+ rest[_key] = arguments[_key];
42
+ }
43
+ var key = rest[0],
44
+ placeholders = rest.slice(1);
45
+ // 根据 key 在字典中查找对应的文本
46
+ var text = fullLocale[key];
47
+
48
+ // 如果 key 是嵌套结构,递归查找
49
+ if (!text && key.includes(".")) {
50
+ var keys = key.split(".");
51
+ var current = fullLocale; // 使用 any 类型以便支持嵌套结构
52
+ var _iterator = _createForOfIteratorHelper(keys),
53
+ _step;
54
+ try {
55
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
56
+ var k = _step.value;
57
+ if (current && _typeof(current) === "object" && current[k]) {
58
+ current = current[k];
59
+ text = typeof current === "string" ? current : undefined;
60
+ } else {
61
+ text = undefined;
62
+ break;
63
+ }
64
+ }
65
+ } catch (err) {
66
+ _iterator.e(err);
67
+ } finally {
68
+ _iterator.f();
69
+ }
70
+ }
71
+
72
+ // 如果没有找到对应的文本,返回 key 作为默认值
73
+ if (!text || typeof text !== "string") {
74
+ console.warn("Missing translation for key: ".concat(key));
75
+ return key;
76
+ }
77
+
78
+ // 替换占位符
79
+ if (placeholders && placeholders.length > 0) {
80
+ placeholders.forEach(function (value, index) {
81
+ var _text;
82
+ // 构造动态正则表达式,避免特殊字符问题
83
+ var regex = new RegExp("\\{".concat(index, "\\}"), 'g');
84
+ // 安全转换为字符串,处理 null/undefined
85
+ text = (_text = text) === null || _text === void 0 ? void 0 : _text.replace(regex, String(value));
86
+ });
87
+ }
88
+ return text;
89
+ };
90
+ var enhancedLocaleFunction = Object.assign(getLocalText, {
91
+ //转换数组,通用逻辑
92
+ tA: function tA(data, options) {
93
+ var fieldKey = options.fieldKey,
94
+ labelKey = options.labelKey,
95
+ _options$groupPrefix = options.groupPrefix,
96
+ groupPrefix = _options$groupPrefix === void 0 ? "" : _options$groupPrefix;
97
+ var processArray = function processArray(array) {
98
+ return array.map(function (item) {
99
+ if (_typeof(item) === "object" && !Array.isArray(item)) {
100
+ var newItem = _objectSpread({}, item);
101
+ if (fieldKey in newItem) {
102
+ // 如果有分组前缀,动态拼接键
103
+ var translationKey = groupPrefix ? "".concat(groupPrefix, ".").concat(newItem[fieldKey]) : newItem[fieldKey];
104
+ newItem[labelKey] = enhancedLocaleFunction(translationKey);
105
+ }
106
+ for (var key in newItem) {
107
+ if (Array.isArray(newItem[key])) {
108
+ newItem[key] = processArray(newItem[key]);
109
+ }
110
+ }
111
+ return newItem;
112
+ } else if (Array.isArray(item)) {
113
+ return processArray(item);
114
+ }
115
+ return item;
116
+ });
117
+ };
118
+ return processArray(data);
119
+ },
120
+ //转换表格TableMax配置
121
+ tT: function tT(data) {
122
+ return data.map(function (item) {
123
+ return _objectSpread(_objectSpread({}, item), {}, {
124
+ header: enhancedLocaleFunction("apiField.".concat(item === null || item === void 0 ? void 0 : item.accessorKey))
125
+ });
126
+ });
127
+ },
128
+ //转换筛选QueryFilter配置
129
+ tQ: function tQ(data) {
130
+ var getInputTip = function getInputTip(formType) {
131
+ if (formType === FormItemType.DateRang) {
132
+ return {
133
+ start: enhancedLocaleFunction("global.placeholder.startTime"),
134
+ end: enhancedLocaleFunction("global.placeholder.endTime")
135
+ };
136
+ } else if (formType === FormItemType.Select) {
137
+ return enhancedLocaleFunction("global.placeholder.select");
138
+ } else if (formType === FormItemType.AutoComplete || formType === FormItemType.TextArea || formType === FormItemType.Text) {
139
+ return enhancedLocaleFunction("global.placeholder.input");
140
+ }
141
+ return enhancedLocaleFunction("global.placeholder.input");
142
+ };
143
+ return data.map(function (item) {
144
+ return _objectSpread(_objectSpread({}, item), {}, {
145
+ label: enhancedLocaleFunction("apiField.".concat(item === null || item === void 0 ? void 0 : item.field)),
146
+ inputTips: getInputTip(item.formType)
147
+ });
148
+ });
149
+ },
150
+ //转换自定义表单配置
151
+ tF: function tF(data) {
152
+ var getInputTip = function getInputTip(formType) {
153
+ if (formType === FormItemType.DateRang) {
154
+ return {
155
+ start: enhancedLocaleFunction("global.placeholder.startTime"),
156
+ end: enhancedLocaleFunction("global.placeholder.endTime")
157
+ };
158
+ } else if (formType === FormItemType.Select) {
159
+ return enhancedLocaleFunction("global.placeholder.select");
160
+ } else if (formType === FormItemType.AutoComplete || formType === FormItemType.TextArea || formType === FormItemType.Text) {
161
+ return enhancedLocaleFunction("global.placeholder.input");
162
+ }
163
+ return enhancedLocaleFunction("global.placeholder.input");
164
+ };
165
+ return data.map(function (item) {
166
+ return _objectSpread(_objectSpread({}, item), {}, {
167
+ label: enhancedLocaleFunction("apiField.".concat(item === null || item === void 0 ? void 0 : item.field)),
168
+ inputTips: getInputTip(item.formType)
169
+ });
170
+ });
171
+ },
172
+ //转换baseInfo配置
173
+ tB: function tB(data) {
174
+ return data.map(function (item) {
175
+ return _objectSpread(_objectSpread({}, item), {}, {
176
+ text: enhancedLocaleFunction("apiField.".concat(item === null || item === void 0 ? void 0 : item.field))
177
+ });
178
+ });
179
+ }
180
+ });
181
+ // 获取当前的语言代码
182
+ var getLocaleCode = React.useMemo(function () {
183
+ var localeCode = fullLocale === null || fullLocale === void 0 ? void 0 : fullLocale.locale;
184
+ // 如果使用了 LocaleProvider 但未设置 locale
185
+ // if (fullLocale?.exist && !localeCode) {
186
+ // return defaultLocaleData.locale; // 假设 defaultLocaleData 已定义
187
+ // }
188
+ // return localeCode ?? defaultLocaleData.locale; // 提供默认值
189
+ return localeCode;
190
+ }, [fullLocale]);
191
+ var switchLocale = React.useMemo(function () {
192
+ return fullLocale.switchLocale;
193
+ }, [fullLocale]);
194
+ return [enhancedLocaleFunction, getLocaleCode, switchLocale];
195
+ };
package/dist/index.d.ts CHANGED
@@ -40,3 +40,7 @@ export { default as useCenterModalState } from './hooks/useCenterModalState';
40
40
  export * from './hooks/useEventBus';
41
41
  export { default as useEventBus } from './hooks/useEventBus';
42
42
  export { default as usePageCacheState } from './hooks/usePageCacheState';
43
+ /**locale */
44
+ export { default as public_zhCN } from './locales/zh_CN';
45
+ export { default as public_enUS } from './locales/en_US';
46
+ export { default as public_viVN } from './locales/vi_VN';
package/dist/index.js CHANGED
@@ -42,4 +42,9 @@ export * from "./components/CacheTabs";
42
42
  export { default as useCenterModalState } from "./hooks/useCenterModalState";
43
43
  export * from "./hooks/useEventBus";
44
44
  export { default as useEventBus } from "./hooks/useEventBus";
45
- export { default as usePageCacheState } from "./hooks/usePageCacheState";
45
+ export { default as usePageCacheState } from "./hooks/usePageCacheState";
46
+
47
+ /**locale */
48
+ export { default as public_zhCN } from "./locales/zh_CN";
49
+ export { default as public_enUS } from "./locales/en_US";
50
+ export { default as public_viVN } from "./locales/vi_VN";
@@ -0,0 +1,3 @@
1
+ import { Locale } from '.';
2
+ declare const localeValues: Locale;
3
+ export default localeValues;
@@ -0,0 +1,19 @@
1
+ var localeValues = {
2
+ locale: 'en_US',
3
+ // locales for globals
4
+ global: {
5
+ placeholder: {},
6
+ button: {
7
+ cancel: '取消',
8
+ confirm: '确定'
9
+ },
10
+ text: {
11
+ emptyText: 'no data'
12
+ },
13
+ message: {},
14
+ pagination: {
15
+ total: '共{0}条'
16
+ }
17
+ }
18
+ };
19
+ export default localeValues;
@@ -0,0 +1,9 @@
1
+ export declare const ANT_MARK = "internalMark";
2
+ export type LocaleContextProps = Locale & {
3
+ exist?: boolean;
4
+ };
5
+ export interface Locale {
6
+ locale: string;
7
+ global?: Record<string, any>;
8
+ [prop: string]: any;
9
+ }
@@ -0,0 +1 @@
1
+ export var ANT_MARK = 'internalMark';
@@ -0,0 +1,3 @@
1
+ import { Locale } from '.';
2
+ declare const localeValues: Locale;
3
+ export default localeValues;
@@ -0,0 +1,19 @@
1
+ var localeValues = {
2
+ locale: 'vi_VN',
3
+ // locales for globals
4
+ global: {
5
+ placeholder: {},
6
+ button: {
7
+ cancel: '取消',
8
+ confirm: '确定'
9
+ },
10
+ text: {
11
+ emptyText: '暂无数据'
12
+ },
13
+ message: {},
14
+ pagination: {
15
+ total: '共{0}条'
16
+ }
17
+ }
18
+ };
19
+ export default localeValues;
@@ -0,0 +1,3 @@
1
+ import { Locale } from '.';
2
+ declare const localeValues: Locale;
3
+ export default localeValues;
@@ -0,0 +1,42 @@
1
+ var localeValues = {
2
+ locale: 'zh_CN',
3
+ // locales for globals
4
+ global: {
5
+ setting: {
6
+ "oneRow": "1行",
7
+ "twoRow": "2行",
8
+ "threeRow": "3行",
9
+ "pinToTail": "固定列尾",
10
+ "unpin": "不固定",
11
+ "pinToHead": "固定列首",
12
+ "showFilter": "显示筛选",
13
+ "headerRowNum": "标题行数",
14
+ "selectAll": "全选",
15
+ "reset": "重置"
16
+ },
17
+ placeholder: {},
18
+ button: {
19
+ reset: '重置',
20
+ cancel: '取消',
21
+ confirm: '确定'
22
+ },
23
+ text: {
24
+ emptyText: '暂无数据'
25
+ },
26
+ message: {
27
+ confirmDeleteTitle: '确认删除这条信息吗?',
28
+ confirmDeleteSubTitle: '删除后可能无法恢复,请谨慎操作!',
29
+ deleting: '删除中',
30
+ actioning: '{0}中',
31
+ successAction: '{0}成功',
32
+ deleteSuccess: '删除成功'
33
+ },
34
+ pagination: {
35
+ total: '共{0}条',
36
+ totalInfo: '{0}条/共{1}条',
37
+ perPage: '每页',
38
+ pieces: '条'
39
+ }
40
+ }
41
+ };
42
+ export default localeValues;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arim-aisdc/public-components",
3
- "version": "2.3.1",
3
+ "version": "2.3.2",
4
4
  "description": "前端组件库",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",