@ant-design/pro-provider
Advanced tools
Comparing version 2.0.6 to 2.0.7
@@ -24,5 +24,11 @@ import React from 'react'; | ||
fieldProps?: any; | ||
/** 模式类型 */ | ||
/** | ||
* 组件的渲染模式类型 | ||
* @option read 渲染只读模式 | ||
* @option edit 渲染编辑模式 | ||
* */ | ||
mode: ProFieldFCMode; | ||
/** 简约模式 */ | ||
/** | ||
* 简约模式 | ||
*/ | ||
plain?: boolean; | ||
@@ -48,3 +54,16 @@ /** 轻量模式 */ | ||
export declare type ProRenderFieldPropsType = { | ||
/** | ||
* 自定义只读模式的渲染器 | ||
* @params props 关于dom的配置 | ||
* @params dom 默认的 dom | ||
* @return 返回一个用于读的 dom | ||
*/ | ||
render?: ((text: any, props: Omit<ProFieldFCRenderProps, 'value' | 'onChange'>, dom: JSX.Element) => JSX.Element) | undefined; | ||
/** | ||
* 一个自定义的编辑渲染器。 | ||
* @params text 默认的值类型 | ||
* @params props 关于dom的配置 | ||
* @params dom 默认的 dom | ||
* @return 返回一个用于编辑的dom | ||
*/ | ||
renderFormItem?: ((text: any, props: ProFieldFCRenderProps, dom: JSX.Element) => JSX.Element) | undefined; | ||
@@ -57,3 +76,3 @@ }; | ||
/** | ||
* 创建一个操作函数 | ||
* 创建一个国际化的操作函数 | ||
* | ||
@@ -115,2 +134,5 @@ * @param locale | ||
export { mnMNIntl, arEGIntl, enUSIntl, enGBIntl, zhCNIntl, viVNIntl, itITIntl, jaJPIntl, esESIntl, caESIntl, ruRUIntl, srRSIntl, msMYIntl, zhTWIntl, frFRIntl, ptBRIntl, koKRIntl, idIDIntl, deDEIntl, faIRIntl, trTRIntl, plPLIntl, hrHRIntl, intlMap, intlMapKeys, }; | ||
/** | ||
* 国际化的配置类型 | ||
*/ | ||
export declare type ConfigContextPropsType = { | ||
@@ -129,4 +151,9 @@ intl: IntlType; | ||
export declare const ConfigProviderWrap: React.FC<Record<string, unknown>>; | ||
/** | ||
* It returns the intl object from the context if it exists, otherwise it returns the intl object for | ||
* the current locale | ||
* @returns The return value of the function is the intl object. | ||
*/ | ||
export declare function useIntl(): IntlType; | ||
export declare const ProProvider: React.Context<ConfigContextPropsType>; | ||
export default ConfigContext; |
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2"; | ||
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper"; | ||
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime"; //@ts-ignore | ||
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime"; | ||
//@ts-ignore | ||
import { theme, ConfigProvider as AntdConfigProvider } from 'antd'; | ||
@@ -32,12 +32,17 @@ import zh_CN from 'antd/es/locale/zh_CN'; | ||
import zhTW from './locale/zh_TW'; | ||
var _ref = theme || { | ||
useToken: function useToken() { | ||
return { | ||
hashId: '' | ||
}; | ||
} | ||
}, | ||
useToken = _ref.useToken; | ||
useToken: function useToken() { | ||
return { | ||
hashId: '' | ||
}; | ||
} | ||
}, | ||
useToken = _ref.useToken; | ||
/** | ||
* 安全的从一个对象中读取相应的值 | ||
* @param source | ||
* @param path | ||
* @param defaultValue | ||
* @returns | ||
*/ | ||
function get(source, path, defaultValue) { | ||
@@ -47,7 +52,6 @@ // a[3].b -> a.3.b | ||
var result = source; | ||
var message = defaultValue; // eslint-disable-next-line no-restricted-syntax | ||
var message = defaultValue; | ||
// eslint-disable-next-line no-restricted-syntax | ||
var _iterator = _createForOfIteratorHelper(paths), | ||
_step; | ||
_step; | ||
try { | ||
@@ -58,3 +62,2 @@ for (_iterator.s(); !(_step = _iterator.n()).done;) { | ||
result = Object(result)[p]; | ||
if (message === undefined) { | ||
@@ -69,7 +72,6 @@ return defaultValue; | ||
} | ||
return message; | ||
} | ||
/** | ||
* 创建一个操作函数 | ||
* 创建一个国际化的操作函数 | ||
* | ||
@@ -79,4 +81,2 @@ * @param locale | ||
*/ | ||
export var createIntl = function createIntl(locale, localeMap) { | ||
@@ -140,2 +140,3 @@ return { | ||
export { mnMNIntl, arEGIntl, enUSIntl, enGBIntl, zhCNIntl, viVNIntl, itITIntl, jaJPIntl, esESIntl, caESIntl, ruRUIntl, srRSIntl, msMYIntl, zhTWIntl, frFRIntl, ptBRIntl, koKRIntl, idIDIntl, deDEIntl, faIRIntl, trTRIntl, plPLIntl, hrHRIntl, intlMap, intlMapKeys }; | ||
/* Creating a context object with the default values. */ | ||
var ConfigContext = /*#__PURE__*/React.createContext({ | ||
@@ -149,3 +150,3 @@ intl: _objectSpread(_objectSpread({}, zhCNIntl), {}, { | ||
var ConfigConsumer = ConfigContext.Consumer, | ||
ConfigProvider = ConfigContext.Provider; | ||
ConfigProvider = ConfigContext.Provider; | ||
/** | ||
@@ -156,5 +157,3 @@ * 根据 antd 的 key 来找到的 locale 插件的 key | ||
*/ | ||
export { ConfigConsumer, ConfigProvider }; | ||
var findIntlKeyByAntdLocaleKey = function findIntlKeyByAntdLocaleKey(localeKey) { | ||
@@ -164,3 +163,2 @@ if (!localeKey) { | ||
} | ||
var localeName = localeKey.toLocaleLowerCase(); | ||
@@ -177,8 +175,5 @@ return intlMapKeys.find(function (intlKey) { | ||
*/ | ||
var CacheClean = function CacheClean() { | ||
var _useSWRConfig = useSWRConfig(), | ||
cache = _useSWRConfig.cache; | ||
cache = _useSWRConfig.cache; | ||
useEffect(function () { | ||
@@ -189,3 +184,4 @@ return function () { | ||
cache.clear(); | ||
}; // eslint-disable-next-line react-hooks/exhaustive-deps | ||
}; | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, []); | ||
@@ -199,15 +195,11 @@ return null; | ||
*/ | ||
export var ConfigProviderWrap = function ConfigProviderWrap(_ref2) { | ||
var children = _ref2.children, | ||
_ref2$autoClearCache = _ref2.autoClearCache, | ||
autoClearCache = _ref2$autoClearCache === void 0 ? false : _ref2$autoClearCache; | ||
_ref2$autoClearCache = _ref2.autoClearCache, | ||
autoClearCache = _ref2$autoClearCache === void 0 ? false : _ref2$autoClearCache; | ||
var _useContext = useContext(AntdConfigProvider.ConfigContext), | ||
locale = _useContext.locale, | ||
getPrefixCls = _useContext.getPrefixCls; | ||
var token = useToken === null || useToken === void 0 ? void 0 : useToken(); // 如果 locale 不存在自动注入的 AntdConfigProvider | ||
locale = _useContext.locale, | ||
getPrefixCls = _useContext.getPrefixCls; | ||
var token = useToken === null || useToken === void 0 ? void 0 : useToken(); | ||
// 如果 locale 不存在自动注入的 AntdConfigProvider | ||
var Provider = locale === undefined ? AntdConfigProvider : React.Fragment; | ||
@@ -217,6 +209,5 @@ var proProvide = useContext(ConfigContext); | ||
var _proProvide$intl; | ||
var localeName = locale === null || locale === void 0 ? void 0 : locale.locale; | ||
var key = findIntlKeyByAntdLocaleKey(localeName); // antd 的 key 存在的时候以 antd 的为主 | ||
var key = findIntlKeyByAntdLocaleKey(localeName); | ||
// antd 的 key 存在的时候以 antd 的为主 | ||
var intl = localeName && ((_proProvide$intl = proProvide.intl) === null || _proProvide$intl === void 0 ? void 0 : _proProvide$intl.locale) === 'default' ? intlMap[key] : proProvide.intl || intlMap[key]; | ||
@@ -230,3 +221,2 @@ return _objectSpread(_objectSpread({}, proProvide), {}, { | ||
var _process$env$NODE_ENV; | ||
// 自动注入 antd 的配置 | ||
@@ -239,3 +229,2 @@ var configProvider = locale === undefined ? { | ||
} : {}; | ||
var provide = _jsx(Provider, _objectSpread(_objectSpread({}, configProvider), {}, { | ||
@@ -249,3 +238,2 @@ children: _jsx(ConfigProvider, { | ||
})); | ||
if (proProvide.isDeps) return provide; | ||
@@ -267,17 +255,18 @@ return _jsx("div", { | ||
}; | ||
/** | ||
* It returns the intl object from the context if it exists, otherwise it returns the intl object for | ||
* the current locale | ||
* @returns The return value of the function is the intl object. | ||
*/ | ||
export function useIntl() { | ||
var _useContext2 = useContext(AntdConfigProvider.ConfigContext), | ||
locale = _useContext2.locale; | ||
locale = _useContext2.locale; | ||
var _useContext3 = useContext(ConfigContext), | ||
intl = _useContext3.intl; | ||
intl = _useContext3.intl; | ||
if (intl && intl.locale !== 'default') { | ||
return intl; | ||
return intl || zhCNIntl; | ||
} | ||
if (locale === null || locale === void 0 ? void 0 : locale.locale) { | ||
return intlMap[findIntlKeyByAntdLocaleKey(locale.locale)]; | ||
return intlMap[findIntlKeyByAntdLocaleKey(locale.locale)] || zhCNIntl; | ||
} | ||
return zhCNIntl; | ||
@@ -284,0 +273,0 @@ } |
{ | ||
"name": "@ant-design/pro-provider", | ||
"version": "2.0.6", | ||
"version": "2.0.7", | ||
"description": "@ant-design/pro-provider", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
87724
3689