@fle-ui/next 2.0.0-alpha.7 → 2.0.0-alpha.9
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/es/config-provider/DisabledContext.d.ts +9 -0
- package/es/config-provider/DisabledContext.js +11 -0
- package/es/config-provider/SizeContext.d.ts +9 -0
- package/es/config-provider/SizeContext.js +12 -0
- package/es/config-provider/context.d.ts +58 -0
- package/es/config-provider/context.js +41 -0
- package/es/config-provider/cssVariables.d.ts +3 -0
- package/es/config-provider/cssVariables.js +97 -0
- package/es/config-provider/defaultRenderEmpty.d.ts +4 -0
- package/es/config-provider/defaultRenderEmpty.js +36 -0
- package/es/config-provider/index.d.ts +61 -5
- package/es/config-provider/index.js +209 -10
- package/es/config-provider/style/css.js +1 -0
- package/es/config-provider/style/index-pure.less +2 -0
- package/es/config-provider/style/index.css +4 -0
- package/es/config-provider/style/index.d.ts +1 -0
- package/es/config-provider/style/index.js +1 -0
- package/es/config-provider/style/index.less +3 -0
- package/es/style/index.less +1 -0
- package/lib/config-provider/DisabledContext.d.ts +9 -0
- package/lib/config-provider/DisabledContext.js +25 -0
- package/lib/config-provider/SizeContext.d.ts +9 -0
- package/lib/config-provider/SizeContext.js +26 -0
- package/lib/config-provider/context.d.ts +58 -0
- package/lib/config-provider/context.js +57 -0
- package/lib/config-provider/cssVariables.d.ts +3 -0
- package/lib/config-provider/cssVariables.js +115 -0
- package/lib/config-provider/defaultRenderEmpty.d.ts +4 -0
- package/lib/config-provider/defaultRenderEmpty.js +50 -0
- package/lib/config-provider/index.d.ts +61 -5
- package/lib/config-provider/index.js +250 -10
- package/lib/config-provider/style/css.js +3 -0
- package/lib/config-provider/style/index-pure.less +2 -0
- package/lib/config-provider/style/index.css +4 -0
- package/lib/config-provider/style/index.d.ts +1 -0
- package/lib/config-provider/style/index.js +3 -0
- package/lib/config-provider/style/index.less +3 -0
- package/lib/style/index.less +1 -0
- package/package.json +1 -1
@@ -0,0 +1,9 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
export type DisabledType = true | false | undefined;
|
3
|
+
declare const DisabledContext: React.Context<DisabledType>;
|
4
|
+
export interface DisabledContextProps {
|
5
|
+
disabled?: DisabledType;
|
6
|
+
children?: React.ReactNode;
|
7
|
+
}
|
8
|
+
export declare const DisabledContextProvider: React.FC<DisabledContextProps>;
|
9
|
+
export default DisabledContext;
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
var DisabledContext = /*#__PURE__*/React.createContext(false);
|
3
|
+
export var DisabledContextProvider = function DisabledContextProvider(_ref) {
|
4
|
+
var children = _ref.children,
|
5
|
+
disabled = _ref.disabled;
|
6
|
+
var originDisabled = React.useContext(DisabledContext);
|
7
|
+
return /*#__PURE__*/React.createElement(DisabledContext.Provider, {
|
8
|
+
value: disabled !== null && disabled !== void 0 ? disabled : originDisabled
|
9
|
+
}, children);
|
10
|
+
};
|
11
|
+
export default DisabledContext;
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
export type SizeType = 'small' | 'middle' | 'large' | undefined;
|
3
|
+
declare const SizeContext: React.Context<SizeType>;
|
4
|
+
export interface SizeContextProps {
|
5
|
+
size?: SizeType;
|
6
|
+
children?: React.ReactNode;
|
7
|
+
}
|
8
|
+
export declare const SizeContextProvider: React.FC<SizeContextProps>;
|
9
|
+
export default SizeContext;
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
var SizeContext = /*#__PURE__*/React.createContext(undefined);
|
3
|
+
export var SizeContextProvider = function SizeContextProvider(_ref) {
|
4
|
+
var children = _ref.children,
|
5
|
+
size = _ref.size;
|
6
|
+
return /*#__PURE__*/React.createElement(SizeContext.Consumer, null, function (originSize) {
|
7
|
+
return /*#__PURE__*/React.createElement(SizeContext.Provider, {
|
8
|
+
value: size || originSize
|
9
|
+
}, children);
|
10
|
+
});
|
11
|
+
};
|
12
|
+
export default SizeContext;
|
@@ -0,0 +1,58 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
import type { RequiredMark } from '../form/Form';
|
3
|
+
import type { Locale } from '../locale-provider';
|
4
|
+
import type { RenderEmptyHandler } from './defaultRenderEmpty';
|
5
|
+
import type { SizeType } from './SizeContext';
|
6
|
+
export interface Theme {
|
7
|
+
primaryColor?: string;
|
8
|
+
infoColor?: string;
|
9
|
+
successColor?: string;
|
10
|
+
processingColor?: string;
|
11
|
+
errorColor?: string;
|
12
|
+
warningColor?: string;
|
13
|
+
}
|
14
|
+
export interface CSPConfig {
|
15
|
+
nonce?: string;
|
16
|
+
}
|
17
|
+
export type DirectionType = 'ltr' | 'rtl' | undefined;
|
18
|
+
export interface ConfigConsumerProps {
|
19
|
+
getTargetContainer?: () => HTMLElement;
|
20
|
+
getPopupContainer?: (triggerNode?: HTMLElement) => HTMLElement;
|
21
|
+
rootPrefixCls?: string;
|
22
|
+
iconPrefixCls?: string;
|
23
|
+
getPrefixCls: (suffixCls?: string, customizePrefixCls?: string) => string;
|
24
|
+
renderEmpty?: RenderEmptyHandler;
|
25
|
+
csp?: CSPConfig;
|
26
|
+
autoInsertSpaceInButton?: boolean;
|
27
|
+
input?: {
|
28
|
+
autoComplete?: string;
|
29
|
+
};
|
30
|
+
pagination?: {
|
31
|
+
showSizeChanger?: boolean;
|
32
|
+
};
|
33
|
+
locale?: Locale;
|
34
|
+
pageHeader?: {
|
35
|
+
ghost: boolean;
|
36
|
+
};
|
37
|
+
direction?: DirectionType;
|
38
|
+
space?: {
|
39
|
+
size?: SizeType | number;
|
40
|
+
};
|
41
|
+
virtual?: boolean;
|
42
|
+
dropdownMatchSelectWidth?: boolean;
|
43
|
+
form?: {
|
44
|
+
requiredMark?: RequiredMark;
|
45
|
+
colon?: boolean;
|
46
|
+
};
|
47
|
+
}
|
48
|
+
export declare const ConfigContext: React.Context<ConfigConsumerProps>;
|
49
|
+
export declare const ConfigConsumer: React.Consumer<ConfigConsumerProps>;
|
50
|
+
interface BasicExportProps {
|
51
|
+
prefixCls?: string;
|
52
|
+
}
|
53
|
+
interface ConsumerConfig {
|
54
|
+
prefixCls: string;
|
55
|
+
}
|
56
|
+
/** @deprecated Use hooks instead. This is a legacy function */
|
57
|
+
export declare function withConfigConsumer<ExportProps extends BasicExportProps>(config: ConsumerConfig): <ComponentDef>(Component: React.ComponentType<ExportProps>) => React.FC<ExportProps> & ComponentDef;
|
58
|
+
export {};
|
@@ -0,0 +1,41 @@
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
2
|
+
import * as React from 'react';
|
3
|
+
|
4
|
+
var defaultGetPrefixCls = function defaultGetPrefixCls(suffixCls, customizePrefixCls) {
|
5
|
+
if (customizePrefixCls) return customizePrefixCls;
|
6
|
+
return suffixCls ? "ant-".concat(suffixCls) : 'ant';
|
7
|
+
}; // zombieJ: 🚨 Do not pass `defaultRenderEmpty` here since it will case circular dependency.
|
8
|
+
|
9
|
+
|
10
|
+
export var ConfigContext = /*#__PURE__*/React.createContext({
|
11
|
+
// We provide a default function for Context without provider
|
12
|
+
getPrefixCls: defaultGetPrefixCls
|
13
|
+
});
|
14
|
+
export var ConfigConsumer = ConfigContext.Consumer;
|
15
|
+
/** @deprecated Use hooks instead. This is a legacy function */
|
16
|
+
|
17
|
+
export function withConfigConsumer(config) {
|
18
|
+
return function withConfigConsumerFunc(Component) {
|
19
|
+
// Wrap with ConfigConsumer. Since we need compatible with react 15, be care when using ref methods
|
20
|
+
var SFC = function SFC(props) {
|
21
|
+
return /*#__PURE__*/React.createElement(ConfigConsumer, null, function (configProps) {
|
22
|
+
var basicPrefixCls = config.prefixCls;
|
23
|
+
var getPrefixCls = configProps.getPrefixCls;
|
24
|
+
var customizePrefixCls = props.prefixCls;
|
25
|
+
var prefixCls = getPrefixCls(basicPrefixCls, customizePrefixCls);
|
26
|
+
return /*#__PURE__*/React.createElement(Component, _extends({}, configProps, props, {
|
27
|
+
prefixCls: prefixCls
|
28
|
+
}));
|
29
|
+
});
|
30
|
+
};
|
31
|
+
|
32
|
+
var cons = Component.constructor;
|
33
|
+
var name = cons && cons.displayName || Component.name || 'Component';
|
34
|
+
|
35
|
+
if (process.env.NODE_ENV !== 'production') {
|
36
|
+
SFC.displayName = "withConfigConsumer(".concat(name, ")");
|
37
|
+
}
|
38
|
+
|
39
|
+
return SFC;
|
40
|
+
};
|
41
|
+
}
|
@@ -0,0 +1,97 @@
|
|
1
|
+
/* eslint-disable import/prefer-default-export, prefer-destructuring */
|
2
|
+
import { generate } from '@ant-design/colors';
|
3
|
+
import { TinyColor } from '@ctrl/tinycolor';
|
4
|
+
import canUseDom from "rc-util/es/Dom/canUseDom";
|
5
|
+
import { updateCSS } from "rc-util/es/Dom/dynamicCSS";
|
6
|
+
import warning from "../_util/warning";
|
7
|
+
var dynamicStyleMark = "-ant-".concat(Date.now(), "-").concat(Math.random());
|
8
|
+
export function getStyle(globalPrefixCls, theme) {
|
9
|
+
var variables = {};
|
10
|
+
|
11
|
+
var formatColor = function formatColor(color, updater) {
|
12
|
+
var clone = color.clone();
|
13
|
+
clone = (updater === null || updater === void 0 ? void 0 : updater(clone)) || clone;
|
14
|
+
return clone.toRgbString();
|
15
|
+
};
|
16
|
+
|
17
|
+
var fillColor = function fillColor(colorVal, type) {
|
18
|
+
var baseColor = new TinyColor(colorVal);
|
19
|
+
var colorPalettes = generate(baseColor.toRgbString());
|
20
|
+
variables["".concat(type, "-color")] = formatColor(baseColor);
|
21
|
+
variables["".concat(type, "-color-disabled")] = colorPalettes[1];
|
22
|
+
variables["".concat(type, "-color-hover")] = colorPalettes[4];
|
23
|
+
variables["".concat(type, "-color-active")] = colorPalettes[6];
|
24
|
+
variables["".concat(type, "-color-outline")] = baseColor.clone().setAlpha(0.2).toRgbString();
|
25
|
+
variables["".concat(type, "-color-deprecated-bg")] = colorPalettes[0];
|
26
|
+
variables["".concat(type, "-color-deprecated-border")] = colorPalettes[2];
|
27
|
+
}; // ================ Primary Color ================
|
28
|
+
|
29
|
+
|
30
|
+
if (theme.primaryColor) {
|
31
|
+
fillColor(theme.primaryColor, 'primary');
|
32
|
+
var primaryColor = new TinyColor(theme.primaryColor);
|
33
|
+
var primaryColors = generate(primaryColor.toRgbString()); // Legacy - We should use semantic naming standard
|
34
|
+
|
35
|
+
primaryColors.forEach(function (color, index) {
|
36
|
+
variables["primary-".concat(index + 1)] = color;
|
37
|
+
}); // Deprecated
|
38
|
+
|
39
|
+
variables['primary-color-deprecated-l-35'] = formatColor(primaryColor, function (c) {
|
40
|
+
return c.lighten(35);
|
41
|
+
});
|
42
|
+
variables['primary-color-deprecated-l-20'] = formatColor(primaryColor, function (c) {
|
43
|
+
return c.lighten(20);
|
44
|
+
});
|
45
|
+
variables['primary-color-deprecated-t-20'] = formatColor(primaryColor, function (c) {
|
46
|
+
return c.tint(20);
|
47
|
+
});
|
48
|
+
variables['primary-color-deprecated-t-50'] = formatColor(primaryColor, function (c) {
|
49
|
+
return c.tint(50);
|
50
|
+
});
|
51
|
+
variables['primary-color-deprecated-f-12'] = formatColor(primaryColor, function (c) {
|
52
|
+
return c.setAlpha(c.getAlpha() * 0.12);
|
53
|
+
});
|
54
|
+
var primaryActiveColor = new TinyColor(primaryColors[0]);
|
55
|
+
variables['primary-color-active-deprecated-f-30'] = formatColor(primaryActiveColor, function (c) {
|
56
|
+
return c.setAlpha(c.getAlpha() * 0.3);
|
57
|
+
});
|
58
|
+
variables['primary-color-active-deprecated-d-02'] = formatColor(primaryActiveColor, function (c) {
|
59
|
+
return c.darken(2);
|
60
|
+
});
|
61
|
+
} // ================ Success Color ================
|
62
|
+
|
63
|
+
|
64
|
+
if (theme.successColor) {
|
65
|
+
fillColor(theme.successColor, 'success');
|
66
|
+
} // ================ Warning Color ================
|
67
|
+
|
68
|
+
|
69
|
+
if (theme.warningColor) {
|
70
|
+
fillColor(theme.warningColor, 'warning');
|
71
|
+
} // ================= Error Color =================
|
72
|
+
|
73
|
+
|
74
|
+
if (theme.errorColor) {
|
75
|
+
fillColor(theme.errorColor, 'error');
|
76
|
+
} // ================= Info Color ==================
|
77
|
+
|
78
|
+
|
79
|
+
if (theme.infoColor) {
|
80
|
+
fillColor(theme.infoColor, 'info');
|
81
|
+
} // Convert to css variables
|
82
|
+
|
83
|
+
|
84
|
+
var cssList = Object.keys(variables).map(function (key) {
|
85
|
+
return "--".concat(globalPrefixCls, "-").concat(key, ": ").concat(variables[key], ";");
|
86
|
+
});
|
87
|
+
return "\n :root {\n ".concat(cssList.join('\n'), "\n }\n ").trim();
|
88
|
+
}
|
89
|
+
export function registerTheme(globalPrefixCls, theme) {
|
90
|
+
var style = getStyle(globalPrefixCls, theme);
|
91
|
+
|
92
|
+
if (canUseDom()) {
|
93
|
+
updateCSS(style, "".concat(dynamicStyleMark, "-dynamic-theme"));
|
94
|
+
} else {
|
95
|
+
process.env.NODE_ENV !== "production" ? warning(false, 'ConfigProvider', 'SSR do not support dynamic theme with css variables.') : void 0;
|
96
|
+
}
|
97
|
+
}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
import { ConfigConsumer } from '.';
|
3
|
+
import Empty from "../empty";
|
4
|
+
|
5
|
+
var defaultRenderEmpty = function defaultRenderEmpty(componentName) {
|
6
|
+
return /*#__PURE__*/React.createElement(ConfigConsumer, null, function (_ref) {
|
7
|
+
var getPrefixCls = _ref.getPrefixCls;
|
8
|
+
var prefix = getPrefixCls('empty');
|
9
|
+
|
10
|
+
switch (componentName) {
|
11
|
+
case 'Table':
|
12
|
+
case 'List':
|
13
|
+
return /*#__PURE__*/React.createElement(Empty, {
|
14
|
+
image: Empty.PRESENTED_IMAGE_SIMPLE
|
15
|
+
});
|
16
|
+
|
17
|
+
case 'Select':
|
18
|
+
case 'TreeSelect':
|
19
|
+
case 'Cascader':
|
20
|
+
case 'Transfer':
|
21
|
+
case 'Mentions':
|
22
|
+
return /*#__PURE__*/React.createElement(Empty, {
|
23
|
+
image: Empty.PRESENTED_IMAGE_SIMPLE,
|
24
|
+
className: "".concat(prefix, "-small")
|
25
|
+
});
|
26
|
+
|
27
|
+
/* istanbul ignore next */
|
28
|
+
|
29
|
+
default:
|
30
|
+
// Should never hit if we take all the component into consider.
|
31
|
+
return /*#__PURE__*/React.createElement(Empty, null);
|
32
|
+
}
|
33
|
+
});
|
34
|
+
};
|
35
|
+
|
36
|
+
export default defaultRenderEmpty;
|
@@ -1,5 +1,61 @@
|
|
1
|
-
import {
|
2
|
-
import '
|
3
|
-
import type {
|
4
|
-
|
5
|
-
|
1
|
+
import type { ValidateMessages } from 'rc-field-form/lib/interface';
|
2
|
+
import * as React from 'react';
|
3
|
+
import type { RequiredMark } from '../form/Form';
|
4
|
+
import type { Locale } from '../locale-provider';
|
5
|
+
import type { Theme } from './context';
|
6
|
+
import { ConfigConsumer, ConfigConsumerProps, ConfigContext, CSPConfig, DirectionType } from './context';
|
7
|
+
import { RenderEmptyHandler } from './defaultRenderEmpty';
|
8
|
+
import type { SizeType } from './SizeContext';
|
9
|
+
import SizeContext from './SizeContext';
|
10
|
+
export { RenderEmptyHandler, ConfigContext, ConfigConsumer, CSPConfig, DirectionType, ConfigConsumerProps, };
|
11
|
+
export declare const configConsumerProps: string[];
|
12
|
+
export interface ConfigProviderProps {
|
13
|
+
getTargetContainer?: () => HTMLElement | Window;
|
14
|
+
getPopupContainer?: (triggerNode?: HTMLElement) => HTMLElement;
|
15
|
+
prefixCls?: string;
|
16
|
+
iconPrefixCls?: string;
|
17
|
+
children?: React.ReactNode;
|
18
|
+
renderEmpty?: RenderEmptyHandler;
|
19
|
+
csp?: CSPConfig;
|
20
|
+
autoInsertSpaceInButton?: boolean;
|
21
|
+
form?: {
|
22
|
+
validateMessages?: ValidateMessages;
|
23
|
+
requiredMark?: RequiredMark;
|
24
|
+
colon?: boolean;
|
25
|
+
};
|
26
|
+
input?: {
|
27
|
+
autoComplete?: string;
|
28
|
+
};
|
29
|
+
pagination?: {
|
30
|
+
showSizeChanger?: boolean;
|
31
|
+
};
|
32
|
+
locale?: Locale;
|
33
|
+
pageHeader?: {
|
34
|
+
ghost: boolean;
|
35
|
+
};
|
36
|
+
componentSize?: SizeType;
|
37
|
+
componentDisabled?: boolean;
|
38
|
+
direction?: DirectionType;
|
39
|
+
space?: {
|
40
|
+
size?: SizeType | number;
|
41
|
+
};
|
42
|
+
virtual?: boolean;
|
43
|
+
dropdownMatchSelectWidth?: boolean;
|
44
|
+
}
|
45
|
+
export declare const defaultPrefixCls = "ant";
|
46
|
+
export declare const defaultIconPrefixCls = "anticon";
|
47
|
+
declare function getGlobalIconPrefixCls(): string;
|
48
|
+
declare const setGlobalConfig: ({ prefixCls, iconPrefixCls, theme, }: Pick<ConfigProviderProps, "prefixCls" | "iconPrefixCls"> & {
|
49
|
+
theme?: Theme | undefined;
|
50
|
+
}) => void;
|
51
|
+
export declare const globalConfig: () => {
|
52
|
+
getPrefixCls: (suffixCls?: string, customizePrefixCls?: string) => string;
|
53
|
+
getIconPrefixCls: typeof getGlobalIconPrefixCls;
|
54
|
+
getRootPrefixCls: (rootPrefixCls?: string, customizePrefixCls?: string) => string;
|
55
|
+
};
|
56
|
+
declare const ConfigProvider: React.FC<ConfigProviderProps> & {
|
57
|
+
ConfigContext: typeof ConfigContext;
|
58
|
+
SizeContext: typeof SizeContext;
|
59
|
+
config: typeof setGlobalConfig;
|
60
|
+
};
|
61
|
+
export default ConfigProvider;
|
@@ -1,14 +1,213 @@
|
|
1
|
-
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
2
|
+
import IconContext from "@ant-design/icons/es/components/Context";
|
3
|
+
import { FormProvider as RcFormProvider } from 'rc-field-form';
|
4
|
+
import useMemo from "rc-util/es/hooks/useMemo";
|
5
|
+
import * as React from 'react';
|
6
|
+
import LocaleProvider, { ANT_MARK } from "../locale-provider";
|
7
|
+
import LocaleReceiver from "../locale-provider/LocaleReceiver";
|
8
|
+
import defaultLocale from "../locale/default";
|
9
|
+
import message from "../message";
|
10
|
+
import notification from "../notification";
|
11
|
+
import { ConfigConsumer, ConfigContext } from "./context";
|
12
|
+
import { registerTheme } from "./cssVariables";
|
13
|
+
import { DisabledContextProvider } from "./DisabledContext";
|
14
|
+
import SizeContext, { SizeContextProvider } from "./SizeContext";
|
15
|
+
export { ConfigContext, ConfigConsumer };
|
16
|
+
export var configConsumerProps = ['getTargetContainer', 'getPopupContainer', 'rootPrefixCls', 'getPrefixCls', 'renderEmpty', 'csp', 'autoInsertSpaceInButton', 'locale', 'pageHeader']; // These props is used by `useContext` directly in sub component
|
2
17
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
18
|
+
var PASSED_PROPS = ['getTargetContainer', 'getPopupContainer', 'renderEmpty', 'pageHeader', 'input', 'pagination', 'form'];
|
19
|
+
export var defaultPrefixCls = 'ant';
|
20
|
+
export var defaultIconPrefixCls = 'anticon';
|
21
|
+
var globalPrefixCls;
|
22
|
+
var globalIconPrefixCls;
|
7
23
|
|
8
|
-
|
9
|
-
return
|
10
|
-
|
11
|
-
|
24
|
+
function getGlobalPrefixCls() {
|
25
|
+
return globalPrefixCls || defaultPrefixCls;
|
26
|
+
}
|
27
|
+
|
28
|
+
function getGlobalIconPrefixCls() {
|
29
|
+
return globalIconPrefixCls || defaultIconPrefixCls;
|
30
|
+
}
|
31
|
+
|
32
|
+
var setGlobalConfig = function setGlobalConfig(_ref) {
|
33
|
+
var prefixCls = _ref.prefixCls,
|
34
|
+
iconPrefixCls = _ref.iconPrefixCls,
|
35
|
+
theme = _ref.theme;
|
36
|
+
|
37
|
+
if (prefixCls !== undefined) {
|
38
|
+
globalPrefixCls = prefixCls;
|
39
|
+
}
|
40
|
+
|
41
|
+
if (iconPrefixCls !== undefined) {
|
42
|
+
globalIconPrefixCls = iconPrefixCls;
|
43
|
+
}
|
44
|
+
|
45
|
+
if (theme) {
|
46
|
+
registerTheme(getGlobalPrefixCls(), theme);
|
47
|
+
}
|
12
48
|
};
|
13
49
|
|
14
|
-
export
|
50
|
+
export var globalConfig = function globalConfig() {
|
51
|
+
return {
|
52
|
+
getPrefixCls: function getPrefixCls(suffixCls, customizePrefixCls) {
|
53
|
+
if (customizePrefixCls) return customizePrefixCls;
|
54
|
+
return suffixCls ? "".concat(getGlobalPrefixCls(), "-").concat(suffixCls) : getGlobalPrefixCls();
|
55
|
+
},
|
56
|
+
getIconPrefixCls: getGlobalIconPrefixCls,
|
57
|
+
getRootPrefixCls: function getRootPrefixCls(rootPrefixCls, customizePrefixCls) {
|
58
|
+
// Customize rootPrefixCls is first priority
|
59
|
+
if (rootPrefixCls) {
|
60
|
+
return rootPrefixCls;
|
61
|
+
} // If Global prefixCls provided, use this
|
62
|
+
|
63
|
+
|
64
|
+
if (globalPrefixCls) {
|
65
|
+
return globalPrefixCls;
|
66
|
+
} // [Legacy] If customize prefixCls provided, we cut it to get the prefixCls
|
67
|
+
|
68
|
+
|
69
|
+
if (customizePrefixCls && customizePrefixCls.includes('-')) {
|
70
|
+
return customizePrefixCls.replace(/^(.*)-[^-]*$/, '$1');
|
71
|
+
} // Fallback to default prefixCls
|
72
|
+
|
73
|
+
|
74
|
+
return getGlobalPrefixCls();
|
75
|
+
}
|
76
|
+
};
|
77
|
+
};
|
78
|
+
|
79
|
+
var ProviderChildren = function ProviderChildren(props) {
|
80
|
+
var _a, _b;
|
81
|
+
|
82
|
+
var children = props.children,
|
83
|
+
csp = props.csp,
|
84
|
+
autoInsertSpaceInButton = props.autoInsertSpaceInButton,
|
85
|
+
form = props.form,
|
86
|
+
locale = props.locale,
|
87
|
+
componentSize = props.componentSize,
|
88
|
+
direction = props.direction,
|
89
|
+
space = props.space,
|
90
|
+
virtual = props.virtual,
|
91
|
+
dropdownMatchSelectWidth = props.dropdownMatchSelectWidth,
|
92
|
+
legacyLocale = props.legacyLocale,
|
93
|
+
parentContext = props.parentContext,
|
94
|
+
iconPrefixCls = props.iconPrefixCls,
|
95
|
+
componentDisabled = props.componentDisabled;
|
96
|
+
var getPrefixCls = React.useCallback(function (suffixCls, customizePrefixCls) {
|
97
|
+
var prefixCls = props.prefixCls;
|
98
|
+
if (customizePrefixCls) return customizePrefixCls;
|
99
|
+
var mergedPrefixCls = prefixCls || parentContext.getPrefixCls('');
|
100
|
+
return suffixCls ? "".concat(mergedPrefixCls, "-").concat(suffixCls) : mergedPrefixCls;
|
101
|
+
}, [parentContext.getPrefixCls, props.prefixCls]);
|
102
|
+
|
103
|
+
var config = _extends(_extends({}, parentContext), {
|
104
|
+
csp: csp,
|
105
|
+
autoInsertSpaceInButton: autoInsertSpaceInButton,
|
106
|
+
locale: locale || legacyLocale,
|
107
|
+
direction: direction,
|
108
|
+
space: space,
|
109
|
+
virtual: virtual,
|
110
|
+
dropdownMatchSelectWidth: dropdownMatchSelectWidth,
|
111
|
+
getPrefixCls: getPrefixCls
|
112
|
+
}); // Pass the props used by `useContext` directly with child component.
|
113
|
+
// These props should merged into `config`.
|
114
|
+
|
115
|
+
|
116
|
+
PASSED_PROPS.forEach(function (propName) {
|
117
|
+
var propValue = props[propName];
|
118
|
+
|
119
|
+
if (propValue) {
|
120
|
+
config[propName] = propValue;
|
121
|
+
}
|
122
|
+
}); // https://github.com/ant-design/ant-design/issues/27617
|
123
|
+
|
124
|
+
var memoedConfig = useMemo(function () {
|
125
|
+
return config;
|
126
|
+
}, config, function (prevConfig, currentConfig) {
|
127
|
+
var prevKeys = Object.keys(prevConfig);
|
128
|
+
var currentKeys = Object.keys(currentConfig);
|
129
|
+
return prevKeys.length !== currentKeys.length || prevKeys.some(function (key) {
|
130
|
+
return prevConfig[key] !== currentConfig[key];
|
131
|
+
});
|
132
|
+
});
|
133
|
+
var memoIconContextValue = React.useMemo(function () {
|
134
|
+
return {
|
135
|
+
prefixCls: iconPrefixCls,
|
136
|
+
csp: csp
|
137
|
+
};
|
138
|
+
}, [iconPrefixCls, csp]);
|
139
|
+
var childNode = children; // Additional Form provider
|
140
|
+
|
141
|
+
var validateMessages = {};
|
142
|
+
|
143
|
+
if (locale) {
|
144
|
+
validateMessages = ((_a = locale.Form) === null || _a === void 0 ? void 0 : _a.defaultValidateMessages) || ((_b = defaultLocale.Form) === null || _b === void 0 ? void 0 : _b.defaultValidateMessages) || {};
|
145
|
+
}
|
146
|
+
|
147
|
+
if (form && form.validateMessages) {
|
148
|
+
validateMessages = _extends(_extends({}, validateMessages), form.validateMessages);
|
149
|
+
}
|
150
|
+
|
151
|
+
if (Object.keys(validateMessages).length > 0) {
|
152
|
+
childNode = /*#__PURE__*/React.createElement(RcFormProvider, {
|
153
|
+
validateMessages: validateMessages
|
154
|
+
}, children);
|
155
|
+
}
|
156
|
+
|
157
|
+
if (locale) {
|
158
|
+
childNode = /*#__PURE__*/React.createElement(LocaleProvider, {
|
159
|
+
locale: locale,
|
160
|
+
_ANT_MARK__: ANT_MARK
|
161
|
+
}, childNode);
|
162
|
+
}
|
163
|
+
|
164
|
+
if (iconPrefixCls || csp) {
|
165
|
+
childNode = /*#__PURE__*/React.createElement(IconContext.Provider, {
|
166
|
+
value: memoIconContextValue
|
167
|
+
}, childNode);
|
168
|
+
}
|
169
|
+
|
170
|
+
if (componentSize) {
|
171
|
+
childNode = /*#__PURE__*/React.createElement(SizeContextProvider, {
|
172
|
+
size: componentSize
|
173
|
+
}, childNode);
|
174
|
+
}
|
175
|
+
|
176
|
+
if (componentDisabled !== undefined) {
|
177
|
+
childNode = /*#__PURE__*/React.createElement(DisabledContextProvider, {
|
178
|
+
disabled: componentDisabled
|
179
|
+
}, childNode);
|
180
|
+
}
|
181
|
+
|
182
|
+
return /*#__PURE__*/React.createElement(ConfigContext.Provider, {
|
183
|
+
value: memoedConfig
|
184
|
+
}, childNode);
|
185
|
+
};
|
186
|
+
|
187
|
+
var ConfigProvider = function ConfigProvider(props) {
|
188
|
+
React.useEffect(function () {
|
189
|
+
if (props.direction) {
|
190
|
+
message.config({
|
191
|
+
rtl: props.direction === 'rtl'
|
192
|
+
});
|
193
|
+
notification.config({
|
194
|
+
rtl: props.direction === 'rtl'
|
195
|
+
});
|
196
|
+
}
|
197
|
+
}, [props.direction]);
|
198
|
+
return /*#__PURE__*/React.createElement(LocaleReceiver, null, function (_, __, legacyLocale) {
|
199
|
+
return /*#__PURE__*/React.createElement(ConfigConsumer, null, function (context) {
|
200
|
+
return /*#__PURE__*/React.createElement(ProviderChildren, _extends({
|
201
|
+
parentContext: context,
|
202
|
+
legacyLocale: legacyLocale
|
203
|
+
}, props));
|
204
|
+
});
|
205
|
+
});
|
206
|
+
};
|
207
|
+
/** @private internal Usage. do not use in your production */
|
208
|
+
|
209
|
+
|
210
|
+
ConfigProvider.ConfigContext = ConfigContext;
|
211
|
+
ConfigProvider.SizeContext = SizeContext;
|
212
|
+
ConfigProvider.config = setGlobalConfig;
|
213
|
+
export default ConfigProvider;
|
@@ -0,0 +1 @@
|
|
1
|
+
import "./index.css";
|
@@ -0,0 +1 @@
|
|
1
|
+
import './index.less';
|
@@ -0,0 +1 @@
|
|
1
|
+
import "./index.less";
|
package/es/style/index.less
CHANGED
@@ -0,0 +1,9 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
export type DisabledType = true | false | undefined;
|
3
|
+
declare const DisabledContext: React.Context<DisabledType>;
|
4
|
+
export interface DisabledContextProps {
|
5
|
+
disabled?: DisabledType;
|
6
|
+
children?: React.ReactNode;
|
7
|
+
}
|
8
|
+
export declare const DisabledContextProvider: React.FC<DisabledContextProps>;
|
9
|
+
export default DisabledContext;
|
@@ -0,0 +1,25 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];
|
4
|
+
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
6
|
+
value: true
|
7
|
+
});
|
8
|
+
exports["default"] = exports.DisabledContextProvider = void 0;
|
9
|
+
|
10
|
+
var React = _interopRequireWildcard(require("react"));
|
11
|
+
|
12
|
+
var DisabledContext = /*#__PURE__*/React.createContext(false);
|
13
|
+
|
14
|
+
var DisabledContextProvider = function DisabledContextProvider(_ref) {
|
15
|
+
var children = _ref.children,
|
16
|
+
disabled = _ref.disabled;
|
17
|
+
var originDisabled = React.useContext(DisabledContext);
|
18
|
+
return /*#__PURE__*/React.createElement(DisabledContext.Provider, {
|
19
|
+
value: disabled !== null && disabled !== void 0 ? disabled : originDisabled
|
20
|
+
}, children);
|
21
|
+
};
|
22
|
+
|
23
|
+
exports.DisabledContextProvider = DisabledContextProvider;
|
24
|
+
var _default = DisabledContext;
|
25
|
+
exports["default"] = _default;
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
export type SizeType = 'small' | 'middle' | 'large' | undefined;
|
3
|
+
declare const SizeContext: React.Context<SizeType>;
|
4
|
+
export interface SizeContextProps {
|
5
|
+
size?: SizeType;
|
6
|
+
children?: React.ReactNode;
|
7
|
+
}
|
8
|
+
export declare const SizeContextProvider: React.FC<SizeContextProps>;
|
9
|
+
export default SizeContext;
|