Update from Vibe Studio

This commit is contained in:
Vibe Studio
2026-01-12 09:12:41 +00:00
parent a4605e311a
commit a6ae5199b0
29756 changed files with 2526222 additions and 278 deletions

19
node_modules/@ant-design/pro-utils/README.md generated vendored Normal file
View File

@@ -0,0 +1,19 @@
# @ant-design/pro-utils
> @ant-design/pro-utils.
See our website [@ant-design/pro-utils](https://procomponent.ant.design/) for more information.
## Install
Using npm:
```bash
$ npm install --save @ant-design/pro-utils
```
or using yarn:
```bash
$ yarn add @ant-design/pro-utils
```

View File

@@ -0,0 +1,2 @@
import { ComponentToken } from 'antd/es/menu/style';
export declare function coverToNewToken(token: Partial<ComponentToken>): Partial<ComponentToken>;

View File

@@ -0,0 +1,40 @@
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import { compareVersions } from "./index";
import { getVersion } from "./openVisibleCompatible";
export function coverToNewToken(token) {
if (compareVersions(getVersion(), '5.6.0') < 0) return token;
var deprecatedTokens = {
colorGroupTitle: 'groupTitleColor',
radiusItem: 'itemBorderRadius',
radiusSubMenuItem: 'subMenuItemBorderRadius',
colorItemText: 'itemColor',
colorItemTextHover: 'itemHoverColor',
colorItemTextHoverHorizontal: 'horizontalItemHoverColor',
colorItemTextSelected: 'itemSelectedColor',
colorItemTextSelectedHorizontal: 'horizontalItemSelectedColor',
colorItemTextDisabled: 'itemDisabledColor',
colorDangerItemText: 'dangerItemColor',
colorDangerItemTextHover: 'dangerItemHoverColor',
colorDangerItemTextSelected: 'dangerItemSelectedColor',
colorDangerItemBgActive: 'dangerItemActiveBg',
colorDangerItemBgSelected: 'dangerItemSelectedBg',
colorItemBg: 'itemBg',
colorItemBgHover: 'itemHoverBg',
colorSubItemBg: 'subMenuItemBg',
colorItemBgActive: 'itemActiveBg',
colorItemBgSelected: 'itemSelectedBg',
colorItemBgSelectedHorizontal: 'horizontalItemSelectedBg',
colorActiveBarWidth: 'activeBarWidth',
colorActiveBarHeight: 'activeBarHeight',
colorActiveBarBorderSize: 'activeBarBorderWidth'
};
var newToken = _objectSpread({}, token);
Object.keys(deprecatedTokens).forEach(function (key) {
if (newToken[key] !== undefined) {
// @ts-ignore
newToken[deprecatedTokens[key]] = newToken[key];
delete newToken[key];
}
});
return newToken;
}

View File

@@ -0,0 +1,8 @@
/**
* Compare [semver](https://semver.org/) version strings to find greater, equal or lesser.
* This library supports the full semver specification, including comparing versions with different number of digits like `1.0.0`, `1.0`, `1`, and pre-release versions like `1.0.0-alpha`.
* @param v1 - First version to compare
* @param v2 - Second version to compare
* @returns Numeric value compatible with the [Array.sort(fn) interface](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#Parameters).
*/
export declare const compareVersions: (v1: string, v2: string) => number;

View File

@@ -0,0 +1,87 @@
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
import _typeof from "@babel/runtime/helpers/esm/typeof";
var semver = /^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i;
/**
* @param {string} s
*/
var isWildcard = function isWildcard(s) {
return s === '*' || s === 'x' || s === 'X';
};
/**
* @param {string} v
*/
var tryParse = function tryParse(v) {
var n = parseInt(v, 10);
return isNaN(n) ? v : n;
};
/**
* @param {string|number} a
* @param {string|number} b
*/
var forceType = function forceType(a, b) {
return _typeof(a) !== _typeof(b) ? [String(a), String(b)] : [a, b];
};
/**
* @param {string} a
* @param {string} b
* @returns number
*/
var compareStrings = function compareStrings(a, b) {
if (isWildcard(a) || isWildcard(b)) return 0;
var _forceType = forceType(tryParse(a), tryParse(b)),
_forceType2 = _slicedToArray(_forceType, 2),
ap = _forceType2[0],
bp = _forceType2[1];
if (ap > bp) return 1;
if (ap < bp) return -1;
return 0;
};
/**
* @param {string|RegExpMatchArray} a
* @param {string|RegExpMatchArray} b
* @returns number
*/
var compareSegments = function compareSegments(a, b) {
for (var i = 0; i < Math.max(a.length, b.length); i++) {
var r = compareStrings(a[i] || '0', b[i] || '0');
if (r !== 0) return r;
}
return 0;
};
/**
* @param {string} version
* @returns RegExpMatchArray
*/
var validateAndParse = function validateAndParse(version) {
var _match$shift;
var match = version.match(semver);
match === null || match === void 0 || (_match$shift = match.shift) === null || _match$shift === void 0 || _match$shift.call(match);
return match;
};
/**
* Compare [semver](https://semver.org/) version strings to find greater, equal or lesser.
* This library supports the full semver specification, including comparing versions with different number of digits like `1.0.0`, `1.0`, `1`, and pre-release versions like `1.0.0-alpha`.
* @param v1 - First version to compare
* @param v2 - Second version to compare
* @returns Numeric value compatible with the [Array.sort(fn) interface](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#Parameters).
*/
export var compareVersions = function compareVersions(v1, v2) {
// validate input and split into segments
var n1 = validateAndParse(v1);
var n2 = validateAndParse(v2);
// pop off the patch
var p1 = n1.pop();
var p2 = n2.pop();
// validate numbers
var r = compareSegments(n1, n2);
if (r !== 0) return r;
if (p1 || p2) {
return p1 ? -1 : 1;
}
return 0;
};

View File

@@ -0,0 +1,9 @@
import type { MenuProps } from 'antd';
declare const menuOverlayCompatible: (menu: MenuProps) => {
menu: MenuProps;
overlay?: undefined;
} | {
overlay: import("react/jsx-runtime").JSX.Element;
menu?: undefined;
};
export { menuOverlayCompatible };

View File

@@ -0,0 +1,15 @@
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import { Menu } from 'antd';
import { omitUndefined } from "../omitUndefined";
import { compareVersions } from "./index";
import { getVersion } from "./openVisibleCompatible";
import { jsx as _jsx } from "react/jsx-runtime";
var menuOverlayCompatible = function menuOverlayCompatible(menu) {
var props = compareVersions(getVersion(), '4.24.0') > -1 ? {
menu: menu
} : {
overlay: /*#__PURE__*/_jsx(Menu, _objectSpread({}, menu))
};
return omitUndefined(props);
};
export { menuOverlayCompatible };

View File

@@ -0,0 +1,13 @@
export declare const getVersion: () => string;
declare const openVisibleCompatible: (open?: boolean, onOpenChange?: any) => {
open: NonNullable<boolean | undefined>;
onOpenChange: any;
visible?: undefined;
onVisibleChange?: undefined;
} | {
visible: NonNullable<boolean | undefined>;
onVisibleChange: any;
open?: undefined;
onOpenChange?: undefined;
};
export { openVisibleCompatible };

View File

@@ -0,0 +1,19 @@
import { version } from 'antd';
import { omitUndefined } from "../omitUndefined";
import { compareVersions } from "./index";
export var getVersion = function getVersion() {
var _process;
if (typeof process === 'undefined') return version;
return ((_process = process) === null || _process === void 0 || (_process = _process.env) === null || _process === void 0 ? void 0 : _process.ANTD_VERSION) || version;
};
var openVisibleCompatible = function openVisibleCompatible(open, onOpenChange) {
var props = compareVersions(getVersion(), '4.23.0') > -1 ? {
open: open,
onOpenChange: onOpenChange
} : {
visible: open,
onVisibleChange: onOpenChange
};
return omitUndefined(props);
};
export { openVisibleCompatible };

View File

@@ -0,0 +1,10 @@
/**
* 兼容 antd 5.13.0 以下版本的 bordered 属性
* @param bordered
* @returns
*/
export declare const compatibleBorder: (bordered?: boolean) => {
variant?: "outlined" | "borderless" | "filled" | "underlined" | undefined;
} | {
bordered: boolean;
};

View File

@@ -0,0 +1,18 @@
import { version } from 'antd';
import { compareVersions } from "../compareVersions";
/**
* 兼容 antd 5.13.0 以下版本的 bordered 属性
* @param bordered
* @returns
*/
export var compatibleBorder = function compatibleBorder(bordered) {
if (bordered === undefined) {
return {};
}
return compareVersions(version, '5.13.0') <= 0 ? {
bordered: bordered
} : {
variant: bordered ? undefined : 'borderless'
};
};

View File

@@ -0,0 +1,12 @@
import React from 'react';
type LightFilterFooterRender = ((onConfirm?: (e?: React.MouseEvent) => void, onClear?: (e?: React.MouseEvent) => void) => JSX.Element | false) | false;
type OnClick = (e?: React.MouseEvent) => void;
export type DropdownFooterProps = {
onClear?: OnClick;
onConfirm?: OnClick;
disabled?: boolean;
footerRender?: LightFilterFooterRender;
children?: React.ReactNode;
};
declare const DropdownFooter: React.FC<DropdownFooterProps>;
export { DropdownFooter };

View File

@@ -0,0 +1,53 @@
import { useIntl } from '@ant-design/pro-provider';
import { Button, ConfigProvider } from 'antd';
import classNames from 'classnames';
import React, { useContext } from 'react';
import { useStyle } from "./style";
import { jsx as _jsx } from "react/jsx-runtime";
var DropdownFooter = function DropdownFooter(props) {
var intl = useIntl();
var onClear = props.onClear,
onConfirm = props.onConfirm,
disabled = props.disabled,
footerRender = props.footerRender;
var _useContext = useContext(ConfigProvider.ConfigContext),
getPrefixCls = _useContext.getPrefixCls;
var prefixCls = getPrefixCls('pro-core-dropdown-footer');
var _useStyle = useStyle(prefixCls),
wrapSSR = _useStyle.wrapSSR,
hashId = _useStyle.hashId;
var defaultFooter = [/*#__PURE__*/_jsx(Button, {
style: {
visibility: onClear ? 'visible' : 'hidden'
},
type: "link",
size: "small",
disabled: disabled,
onClick: function onClick(e) {
if (onClear) {
onClear(e);
}
e.stopPropagation();
},
children: intl.getMessage('form.lightFilter.clear', '清除')
}, "clear"), /*#__PURE__*/_jsx(Button, {
"data-type": "confirm",
type: "primary",
size: "small",
onClick: onConfirm,
disabled: disabled,
children: intl.getMessage('form.lightFilter.confirm', '确认')
}, "confirm")];
if (footerRender === false || (footerRender === null || footerRender === void 0 ? void 0 : footerRender(onConfirm, onClear)) === false) {
return null;
}
var renderDom = (footerRender === null || footerRender === void 0 ? void 0 : footerRender(onConfirm, onClear)) || defaultFooter;
return wrapSSR( /*#__PURE__*/_jsx("div", {
className: classNames(prefixCls, hashId),
onClick: function onClick(e) {
return e.target.getAttribute('data-type') !== 'confirm' && e.stopPropagation();
},
children: renderDom
}));
};
export { DropdownFooter };

View File

@@ -0,0 +1,9 @@
/// <reference types="react" />
import type { ProAliasToken } from '@ant-design/pro-provider';
export interface ProToken extends ProAliasToken {
componentCls: string;
}
export declare function useStyle(prefixCls: string): {
wrapSSR: (node: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>) => import("react").JSX.Element;
hashId: string;
};

View File

@@ -0,0 +1,21 @@
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import { useStyle as useAntdStyle } from '@ant-design/pro-provider';
var genProStyle = function genProStyle(token) {
return _defineProperty({}, token.componentCls, {
display: 'flex',
justifyContent: 'space-between',
paddingBlock: 8,
paddingInlineStart: 8,
paddingInlineEnd: 8,
borderBlockStart: "1px solid ".concat(token.colorSplit)
});
};
export function useStyle(prefixCls) {
return useAntdStyle('DropdownFooter', function (token) {
var proToken = _objectSpread(_objectSpread({}, token), {}, {
componentCls: ".".concat(prefixCls)
});
return [genProStyle(proToken)];
});
}

View File

@@ -0,0 +1,20 @@
import type { ErrorInfo } from 'react';
import React from 'react';
declare class ErrorBoundary extends React.Component<{
children?: React.ReactNode;
}, {
hasError: boolean;
errorInfo: string;
}> {
state: {
hasError: boolean;
errorInfo: string;
};
static getDerivedStateFromError(error: Error): {
hasError: boolean;
errorInfo: string;
};
componentDidCatch(error: any, errorInfo: ErrorInfo): void;
render(): string | number | boolean | Iterable<React.ReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
}
export { ErrorBoundary };

View File

@@ -0,0 +1,59 @@
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import { Result } from 'antd';
import React from 'react';
// eslint-disable-next-line @typescript-eslint/ban-types
import { jsx as _jsx } from "react/jsx-runtime";
var ErrorBoundary = /*#__PURE__*/function (_React$Component) {
_inherits(ErrorBoundary, _React$Component);
var _super = _createSuper(ErrorBoundary);
function ErrorBoundary() {
var _this;
_classCallCheck(this, ErrorBoundary);
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
_this = _super.call.apply(_super, [this].concat(args));
_defineProperty(_assertThisInitialized(_this), "state", {
hasError: false,
errorInfo: ''
});
return _this;
}
_createClass(ErrorBoundary, [{
key: "componentDidCatch",
value: function componentDidCatch(error, errorInfo) {
// You can also log the error to an error reporting service
// eslint-disable-next-line no-console
console.log(error, errorInfo);
}
}, {
key: "render",
value: function render() {
if (this.state.hasError) {
// You can render any custom fallback UI
return /*#__PURE__*/_jsx(Result, {
status: "error",
title: "Something went wrong.",
extra: this.state.errorInfo
});
}
return this.props.children;
}
}], [{
key: "getDerivedStateFromError",
value: function getDerivedStateFromError(error) {
return {
hasError: true,
errorInfo: error.message
};
}
}]);
return ErrorBoundary;
}(React.Component);
export { ErrorBoundary };

View File

@@ -0,0 +1,24 @@
import type { SizeType } from 'antd/lib/config-provider/SizeContext';
import React from 'react';
export type FieldLabelProps = {
label?: React.ReactNode;
value?: any;
disabled?: boolean;
onClear?: () => void;
size?: SizeType;
ellipsis?: boolean;
placeholder?: React.ReactNode;
className?: string;
formatter?: (value: any) => React.ReactNode;
style?: React.CSSProperties;
bordered?: boolean;
allowClear?: boolean;
downIcon?: React.ReactNode | false;
onClick?: () => void;
valueMaxLength?: number;
/**
* 点击标签的事件,用来唤醒 down menu 状态
*/
onLabelClick?: () => void;
};
export declare const FieldLabel: React.ForwardRefExoticComponent<FieldLabelProps & React.RefAttributes<any>>;

View File

@@ -0,0 +1,141 @@
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import { CloseCircleFilled, DownOutlined } from '@ant-design/icons';
import { useIntl } from '@ant-design/pro-provider';
import { ConfigProvider } from 'antd';
import classNames from 'classnames';
import React, { useContext, useImperativeHandle, useRef } from 'react';
import { useStyle } from "./style";
import { jsxs as _jsxs } from "react/jsx-runtime";
import { jsx as _jsx } from "react/jsx-runtime";
var FieldLabelFunction = function FieldLabelFunction(props, ref) {
var _ConfigProvider$useCo, _ref2, _props$size;
var label = props.label,
onClear = props.onClear,
value = props.value,
disabled = props.disabled,
onLabelClick = props.onLabelClick,
ellipsis = props.ellipsis,
placeholder = props.placeholder,
className = props.className,
formatter = props.formatter,
bordered = props.bordered,
style = props.style,
downIcon = props.downIcon,
_props$allowClear = props.allowClear,
allowClear = _props$allowClear === void 0 ? true : _props$allowClear,
_props$valueMaxLength = props.valueMaxLength,
valueMaxLength = _props$valueMaxLength === void 0 ? 41 : _props$valueMaxLength;
var _ref = (ConfigProvider === null || ConfigProvider === void 0 || (_ConfigProvider$useCo = ConfigProvider.useConfig) === null || _ConfigProvider$useCo === void 0 ? void 0 : _ConfigProvider$useCo.call(ConfigProvider)) || {
componentSize: 'middle'
},
componentSize = _ref.componentSize;
var size = componentSize;
var _useContext = useContext(ConfigProvider.ConfigContext),
getPrefixCls = _useContext.getPrefixCls;
var prefixCls = getPrefixCls('pro-core-field-label');
var _useStyle = useStyle(prefixCls),
wrapSSR = _useStyle.wrapSSR,
hashId = _useStyle.hashId;
var intl = useIntl();
var clearRef = useRef(null);
var labelRef = useRef(null);
useImperativeHandle(ref, function () {
return {
labelRef: labelRef,
clearRef: clearRef
};
});
var wrapElements = function wrapElements(array) {
if (array.every(function (item) {
return typeof item === 'string';
})) return array.join(',');
return array.map(function (item, index) {
var comma = index === array.length - 1 ? '' : ',';
if (typeof item === 'string') {
return /*#__PURE__*/_jsxs("span", {
children: [item, comma]
}, index);
}
return /*#__PURE__*/_jsxs("span", {
style: {
display: 'flex'
},
children: [item, comma]
}, index);
});
};
var formatterText = function formatterText(aValue) {
if (formatter) {
return formatter(aValue);
}
return Array.isArray(aValue) ? wrapElements(aValue) : aValue;
};
var getTextByValue = function getTextByValue(aLabel, aValue) {
if (aValue !== undefined && aValue !== null && aValue !== '' && (!Array.isArray(aValue) || aValue.length)) {
var _str$toString, _str$toString$slice;
var prefix = aLabel ? /*#__PURE__*/_jsxs("span", {
onClick: function onClick() {
onLabelClick === null || onLabelClick === void 0 || onLabelClick();
},
className: "".concat(prefixCls, "-text"),
children: [aLabel, ': ']
}) : '';
var str = formatterText(aValue);
if (!ellipsis) {
return /*#__PURE__*/_jsxs("span", {
style: {
display: 'inline-flex',
alignItems: 'center'
},
children: [prefix, formatterText(aValue)]
});
}
var getText = function getText() {
var isArrayValue = Array.isArray(aValue) && aValue.length > 1;
var unitText = intl.getMessage('form.lightFilter.itemUnit', '项');
if (typeof str === 'string' && str.length > valueMaxLength && isArrayValue) {
return "...".concat(aValue.length).concat(unitText);
}
return '';
};
var tail = getText();
return /*#__PURE__*/_jsxs("span", {
title: typeof str === 'string' ? str : undefined,
style: {
display: 'inline-flex',
alignItems: 'center'
},
children: [prefix, /*#__PURE__*/_jsx("span", {
style: {
paddingInlineStart: 4,
display: 'flex'
},
children: typeof str === 'string' ? str === null || str === void 0 || (_str$toString = str.toString()) === null || _str$toString === void 0 || (_str$toString$slice = _str$toString.slice) === null || _str$toString$slice === void 0 ? void 0 : _str$toString$slice.call(_str$toString, 0, valueMaxLength) : str
}), tail]
});
}
return aLabel || placeholder;
};
return wrapSSR( /*#__PURE__*/_jsxs("span", {
className: classNames(prefixCls, hashId, "".concat(prefixCls, "-").concat((_ref2 = (_props$size = props.size) !== null && _props$size !== void 0 ? _props$size : size) !== null && _ref2 !== void 0 ? _ref2 : 'middle'), _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(prefixCls, "-active"), (Array.isArray(value) ? value.length > 0 : !!value) || value === 0), "".concat(prefixCls, "-disabled"), disabled), "".concat(prefixCls, "-bordered"), bordered), "".concat(prefixCls, "-allow-clear"), allowClear), className),
style: style,
ref: labelRef,
onClick: function onClick() {
var _props$onClick;
props === null || props === void 0 || (_props$onClick = props.onClick) === null || _props$onClick === void 0 || _props$onClick.call(props);
},
children: [getTextByValue(label, value), (value || value === 0) && allowClear && /*#__PURE__*/_jsx(CloseCircleFilled, {
role: "button",
title: intl.getMessage('form.lightFilter.clear', '清除'),
className: classNames("".concat(prefixCls, "-icon"), hashId, "".concat(prefixCls, "-close")),
onClick: function onClick(e) {
if (!disabled) onClear === null || onClear === void 0 || onClear();
e.stopPropagation();
},
ref: clearRef
}), downIcon !== false ? downIcon !== null && downIcon !== void 0 ? downIcon : /*#__PURE__*/_jsx(DownOutlined, {
className: classNames("".concat(prefixCls, "-icon"), hashId, "".concat(prefixCls, "-arrow"))
}) : null]
}));
};
export var FieldLabel = /*#__PURE__*/React.forwardRef(FieldLabelFunction);

View File

@@ -0,0 +1,9 @@
/// <reference types="react" />
import type { ProAliasToken } from '@ant-design/pro-provider';
export interface ProToken extends ProAliasToken {
componentCls: string;
}
export declare function useStyle(prefixCls: string): {
wrapSSR: (node: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>) => import("react").JSX.Element;
hashId: string;
};

View File

@@ -0,0 +1,89 @@
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import { useStyle as useAntdStyle } from '@ant-design/pro-provider';
var genProStyle = function genProStyle(token) {
return _defineProperty({}, token.componentCls, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({
display: 'inline-flex',
gap: token.marginXXS,
alignItems: 'center',
height: '30px',
paddingBlock: 0,
paddingInline: 8,
fontSize: token.fontSize,
lineHeight: '30px',
borderRadius: '2px',
cursor: 'pointer',
'&:hover': {
backgroundColor: token.colorBgTextHover
},
'&-active': _defineProperty({
paddingBlock: 0,
paddingInline: 8,
backgroundColor: token.colorBgTextHover
}, "&".concat(token.componentCls, "-allow-clear:hover:not(").concat(token.componentCls, "-disabled)"), _defineProperty(_defineProperty({}, "".concat(token.componentCls, "-arrow"), {
display: 'none'
}), "".concat(token.componentCls, "-close"), {
display: 'inline-flex'
}))
}, "".concat(token.antCls, "-select"), _defineProperty({}, "".concat(token.antCls, "-select-clear"), {
borderRadius: '50%'
})), "".concat(token.antCls, "-picker"), _defineProperty({}, "".concat(token.antCls, "-picker-clear"), {
borderRadius: '50%'
})), '&-icon', _defineProperty(_defineProperty({
color: token.colorIcon,
transition: 'color 0.3s',
fontSize: 12,
verticalAlign: 'middle'
}, "&".concat(token.componentCls, "-close"), {
display: 'none',
fontSize: 12,
alignItems: 'center',
justifyContent: 'center',
color: token.colorTextPlaceholder,
borderRadius: '50%'
}), '&:hover', {
color: token.colorIconHover
})), '&-disabled', _defineProperty({
color: token.colorTextPlaceholder,
cursor: 'not-allowed'
}, "".concat(token.componentCls, "-icon"), {
color: token.colorTextPlaceholder
})), '&-small', _defineProperty(_defineProperty(_defineProperty({
height: '24px',
paddingBlock: 0,
paddingInline: 4,
fontSize: token.fontSizeSM,
lineHeight: '24px'
}, "&".concat(token.componentCls, "-active"), {
paddingBlock: 0,
paddingInline: 8
}), "".concat(token.componentCls, "-icon"), {
paddingBlock: 0,
paddingInline: 0
}), "".concat(token.componentCls, "-close"), {
marginBlockStart: '-2px',
paddingBlock: 4,
paddingInline: 4,
fontSize: '6px'
})), '&-bordered', {
height: '32px',
paddingBlock: 0,
paddingInline: 8,
border: "".concat(token.lineWidth, "px solid ").concat(token.colorBorder),
borderRadius: '@border-radius-base'
}), '&-bordered&-small', {
height: '24px',
paddingBlock: 0,
paddingInline: 8
}), '&-bordered&-active', {
backgroundColor: token.colorBgContainer
}));
};
export function useStyle(prefixCls) {
return useAntdStyle('FieldLabel', function (token) {
var proToken = _objectSpread(_objectSpread({}, token), {}, {
componentCls: ".".concat(prefixCls)
});
return [genProStyle(proToken)];
});
}

View File

@@ -0,0 +1,26 @@
import React from 'react';
import type { DropdownFooterProps } from '../DropdownFooter';
import 'antd/lib/dropdown/style';
import type { TooltipPlacement } from 'antd/lib/tooltip';
export type FooterRender = ((onConfirm?: (e?: React.MouseEvent) => void, onClear?: (e?: React.MouseEvent) => void) => JSX.Element | false) | false;
export type DropdownProps = {
label?: React.ReactNode;
footer?: DropdownFooterProps;
footerRender?: FooterRender;
padding?: number;
disabled?: boolean;
/**
* @deprecated use onOpenChange replace
*/
onVisibleChange?: (visible: boolean) => void;
/**
* @deprecated use open replace
*/
visible?: boolean;
onOpenChange?: (visible: boolean) => void;
open?: boolean;
placement?: TooltipPlacement;
children?: React.ReactNode;
};
declare const FilterDropdown: React.FC<DropdownProps>;
export { FilterDropdown };

View File

@@ -0,0 +1,62 @@
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import { ConfigProvider, Popover } from 'antd';
import React, { useContext, useRef } from 'react';
import { DropdownFooter } from "../DropdownFooter";
import "antd/es/dropdown/style";
import classNames from 'classnames';
import { openVisibleCompatible } from "../../compareVersions/openVisibleCompatible";
import { useStyle } from "./style";
import { jsx as _jsx } from "react/jsx-runtime";
import { jsxs as _jsxs } from "react/jsx-runtime";
var FilterDropdown = function FilterDropdown(props) {
var children = props.children,
label = props.label,
footer = props.footer,
open = props.open,
onOpenChange = props.onOpenChange,
disabled = props.disabled,
onVisibleChange = props.onVisibleChange,
visible = props.visible,
footerRender = props.footerRender,
placement = props.placement;
var _useContext = useContext(ConfigProvider.ConfigContext),
getPrefixCls = _useContext.getPrefixCls;
var prefixCls = getPrefixCls('pro-core-field-dropdown');
var _useStyle = useStyle(prefixCls),
wrapSSR = _useStyle.wrapSSR,
hashId = _useStyle.hashId;
var dropdownOpenProps = openVisibleCompatible(open || visible || false, onOpenChange || onVisibleChange);
var htmlRef = useRef(null);
return wrapSSR( /*#__PURE__*/_jsx(Popover, _objectSpread(_objectSpread({
placement: placement,
trigger: ['click']
}, dropdownOpenProps), {}, {
styles: {
body: {
padding: 0
}
},
content: /*#__PURE__*/_jsxs("div", {
ref: htmlRef,
className: classNames("".concat(prefixCls, "-overlay"), _defineProperty(_defineProperty({}, "".concat(prefixCls, "-overlay-").concat(placement), placement), "hashId", hashId)),
children: [/*#__PURE__*/_jsx(ConfigProvider, {
getPopupContainer: function getPopupContainer() {
return htmlRef.current || document.body;
},
children: /*#__PURE__*/_jsx("div", {
className: "".concat(prefixCls, "-content ").concat(hashId).trim(),
children: children
})
}), footer && /*#__PURE__*/_jsx(DropdownFooter, _objectSpread({
disabled: disabled,
footerRender: footerRender
}, footer))]
}),
children: /*#__PURE__*/_jsx("span", {
className: "".concat(prefixCls, "-label ").concat(hashId).trim(),
children: label
})
})));
};
export { FilterDropdown };

View File

@@ -0,0 +1,9 @@
/// <reference types="react" />
import type { ProAliasToken } from '@ant-design/pro-provider';
export interface ProToken extends ProAliasToken {
componentCls: string;
}
export declare function useStyle(prefixCls: string): {
wrapSSR: (node: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>) => import("react").JSX.Element;
hashId: string;
};

View File

@@ -0,0 +1,22 @@
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import { useStyle as useAntdStyle } from '@ant-design/pro-provider';
var genProStyle = function genProStyle(token) {
return _defineProperty(_defineProperty(_defineProperty({}, "".concat(token.componentCls, "-label"), {
cursor: 'pointer'
}), "".concat(token.componentCls, "-overlay"), {
minWidth: '200px',
marginBlockStart: '4px'
}), "".concat(token.componentCls, "-content"), {
paddingBlock: 16,
paddingInline: 16
});
};
export function useStyle(prefixCls) {
return useAntdStyle('FilterDropdown', function (token) {
var proToken = _objectSpread(_objectSpread({}, token), {}, {
componentCls: ".".concat(prefixCls)
});
return [genProStyle(proToken)];
});
}

View File

@@ -0,0 +1,8 @@
import type { FormItemProps, PopoverProps } from 'antd';
interface InlineErrorFormItemProps extends FormItemProps {
errorType?: 'popover' | 'default';
popoverProps?: PopoverProps;
children: any;
}
export declare const InlineErrorFormItem: (props: InlineErrorFormItemProps) => import("react/jsx-runtime").JSX.Element;
export {};

View File

@@ -0,0 +1,149 @@
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
var _excluded = ["rules", "name", "children", "popoverProps"],
_excluded2 = ["errorType", "rules", "name", "popoverProps", "children"];
import { LoadingOutlined } from '@ant-design/icons';
import { useToken } from '@ant-design/pro-provider';
import { ConfigProvider, Form, Popover } from 'antd';
import get from "rc-util/es/utils/get";
import React, { useContext, useEffect, useState } from 'react';
import { openVisibleCompatible } from "../../compareVersions/openVisibleCompatible";
import { useStyle } from "./style";
import { jsx as _jsx } from "react/jsx-runtime";
import { jsxs as _jsxs } from "react/jsx-runtime";
import { Fragment as _Fragment } from "react/jsx-runtime";
var FIX_INLINE_STYLE = {
marginBlockStart: -5,
marginBlockEnd: -5,
marginInlineStart: 0,
marginInlineEnd: 0
};
var InlineErrorFormItemPopover = function InlineErrorFormItemPopover(_ref) {
var inputProps = _ref.inputProps,
input = _ref.input,
extra = _ref.extra,
errorList = _ref.errorList,
popoverProps = _ref.popoverProps;
var _useState = useState(false),
_useState2 = _slicedToArray(_useState, 2),
open = _useState2[0],
setOpen = _useState2[1];
var _useState3 = useState([]),
_useState4 = _slicedToArray(_useState3, 2),
errorStringList = _useState4[0],
setErrorList = _useState4[1];
var _useContext = useContext(ConfigProvider.ConfigContext),
getPrefixCls = _useContext.getPrefixCls;
var prefixCls = getPrefixCls();
var token = useToken();
var _useStyle = useStyle("".concat(prefixCls, "-form-item-with-help")),
wrapSSR = _useStyle.wrapSSR,
hashId = _useStyle.hashId;
useEffect(function () {
if (inputProps.validateStatus !== 'validating') {
setErrorList(inputProps.errors);
}
}, [inputProps.errors, inputProps.validateStatus]);
var popoverOpenProps = openVisibleCompatible(errorStringList.length < 1 ? false : open, function (changeOpen) {
if (changeOpen === open) return;
setOpen(changeOpen);
});
var loading = inputProps.validateStatus === 'validating';
return /*#__PURE__*/_jsx(Popover, _objectSpread(_objectSpread(_objectSpread({
trigger: (popoverProps === null || popoverProps === void 0 ? void 0 : popoverProps.trigger) || ['click'],
placement: (popoverProps === null || popoverProps === void 0 ? void 0 : popoverProps.placement) || 'topLeft'
}, popoverOpenProps), {}, {
getPopupContainer: popoverProps === null || popoverProps === void 0 ? void 0 : popoverProps.getPopupContainer,
getTooltipContainer: popoverProps === null || popoverProps === void 0 ? void 0 : popoverProps.getTooltipContainer,
content: wrapSSR( /*#__PURE__*/_jsx("div", {
className: "".concat(prefixCls, "-form-item ").concat(hashId, " ").concat(token.hashId).trim(),
style: {
margin: 0,
padding: 0
},
children: /*#__PURE__*/_jsxs("div", {
className: "".concat(prefixCls, "-form-item-with-help ").concat(hashId, " ").concat(token.hashId).trim(),
children: [loading ? /*#__PURE__*/_jsx(LoadingOutlined, {}) : null, errorList]
})
}))
}, popoverProps), {}, {
children: /*#__PURE__*/_jsxs(_Fragment, {
children: [input, extra]
})
}), "popover");
};
var InternalFormItemFunction = function InternalFormItemFunction(_ref2) {
var rules = _ref2.rules,
name = _ref2.name,
children = _ref2.children,
popoverProps = _ref2.popoverProps,
rest = _objectWithoutProperties(_ref2, _excluded);
return /*#__PURE__*/_jsx(Form.Item, _objectSpread(_objectSpread({
name: name,
rules: rules,
hasFeedback: false,
shouldUpdate: function shouldUpdate(prev, next) {
if (prev === next) return false;
var shouldName = [name].flat(1);
if (shouldName.length > 1) {
shouldName.pop();
}
try {
return JSON.stringify(get(prev, shouldName)) !== JSON.stringify(get(next, shouldName));
} catch (error) {
return true;
}
}
// @ts-ignore
,
_internalItemRender: {
mark: 'pro_table_render',
render: function render(inputProps, doms) {
return /*#__PURE__*/_jsx(InlineErrorFormItemPopover, _objectSpread({
inputProps: inputProps,
popoverProps: popoverProps
}, doms));
}
}
}, rest), {}, {
style: _objectSpread(_objectSpread({}, FIX_INLINE_STYLE), rest === null || rest === void 0 ? void 0 : rest.style),
children: children
}));
};
export var InlineErrorFormItem = function InlineErrorFormItem(props) {
var errorType = props.errorType,
rules = props.rules,
name = props.name,
popoverProps = props.popoverProps,
children = props.children,
rest = _objectWithoutProperties(props, _excluded2);
if (name && rules !== null && rules !== void 0 && rules.length && errorType === 'popover') {
return /*#__PURE__*/_jsx(InternalFormItemFunction, _objectSpread(_objectSpread({
name: name,
rules: rules,
popoverProps: popoverProps
}, rest), {}, {
children: children
}));
}
return /*#__PURE__*/_jsx(Form.Item, _objectSpread(_objectSpread({
rules: rules,
shouldUpdate: name ? function (prev, next) {
if (prev === next) return false;
var shouldName = [name].flat(1);
if (shouldName.length > 1) {
shouldName.pop();
}
try {
return JSON.stringify(get(prev, shouldName)) !== JSON.stringify(get(next, shouldName));
} catch (error) {
return true;
}
} : undefined
}, rest), {}, {
style: _objectSpread(_objectSpread({}, FIX_INLINE_STYLE), rest.style),
name: name,
children: children
}));
};

View File

@@ -0,0 +1,9 @@
/// <reference types="react" />
import type { ProAliasToken } from '@ant-design/pro-provider';
export interface ProToken extends ProAliasToken {
componentCls: string;
}
export declare function useStyle(prefixCls: string): {
wrapSSR: (node: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>) => import("react").JSX.Element;
hashId: string;
};

View File

@@ -0,0 +1,63 @@
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import { useStyle as useAntdStyle } from '@ant-design/pro-provider';
var genProStyle = function genProStyle(token) {
var progressBgCls = "".concat(token.antCls, "-progress-bg");
return _defineProperty({}, token.componentCls, {
'&-multiple': {
paddingBlockStart: 6,
paddingBlockEnd: 12,
paddingInline: 8
},
'&-progress': {
'&-success': _defineProperty({}, progressBgCls, {
backgroundColor: token.colorSuccess
}),
'&-error': _defineProperty({}, progressBgCls, {
backgroundColor: token.colorError
}),
'&-warning': _defineProperty({}, progressBgCls, {
backgroundColor: token.colorWarning
})
},
'&-rule': {
display: 'flex',
alignItems: 'center',
'&-icon': {
'&-default': {
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
width: '14px',
height: '22px',
'&-circle': {
width: '6px',
height: '6px',
backgroundColor: token.colorTextSecondary,
borderRadius: '4px'
}
},
'&-loading': {
color: token.colorPrimary
},
'&-error': {
color: token.colorError
},
'&-success': {
color: token.colorSuccess
}
},
'&-text': {
color: token.colorText
}
}
});
};
export function useStyle(prefixCls) {
return useAntdStyle('InlineErrorFormItem', function (token) {
var proToken = _objectSpread(_objectSpread({}, token), {}, {
componentCls: ".".concat(prefixCls)
});
return [genProStyle(proToken)];
});
}

View File

@@ -0,0 +1,15 @@
import type { LabelTooltipType } from 'antd/lib/form/FormItemLabel';
import React from 'react';
/**
* 在 form 的 label 后面增加一个 tips 来展示一些说明文案
*
* @param props
*/
export declare const LabelIconTip: React.FC<{
label: React.ReactNode;
subTitle?: React.ReactNode;
tooltip?: string | LabelTooltipType;
ellipsis?: boolean | {
showTitle?: boolean;
};
}>;

View File

@@ -0,0 +1,61 @@
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import { InfoCircleOutlined } from '@ant-design/icons';
import { ConfigProvider, Tooltip } from 'antd';
import classNames from 'classnames';
import React, { useContext } from 'react';
import { useStyle } from "./style";
/**
* 在 form 的 label 后面增加一个 tips 来展示一些说明文案
*
* @param props
*/
import { Fragment as _Fragment } from "react/jsx-runtime";
import { jsx as _jsx } from "react/jsx-runtime";
import { jsxs as _jsxs } from "react/jsx-runtime";
export var LabelIconTip = /*#__PURE__*/React.memo(function (props) {
var label = props.label,
tooltip = props.tooltip,
ellipsis = props.ellipsis,
subTitle = props.subTitle;
var _useContext = useContext(ConfigProvider.ConfigContext),
getPrefixCls = _useContext.getPrefixCls;
var className = getPrefixCls('pro-core-label-tip');
var _useStyle = useStyle(className),
wrapSSR = _useStyle.wrapSSR,
hashId = _useStyle.hashId;
if (!tooltip && !subTitle) {
return /*#__PURE__*/_jsx(_Fragment, {
children: label
});
}
var tooltipProps = typeof tooltip === 'string' || /*#__PURE__*/React.isValidElement(tooltip) ? {
title: tooltip
} : tooltip;
var icon = (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.icon) || /*#__PURE__*/_jsx(InfoCircleOutlined, {});
return wrapSSR( /*#__PURE__*/_jsxs("div", {
className: classNames(className, hashId),
onMouseDown: function onMouseDown(e) {
return e.stopPropagation();
},
onMouseLeave: function onMouseLeave(e) {
return e.stopPropagation();
},
onMouseMove: function onMouseMove(e) {
return e.stopPropagation();
},
children: [/*#__PURE__*/_jsx("div", {
className: classNames("".concat(className, "-title"), hashId, _defineProperty({}, "".concat(className, "-title-ellipsis"), ellipsis)),
children: label
}), subTitle && /*#__PURE__*/_jsx("div", {
className: "".concat(className, "-subtitle ").concat(hashId).trim(),
children: subTitle
}), tooltip && /*#__PURE__*/_jsx(Tooltip, _objectSpread(_objectSpread({}, tooltipProps), {}, {
children: /*#__PURE__*/_jsx("span", {
className: "".concat(className, "-icon ").concat(hashId).trim(),
children: icon
})
}))]
}));
});

View File

@@ -0,0 +1,9 @@
/// <reference types="react" />
import type { ProAliasToken } from '@ant-design/pro-provider';
export interface ProToken extends ProAliasToken {
componentCls: string;
}
export declare function useStyle(prefixCls: string): {
wrapSSR: (node: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>) => import("react").JSX.Element;
hashId: string;
};

View File

@@ -0,0 +1,43 @@
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import { useStyle as useAntdStyle } from '@ant-design/pro-provider';
var genProStyle = function genProStyle(token) {
return _defineProperty({}, token.componentCls, {
display: 'inline-flex',
alignItems: 'center',
maxWidth: '100%',
'&-icon': {
display: 'block',
marginInlineStart: '4px',
cursor: 'pointer',
'&:hover': {
color: token.colorPrimary
}
},
'&-title': {
display: 'inline-flex',
flex: '1'
},
'&-subtitle ': {
marginInlineStart: 8,
color: token.colorTextSecondary,
fontWeight: 'normal',
fontSize: token.fontSize,
whiteSpace: 'nowrap'
},
'&-title-ellipsis': {
overflow: 'hidden',
whiteSpace: 'nowrap',
textOverflow: 'ellipsis',
wordBreak: 'keep-all'
}
});
};
export function useStyle(prefixCls) {
return useAntdStyle('LabelIconTip', function (token) {
var proToken = _objectSpread(_objectSpread({}, token), {}, {
componentCls: ".".concat(prefixCls)
});
return [genProStyle(proToken)];
});
}

View File

@@ -0,0 +1,41 @@
import type { FormInstance } from 'antd';
import type { NamePath } from 'antd/lib/form/interface';
import React from 'react';
export type ProFormInstanceType<T> = {
/**
* 获取被 ProForm 格式化后的所有数据
* @param nameList boolean
* @returns T
*
* @example getFieldsFormatValue() ->返回所有数据
* @example getFieldsFormatValue(true) ->返回所有数据,即使没有被 form 托管的
*/
getFieldsFormatValue?: (nameList?: true, omitNil?: boolean) => T;
/**
* 获取被 ProForm 格式化后的单个数据
* @param nameList (string|number)[]
* @returns T
*
* @example {a:{b:value}} -> getFieldFormatValue(['a', 'b']) -> value
*/
getFieldFormatValue?: (nameList?: NamePath) => T;
/**
* 获取被 ProForm 格式化后的单个数据, 包含他的 name
* @param nameList (string|number)[]
* @returns T
*
* @example {a:{b:value}}->getFieldFormatValueObject(['a','b'])->{a:{b:value}}
*/
getFieldFormatValueObject?: (nameList?: NamePath) => T;
/**
*验字段后返回格式化之后的所有数据
* @param nameList (string|number)[]
* @returns T
*
* @example validateFieldsReturnFormatValue -> {a:{b:value}}
*/
validateFieldsReturnFormatValue?: (nameList?: NamePath[]) => Promise<T>;
};
export declare const ProFormContext: React.Context<ProFormInstanceType<any> & {
formRef?: React.MutableRefObject<FormInstance<any>> | undefined;
}>;

View File

@@ -0,0 +1,2 @@
import React from 'react';
export var ProFormContext = /*#__PURE__*/React.createContext({});

View File

@@ -0,0 +1,45 @@
import type { NamePath } from 'antd/lib/form/interface';
import dayjs from 'dayjs';
import type { ProFieldValueType } from '../typing';
type DateFormatter = (string & {}) | 'number' | 'string' | ((value: dayjs.Dayjs, valueType: string) => string | number) | false;
export declare const dateFormatterMap: {
time: string;
timeRange: string;
date: string;
dateWeek: string;
dateMonth: string;
dateQuarter: string;
dateYear: string;
dateRange: string;
dateTime: string;
dateTimeRange: string;
};
/**
* 判断是否是一个的简单的 object
* @param {{constructor:any}} o
* @returns boolean
*/
export declare function isPlainObject(o: {
constructor: any;
}): boolean;
/**
* 根据不同的格式转化 dayjs
* @param {dayjs.Dayjs} value
* @param {string|((value:dayjs.Dayjs} dateFormatter
* @param {string} valueType
*/
export declare const convertMoment: (value: dayjs.Dayjs, dateFormatter: DateFormatter, valueType: string) => string | number | dayjs.Dayjs;
/**
* 这里主要是来转化一下数据 将 dayjs 转化为 string 将 all 默认删除
* @param {T} value
* @param {DateFormatter} dateFormatter
* @param {Record<string} valueTypeMap
* @param {ProFieldValueType;dateFormat:string;}|any>} |{valueType
* @param {boolean} omitNil?
* @param {NamePath} parentKey?
*/
export declare const conversionMomentValue: <T extends {} = any>(value: T, dateFormatter: DateFormatter, valueTypeMap: Record<string, {
valueType: ProFieldValueType;
dateFormat: string;
} | any>, omitNil?: boolean, parentKey?: NamePath) => T;
export {};

View File

@@ -0,0 +1,144 @@
import _typeof from "@babel/runtime/helpers/esm/typeof";
import dayjs from 'dayjs';
import quarterOfYear from 'dayjs/plugin/quarterOfYear';
import get from "rc-util/es/utils/get";
import { isNil } from "../isNil";
dayjs.extend(quarterOfYear);
export var dateFormatterMap = {
time: 'HH:mm:ss',
timeRange: 'HH:mm:ss',
date: 'YYYY-MM-DD',
dateWeek: 'YYYY-wo',
dateMonth: 'YYYY-MM',
dateQuarter: 'YYYY-[Q]Q',
dateYear: 'YYYY',
dateRange: 'YYYY-MM-DD',
dateTime: 'YYYY-MM-DD HH:mm:ss',
dateTimeRange: 'YYYY-MM-DD HH:mm:ss'
};
/**
* 判断是不是一个 object
* @param {any} o
* @returns boolean
*/
function isObject(o) {
return Object.prototype.toString.call(o) === '[object Object]';
}
/**
* 判断是否是一个的简单的 object
* @param {{constructor:any}} o
* @returns boolean
*/
export function isPlainObject(o) {
if (isObject(o) === false) return false;
// If has modified constructor
var ctor = o.constructor;
if (ctor === undefined) return true;
// If has modified prototype
var prot = ctor.prototype;
if (isObject(prot) === false) return false;
// If constructor does not have an Object-specific method
if (prot.hasOwnProperty('isPrototypeOf') === false) {
return false;
}
// Most likely a plain Object
return true;
}
/**
* 一个比较hack的moment判断工具
* @param {any} value
* @returns boolean
*/
var isMoment = function isMoment(value) {
return !!(value !== null && value !== void 0 && value._isAMomentObject);
};
/**
* 根据不同的格式转化 dayjs
* @param {dayjs.Dayjs} value
* @param {string|((value:dayjs.Dayjs} dateFormatter
* @param {string} valueType
*/
export var convertMoment = function convertMoment(value, dateFormatter, valueType) {
if (!dateFormatter) {
return value;
}
if (dayjs.isDayjs(value) || isMoment(value)) {
if (dateFormatter === 'number') {
return value.valueOf();
}
if (dateFormatter === 'string') {
return value.format(dateFormatterMap[valueType] || 'YYYY-MM-DD HH:mm:ss');
}
if (typeof dateFormatter === 'string' && dateFormatter !== 'string') {
return value.format(dateFormatter);
}
if (typeof dateFormatter === 'function') {
return dateFormatter(value, valueType);
}
}
return value;
};
/**
* 这里主要是来转化一下数据 将 dayjs 转化为 string 将 all 默认删除
* @param {T} value
* @param {DateFormatter} dateFormatter
* @param {Record<string} valueTypeMap
* @param {ProFieldValueType;dateFormat:string;}|any>} |{valueType
* @param {boolean} omitNil?
* @param {NamePath} parentKey?
*/
export var conversionMomentValue = function conversionMomentValue(value, dateFormatter, valueTypeMap, omitNil, parentKey) {
var tmpValue = {};
if (typeof window === 'undefined') return value;
// 如果 value 是 string | null | Blob类型 其中之一,直接返回
// 形如 {key: [File, File]} 的表单字段当进行第二次递归时会导致其直接越过 typeof value !== 'object' 这一判断 https://github.com/ant-design/pro-components/issues/2071
if (_typeof(value) !== 'object' || isNil(value) || value instanceof Blob || Array.isArray(value)) {
return value;
}
Object.keys(value).forEach(function (valueKey) {
var namePath = parentKey ? [parentKey, valueKey].flat(1) : [valueKey];
var valueFormatMap = get(valueTypeMap, namePath) || 'text';
var valueType = 'text';
var dateFormat;
if (typeof valueFormatMap === 'string') {
valueType = valueFormatMap;
} else if (valueFormatMap) {
valueType = valueFormatMap.valueType;
dateFormat = valueFormatMap.dateFormat;
}
var itemValue = value[valueKey];
if (isNil(itemValue) && omitNil) {
return;
}
// 处理嵌套的情况
if (isPlainObject(itemValue) &&
// 不是数组
!Array.isArray(itemValue) &&
// 不是 dayjs
!dayjs.isDayjs(itemValue) &&
// 不是 moment
!isMoment(itemValue)) {
tmpValue[valueKey] = conversionMomentValue(itemValue, dateFormatter, valueTypeMap, omitNil, namePath);
return;
}
// 处理 FormList 的 value
if (Array.isArray(itemValue)) {
tmpValue[valueKey] = itemValue.map(function (arrayValue, index) {
if (dayjs.isDayjs(arrayValue) || isMoment(arrayValue)) {
return convertMoment(arrayValue, dateFormat || dateFormatter, valueType);
}
return conversionMomentValue(arrayValue, dateFormatter, valueTypeMap, omitNil, [valueKey, "".concat(index)].flat(1));
});
return;
}
tmpValue[valueKey] = convertMoment(itemValue, dateFormat || dateFormatter, valueType);
});
return tmpValue;
};

View File

@@ -0,0 +1,12 @@
type FormatType = ((dayjs: any) => string) | string;
/**
* 格式化区域日期,如果是一个数组,会返回 start ~ end
* @param {any} value
* @param {FormatType | FormatType[]} format
* returns string
*/
export declare const dateArrayFormatter: (value: any[], format: FormatType | {
format: string;
type?: "mask" | undefined;
} | FormatType[]) => string;
export {};

View File

@@ -0,0 +1,45 @@
import _typeof from "@babel/runtime/helpers/esm/typeof";
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
import dayjs from 'dayjs';
/**
* 通过 format 来格式化日期因为支持了function 所以需要单独的方法来处理
* @param {any} endText
* @param {FormatType} format
* @return string
*/
var formatString = function formatString(endText, format) {
if (typeof format === 'function') {
return format(dayjs(endText));
}
return dayjs(endText).format(format);
};
/**
* 格式化区域日期,如果是一个数组,会返回 start ~ end
* @param {any} value
* @param {FormatType | FormatType[]} format
* returns string
*/
export var dateArrayFormatter = function dateArrayFormatter(value, format) {
var _ref = Array.isArray(value) ? value : [],
_ref2 = _slicedToArray(_ref, 2),
startText = _ref2[0],
endText = _ref2[1];
var formatFirst;
var formatEnd;
if (Array.isArray(format)) {
formatFirst = format[0];
formatEnd = format[1];
} else if (_typeof(format) === 'object' && format.type === 'mask') {
formatFirst = format.format;
formatEnd = format.format;
} else {
formatFirst = format;
formatEnd = format;
}
// activePickerIndex for https://github.com/ant-design/ant-design/issues/22158
var parsedStartText = startText ? formatString(startText, formatFirst) : '';
var parsedEndText = endText ? formatString(endText, formatEnd) : '';
var valueStr = parsedStartText && parsedEndText ? "".concat(parsedStartText, " ~ ").concat(parsedEndText) : '';
return valueStr;
};

View File

@@ -0,0 +1,9 @@
import React from 'react';
/**
* 生成 Copyable 或 Ellipsis 的 dom
*
* @param dom
* @param item
* @param text
*/
export declare const genCopyable: (dom: React.ReactNode, item: any, text: string) => string | number | boolean | Iterable<React.ReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;

View File

@@ -0,0 +1,59 @@
import { Typography } from 'antd';
import React from 'react';
import { jsx as _jsx } from "react/jsx-runtime";
var isNeedTranText = function isNeedTranText(item) {
var _item$valueType;
if (item !== null && item !== void 0 && (_item$valueType = item.valueType) !== null && _item$valueType !== void 0 && _item$valueType.toString().startsWith('date')) {
return true;
}
if ((item === null || item === void 0 ? void 0 : item.valueType) === 'select' || item !== null && item !== void 0 && item.valueEnum) {
return true;
}
return false;
};
var getEllipsis = function getEllipsis(item) {
var _item$ellipsis;
if (((_item$ellipsis = item.ellipsis) === null || _item$ellipsis === void 0 ? void 0 : _item$ellipsis.showTitle) === false) {
return false;
}
return item.ellipsis;
};
/**
* 生成 Copyable 或 Ellipsis 的 dom
*
* @param dom
* @param item
* @param text
*/
export var genCopyable = function genCopyable(dom, item, text) {
if (item.copyable || item.ellipsis) {
var copyable = item.copyable && text ? {
text: text,
tooltips: ['', '']
} : undefined;
/** 有些 valueType 需要设置copy的为string */
var needTranText = isNeedTranText(item);
var ellipsis = getEllipsis(item) && text ? {
tooltip:
// 支持一下 tooltip 的关闭
(item === null || item === void 0 ? void 0 : item.tooltip) !== false && needTranText ? /*#__PURE__*/_jsx("div", {
className: "pro-table-tooltip-text",
children: dom
}) : text
} : false;
return /*#__PURE__*/_jsx(Typography.Text, {
style: {
width: '100%',
margin: 0,
padding: 0
},
title: "",
copyable: copyable,
ellipsis: ellipsis,
children: dom
});
}
return dom;
};

View File

@@ -0,0 +1,11 @@
import type { FormInstance } from 'antd';
/**
* 因为 fieldProps 支持了 function 所以新增了这个方法
*
* @param fieldProps
* @param form
*/
export declare const getFieldPropsOrFormItemProps: (fieldProps: any, form?: FormInstance<any> | null, extraProps?: any) => Record<string, any> & {
onChange: any;
colSize: number;
};

View File

@@ -0,0 +1,14 @@
import { runFunction } from "../runFunction";
/**
* 因为 fieldProps 支持了 function 所以新增了这个方法
*
* @param fieldProps
* @param form
*/
export var getFieldPropsOrFormItemProps = function getFieldPropsOrFormItemProps(fieldProps, form, extraProps) {
if (form === undefined) {
return fieldProps;
}
return runFunction(fieldProps, form, extraProps);
};

View File

@@ -0,0 +1,9 @@
/**
* 一个去抖的 hook传入一个 function返回一个去抖后的 function
* @param {(...args:T) => Promise<any>} fn
* @param {number} wait?
*/
export declare function useDebounceFn<T extends any[], U = any>(fn: (...args: T) => Promise<any>, wait?: number): {
run: (...args: any) => Promise<U | undefined>;
cancel: () => void;
};

View File

@@ -0,0 +1,69 @@
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
import { useCallback, useEffect, useRef } from 'react';
import { useRefFunction } from "../useRefFunction";
/**
* 一个去抖的 hook传入一个 function返回一个去抖后的 function
* @param {(...args:T) => Promise<any>} fn
* @param {number} wait?
*/
export function useDebounceFn(fn, wait) {
var callback = useRefFunction(fn);
var timer = useRef();
var cancel = useCallback(function () {
if (timer.current) {
clearTimeout(timer.current);
timer.current = null;
}
}, []);
var run = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
var _len,
args,
_key,
_args2 = arguments;
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
while (1) switch (_context2.prev = _context2.next) {
case 0:
for (_len = _args2.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = _args2[_key];
}
if (!(wait === 0 || wait === undefined)) {
_context2.next = 3;
break;
}
return _context2.abrupt("return", callback.apply(void 0, args));
case 3:
cancel();
return _context2.abrupt("return", new Promise(function (resolve) {
timer.current = setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
_context.t0 = resolve;
_context.next = 3;
return callback.apply(void 0, args);
case 3:
_context.t1 = _context.sent;
(0, _context.t0)(_context.t1);
return _context.abrupt("return");
case 6:
case "end":
return _context.stop();
}
}, _callee);
})), wait);
}));
case 5:
case "end":
return _context2.stop();
}
}, _callee2);
})), [callback, cancel, wait]);
useEffect(function () {
return cancel;
}, [cancel]);
return {
run: run,
cancel: cancel
};
}

View File

@@ -0,0 +1,9 @@
import type { DependencyList } from 'react';
/**
* 一个去抖的setState 减少更新的频率
* @param {T} value
* @param {number=100} delay
* @param {DependencyList} deps?
* @returns T
*/
export declare function useDebounceValue<T>(value: T, delay?: number, deps?: DependencyList): T;

View File

@@ -0,0 +1,31 @@
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
import { useEffect, useState } from 'react';
import { useLatest } from "../useLatest";
/**
* 一个去抖的setState 减少更新的频率
* @param {T} value
* @param {number=100} delay
* @param {DependencyList} deps?
* @returns T
*/
export function useDebounceValue(value) {
var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 100;
var deps = arguments.length > 2 ? arguments[2] : undefined;
var _useState = useState(value),
_useState2 = _slicedToArray(_useState, 2),
debouncedValue = _useState2[0],
setDebouncedValue = _useState2[1];
var valueRef = useLatest(value);
useEffect(function () {
var handler = setTimeout(function () {
setDebouncedValue(valueRef.current);
}, delay);
return function () {
return clearTimeout(handler);
};
},
// eslint-disable-next-line react-hooks/exhaustive-deps
deps ? [delay].concat(_toConsumableArray(deps)) : undefined);
return debouncedValue;
}

View File

@@ -0,0 +1,5 @@
import type { DependencyList } from 'react';
export declare const isDeepEqual: (a: any, b: any, ignoreKeys?: string[]) => boolean;
export declare function useDeepCompareMemoize(value: any, ignoreKeys?: any): undefined;
export declare function useDeepCompareEffect(effect: React.EffectCallback, dependencies: DependencyList, ignoreKeys?: string[]): void;
export declare function useDeepCompareEffectDebounce(effect: React.EffectCallback, dependencies: DependencyList, ignoreKeys?: string[], waitTime?: number): void;

View File

@@ -0,0 +1,38 @@
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
import { useEffect, useRef } from 'react';
import { isDeepEqualReact } from "../../isDeepEqualReact";
import { useDebounceFn } from "../useDebounceFn";
export var isDeepEqual = function isDeepEqual(a, b, ignoreKeys) {
return isDeepEqualReact(a, b, ignoreKeys);
};
export function useDeepCompareMemoize(value, ignoreKeys) {
var ref = useRef();
// it can be done by using useMemo as well
// but useRef is rather cleaner and easier
if (!isDeepEqual(value, ref.current, ignoreKeys)) {
ref.current = value;
}
return ref.current;
}
export function useDeepCompareEffect(effect, dependencies, ignoreKeys) {
// eslint-disable-next-line react-hooks/exhaustive-deps
useEffect(effect, useDeepCompareMemoize(dependencies || [], ignoreKeys));
}
export function useDeepCompareEffectDebounce(effect, dependencies, ignoreKeys, waitTime) {
var effectDn = useDebounceFn( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
effect();
case 1:
case "end":
return _context.stop();
}
}, _callee);
})), waitTime || 16);
useEffect(function () {
effectDn.run();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, useDeepCompareMemoize(dependencies || [], ignoreKeys));
}

View File

@@ -0,0 +1,11 @@
import React from 'react';
/**
* `useDeepCompareMemo` will only recompute the memoized value when one of the
* `deps` has changed.
*
* Usage note: only use this if `deps` are objects or arrays that contain
* objects. Otherwise you should just use React.useMemo.
*
*/
declare function useDeepCompareMemo<T>(factory: () => T, dependencies: React.DependencyList): T;
export default useDeepCompareMemo;

View File

@@ -0,0 +1,15 @@
import React from 'react';
import { useDeepCompareMemoize } from "../useDeepCompareEffect";
/**
* `useDeepCompareMemo` will only recompute the memoized value when one of the
* `deps` has changed.
*
* Usage note: only use this if `deps` are objects or arrays that contain
* objects. Otherwise you should just use React.useMemo.
*
*/
function useDeepCompareMemo(factory, dependencies) {
return React.useMemo(factory, useDeepCompareMemoize(dependencies));
}
export default useDeepCompareMemo;

View File

@@ -0,0 +1,5 @@
export declare function useDocumentTitle(titleInfo: {
title: string;
id: string;
pageName: string;
}, appDefaultTitle: string | false): void;

View File

@@ -0,0 +1,10 @@
import { useEffect } from 'react';
import { isBrowser } from "../../isBrowser";
export function useDocumentTitle(titleInfo, appDefaultTitle) {
var titleText = typeof titleInfo.pageName === 'string' ? titleInfo.title : appDefaultTitle;
useEffect(function () {
if (isBrowser() && titleText) {
document.title = titleText;
}
}, [titleInfo.title, titleText]);
}

View File

@@ -0,0 +1,7 @@
/// <reference types="react" />
export type ProRequestData<T, U = Record<string, any>> = (params: U, props: any) => Promise<T>;
export declare function useFetchData<T, U = Record<string, any>>(props: {
proFieldKey?: React.Key;
params?: U;
request?: ProRequestData<T, U>;
}): [T | undefined];

View File

@@ -0,0 +1,63 @@
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
import { useEffect, useRef, useState } from 'react';
import useSWR from 'swr';
var testId = 0;
export function useFetchData(props) {
var abortRef = useRef(null);
/** Key 是用来缓存请求的,如果不在是有问题 */
var _useState = useState(function () {
if (props.proFieldKey) {
return props.proFieldKey.toString();
}
testId += 1;
return testId.toString();
}),
_useState2 = _slicedToArray(_useState, 1),
cacheKey = _useState2[0];
var proFieldKeyRef = useRef(cacheKey);
var fetchData = /*#__PURE__*/function () {
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
var _abortRef$current, _props$request;
var abort, loadData;
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
(_abortRef$current = abortRef.current) === null || _abortRef$current === void 0 || _abortRef$current.abort();
abort = new AbortController();
abortRef.current = abort;
_context.next = 5;
return Promise.race([(_props$request = props.request) === null || _props$request === void 0 ? void 0 : _props$request.call(props, props.params, props), new Promise(function (_, reject) {
var _abortRef$current2;
(_abortRef$current2 = abortRef.current) === null || _abortRef$current2 === void 0 || (_abortRef$current2 = _abortRef$current2.signal) === null || _abortRef$current2 === void 0 || _abortRef$current2.addEventListener('abort', function () {
reject(new Error('aborted'));
});
})]);
case 5:
loadData = _context.sent;
return _context.abrupt("return", loadData);
case 7:
case "end":
return _context.stop();
}
}, _callee);
}));
return function fetchData() {
return _ref.apply(this, arguments);
};
}();
useEffect(function () {
return function () {
testId += 1;
};
}, []);
var _useSWR = useSWR([proFieldKeyRef.current, props.params], fetchData, {
revalidateOnFocus: false,
shouldRetryOnError: false,
revalidateOnReconnect: false
}),
data = _useSWR.data,
error = _useSWR.error;
return [data || error];
}

View File

@@ -0,0 +1 @@
export default function useForceRender(): () => void;

View File

@@ -0,0 +1,13 @@
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
import { useCallback, useState } from 'react';
export default function useForceRender() {
var _useState = useState(true),
_useState2 = _slicedToArray(_useState, 2),
setValue = _useState2[1];
var updateValue = useCallback(function () {
return setValue(function (oldValue) {
return !oldValue;
});
}, []);
return updateValue;
}

View File

@@ -0,0 +1,6 @@
/**
* @see https://github.com/streamich/react-use/blob/master/docs/useLatest.md
*/
export declare const useLatest: <T>(value: T) => {
readonly current: T;
};

View File

@@ -0,0 +1,10 @@
import { useRef } from 'react';
/**
* @see https://github.com/streamich/react-use/blob/master/docs/useLatest.md
*/
export var useLatest = function useLatest(value) {
var ref = useRef(value);
ref.current = value;
return ref;
};

View File

@@ -0,0 +1 @@
export declare const usePrevious: <T>(state: T) => T | undefined;

View File

@@ -0,0 +1,8 @@
import { useEffect, useRef } from 'react';
export var usePrevious = function usePrevious(state) {
var ref = useRef();
useEffect(function () {
ref.current = state;
});
return ref.current;
};

View File

@@ -0,0 +1,4 @@
import type { MutableRefObject, RefObject } from 'react';
export declare function useReactiveRef<T>(initialValue: T): MutableRefObject<T>;
export declare function useReactiveRef<T>(initialValue: T | null): RefObject<T>;
export declare function useReactiveRef<T = undefined>(): MutableRefObject<T | undefined>;

View File

@@ -0,0 +1,7 @@
import useForceRender from "../useForceRender";
import { useRefCallback } from "../useRefCallback";
export function useReactiveRef(initialValue) {
var forceRender = useForceRender();
var ref = useRefCallback(forceRender, initialValue);
return ref;
}

View File

@@ -0,0 +1,6 @@
import type { MutableRefObject, RefObject } from 'react';
type Callback<T> = (currentRef: T) => void;
export declare function useRefCallback<T>(callback: Callback<MutableRefObject<T>>, initialValue: T): MutableRefObject<T>;
export declare function useRefCallback<T>(callback: Callback<RefObject<T>>, initialValue: T | null): RefObject<T>;
export declare function useRefCallback<T = undefined>(callback: Callback<MutableRefObject<T | undefined>>): MutableRefObject<T | undefined>;
export {};

View File

@@ -0,0 +1,18 @@
import { useMemo } from 'react';
export function useRefCallback(callback, initialValue) {
var ref = useMemo(function () {
var defaultValue = {
current: initialValue
};
return new Proxy(defaultValue, {
set: function set(target, prop, newValue) {
if (!Object.is(target[prop], newValue)) {
target[prop] = newValue;
callback(ref);
}
return true;
}
});
}, []);
return ref;
}

View File

@@ -0,0 +1,2 @@
declare const useRefFunction: <T extends (...args: any) => any>(reFunction: T) => (...rest: Parameters<T>) => ReturnType<T>;
export { useRefFunction };

View File

@@ -0,0 +1,14 @@
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
import { useCallback, useRef } from 'react';
var useRefFunction = function useRefFunction(reFunction) {
var ref = useRef(null);
ref.current = reFunction;
return useCallback(function () {
var _ref$current;
for (var _len = arguments.length, rest = new Array(_len), _key = 0; _key < _len; _key++) {
rest[_key] = arguments[_key];
}
return (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.call.apply(_ref$current, [ref].concat(_toConsumableArray(rest)));
}, []);
};
export { useRefFunction };

58
node_modules/@ant-design/pro-utils/es/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,58 @@
import { DropdownFooter } from './components/DropdownFooter';
import { ErrorBoundary } from './components/ErrorBoundary';
import { FieldLabel } from './components/FieldLabel';
import { FilterDropdown } from './components/FilterDropdown';
import { InlineErrorFormItem } from './components/InlineErrorFormItem';
import { LabelIconTip } from './components/LabelIconTip';
import type { ProFormInstanceType } from './components/ProFormContext';
import { ProFormContext } from './components/ProFormContext';
import { conversionMomentValue, convertMoment, dateFormatterMap } from './conversionMomentValue';
import { dateArrayFormatter } from './dateArrayFormatter';
import { genCopyable } from './genCopyable';
import { getFieldPropsOrFormItemProps } from './getFieldPropsOrFormItemProps';
/** Hooks */
import { lighten, operationUnit, resetComponent, setAlpha, useStyle } from '@ant-design/pro-provider';
import { compareVersions } from './compareVersions';
import { coverToNewToken } from './compareVersions/coverToNewToken';
import { menuOverlayCompatible } from './compareVersions/menuOverlayCompatible';
import { openVisibleCompatible } from './compareVersions/openVisibleCompatible';
import { useDebounceFn } from './hooks/useDebounceFn';
import { useDebounceValue } from './hooks/useDebounceValue';
import { useDeepCompareEffect, useDeepCompareEffectDebounce } from './hooks/useDeepCompareEffect';
import useDeepCompareMemo from './hooks/useDeepCompareMemo';
import { useDocumentTitle } from './hooks/useDocumentTitle';
import type { ProRequestData } from './hooks/useFetchData';
import { useFetchData } from './hooks/useFetchData';
import { useLatest } from './hooks/useLatest';
import { usePrevious } from './hooks/usePrevious';
import { useReactiveRef } from './hooks/useReactiveRef';
import { useRefCallback } from './hooks/useRefCallback';
import { useRefFunction } from './hooks/useRefFunction';
import { isBrowser } from './isBrowser';
import { isDeepEqualReact } from './isDeepEqualReact';
import { isDropdownValueType } from './isDropdownValueType';
import { isImg } from './isImg';
import { isNil } from './isNil';
import { isUrl } from './isUrl';
import { merge } from './merge';
import { nanoid } from './nanoid';
import { omitBoolean } from './omitBoolean';
import { omitUndefined } from './omitUndefined';
import { omitUndefinedAndEmptyArr } from './omitUndefinedAndEmptyArr';
import { parseValueToDay } from './parseValueToMoment';
import { pickProFormItemProps } from './pickProFormItemProps';
import { pickProProps } from './pickProProps';
import { objectToMap, proFieldParsingText } from './proFieldParsingText';
import { runFunction } from './runFunction';
import stringify from './stringify';
import { transformKeySubmitValue } from './transformKeySubmitValue';
export { compatibleBorder } from './compatible/compatibleBorder';
import type { RowEditableConfig, RowEditableType, UseEditableType, UseEditableUtilType } from './useEditableArray';
import { editableRowByKey, recordKeyToString, useEditableArray } from './useEditableArray';
import type { UseEditableMapType, UseEditableMapUtilType } from './useEditableMap';
import { useEditableMap } from './useEditableMap';
import { useBreakpoint } from './useMediaQuery';
import { useMountMergeState } from './useMountMergeState';
export * from './typing';
export { compareVersions, conversionMomentValue, conversionMomentValue as conversionSubmitValue, convertMoment, coverToNewToken, dateArrayFormatter, dateFormatterMap, DropdownFooter, editableRowByKey, ErrorBoundary, FieldLabel, FilterDropdown, genCopyable, getFieldPropsOrFormItemProps, InlineErrorFormItem, isBrowser, isDeepEqualReact, isDropdownValueType, isImg, isNil, isUrl, LabelIconTip, lighten, menuOverlayCompatible, merge, nanoid, objectToMap, omitBoolean, omitUndefined, omitUndefinedAndEmptyArr, openVisibleCompatible, operationUnit, parseValueToDay, pickProFormItemProps, pickProProps, proFieldParsingText, ProFormContext, recordKeyToString, resetComponent, runFunction, setAlpha, stringify, transformKeySubmitValue, useBreakpoint, useDebounceFn, useDebounceValue, useDeepCompareEffect, useDeepCompareEffectDebounce, useDeepCompareMemo, useDocumentTitle, useEditableArray, useEditableMap, useFetchData, useLatest, useMountMergeState, usePrevious, useReactiveRef, useRefCallback, useRefFunction, useStyle, };
export type { ProFormInstanceType, ProRequestData, RowEditableConfig, RowEditableType, UseEditableMapType, UseEditableMapUtilType, UseEditableType, UseEditableUtilType, };

57
node_modules/@ant-design/pro-utils/es/index.js generated vendored Normal file
View File

@@ -0,0 +1,57 @@
import { DropdownFooter } from "./components/DropdownFooter";
import { ErrorBoundary } from "./components/ErrorBoundary";
import { FieldLabel } from "./components/FieldLabel";
import { FilterDropdown } from "./components/FilterDropdown";
import { InlineErrorFormItem } from "./components/InlineErrorFormItem";
import { LabelIconTip } from "./components/LabelIconTip";
import { ProFormContext } from "./components/ProFormContext";
import { conversionMomentValue, convertMoment, dateFormatterMap } from "./conversionMomentValue";
import { dateArrayFormatter } from "./dateArrayFormatter";
import { genCopyable } from "./genCopyable";
import { getFieldPropsOrFormItemProps } from "./getFieldPropsOrFormItemProps";
/** Hooks */
import { lighten, operationUnit, resetComponent, setAlpha, useStyle } from '@ant-design/pro-provider';
import { compareVersions } from "./compareVersions";
import { coverToNewToken } from "./compareVersions/coverToNewToken";
import { menuOverlayCompatible } from "./compareVersions/menuOverlayCompatible";
import { openVisibleCompatible } from "./compareVersions/openVisibleCompatible";
import { useDebounceFn } from "./hooks/useDebounceFn";
import { useDebounceValue } from "./hooks/useDebounceValue";
import { useDeepCompareEffect, useDeepCompareEffectDebounce } from "./hooks/useDeepCompareEffect";
import useDeepCompareMemo from "./hooks/useDeepCompareMemo";
import { useDocumentTitle } from "./hooks/useDocumentTitle";
import { useFetchData } from "./hooks/useFetchData";
import { useLatest } from "./hooks/useLatest";
import { usePrevious } from "./hooks/usePrevious";
import { useReactiveRef } from "./hooks/useReactiveRef";
import { useRefCallback } from "./hooks/useRefCallback";
import { useRefFunction } from "./hooks/useRefFunction";
import { isBrowser } from "./isBrowser";
import { isDeepEqualReact } from "./isDeepEqualReact";
import { isDropdownValueType } from "./isDropdownValueType";
import { isImg } from "./isImg";
import { isNil } from "./isNil";
import { isUrl } from "./isUrl";
import { merge } from "./merge";
import { nanoid } from "./nanoid";
import { omitBoolean } from "./omitBoolean";
import { omitUndefined } from "./omitUndefined";
import { omitUndefinedAndEmptyArr } from "./omitUndefinedAndEmptyArr";
import { parseValueToDay } from "./parseValueToMoment";
import { pickProFormItemProps } from "./pickProFormItemProps";
import { pickProProps } from "./pickProProps";
import { objectToMap, proFieldParsingText } from "./proFieldParsingText";
import { runFunction } from "./runFunction";
import stringify from "./stringify";
import { transformKeySubmitValue } from "./transformKeySubmitValue";
export { compatibleBorder } from "./compatible/compatibleBorder";
import { editableRowByKey, recordKeyToString, useEditableArray } from "./useEditableArray";
import { useEditableMap } from "./useEditableMap";
import { useBreakpoint } from "./useMediaQuery";
import { useMountMergeState } from "./useMountMergeState";
export * from "./typing";
export { compareVersions, conversionMomentValue, conversionMomentValue as conversionSubmitValue, convertMoment, coverToNewToken, dateArrayFormatter, dateFormatterMap, DropdownFooter, editableRowByKey, ErrorBoundary, FieldLabel, FilterDropdown, genCopyable, getFieldPropsOrFormItemProps, InlineErrorFormItem, isBrowser, isDeepEqualReact, isDropdownValueType, isImg, isNil, isUrl, LabelIconTip, lighten, menuOverlayCompatible, merge, nanoid, objectToMap, omitBoolean, omitUndefined, omitUndefinedAndEmptyArr, openVisibleCompatible, operationUnit, parseValueToDay, pickProFormItemProps, pickProProps, proFieldParsingText, ProFormContext, recordKeyToString, resetComponent, runFunction, setAlpha, stringify,
// function
transformKeySubmitValue, useBreakpoint, useDebounceFn, useDebounceValue, useDeepCompareEffect, useDeepCompareEffectDebounce, useDeepCompareMemo, useDocumentTitle,
// hooks
useEditableArray, useEditableMap, useFetchData, useLatest, useMountMergeState, usePrevious, useReactiveRef, useRefCallback, useRefFunction, useStyle };

View File

@@ -0,0 +1,9 @@
/**
* 用于判断当前是否在浏览器环境中。
* 首先会判断当前是否处于测试环境中(通过 process.env.NODE_ENV === 'TEST' 判断),
* 如果是,则返回 true。否则会进一步判断是否存在 window 对象、document 对象以及 matchMedia 方法
* 同时通过 !isNode 判断当前不是在服务器Node.js环境下执行
* 如果都符合,则返回 true 表示当前处于浏览器环境中。
* @returns boolean
*/
export declare const isBrowser: () => boolean;

View File

@@ -0,0 +1,16 @@
var isNode = typeof process !== 'undefined' && process.versions != null && process.versions.node != null;
/**
* 用于判断当前是否在浏览器环境中。
* 首先会判断当前是否处于测试环境中(通过 process.env.NODE_ENV === 'TEST' 判断),
* 如果是,则返回 true。否则会进一步判断是否存在 window 对象、document 对象以及 matchMedia 方法
* 同时通过 !isNode 判断当前不是在服务器Node.js环境下执行
* 如果都符合,则返回 true 表示当前处于浏览器环境中。
* @returns boolean
*/
export var isBrowser = function isBrowser() {
if (typeof process !== 'undefined' && process.env.NODE_ENV === 'TEST') {
return true;
}
return typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.matchMedia !== 'undefined' && !isNode;
};

View File

@@ -0,0 +1 @@
export declare function isDeepEqualReact(a: any, b: any, ignoreKeys?: string[], debug?: boolean): boolean;

View File

@@ -0,0 +1,107 @@
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
import _typeof from "@babel/runtime/helpers/esm/typeof";
/* eslint-disable no-restricted-syntax */
/* eslint-disable no-continue */
/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable no-self-compare */
/* eslint-disable eqeqeq */
/* eslint-disable no-plusplus */
// do not edit .js files directly - edit src/index.jst
export function isDeepEqualReact(a, b, ignoreKeys, debug) {
if (a === b) return true;
if (a && b && _typeof(a) === 'object' && _typeof(b) === 'object') {
if (a.constructor !== b.constructor) return false;
var length;
var i;
var keys;
if (Array.isArray(a)) {
length = a.length;
if (length != b.length) return false;
for (i = length; i-- !== 0;) if (!isDeepEqualReact(a[i], b[i], ignoreKeys, debug)) return false;
return true;
}
if (a instanceof Map && b instanceof Map) {
if (a.size !== b.size) return false;
var _iterator = _createForOfIteratorHelper(a.entries()),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
i = _step.value;
if (!b.has(i[0])) return false;
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
var _iterator2 = _createForOfIteratorHelper(a.entries()),
_step2;
try {
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
i = _step2.value;
if (!isDeepEqualReact(i[1], b.get(i[0]), ignoreKeys, debug)) return false;
}
} catch (err) {
_iterator2.e(err);
} finally {
_iterator2.f();
}
return true;
}
if (a instanceof Set && b instanceof Set) {
if (a.size !== b.size) return false;
var _iterator3 = _createForOfIteratorHelper(a.entries()),
_step3;
try {
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
i = _step3.value;
if (!b.has(i[0])) return false;
}
} catch (err) {
_iterator3.e(err);
} finally {
_iterator3.f();
}
return true;
}
if (ArrayBuffer.isView(a) && ArrayBuffer.isView(b)) {
// @ts-ignore
length = a.length;
// @ts-ignore
if (length != b.length) return false;
// @ts-ignore
for (i = length; i-- !== 0;) if (a[i] !== b[i]) return false;
return true;
}
if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
if (a.valueOf !== Object.prototype.valueOf && a.valueOf) return a.valueOf() === b.valueOf();
if (a.toString !== Object.prototype.toString && a.toString) return a.toString() === b.toString();
// eslint-disable-next-line prefer-const
keys = Object.keys(a);
length = keys.length;
if (length !== Object.keys(b).length) return false;
for (i = length; i-- !== 0;) if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
for (i = length; i-- !== 0;) {
var key = keys[i];
if (ignoreKeys !== null && ignoreKeys !== void 0 && ignoreKeys.includes(key)) continue;
if (key === '_owner' && a.$$typeof) {
// React-specific: avoid traversing React elements' _owner.
// _owner contains circular references
// and is not needed when comparing the actual elements (and not their owners)
continue;
}
if (!isDeepEqualReact(a[key], b[key], ignoreKeys, debug)) {
if (debug) {
console.log(key);
}
return false;
}
}
return true;
}
// true if both NaN, false otherwise
return a !== a && b !== b;
}

View File

@@ -0,0 +1 @@
export declare const isDropdownValueType: (valueType: string) => boolean;

View File

@@ -0,0 +1,7 @@
export var isDropdownValueType = function isDropdownValueType(valueType) {
var isDropdown = false;
if (typeof valueType === 'string' && valueType.startsWith('date') && !valueType.endsWith('Range') || valueType === 'select' || valueType === 'time') {
isDropdown = true;
}
return isDropdown;
};

View File

@@ -0,0 +1,2 @@
/** 判断是否是图片链接 */
export declare function isImg(path: string): boolean;

4
node_modules/@ant-design/pro-utils/es/isImg/index.js generated vendored Normal file
View File

@@ -0,0 +1,4 @@
/** 判断是否是图片链接 */
export function isImg(path) {
return /\w.(png|jpg|jpeg|svg|webp|gif|bmp)$/i.test(path);
}

View File

@@ -0,0 +1 @@
export declare const isNil: (value: any) => value is null | undefined;

3
node_modules/@ant-design/pro-utils/es/isNil/index.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
export var isNil = function isNil(value) {
return value === null || value === undefined;
};

View File

@@ -0,0 +1,6 @@
/**
* 判断是不是一个 url
* @param {string|undefined} path
* @returns boolean
*/
export declare const isUrl: (path: string | undefined) => boolean;

17
node_modules/@ant-design/pro-utils/es/isUrl/index.js generated vendored Normal file
View File

@@ -0,0 +1,17 @@
/**
* 判断是不是一个 url
* @param {string|undefined} path
* @returns boolean
*/
export var isUrl = function isUrl(path) {
if (!path) return false;
if (!path.startsWith('http')) {
return false;
}
try {
var url = new URL(path);
return !!url;
} catch (error) {
return false;
}
};

View File

@@ -0,0 +1,7 @@
/**
* 用于合并 n 个对象
* @param {any[]} ...rest
* @returns T
*/
declare const merge: <T = any>(...rest: any[]) => T;
export { merge };

32
node_modules/@ant-design/pro-utils/es/merge/index.js generated vendored Normal file
View File

@@ -0,0 +1,32 @@
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _typeof from "@babel/runtime/helpers/esm/typeof";
/* eslint-disable prefer-rest-params */
/**
* 用于合并 n 个对象
* @param {any[]} ...rest
* @returns T
*/
var merge = function merge() {
var obj = {};
for (var _len = arguments.length, rest = new Array(_len), _key = 0; _key < _len; _key++) {
rest[_key] = arguments[_key];
}
var il = rest.length;
var key;
var i = 0;
for (; i < il; i += 1) {
// eslint-disable-next-line no-restricted-syntax
for (key in rest[i]) {
if (rest[i].hasOwnProperty(key)) {
if (_typeof(obj[key]) === 'object' && _typeof(rest[i][key]) === 'object' && obj[key] !== undefined && obj[key] !== null && !Array.isArray(obj[key]) && !Array.isArray(rest[i][key])) {
obj[key] = _objectSpread(_objectSpread({}, obj[key]), rest[i][key]);
} else {
obj[key] = rest[i][key];
}
}
}
}
return obj;
};
export { merge };

View File

@@ -0,0 +1,6 @@
/**
* 生成uuid如果不支持 randomUUID就用 genNanoid
*
* @returns string
*/
export declare const nanoid: () => string;

31
node_modules/@ant-design/pro-utils/es/nanoid/index.js generated vendored Normal file
View File

@@ -0,0 +1,31 @@
/* eslint-disable prefer-const */
var index = 0;
var genNanoid = function genNanoid() {
var t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 21;
if (typeof window === 'undefined') return (index += 1).toFixed(0);
if (!window.crypto) return (index += 1).toFixed(0);
var e = '',
r = crypto.getRandomValues(new Uint8Array(t));
// eslint-disable-next-line no-param-reassign
for (; t--;) {
var n = 63 & r[t];
e += n < 36 ? n.toString(36) : n < 62 ? (n - 26).toString(36).toUpperCase() : n < 63 ? '_' : '-';
}
return e;
};
/**
* 生成uuid如果不支持 randomUUID就用 genNanoid
*
* @returns string
*/
export var nanoid = function nanoid() {
if (typeof window === 'undefined') return genNanoid();
// @ts-ignore
if (window.crypto && window.crypto.randomUUID && typeof crypto.randomUUID == 'function') {
// @ts-ignore
return crypto.randomUUID();
}
return genNanoid();
};

View File

@@ -0,0 +1,6 @@
/**
* 剔除 boolean 值
* @param {boolean|T} obj
* @returns T
*/
export declare const omitBoolean: <T>(obj: boolean | T) => T | undefined;

View File

@@ -0,0 +1,11 @@
/**
* 剔除 boolean 值
* @param {boolean|T} obj
* @returns T
*/
export var omitBoolean = function omitBoolean(obj) {
if (obj && obj !== true) {
return obj;
}
return undefined;
};

View File

@@ -0,0 +1,5 @@
type OmitUndefined<T> = {
[P in keyof T]: NonNullable<T[P]>;
};
export declare const omitUndefined: <T extends Record<string, any>>(obj: T) => OmitUndefined<T>;
export {};

View File

@@ -0,0 +1,12 @@
export var omitUndefined = function omitUndefined(obj) {
var newObj = {};
Object.keys(obj || {}).forEach(function (key) {
if (obj[key] !== undefined) {
newObj[key] = obj[key];
}
});
if (Object.keys(newObj).length < 1) {
return undefined;
}
return newObj;
};

View File

@@ -0,0 +1 @@
export declare const omitUndefinedAndEmptyArr: <T extends Record<string, any>>(obj: T) => T;

View File

@@ -0,0 +1,14 @@
export var omitUndefinedAndEmptyArr = function omitUndefinedAndEmptyArr(obj) {
var newObj = {};
Object.keys(obj || {}).forEach(function (key) {
var _obj$key;
if (Array.isArray(obj[key]) && ((_obj$key = obj[key]) === null || _obj$key === void 0 ? void 0 : _obj$key.length) === 0) {
return;
}
if (obj[key] === undefined) {
return;
}
newObj[key] = obj[key];
});
return newObj;
};

View File

@@ -0,0 +1,4 @@
import dayjs from 'dayjs';
type DateValue = dayjs.Dayjs | dayjs.Dayjs[] | string | string[] | number | number[];
export declare const parseValueToDay: (value: DateValue, formatter?: string) => dayjs.Dayjs | dayjs.Dayjs[] | null | undefined;
export {};

View File

@@ -0,0 +1,27 @@
import dayjs from 'dayjs';
import customParseFormat from 'dayjs/plugin/customParseFormat';
import { isNil } from "../isNil";
dayjs.extend(customParseFormat);
/**
* 一个比较hack的moment判断工具
* @param value
* @returns
*/
var isMoment = function isMoment(value) {
return !!(value !== null && value !== void 0 && value._isAMomentObject);
};
export var parseValueToDay = function parseValueToDay(value, formatter) {
if (isNil(value) || dayjs.isDayjs(value) || isMoment(value)) {
if (isMoment(value)) {
return dayjs(value);
}
return value;
}
if (Array.isArray(value)) {
return value.map(function (v) {
return parseValueToDay(v, formatter);
});
}
if (typeof value === 'number') return dayjs(value);
return dayjs(value, formatter);
};

View File

@@ -0,0 +1 @@
export declare function pickProFormItemProps(props: {}): Record<string, any>;

View File

@@ -0,0 +1,16 @@
var antdFormItemPropsList = [
// https://ant.design/components/form-cn/#Form.Item
'colon', 'dependencies', 'extra', 'getValueFromEvent', 'getValueProps', 'hasFeedback', 'help', 'htmlFor', 'initialValue', 'noStyle', 'label', 'labelAlign', 'labelCol', 'name', 'preserve', 'normalize', 'required', 'rules', 'shouldUpdate', 'trigger', 'validateFirst', 'validateStatus', 'validateTrigger', 'valuePropName', 'wrapperCol', 'hidden', 'validateDebounce',
// 我自定义的
'addonBefore', 'addonAfter', 'addonWarpStyle'];
// eslint-disable-next-line @typescript-eslint/ban-types
export function pickProFormItemProps(props) {
var attrs = {};
antdFormItemPropsList.forEach(function (key) {
if (props[key] !== undefined) {
attrs[key] = props[key];
}
});
return attrs;
}

View File

@@ -0,0 +1 @@
export declare function pickProProps(props: Record<string, any>, customValueType?: boolean): Record<string, any>;

View File

@@ -0,0 +1,15 @@
var proFieldProps = "valueType request plain renderFormItem render text formItemProps valueEnum";
var proFormProps = "fieldProps isDefaultDom groupProps contentRender submitterProps submitter";
export function pickProProps(props) {
var customValueType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var propList = "".concat(proFieldProps, " ").concat(proFormProps).split(/[\s\n]+/);
var attrs = {};
Object.keys(props || {}).forEach(function (key) {
//如果是自定义的 valueType则不需要过滤掉全部传给使用者
if (propList.includes(key) && !customValueType) {
return;
}
attrs[key] = props[key];
});
return attrs;
}

View File

@@ -0,0 +1,21 @@
import type { CSSProperties, ReactNode } from 'react';
import React from 'react';
import { ProFieldValueEnumType, ProSchemaValueEnumMap } from '../typing';
type StatusProps = {
className?: string;
style?: CSSProperties;
children?: React.ReactNode;
};
export declare const ProFieldBadgeColor: React.FC<StatusProps & {
color: string;
}>;
export declare const objectToMap: (value: ProFieldValueEnumType | undefined) => ProSchemaValueEnumMap;
/**
* 转化 text 和 valueEnum 通过 type 来添加 Status
*
* @param text
* @param valueEnum
* @param pure 纯净模式,不增加 status
*/
export declare const proFieldParsingText: (text: string | number | (string | number)[], valueEnumParams: ProFieldValueEnumType, key?: number | string) => React.ReactNode;
export {};

View File

@@ -0,0 +1,158 @@
import _typeof from "@babel/runtime/helpers/esm/typeof";
import { Badge, Space } from 'antd';
import React from 'react';
import { jsx as _jsx } from "react/jsx-runtime";
/**
* 获取类型的 type
*
* @param obj
*/
function getType(obj) {
// @ts-ignore
var type = Object.prototype.toString.call(obj).match(/^\[object (.*)\]$/)[1].toLowerCase();
if (type === 'string' && _typeof(obj) === 'object') return 'object'; // Let "new String('')" return 'object'
if (obj === null) return 'null'; // PhantomJS has type "DOMWindow" for null
if (obj === undefined) return 'undefined'; // PhantomJS has type "DOMWindow" for undefined
return type;
}
export var ProFieldBadgeColor = function ProFieldBadgeColor(_ref) {
var color = _ref.color,
children = _ref.children;
return /*#__PURE__*/_jsx(Badge, {
color: color,
text: children
});
};
export var objectToMap = function objectToMap(value) {
if (getType(value) === 'map') {
return value;
}
return new Map(Object.entries(value || {}));
};
var TableStatus = {
Success: function Success(_ref2) {
var children = _ref2.children;
return /*#__PURE__*/_jsx(Badge, {
status: "success",
text: children
});
},
Error: function Error(_ref3) {
var children = _ref3.children;
return /*#__PURE__*/_jsx(Badge, {
status: "error",
text: children
});
},
Default: function Default(_ref4) {
var children = _ref4.children;
return /*#__PURE__*/_jsx(Badge, {
status: "default",
text: children
});
},
Processing: function Processing(_ref5) {
var children = _ref5.children;
return /*#__PURE__*/_jsx(Badge, {
status: "processing",
text: children
});
},
Warning: function Warning(_ref6) {
var children = _ref6.children;
return /*#__PURE__*/_jsx(Badge, {
status: "warning",
text: children
});
},
success: function success(_ref7) {
var children = _ref7.children;
return /*#__PURE__*/_jsx(Badge, {
status: "success",
text: children
});
},
error: function error(_ref8) {
var children = _ref8.children;
return /*#__PURE__*/_jsx(Badge, {
status: "error",
text: children
});
},
default: function _default(_ref9) {
var children = _ref9.children;
return /*#__PURE__*/_jsx(Badge, {
status: "default",
text: children
});
},
processing: function processing(_ref10) {
var children = _ref10.children;
return /*#__PURE__*/_jsx(Badge, {
status: "processing",
text: children
});
},
warning: function warning(_ref11) {
var children = _ref11.children;
return /*#__PURE__*/_jsx(Badge, {
status: "warning",
text: children
});
}
};
/**
* 转化 text 和 valueEnum 通过 type 来添加 Status
*
* @param text
* @param valueEnum
* @param pure 纯净模式,不增加 status
*/
export var proFieldParsingText = function proFieldParsingText(text, valueEnumParams, key) {
if (Array.isArray(text)) {
return /*#__PURE__*/_jsx(Space, {
split: ",",
size: 2,
wrap: true,
children: text.map(function (value, index) {
return (
// @ts-ignore
proFieldParsingText(value, valueEnumParams, index)
);
})
}, key);
}
var valueEnum = objectToMap(valueEnumParams);
if (!valueEnum.has(text) && !valueEnum.has("".concat(text))) {
// @ts-ignore
return (text === null || text === void 0 ? void 0 : text.label) || text;
}
var domText = valueEnum.get(text) || valueEnum.get("".concat(text));
if (!domText) {
// @ts-ignore
return /*#__PURE__*/_jsx(React.Fragment, {
children: (text === null || text === void 0 ? void 0 : text.label) || text
}, key);
}
var status = domText.status,
color = domText.color;
var Status = TableStatus[status || 'Init'];
// 如果类型存在优先使用类型
if (Status) {
return /*#__PURE__*/_jsx(Status, {
children: domText.text
}, key);
}
// 如果不存在使用颜色
if (color) {
return /*#__PURE__*/_jsx(ProFieldBadgeColor, {
color: color,
children: domText.text
}, key);
}
// 什么都没有使用 text
return /*#__PURE__*/_jsx(React.Fragment, {
children: domText.text || domText
}, key);
};

View File

@@ -0,0 +1,2 @@
/** 如果是个方法执行一下它 */
export declare function runFunction<T extends any[]>(valueEnum: any, ...rest: T): any;

Some files were not shown because too many files have changed in this diff Show More