@vtx/modals2 6.0.0-beta.0 → 6.0.0-beta.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.
|
@@ -9,15 +9,14 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
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
10
|
import { Calendar, Progress } from 'antd';
|
|
11
11
|
import classnames from 'classnames';
|
|
12
|
-
import dayjs from "../../_util/setupDayjs";
|
|
13
12
|
import useSettings from "../../_hooks/useSettings";
|
|
14
13
|
import "./style";
|
|
15
|
-
import zhCN from 'antd/es/calendar/locale/zh_CN.js';
|
|
16
14
|
import enUS from 'antd/es/calendar/locale/en_US.js';
|
|
17
|
-
import
|
|
15
|
+
import zhCN from 'antd/es/calendar/locale/zh_CN.js';
|
|
18
16
|
import BlockA from "../../_imgs/block_alarm.png";
|
|
19
17
|
import BlockN from "../../_imgs/block_normal.png";
|
|
20
18
|
import { transformRgb } from "../../_util";
|
|
19
|
+
import { getRuntimeLanguage } from "./../../hooks/useTranslation.js";
|
|
21
20
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
22
21
|
var prefix = 'vm-calendar';
|
|
23
22
|
function VmCalendar(props) {
|
|
@@ -40,7 +39,7 @@ function VmCalendar(props) {
|
|
|
40
39
|
'--height': height + 'px'
|
|
41
40
|
}),
|
|
42
41
|
children: /*#__PURE__*/_jsx(Calendar, _objectSpread({
|
|
43
|
-
locale:
|
|
42
|
+
locale: getRuntimeLanguage() === 'zh-CN' ? zhCN : enUS,
|
|
44
43
|
headerRender: function headerRender() {
|
|
45
44
|
return null;
|
|
46
45
|
},
|
|
@@ -13,14 +13,14 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
13
13
|
import { SearchOutlined } from '@ant-design/icons';
|
|
14
14
|
import { useDebounce } from 'ahooks';
|
|
15
15
|
import { DatePicker, Input, Select } from 'antd';
|
|
16
|
-
import zhCN from 'antd/es/date-picker/locale/zh_CN';
|
|
17
16
|
import enUS from 'antd/es/date-picker/locale/en_US';
|
|
18
|
-
import
|
|
19
|
-
import "
|
|
17
|
+
import zhCN from 'antd/es/date-picker/locale/zh_CN';
|
|
18
|
+
import { getRuntimeLanguage, translateLocaleText } from "./../../hooks/useTranslation.js";
|
|
20
19
|
import { useEffect, useState } from 'react';
|
|
21
20
|
import useSettings from "../../_hooks/useSettings";
|
|
22
|
-
import "
|
|
21
|
+
import "../../_util/setupDayjs";
|
|
23
22
|
import VmEmpty from "../vm-empty";
|
|
23
|
+
import "./style";
|
|
24
24
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
25
25
|
var RangePicker = DatePicker.RangePicker,
|
|
26
26
|
MonthPicker = DatePicker.MonthPicker,
|
|
@@ -42,7 +42,7 @@ export var VMRangePicker = function VMRangePicker(props) {
|
|
|
42
42
|
},
|
|
43
43
|
allowClear: false
|
|
44
44
|
}, props), {}, {
|
|
45
|
-
locale:
|
|
45
|
+
locale: getRuntimeLanguage() === 'zh-CN' ? zhCN : enUS
|
|
46
46
|
}));
|
|
47
47
|
};
|
|
48
48
|
export var VMDatePicker = function VMDatePicker(props) {
|
|
@@ -57,7 +57,7 @@ export var VMDatePicker = function VMDatePicker(props) {
|
|
|
57
57
|
},
|
|
58
58
|
allowClear: false
|
|
59
59
|
}, props), {}, {
|
|
60
|
-
locale:
|
|
60
|
+
locale: getRuntimeLanguage() === 'zh-CN' ? zhCN : enUS
|
|
61
61
|
}));
|
|
62
62
|
};
|
|
63
63
|
export var VMMonthPicker = function VMMonthPicker(props) {
|
|
@@ -72,7 +72,7 @@ export var VMMonthPicker = function VMMonthPicker(props) {
|
|
|
72
72
|
},
|
|
73
73
|
allowClear: false
|
|
74
74
|
}, props), {}, {
|
|
75
|
-
locale:
|
|
75
|
+
locale: getRuntimeLanguage() === 'zh-CN' ? zhCN : enUS
|
|
76
76
|
}));
|
|
77
77
|
};
|
|
78
78
|
export var VMYearPicker = function VMYearPicker(props) {
|
|
@@ -87,7 +87,7 @@ export var VMYearPicker = function VMYearPicker(props) {
|
|
|
87
87
|
},
|
|
88
88
|
allowClear: false
|
|
89
89
|
}, props), {}, {
|
|
90
|
-
locale:
|
|
90
|
+
locale: getRuntimeLanguage() === 'zh-CN' ? zhCN : enUS
|
|
91
91
|
}));
|
|
92
92
|
};
|
|
93
93
|
export var VMSelect = function VMSelect(props) {
|
|
@@ -21,12 +21,12 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
21
21
|
import { DownOutlined, ExportOutlined } from '@ant-design/icons';
|
|
22
22
|
import { useMemoizedFn, useSetState } from 'ahooks';
|
|
23
23
|
import { Button, ConfigProvider, Dropdown, Table } from 'antd';
|
|
24
|
-
import zhCN from 'antd/es/locale/zh_CN';
|
|
25
24
|
import enUS from 'antd/es/locale/en_US';
|
|
25
|
+
import zhCN from 'antd/es/locale/zh_CN';
|
|
26
26
|
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
27
27
|
import useSettings from "../../_hooks/useSettings";
|
|
28
28
|
import "./style";
|
|
29
|
-
import {
|
|
29
|
+
import { getRuntimeLanguage, translateLocaleText } from "./../../hooks/useTranslation.js";
|
|
30
30
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
31
31
|
var VMTable = function VMTable(props) {
|
|
32
32
|
var _props$rowKey = props.rowKey,
|
|
@@ -136,7 +136,7 @@ var VMTable = function VMTable(props) {
|
|
|
136
136
|
}
|
|
137
137
|
}, [JSON.stringify(dataSource), JSON.stringify(currentLayer)]);
|
|
138
138
|
return /*#__PURE__*/_jsx(ConfigProvider, {
|
|
139
|
-
locale:
|
|
139
|
+
locale: getRuntimeLanguage() === 'zh-CN' ? zhCN : enUS,
|
|
140
140
|
children: /*#__PURE__*/_jsx(Table, _objectSpread({
|
|
141
141
|
className: "vm-table ".concat(isDark ? 'dark' : ''),
|
|
142
142
|
ref: tableRef,
|
|
@@ -10,7 +10,6 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
10
10
|
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
11
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
12
12
|
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); }
|
|
13
|
-
import { useIntl } from 'dumi';
|
|
14
13
|
import zhCN from "../locales/zh-CN.json";
|
|
15
14
|
import enUS from "../locales/en.json";
|
|
16
15
|
var keyFieldMap = {
|
|
@@ -57,9 +56,9 @@ export function getTranslationKey(text) {
|
|
|
57
56
|
return undefined;
|
|
58
57
|
}
|
|
59
58
|
var match = text.match(/^t\('([^']+)'\)$/);
|
|
60
|
-
return match
|
|
59
|
+
return match === null || match === void 0 ? void 0 : match[1];
|
|
61
60
|
}
|
|
62
|
-
function
|
|
61
|
+
function getHashLanguage() {
|
|
63
62
|
if (typeof window === 'undefined') {
|
|
64
63
|
return undefined;
|
|
65
64
|
}
|
|
@@ -70,13 +69,13 @@ function getHashLocale() {
|
|
|
70
69
|
}
|
|
71
70
|
return new URLSearchParams(hash.slice(queryIndex + 1)).get('vtxLanguage') || undefined;
|
|
72
71
|
}
|
|
73
|
-
export function
|
|
74
|
-
var _window$localStorage
|
|
75
|
-
var
|
|
76
|
-
var
|
|
77
|
-
var
|
|
78
|
-
var
|
|
79
|
-
return
|
|
72
|
+
export function getRuntimeLanguage() {
|
|
73
|
+
var _window$localStorage;
|
|
74
|
+
var searchLanguage = typeof window !== 'undefined' ? new URLSearchParams(window.location.search).get('vtxLanguage') : undefined;
|
|
75
|
+
var hashLanguage = getHashLanguage();
|
|
76
|
+
var storedLanguage = typeof window !== 'undefined' ? (_window$localStorage = window.localStorage) === null || _window$localStorage === void 0 ? void 0 : _window$localStorage.getItem('vtxLanguage') : undefined;
|
|
77
|
+
var language = searchLanguage || hashLanguage || storedLanguage;
|
|
78
|
+
return language === 'en-US' || language === 'en_US' || language === 'en-us' || language === 'en' ? 'en-US' : 'zh-CN';
|
|
80
79
|
}
|
|
81
80
|
function formatMessage(template, values) {
|
|
82
81
|
if (!values) {
|
|
@@ -98,20 +97,20 @@ export function translateLocaleText(text, values) {
|
|
|
98
97
|
if (!key) {
|
|
99
98
|
return text;
|
|
100
99
|
}
|
|
101
|
-
var
|
|
102
|
-
var localeData =
|
|
100
|
+
var language = getRuntimeLanguage();
|
|
101
|
+
var localeData = language === 'en-US' ? enUS : zhCN;
|
|
103
102
|
return formatMessage(localeData[key] || zhCN[key] || key, values);
|
|
104
103
|
}
|
|
105
104
|
function applyKeyFields(source, t) {
|
|
106
105
|
var next = _objectSpread({}, source);
|
|
107
|
-
Object.entries(keyFieldMap).
|
|
108
|
-
var
|
|
109
|
-
keyField =
|
|
110
|
-
targetField =
|
|
106
|
+
for (var _i = 0, _Object$entries = Object.entries(keyFieldMap); _i < _Object$entries.length; _i++) {
|
|
107
|
+
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
108
|
+
keyField = _Object$entries$_i[0],
|
|
109
|
+
targetField = _Object$entries$_i[1];
|
|
111
110
|
if (typeof source[keyField] === 'string' && source[keyField]) {
|
|
112
111
|
next[targetField] = translationByKey(source[keyField], t);
|
|
113
112
|
}
|
|
114
|
-
}
|
|
113
|
+
}
|
|
115
114
|
return next;
|
|
116
115
|
}
|
|
117
116
|
function _translationConst(lists, t) {
|
|
@@ -193,19 +192,18 @@ function _translationConst(lists, t) {
|
|
|
193
192
|
return loopOptions(lists);
|
|
194
193
|
}
|
|
195
194
|
export { _translationConst as translationConst };
|
|
196
|
-
export function getT(
|
|
195
|
+
export function getT() {
|
|
197
196
|
var t = function t(id, values) {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
197
|
+
var language = getRuntimeLanguage();
|
|
198
|
+
var localeData = language === 'en-US' ? enUS : zhCN;
|
|
199
|
+
return formatMessage(localeData[id] || zhCN[id] || id, values);
|
|
201
200
|
};
|
|
202
201
|
return {
|
|
203
202
|
t: t
|
|
204
203
|
};
|
|
205
204
|
}
|
|
206
205
|
export function useTranslation() {
|
|
207
|
-
var
|
|
208
|
-
var _getT = getT(intl),
|
|
206
|
+
var _getT = getT(),
|
|
209
207
|
t = _getT.t;
|
|
210
208
|
return {
|
|
211
209
|
t: t,
|