@cloudtower/eagle 0.33.17 → 0.33.19
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/cjs/core/CTModalFooterError/CTModalFooterError.style.js +5 -0
- package/dist/cjs/core/CTModalFooterError/index.js +46 -0
- package/dist/cjs/core/ConfigProvider/index.js +8 -2
- package/dist/cjs/coreX/DateRangePicker/Calendar.js +2 -2
- package/dist/cjs/coreX/DateRangePicker/utils.js +5 -0
- package/dist/cjs/hooks/useCTErrorMsg.js +25 -0
- package/dist/cjs/index.js +117 -114
- package/dist/cjs/stats1.html +1 -1
- package/dist/cjs/utils/cterror.js +62 -0
- package/dist/components.css +1974 -1966
- package/dist/esm/core/CTModalFooterError/CTModalFooterError.style.js +3 -0
- package/dist/esm/core/CTModalFooterError/index.js +40 -0
- package/dist/esm/core/ConfigProvider/index.js +9 -4
- package/dist/esm/coreX/DateRangePicker/Calendar.js +2 -2
- package/dist/esm/coreX/DateRangePicker/utils.js +3 -0
- package/dist/esm/hooks/useCTErrorMsg.js +23 -0
- package/dist/esm/index.js +2 -1
- package/dist/esm/stats1.html +1 -1
- package/dist/esm/utils/cterror.js +56 -0
- package/dist/linaria.merged.scss +2202 -2193
- package/dist/src/core/CTModalFooterError/CTModalFooterError.style.d.ts +1 -0
- package/dist/src/core/CTModalFooterError/CTModalFooterError.type.d.ts +56 -0
- package/dist/src/core/CTModalFooterError/index.d.ts +3 -0
- package/dist/src/core/ConfigProvider/index.d.ts +6 -1
- package/dist/src/core/index.d.ts +1 -0
- package/dist/src/coreX/DateRangePicker/__tests__/utils.test.d.ts +1 -0
- package/dist/src/coreX/DateRangePicker/utils.d.ts +7 -0
- package/dist/src/hooks/__tests__/useCTErrorMsg.test.d.ts +1 -0
- package/dist/src/hooks/index.d.ts +1 -0
- package/dist/src/hooks/useCTErrorMsg.d.ts +7 -0
- package/dist/src/utils/__test__/cterror.test.d.ts +1 -0
- package/dist/src/utils/cterror.d.ts +29 -0
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/utils/type.d.ts +32 -0
- package/dist/stories/docs/core/CTModalFooterError.stories.d.ts +47 -0
- package/dist/style.css +1603 -1596
- package/package.json +5 -4
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React__default, { useMemo } from 'react';
|
|
2
|
+
import { cx } from '@linaria/core';
|
|
3
|
+
import { CTModalFooterErrorStyle } from './CTModalFooterError.style.js';
|
|
4
|
+
import { Typo } from '../Typo/index.js';
|
|
5
|
+
import { useCTErrorMsg } from '../../hooks/useCTErrorMsg.js';
|
|
6
|
+
import useParrotTranslation from '../../hooks/useParrotTranslation.js';
|
|
7
|
+
|
|
8
|
+
const defaultErrorContainerRender = ({
|
|
9
|
+
children,
|
|
10
|
+
className
|
|
11
|
+
}) => {
|
|
12
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
13
|
+
"span",
|
|
14
|
+
{
|
|
15
|
+
className: cx(Typo.Label.l3_regular, CTModalFooterErrorStyle, className)
|
|
16
|
+
},
|
|
17
|
+
children
|
|
18
|
+
);
|
|
19
|
+
};
|
|
20
|
+
const CTModalFooterError = (props) => {
|
|
21
|
+
const {
|
|
22
|
+
error,
|
|
23
|
+
className,
|
|
24
|
+
ErrorItemRender,
|
|
25
|
+
ErrorContainerRender,
|
|
26
|
+
errorMsgOptions
|
|
27
|
+
} = props;
|
|
28
|
+
const msgs = useCTErrorMsg(error, errorMsgOptions);
|
|
29
|
+
const { t } = useParrotTranslation();
|
|
30
|
+
const ContainerRender = ErrorContainerRender || defaultErrorContainerRender;
|
|
31
|
+
const child = useMemo(() => {
|
|
32
|
+
if (ErrorItemRender) {
|
|
33
|
+
return msgs.map((errorMsg, index) => /* @__PURE__ */ React__default.createElement(ErrorItemRender, { errorMsg, index, key: index }));
|
|
34
|
+
}
|
|
35
|
+
return msgs.join("");
|
|
36
|
+
}, [msgs, ErrorItemRender, t]);
|
|
37
|
+
return /* @__PURE__ */ React__default.createElement(ContainerRender, { className, errorMsgs: msgs, children: child });
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export { CTModalFooterError };
|
|
@@ -7,7 +7,7 @@ import antd5enUS from 'antd5/lib/locale/en_US';
|
|
|
7
7
|
import antd5zhCN from 'antd5/lib/locale/zh_CN';
|
|
8
8
|
import dayjs from 'dayjs';
|
|
9
9
|
import moment from 'moment';
|
|
10
|
-
import React__default, { useEffect } from 'react';
|
|
10
|
+
import React__default, { createContext, useContext, useEffect } from 'react';
|
|
11
11
|
|
|
12
12
|
var __defProp = Object.defineProperty;
|
|
13
13
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
@@ -25,9 +25,14 @@ var __spreadValues = (a, b) => {
|
|
|
25
25
|
}
|
|
26
26
|
return a;
|
|
27
27
|
};
|
|
28
|
+
const ConfigProviderContext = createContext({});
|
|
29
|
+
const useConfig = () => {
|
|
30
|
+
return useContext(ConfigProviderContext);
|
|
31
|
+
};
|
|
28
32
|
const ConfigProvider = ({
|
|
29
33
|
antd5Configs,
|
|
30
34
|
antd4Configs,
|
|
35
|
+
config = {},
|
|
31
36
|
children
|
|
32
37
|
}) => {
|
|
33
38
|
const { i18n } = useParrotTranslation();
|
|
@@ -39,7 +44,7 @@ const ConfigProvider = ({
|
|
|
39
44
|
i18n.on("languageChanged", adjustDateLocale);
|
|
40
45
|
adjustDateLocale(i18n.language);
|
|
41
46
|
}, [i18n]);
|
|
42
|
-
return /* @__PURE__ */ React__default.createElement(
|
|
47
|
+
return /* @__PURE__ */ React__default.createElement(ConfigProviderContext.Provider, { value: config }, /* @__PURE__ */ React__default.createElement(
|
|
43
48
|
ConfigProvider$1,
|
|
44
49
|
__spreadValues({
|
|
45
50
|
autoInsertSpaceInButton: false,
|
|
@@ -53,7 +58,7 @@ const ConfigProvider = ({
|
|
|
53
58
|
}, antd4Configs),
|
|
54
59
|
children
|
|
55
60
|
)
|
|
56
|
-
);
|
|
61
|
+
));
|
|
57
62
|
};
|
|
58
63
|
|
|
59
|
-
export { ConfigProvider };
|
|
64
|
+
export { ConfigProvider, useConfig };
|
|
@@ -11,6 +11,7 @@ import dayjs from 'dayjs';
|
|
|
11
11
|
import React__default, { useState, useEffect, useRef } from 'react';
|
|
12
12
|
import { getDiffMonthAndDate, getTime, checkDateNotInRange, getClassNameForDateBlock } from './common.js';
|
|
13
13
|
import { CalendarStyle } from './DateRangePicker.style.js';
|
|
14
|
+
import { getFirstDateOfMonth } from './utils.js';
|
|
14
15
|
import { getCalendarTitle } from '../common/getCalendarTitle.js';
|
|
15
16
|
|
|
16
17
|
const Year = (props) => {
|
|
@@ -203,11 +204,10 @@ const Month = (props) => {
|
|
|
203
204
|
const time = dayjs(`${year}-${month2}`, "YYYY-M");
|
|
204
205
|
const allDateInMonth = time.daysInMonth();
|
|
205
206
|
const dates = new Array(allDateInMonth).fill(1).map((value, index) => index + 1);
|
|
206
|
-
const firstDateOfDay = time.set("date", dates[0]).day();
|
|
207
207
|
monthAndDate.push({
|
|
208
208
|
month: month2,
|
|
209
209
|
dates,
|
|
210
|
-
firstDateOfDay:
|
|
210
|
+
firstDateOfDay: getFirstDateOfMonth(time)
|
|
211
211
|
});
|
|
212
212
|
}
|
|
213
213
|
setMonth(monthAndDate);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import useParrotTranslation from './useParrotTranslation.js';
|
|
2
|
+
import { parseCTError } from '../utils/cterror.js';
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
import { merge } from 'lodash';
|
|
5
|
+
import { useConfig } from '../core/ConfigProvider/index.js';
|
|
6
|
+
|
|
7
|
+
const useCTErrorMsg = (error, options) => {
|
|
8
|
+
const { t } = useParrotTranslation();
|
|
9
|
+
const globalConfig = useConfig();
|
|
10
|
+
const err = parseCTError(error);
|
|
11
|
+
const ns = (options == null ? void 0 : options.CTErrorI18nNs) || (globalConfig == null ? void 0 : globalConfig.ctErrorI18nNs) || "CTError";
|
|
12
|
+
const errMsg = useMemo(() => {
|
|
13
|
+
return err.map((e) => {
|
|
14
|
+
if ("code" in e) {
|
|
15
|
+
return t(`${ns}.${e.code}`, merge(options == null ? void 0 : options.tOptions, e.params));
|
|
16
|
+
}
|
|
17
|
+
return e.message;
|
|
18
|
+
});
|
|
19
|
+
}, [err, t, ns, options == null ? void 0 : options.tOptions]);
|
|
20
|
+
return errMsg;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { useCTErrorMsg };
|
package/dist/esm/index.js
CHANGED
|
@@ -83,7 +83,8 @@ export { Architecture } from './core/Arch/arch.type.js';
|
|
|
83
83
|
export { CascaderDefaultHeader, CascaderDefaultHeaderContainer, CascaderDefaultHeaderSearch, CascaderDefaultOptionLabel, CascaderDropdown, CascaderInputStyle, CascaderLargeDropdown, CascaderNotData, CascaderSmallDropdown, DoubleRowOptionStyleWrapper, Hide } from './core/Cascader/cascader.style.js';
|
|
84
84
|
export { CascaderDoubleRowOption, CascaderOptionWithCount, NotDataContent, PresetCascaderHeader, PresetCascaderRender, defaultTagRender } from './core/Cascader/cascader.widget.js';
|
|
85
85
|
export { Cascader } from './core/Cascader/index.js';
|
|
86
|
-
export { ConfigProvider } from './core/ConfigProvider/index.js';
|
|
86
|
+
export { ConfigProvider, useConfig } from './core/ConfigProvider/index.js';
|
|
87
|
+
export { CTModalFooterError } from './core/CTModalFooterError/index.js';
|
|
87
88
|
export { default as ExpandableContainer } from './core/ExpandableList/ExpandableContainer.js';
|
|
88
89
|
export { default as ExpandableItem } from './core/ExpandableList/ExpandableItem.js';
|
|
89
90
|
export { default as ExpandIcon } from './core/ExpandableList/ExpandIcon.js';
|