@_tc/template-core 0.2.0-bate.12 → 0.2.0-bate.14
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/cjs/app/controller/view.js +1 -1
- package/cjs/app/view/entry.tpl +1 -0
- package/esm/app/controller/view.js +1 -0
- package/esm/app/view/entry.tpl +1 -0
- package/fe/frontend/src/components/AsyncSelect/AsyncSelect.js +10 -2
- package/fe/frontend/src/components/LanguageSwitch/LanguageSwitch.js +2 -1
- package/fe/frontend/src/defaultPages/SidebarSlotPageTmp.js +4 -2
- package/fe/packages/react/ui/components/Date/Calendar.js +9 -5
- package/fe/packages/react/ui/components/Date/LocaleContext.d.ts +22 -1
- package/fe/packages/react/ui/components/Date/LocaleContext.js +28 -3
- package/fe/packages/react/ui/components/Date/LocaleProvider.d.ts +1 -1
- package/fe/packages/react/ui/components/Date/LocaleProvider.js +7 -16
- package/fe/packages/react/ui/components/Date/index.js +2 -2
- package/fe/packages/react/ui/components/Date/locales.d.ts +2 -0
- package/fe/packages/react/ui/components/Date/locales.js +29 -13
- package/fe/packages/react/ui/components/TableSearch/TableSearch.js +21 -1
- package/fe/packages/react/ui/components/TableSearch/lang.d.ts +2 -0
- package/fe/packages/react/ui/components/TableSearch/lang.js +18 -7
- package/model/packages/react/ui/components/Date/LocaleContext.d.ts +22 -1
- package/model/packages/react/ui/components/Date/LocaleProvider.d.ts +1 -1
- package/model/packages/react/ui/components/Date/locales.d.ts +2 -0
- package/model/packages/react/ui/components/TableSearch/lang.d.ts +2 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../../packages/common/string/index.js`);var t=e=>JSON.stringify(e).replace(/</g,`\\u003c`).replace(/>/g,`\\u003e`).replace(/&/g,`\\u0026`).replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`),n=(n=>class{async renderPage(r,i){let a=r.path;if(n.extends.localCacheHtmlEtag.keepFreshFEBuildKey(),a.includes(`${n.options.apiPrefix}/`))await i();else{n.extends.logger.log(` - render page: `+r.params.page);try{let i=r.query.projk;Array.isArray(i)&&(i=e.joinStr(...i));let a={projKey:i??``,name:n.options?.name??``,env:n.envs.get(),basePath:t(`${n.options.pageBasePage}${r.params.page}`),projKeyJson:t(String(r.query.projk??``)),signKey:t(n.config.signKey),options:t(n.options)},o=n.extends.renderView(`${r.params.page}.entry.tpl`,r,a),s=e.joinStr(a.basePath,a.name,a.env,a.projKey);if(!n.extends.localCacheHtmlEtag.hasEtag(s)){let e=n.extends.crypto.hmacSign(o);n.extends.localCacheHtmlEtag.setEtag(s,e)}let c=n.extends.localCacheHtmlEtag.getEtag(s);if(c||console.log(`---- etag 缓存异常 请检查服务 ----`),r.etag=c??Date.now()+``,r.fresh){r.status=304;return}}catch(e){console.log(`-------------- render view error --------------`),console.log(e),n.extends.generateErrorMessage(`template not found`,{status:404,showError:!0,code:0})}}}});module.exports=n;
|
|
1
|
+
const e=require(`../../packages/common/string/index.js`);var t=e=>JSON.stringify(e).replace(/</g,`\\u003c`).replace(/>/g,`\\u003e`).replace(/&/g,`\\u0026`).replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`),n=(n=>class{async renderPage(r,i){let a=r.path;if(n.extends.localCacheHtmlEtag.keepFreshFEBuildKey(),a.includes(`${n.options.apiPrefix}/`))await i();else{n.extends.logger.log(` - render page: `+r.params.page);try{let i=r.query.projk;Array.isArray(i)&&(i=e.joinStr(...i));let a={projKey:i??``,name:n.options?.name??``,env:n.envs.get(),FEBasePage:t(`${n.options.pageBasePage}`),basePath:t(`${n.options.pageBasePage}${r.params.page}`),projKeyJson:t(String(r.query.projk??``)),signKey:t(n.config.signKey),options:t(n.options)},o=n.extends.renderView(`${r.params.page}.entry.tpl`,r,a),s=e.joinStr(a.basePath,a.name,a.env,a.projKey);if(!n.extends.localCacheHtmlEtag.hasEtag(s)){let e=n.extends.crypto.hmacSign(o);n.extends.localCacheHtmlEtag.setEtag(s,e)}let c=n.extends.localCacheHtmlEtag.getEtag(s);if(c||console.log(`---- etag 缓存异常 请检查服务 ----`),r.etag=c??Date.now()+``,r.fresh){r.status=304;return}}catch(e){console.log(`-------------- render view error --------------`),console.log(e),n.extends.generateErrorMessage(`template not found`,{status:404,showError:!0,code:0})}}}});module.exports=n;
|
package/cjs/app/view/entry.tpl
CHANGED
|
@@ -13,6 +13,7 @@ var t = (e) => JSON.stringify(e).replace(/</g, "\\u003c").replace(/>/g, "\\u003e
|
|
|
13
13
|
projKey: i ?? "",
|
|
14
14
|
name: n.options?.name ?? "",
|
|
15
15
|
env: n.envs.get(),
|
|
16
|
+
FEBasePage: t(`${n.options.pageBasePage}`),
|
|
16
17
|
basePath: t(`${n.options.pageBasePage}${r.params.page}`),
|
|
17
18
|
projKeyJson: t(String(r.query.projk ?? "")),
|
|
18
19
|
signKey: t(n.config.signKey),
|
package/esm/app/view/entry.tpl
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { Select } from "../../../../packages/react/ui/components/Select/Select.js";
|
|
2
2
|
import "../../../../packages/react/ui/index.js";
|
|
3
3
|
import { request } from "../../common/request.js";
|
|
4
|
+
import { useText } from "../../hooks/useText.js";
|
|
4
5
|
import { handlingRequestErrors } from "../../common/fetchErrorShow.js";
|
|
5
6
|
import useExecuteOnce from "../../../../packages/react/hooks/useExecuteOnce.js";
|
|
6
|
-
import { useState, useTransition } from "react";
|
|
7
|
+
import { useMemo, useState, useTransition } from "react";
|
|
7
8
|
import { jsx } from "react/jsx-runtime";
|
|
8
9
|
//#region frontend/src/components/AsyncSelect/AsyncSelect.tsx
|
|
9
10
|
var AsyncSelect = (props) => {
|
|
10
11
|
const { fetchConfig, ...params } = props;
|
|
12
|
+
const text = useText();
|
|
11
13
|
const [options, setOptions] = useState([]);
|
|
12
14
|
const [loading, setLoading] = useState(false);
|
|
13
15
|
const [lzayLoading, startTranstion] = useTransition();
|
|
@@ -26,9 +28,15 @@ var AsyncSelect = (props) => {
|
|
|
26
28
|
}
|
|
27
29
|
});
|
|
28
30
|
}, { executionPhase: "mount" });
|
|
31
|
+
const options_ = useMemo(() => {
|
|
32
|
+
return options.map((i) => {
|
|
33
|
+
i.label = i.searchText = text(i.searchText);
|
|
34
|
+
return i;
|
|
35
|
+
});
|
|
36
|
+
}, [options, text]);
|
|
29
37
|
return /* @__PURE__ */ jsx(Select, {
|
|
30
38
|
loading: lzayLoading || loading,
|
|
31
|
-
options,
|
|
39
|
+
options: options_,
|
|
32
40
|
...params
|
|
33
41
|
});
|
|
34
42
|
};
|
|
@@ -42,7 +42,8 @@ var LanguageSwitch = ({ value, defaultValue, options, onChange, className, butto
|
|
|
42
42
|
]);
|
|
43
43
|
const selectedLanguage = value ?? currentLanguage ?? defaultValue;
|
|
44
44
|
const selectedOption = mergedOptions.find((option) => option.value === selectedLanguage);
|
|
45
|
-
|
|
45
|
+
let displayText = selectedOption?.label ?? (placeholder || frontendLangKeys.languageSwitchPlaceholder);
|
|
46
|
+
if (typeof displayText === "string") displayText = text(displayText);
|
|
46
47
|
const handleChange = useCallback((language) => {
|
|
47
48
|
if (!language) return;
|
|
48
49
|
const nextLanguage = String(language);
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { generateMenuItemData } from "../common/generateMenuData.js";
|
|
2
2
|
import { useModeStore } from "../stores/mode.js";
|
|
3
3
|
import { leftSidebarBasePath } from "../common/menu.js";
|
|
4
|
+
import { useText } from "../hooks/useText.js";
|
|
4
5
|
import SidebarSlotContainer from "./SidebarSlotPage/SidebarSlotContainer.js";
|
|
5
6
|
import { useMemo } from "react";
|
|
6
7
|
import { jsx } from "react/jsx-runtime";
|
|
7
8
|
//#region frontend/src/defaultPages/SidebarSlotPageTmp.tsx
|
|
8
9
|
var SidebarSlotPageTmp = () => {
|
|
9
10
|
const projInfo = useModeStore((s) => s.projectInfo);
|
|
11
|
+
const text = useText();
|
|
10
12
|
const [menuItems, rawMenuData] = useMemo(() => {
|
|
11
|
-
if (projInfo) return [generateMenuItemData(projInfo.menu), projInfo.menu];
|
|
13
|
+
if (projInfo) return [generateMenuItemData(projInfo.menu, text), projInfo.menu];
|
|
12
14
|
return [[], []];
|
|
13
|
-
}, [projInfo]);
|
|
15
|
+
}, [projInfo, text]);
|
|
14
16
|
return /* @__PURE__ */ jsx(SidebarSlotContainer, {
|
|
15
17
|
prefixPath: "/" + leftSidebarBasePath,
|
|
16
18
|
rawMenuData,
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { useI18nStore } from "../../i18n/useI18n.js";
|
|
2
|
+
import "../../i18n/index.js";
|
|
1
3
|
import { cn } from "../../lib/utils.js";
|
|
2
4
|
import { Button } from "../Button/Button.js";
|
|
3
5
|
import "../Button/index.js";
|
|
@@ -8,14 +10,16 @@ import { useMemo, useState } from "react";
|
|
|
8
10
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
11
|
import { ChevronLeft, ChevronRight, ChevronsLeft, ChevronsRight } from "lucide-react";
|
|
10
12
|
import { addMonths, addYears, eachDayOfInterval, endOfDay, endOfMonth, endOfWeek, format, isAfter, isBefore, isSameDay, isSameMonth, startOfDay, startOfMonth, startOfWeek, subDays, subMonths, subYears } from "date-fns";
|
|
11
|
-
import { zhCN } from "date-fns/locale";
|
|
13
|
+
import { enUS, zhCN } from "date-fns/locale";
|
|
12
14
|
//#region packages/react/ui/components/Date/Calendar.tsx
|
|
13
15
|
function Calendar({ mode = ModeType.Single, value, onChange, disabledDate, showTime, className, locale: customLocale, quickRanges }) {
|
|
16
|
+
const language = useI18nStore((state) => state.language);
|
|
14
17
|
const contextLocale = useDateLocale();
|
|
15
18
|
const locale = useMemo(() => ({
|
|
16
19
|
...contextLocale,
|
|
17
20
|
...customLocale
|
|
18
21
|
}), [contextLocale, customLocale]);
|
|
22
|
+
const dateFnsLocale = language === "zh-CN" ? zhCN : enUS;
|
|
19
23
|
const [pendingValue, setPendingValue] = useState(value ?? null);
|
|
20
24
|
const [currentMonth, setCurrentMonth] = useState(() => {
|
|
21
25
|
if (value instanceof Date) return value;
|
|
@@ -28,11 +32,11 @@ function Calendar({ mode = ModeType.Single, value, onChange, disabledDate, showT
|
|
|
28
32
|
const monthEnd = endOfMonth(monthStart);
|
|
29
33
|
const daysInGrid = eachDayOfInterval({
|
|
30
34
|
start: startOfWeek(monthStart, {
|
|
31
|
-
locale:
|
|
35
|
+
locale: dateFnsLocale,
|
|
32
36
|
weekStartsOn: 0
|
|
33
37
|
}),
|
|
34
38
|
end: endOfWeek(monthEnd, {
|
|
35
|
-
locale:
|
|
39
|
+
locale: dateFnsLocale,
|
|
36
40
|
weekStartsOn: 0
|
|
37
41
|
})
|
|
38
42
|
});
|
|
@@ -46,7 +50,7 @@ function Calendar({ mode = ModeType.Single, value, onChange, disabledDate, showT
|
|
|
46
50
|
daysInGrid.push(...extraDays);
|
|
47
51
|
}
|
|
48
52
|
return daysInGrid;
|
|
49
|
-
}, [currentMonth]);
|
|
53
|
+
}, [currentMonth, dateFnsLocale]);
|
|
50
54
|
const weekDays = locale.weekDays;
|
|
51
55
|
const isRangeMode = mode === ModeType.Range;
|
|
52
56
|
const builtInQuickRanges = useMemo(() => [
|
|
@@ -238,7 +242,7 @@ function Calendar({ mode = ModeType.Single, value, onChange, disabledDate, showT
|
|
|
238
242
|
}),
|
|
239
243
|
/* @__PURE__ */ jsx("div", {
|
|
240
244
|
className: "font-medium text-sm",
|
|
241
|
-
children: format(currentMonth, locale.monthFormat, { locale:
|
|
245
|
+
children: format(currentMonth, locale.monthFormat, { locale: dateFnsLocale })
|
|
242
246
|
}),
|
|
243
247
|
/* @__PURE__ */ jsxs("div", {
|
|
244
248
|
className: "flex items-center gap-1",
|
|
@@ -1 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
import { type DateLocaleConfig } from "./locales";
|
|
2
|
+
export declare const DateLocaleContext: import("react").Context<Partial<DateLocaleConfig> | undefined>;
|
|
3
|
+
export declare const useDateLocale: () => {
|
|
4
|
+
placeholder: string;
|
|
5
|
+
placeholderDateTime: string;
|
|
6
|
+
placeholderRange: string;
|
|
7
|
+
placeholderDateTimeRange: string;
|
|
8
|
+
weekDays: string[];
|
|
9
|
+
selectTime: string;
|
|
10
|
+
startTime: string;
|
|
11
|
+
endTime: string;
|
|
12
|
+
confirm: string;
|
|
13
|
+
monthFormat: string;
|
|
14
|
+
quickRanges: string;
|
|
15
|
+
quickRangeToday: string;
|
|
16
|
+
quickRangeYesterday: string;
|
|
17
|
+
quickRangeLast7Days: string;
|
|
18
|
+
quickRangeLast30Days: string;
|
|
19
|
+
quickRangeThisMonth: string;
|
|
20
|
+
quickRangeLastYear: string;
|
|
21
|
+
clear: string;
|
|
22
|
+
};
|
|
@@ -1,11 +1,36 @@
|
|
|
1
|
+
import { useI18nStore } from "../../i18n/useI18n.js";
|
|
2
|
+
import "../../i18n/index.js";
|
|
3
|
+
import { defaultLocale, getDateLocale } from "./locales.js";
|
|
1
4
|
import { useDateLocaleStore } from "./dateLocaleStore.js";
|
|
5
|
+
import { createContext, useContext, useMemo } from "react";
|
|
2
6
|
//#region packages/react/ui/components/Date/LocaleContext.tsx
|
|
7
|
+
var DateLocaleContext = createContext(void 0);
|
|
3
8
|
/**
|
|
4
9
|
* Hook for accessing the current Date component locale.
|
|
5
|
-
* Backed by
|
|
10
|
+
* Backed by the shared i18n store, so Date updates with the global language.
|
|
6
11
|
*/
|
|
7
12
|
var useDateLocale = () => {
|
|
8
|
-
|
|
13
|
+
const language = useI18nStore((state) => state.language);
|
|
14
|
+
const fallbackLanguage = useI18nStore((state) => state.fallbackLanguage);
|
|
15
|
+
const resources = useI18nStore((state) => state.resources);
|
|
16
|
+
const storeLocale = useDateLocaleStore((state) => state.locale);
|
|
17
|
+
const localeOverride = useContext(DateLocaleContext);
|
|
18
|
+
const storeLocaleOverride = storeLocale === defaultLocale ? void 0 : storeLocale;
|
|
19
|
+
return useMemo(() => ({
|
|
20
|
+
...getDateLocale({
|
|
21
|
+
language,
|
|
22
|
+
fallbackLanguage,
|
|
23
|
+
resources
|
|
24
|
+
}),
|
|
25
|
+
...storeLocaleOverride,
|
|
26
|
+
...localeOverride
|
|
27
|
+
}), [
|
|
28
|
+
fallbackLanguage,
|
|
29
|
+
language,
|
|
30
|
+
localeOverride,
|
|
31
|
+
resources,
|
|
32
|
+
storeLocaleOverride
|
|
33
|
+
]);
|
|
9
34
|
};
|
|
10
35
|
//#endregion
|
|
11
|
-
export { useDateLocale };
|
|
36
|
+
export { DateLocaleContext, useDateLocale };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
2
|
import { type DateLocaleConfig } from "./locales";
|
|
3
3
|
export interface DateLocaleProviderProps {
|
|
4
|
-
locale?: DateLocaleConfig
|
|
4
|
+
locale?: Partial<DateLocaleConfig>;
|
|
5
5
|
children: ReactNode;
|
|
6
6
|
}
|
|
7
7
|
export declare function DateLocaleProvider({ locale, children }: DateLocaleProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { useEffect } from "react";
|
|
4
|
-
import { Fragment as Fragment$1, jsx } from "react/jsx-runtime";
|
|
1
|
+
import { DateLocaleContext } from "./LocaleContext.js";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
3
|
//#region packages/react/ui/components/Date/LocaleProvider.tsx
|
|
6
4
|
/**
|
|
7
5
|
* Date 组件文案配置 Provider
|
|
@@ -14,18 +12,11 @@ import { Fragment as Fragment$1, jsx } from "react/jsx-runtime";
|
|
|
14
12
|
* </DateLocaleProvider>
|
|
15
13
|
* ```
|
|
16
14
|
*/
|
|
17
|
-
function DateLocaleProvider({ locale
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return () => resetLocale();
|
|
23
|
-
}, [
|
|
24
|
-
locale,
|
|
25
|
-
replaceLocale,
|
|
26
|
-
resetLocale
|
|
27
|
-
]);
|
|
28
|
-
return /* @__PURE__ */ jsx(Fragment$1, { children });
|
|
15
|
+
function DateLocaleProvider({ locale, children }) {
|
|
16
|
+
return /* @__PURE__ */ jsx(DateLocaleContext.Provider, {
|
|
17
|
+
value: locale,
|
|
18
|
+
children
|
|
19
|
+
});
|
|
29
20
|
}
|
|
30
21
|
//#endregion
|
|
31
22
|
export { DateLocaleProvider };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { defaultLocale, enUSLocale, zhCNLocale } from "./locales.js";
|
|
1
|
+
import { defaultLocale, enUSLocale, getDateLocale, zhCNLocale } from "./locales.js";
|
|
2
2
|
import { useDateLocaleStore } from "./dateLocaleStore.js";
|
|
3
3
|
import { useDateLocale } from "./LocaleContext.js";
|
|
4
4
|
import { DatePicker } from "./Date.js";
|
|
5
5
|
import { DateLocaleProvider } from "./LocaleProvider.js";
|
|
6
|
-
export { DateLocaleProvider, DatePicker, defaultLocale, enUSLocale, useDateLocale, useDateLocaleStore, zhCNLocale };
|
|
6
|
+
export { DateLocaleProvider, DatePicker, defaultLocale, enUSLocale, getDateLocale, useDateLocale, useDateLocaleStore, zhCNLocale };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { I18nTranslateState } from "../../../../common/i18n/index";
|
|
1
2
|
export interface DateLocaleConfig {
|
|
2
3
|
placeholder: string;
|
|
3
4
|
placeholderDateTime: string;
|
|
@@ -18,6 +19,7 @@ export interface DateLocaleConfig {
|
|
|
18
19
|
quickRangeLastYear: string;
|
|
19
20
|
clear: string;
|
|
20
21
|
}
|
|
22
|
+
export declare const getDateLocale: (state: I18nTranslateState) => DateLocaleConfig;
|
|
21
23
|
export declare const zhCNLocale: DateLocaleConfig;
|
|
22
24
|
export declare const enUSLocale: DateLocaleConfig;
|
|
23
25
|
export declare const defaultLocale: DateLocaleConfig;
|
|
@@ -1,25 +1,41 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { defaultEnglishResources } from "../../../../common/i18n/en-US.js";
|
|
1
|
+
import { i18nStore, translate } from "../../../../common/i18n/index.js";
|
|
3
2
|
//#region packages/react/ui/components/Date/locales.ts
|
|
4
|
-
var
|
|
5
|
-
|
|
3
|
+
var getDateLocale = (state) => ({
|
|
4
|
+
placeholder: translate(state, "components.date.placeholder"),
|
|
5
|
+
placeholderDateTime: translate(state, "components.date.placeholderDateTime"),
|
|
6
|
+
placeholderRange: translate(state, "components.date.placeholderRange"),
|
|
7
|
+
placeholderDateTimeRange: translate(state, "components.date.placeholderDateTimeRange"),
|
|
8
|
+
weekDays: [...translate(state, "components.date.weekDays")],
|
|
9
|
+
selectTime: translate(state, "components.date.selectTime"),
|
|
10
|
+
startTime: translate(state, "components.date.startTime"),
|
|
11
|
+
endTime: translate(state, "components.date.endTime"),
|
|
12
|
+
confirm: translate(state, "components.date.confirm"),
|
|
13
|
+
monthFormat: translate(state, "components.date.monthFormat"),
|
|
14
|
+
quickRanges: translate(state, "components.date.quickRanges"),
|
|
15
|
+
quickRangeToday: translate(state, "components.date.quickRangeToday"),
|
|
16
|
+
quickRangeYesterday: translate(state, "components.date.quickRangeYesterday"),
|
|
17
|
+
quickRangeLast7Days: translate(state, "components.date.quickRangeLast7Days"),
|
|
18
|
+
quickRangeLast30Days: translate(state, "components.date.quickRangeLast30Days"),
|
|
19
|
+
quickRangeThisMonth: translate(state, "components.date.quickRangeThisMonth"),
|
|
20
|
+
quickRangeLastYear: translate(state, "components.date.quickRangeLastYear"),
|
|
21
|
+
clear: translate(state, "components.date.clear")
|
|
22
|
+
});
|
|
23
|
+
var getDateLocaleByLanguage = (language) => getDateLocale({
|
|
24
|
+
language,
|
|
25
|
+
fallbackLanguage: i18nStore.getState().fallbackLanguage,
|
|
26
|
+
resources: i18nStore.getState().resources
|
|
27
|
+
});
|
|
6
28
|
/**
|
|
7
29
|
* 默认中文文案
|
|
8
30
|
*/
|
|
9
|
-
var zhCNLocale = {
|
|
10
|
-
...dateDefaultLocale,
|
|
11
|
-
weekDays: [...dateDefaultLocale.weekDays]
|
|
12
|
-
};
|
|
31
|
+
var zhCNLocale = { ...getDateLocaleByLanguage("zh-CN") };
|
|
13
32
|
/**
|
|
14
33
|
* 默认英文文案
|
|
15
34
|
*/
|
|
16
|
-
var enUSLocale = {
|
|
17
|
-
...dateDefaultEnglishLocale,
|
|
18
|
-
weekDays: [...dateDefaultEnglishLocale.weekDays]
|
|
19
|
-
};
|
|
35
|
+
var enUSLocale = { ...getDateLocaleByLanguage("en-US") };
|
|
20
36
|
/**
|
|
21
37
|
* 默认使用中文文案
|
|
22
38
|
*/
|
|
23
39
|
var defaultLocale = zhCNLocale;
|
|
24
40
|
//#endregion
|
|
25
|
-
export { defaultLocale, enUSLocale, zhCNLocale };
|
|
41
|
+
export { defaultLocale, enUSLocale, getDateLocale, zhCNLocale };
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { useI18nStore } from "../../i18n/useI18n.js";
|
|
2
|
+
import "../../i18n/index.js";
|
|
1
3
|
import { cn } from "../../lib/utils.js";
|
|
2
4
|
import { Button } from "../Button/Button.js";
|
|
3
5
|
import "../Button/index.js";
|
|
@@ -6,6 +8,7 @@ import "../Dropdown/index.js";
|
|
|
6
8
|
import Search from "../Search/Search.js";
|
|
7
9
|
import "../Search/index.js";
|
|
8
10
|
import { ExportType } from "../../lib/export.js";
|
|
11
|
+
import { defaultLocale, getTableSearchLocale } from "./lang.js";
|
|
9
12
|
import { useTableSearchLocaleStore } from "./tableSearchLocaleStore.js";
|
|
10
13
|
import { useMemo, useRef, useState } from "react";
|
|
11
14
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -27,7 +30,24 @@ var TableSearch = (props) => {
|
|
|
27
30
|
const handleExpand = () => {
|
|
28
31
|
setIsExpanded(!isExpanded);
|
|
29
32
|
};
|
|
30
|
-
const
|
|
33
|
+
const language = useI18nStore((state) => state.language);
|
|
34
|
+
const fallbackLanguage = useI18nStore((state) => state.fallbackLanguage);
|
|
35
|
+
const resources = useI18nStore((state) => state.resources);
|
|
36
|
+
const storeLocale = useTableSearchLocaleStore((state) => state.locale);
|
|
37
|
+
const storeLocaleOverride = storeLocale === defaultLocale ? void 0 : storeLocale;
|
|
38
|
+
const locale = useMemo(() => ({
|
|
39
|
+
...getTableSearchLocale({
|
|
40
|
+
language,
|
|
41
|
+
fallbackLanguage,
|
|
42
|
+
resources
|
|
43
|
+
}),
|
|
44
|
+
...storeLocaleOverride
|
|
45
|
+
}), [
|
|
46
|
+
fallbackLanguage,
|
|
47
|
+
language,
|
|
48
|
+
resources,
|
|
49
|
+
storeLocaleOverride
|
|
50
|
+
]);
|
|
31
51
|
const defaultExportItems = useMemo(() => exportMenuItems || [{
|
|
32
52
|
key: "export-current-page",
|
|
33
53
|
label: locale.exportCurrentPage,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { I18nTranslateState } from "../../../../common/i18n/index";
|
|
1
2
|
export interface TableSearchLocaleConfig {
|
|
2
3
|
reset: string;
|
|
3
4
|
search: string;
|
|
@@ -7,6 +8,7 @@ export interface TableSearchLocaleConfig {
|
|
|
7
8
|
exportCurrentPage: string;
|
|
8
9
|
exportCurrentQuery: string;
|
|
9
10
|
}
|
|
11
|
+
export declare const getTableSearchLocale: (state: I18nTranslateState) => TableSearchLocaleConfig;
|
|
10
12
|
export declare const zhCNLocale: TableSearchLocaleConfig;
|
|
11
13
|
export declare const enUSLocale: TableSearchLocaleConfig;
|
|
12
14
|
export declare const defaultLocale: TableSearchLocaleConfig;
|
|
@@ -1,14 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { defaultEnglishResources } from "../../../../common/i18n/en-US.js";
|
|
1
|
+
import { i18nStore, translate } from "../../../../common/i18n/index.js";
|
|
3
2
|
//#region packages/react/ui/components/TableSearch/lang.ts
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
var getTableSearchLocale = (state) => ({
|
|
4
|
+
reset: translate(state, "components.tableSearch.reset"),
|
|
5
|
+
search: translate(state, "components.tableSearch.search"),
|
|
6
|
+
export: translate(state, "components.tableSearch.export"),
|
|
7
|
+
expand: translate(state, "components.tableSearch.expand"),
|
|
8
|
+
collapse: translate(state, "components.tableSearch.collapse"),
|
|
9
|
+
exportCurrentPage: translate(state, "components.tableSearch.exportCurrentPage"),
|
|
10
|
+
exportCurrentQuery: translate(state, "components.tableSearch.exportCurrentQuery")
|
|
11
|
+
});
|
|
12
|
+
var getTableSearchLocaleByLanguage = (language) => getTableSearchLocale({
|
|
13
|
+
language,
|
|
14
|
+
fallbackLanguage: i18nStore.getState().fallbackLanguage,
|
|
15
|
+
resources: i18nStore.getState().resources
|
|
16
|
+
});
|
|
17
|
+
var zhCNLocale = { ...getTableSearchLocaleByLanguage("zh-CN") };
|
|
18
|
+
var enUSLocale = { ...getTableSearchLocaleByLanguage("en-US") };
|
|
8
19
|
var defaultLocale = zhCNLocale;
|
|
9
20
|
var btnConfig = defaultLocale;
|
|
10
21
|
var updateBtnConfig = (config) => {
|
|
11
22
|
Object.assign(btnConfig, config);
|
|
12
23
|
};
|
|
13
24
|
//#endregion
|
|
14
|
-
export { btnConfig, defaultLocale, enUSLocale, updateBtnConfig, zhCNLocale };
|
|
25
|
+
export { btnConfig, defaultLocale, enUSLocale, getTableSearchLocale, updateBtnConfig, zhCNLocale };
|
|
@@ -1 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
import { type DateLocaleConfig } from "./locales";
|
|
2
|
+
export declare const DateLocaleContext: import("react").Context<Partial<DateLocaleConfig> | undefined>;
|
|
3
|
+
export declare const useDateLocale: () => {
|
|
4
|
+
placeholder: string;
|
|
5
|
+
placeholderDateTime: string;
|
|
6
|
+
placeholderRange: string;
|
|
7
|
+
placeholderDateTimeRange: string;
|
|
8
|
+
weekDays: string[];
|
|
9
|
+
selectTime: string;
|
|
10
|
+
startTime: string;
|
|
11
|
+
endTime: string;
|
|
12
|
+
confirm: string;
|
|
13
|
+
monthFormat: string;
|
|
14
|
+
quickRanges: string;
|
|
15
|
+
quickRangeToday: string;
|
|
16
|
+
quickRangeYesterday: string;
|
|
17
|
+
quickRangeLast7Days: string;
|
|
18
|
+
quickRangeLast30Days: string;
|
|
19
|
+
quickRangeThisMonth: string;
|
|
20
|
+
quickRangeLastYear: string;
|
|
21
|
+
clear: string;
|
|
22
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
2
|
import { type DateLocaleConfig } from "./locales";
|
|
3
3
|
export interface DateLocaleProviderProps {
|
|
4
|
-
locale?: DateLocaleConfig
|
|
4
|
+
locale?: Partial<DateLocaleConfig>;
|
|
5
5
|
children: ReactNode;
|
|
6
6
|
}
|
|
7
7
|
export declare function DateLocaleProvider({ locale, children }: DateLocaleProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { I18nTranslateState } from "@tc/common/i18n";
|
|
1
2
|
export interface DateLocaleConfig {
|
|
2
3
|
placeholder: string;
|
|
3
4
|
placeholderDateTime: string;
|
|
@@ -18,6 +19,7 @@ export interface DateLocaleConfig {
|
|
|
18
19
|
quickRangeLastYear: string;
|
|
19
20
|
clear: string;
|
|
20
21
|
}
|
|
22
|
+
export declare const getDateLocale: (state: I18nTranslateState) => DateLocaleConfig;
|
|
21
23
|
export declare const zhCNLocale: DateLocaleConfig;
|
|
22
24
|
export declare const enUSLocale: DateLocaleConfig;
|
|
23
25
|
export declare const defaultLocale: DateLocaleConfig;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { I18nTranslateState } from "@tc/common/i18n";
|
|
1
2
|
export interface TableSearchLocaleConfig {
|
|
2
3
|
reset: string;
|
|
3
4
|
search: string;
|
|
@@ -7,6 +8,7 @@ export interface TableSearchLocaleConfig {
|
|
|
7
8
|
exportCurrentPage: string;
|
|
8
9
|
exportCurrentQuery: string;
|
|
9
10
|
}
|
|
11
|
+
export declare const getTableSearchLocale: (state: I18nTranslateState) => TableSearchLocaleConfig;
|
|
10
12
|
export declare const zhCNLocale: TableSearchLocaleConfig;
|
|
11
13
|
export declare const enUSLocale: TableSearchLocaleConfig;
|
|
12
14
|
export declare const defaultLocale: TableSearchLocaleConfig;
|
package/package.json
CHANGED