add all frontend files

This commit is contained in:
2026-01-17 15:16:36 -05:00
parent ff16ae7858
commit e40287e4aa
25704 changed files with 1935289 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
import * as React from 'react';
import type { IconDefinition } from '@ant-design/icons-svg/lib/types';
import type { IconBaseProps } from './Icon';
import { getTwoToneColor, setTwoToneColor } from './twoTonePrimaryColor';
import type { TwoToneColor } from './twoTonePrimaryColor';
export interface AntdIconProps extends IconBaseProps {
twoToneColor?: TwoToneColor;
}
export interface IconComponentProps extends AntdIconProps {
icon: IconDefinition;
}
interface IconBaseComponent<Props> extends React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLSpanElement>> {
getTwoToneColor: typeof getTwoToneColor;
setTwoToneColor: typeof setTwoToneColor;
}
declare const Icon: IconBaseComponent<IconComponentProps>;
export default Icon;

View File

@@ -0,0 +1,65 @@
'use client';
import _extends from "@babel/runtime/helpers/esm/extends";
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
var _excluded = ["className", "icon", "spin", "rotate", "tabIndex", "onClick", "twoToneColor"];
import * as React from 'react';
import classNames from 'classnames';
import { blue } from '@ant-design/colors';
import Context from "./Context";
import ReactIcon from "./IconBase";
import { getTwoToneColor, setTwoToneColor } from "./twoTonePrimaryColor";
import { normalizeTwoToneColors } from "../utils";
// Initial setting
// should move it to antd main repo?
setTwoToneColor(blue.primary);
// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/34757#issuecomment-488848720
var Icon = /*#__PURE__*/React.forwardRef(function (props, ref) {
var className = props.className,
icon = props.icon,
spin = props.spin,
rotate = props.rotate,
tabIndex = props.tabIndex,
onClick = props.onClick,
twoToneColor = props.twoToneColor,
restProps = _objectWithoutProperties(props, _excluded);
var _React$useContext = React.useContext(Context),
_React$useContext$pre = _React$useContext.prefixCls,
prefixCls = _React$useContext$pre === void 0 ? 'anticon' : _React$useContext$pre,
rootClassName = _React$useContext.rootClassName;
var classString = classNames(rootClassName, prefixCls, _defineProperty(_defineProperty({}, "".concat(prefixCls, "-").concat(icon.name), !!icon.name), "".concat(prefixCls, "-spin"), !!spin || icon.name === 'loading'), className);
var iconTabIndex = tabIndex;
if (iconTabIndex === undefined && onClick) {
iconTabIndex = -1;
}
var svgStyle = rotate ? {
msTransform: "rotate(".concat(rotate, "deg)"),
transform: "rotate(".concat(rotate, "deg)")
} : undefined;
var _normalizeTwoToneColo = normalizeTwoToneColors(twoToneColor),
_normalizeTwoToneColo2 = _slicedToArray(_normalizeTwoToneColo, 2),
primaryColor = _normalizeTwoToneColo2[0],
secondaryColor = _normalizeTwoToneColo2[1];
return /*#__PURE__*/React.createElement("span", _extends({
role: "img",
"aria-label": icon.name
}, restProps, {
ref: ref,
tabIndex: iconTabIndex,
onClick: onClick,
className: classString
}), /*#__PURE__*/React.createElement(ReactIcon, {
icon: icon,
primaryColor: primaryColor,
secondaryColor: secondaryColor,
style: svgStyle
}));
});
Icon.displayName = 'AntdIcon';
Icon.getTwoToneColor = getTwoToneColor;
Icon.setTwoToneColor = setTwoToneColor;
export default Icon;

View File

@@ -0,0 +1,11 @@
/// <reference types="react" />
export interface IconContextProps {
prefixCls?: string;
rootClassName?: string;
csp?: {
nonce?: string;
};
layer?: string;
}
declare const IconContext: import("react").Context<IconContextProps>;
export default IconContext;

View File

@@ -0,0 +1,3 @@
import { createContext } from 'react';
var IconContext = /*#__PURE__*/createContext({});
export default IconContext;

20
node_modules/@ant-design/icons/es/components/Icon.d.ts generated vendored Normal file
View File

@@ -0,0 +1,20 @@
import * as React from 'react';
export interface IconBaseProps extends React.HTMLProps<HTMLSpanElement> {
spin?: boolean;
rotate?: number;
}
export interface CustomIconComponentProps {
width: string | number;
height: string | number;
fill?: string;
viewBox?: string;
className?: string;
style?: React.CSSProperties;
}
export interface IconComponentProps extends IconBaseProps {
viewBox?: string;
component?: React.ComponentType<CustomIconComponentProps | React.SVGProps<SVGSVGElement>> | React.ForwardRefExoticComponent<CustomIconComponentProps>;
ariaLabel?: React.AriaAttributes['aria-label'];
}
declare const Icon: React.ForwardRefExoticComponent<Omit<IconComponentProps, 'ref'> & React.RefAttributes<HTMLSpanElement>>;
export default Icon;

72
node_modules/@ant-design/icons/es/components/Icon.js generated vendored Normal file
View File

@@ -0,0 +1,72 @@
import _extends from "@babel/runtime/helpers/esm/extends";
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
var _excluded = ["className", "component", "viewBox", "spin", "rotate", "tabIndex", "onClick", "children"];
// Seems this is used for iconFont
import * as React from 'react';
import classNames from 'classnames';
import { useComposeRef } from "rc-util/es/ref";
import Context from "./Context";
import { svgBaseProps, warning, useInsertStyles } from "../utils";
var Icon = /*#__PURE__*/React.forwardRef(function (props, ref) {
var className = props.className,
Component = props.component,
viewBox = props.viewBox,
spin = props.spin,
rotate = props.rotate,
tabIndex = props.tabIndex,
onClick = props.onClick,
children = props.children,
restProps = _objectWithoutProperties(props, _excluded);
var iconRef = React.useRef();
var mergedRef = useComposeRef(iconRef, ref);
warning(Boolean(Component || children), 'Should have `component` prop or `children`.');
useInsertStyles(iconRef);
var _React$useContext = React.useContext(Context),
_React$useContext$pre = _React$useContext.prefixCls,
prefixCls = _React$useContext$pre === void 0 ? 'anticon' : _React$useContext$pre,
rootClassName = _React$useContext.rootClassName;
var classString = classNames(rootClassName, prefixCls, _defineProperty({}, "".concat(prefixCls, "-spin"), !!spin && !!Component), className);
var svgClassString = classNames(_defineProperty({}, "".concat(prefixCls, "-spin"), !!spin));
var svgStyle = rotate ? {
msTransform: "rotate(".concat(rotate, "deg)"),
transform: "rotate(".concat(rotate, "deg)")
} : undefined;
var innerSvgProps = _objectSpread(_objectSpread({}, svgBaseProps), {}, {
className: svgClassString,
style: svgStyle,
viewBox: viewBox
});
if (!viewBox) {
delete innerSvgProps.viewBox;
}
// component > children
var renderInnerNode = function renderInnerNode() {
if (Component) {
return /*#__PURE__*/React.createElement(Component, innerSvgProps, children);
}
if (children) {
warning(Boolean(viewBox) || React.Children.count(children) === 1 && /*#__PURE__*/React.isValidElement(children) && React.Children.only(children).type === 'use', 'Make sure that you provide correct `viewBox`' + ' prop (default `0 0 1024 1024`) to the icon.');
return /*#__PURE__*/React.createElement("svg", _extends({}, innerSvgProps, {
viewBox: viewBox
}), children);
}
return null;
};
var iconTabIndex = tabIndex;
if (iconTabIndex === undefined && onClick) {
iconTabIndex = -1;
}
return /*#__PURE__*/React.createElement("span", _extends({
role: "img"
}, restProps, {
ref: mergedRef,
tabIndex: iconTabIndex,
onClick: onClick,
className: classString
}), renderInnerNode());
});
Icon.displayName = 'AntdIcon';
export default Icon;

View File

@@ -0,0 +1,26 @@
import * as React from 'react';
import type { IconDefinition } from '@ant-design/icons-svg/lib/types';
export interface IconProps {
icon: IconDefinition;
className?: string;
onClick?: React.MouseEventHandler<SVGSVGElement>;
style?: React.CSSProperties;
primaryColor?: string;
secondaryColor?: string;
focusable?: string;
}
export interface TwoToneColorPaletteSetter {
primaryColor: string;
secondaryColor?: string;
}
export interface TwoToneColorPalette extends TwoToneColorPaletteSetter {
calculated?: boolean;
}
declare function setTwoToneColors({ primaryColor, secondaryColor }: TwoToneColorPaletteSetter): void;
declare function getTwoToneColors(): TwoToneColorPalette;
interface IconBaseComponent<P> extends React.FC<P> {
getTwoToneColors: typeof getTwoToneColors;
setTwoToneColors: typeof setTwoToneColors;
}
declare const IconBase: IconBaseComponent<IconProps>;
export default IconBase;

View File

@@ -0,0 +1,64 @@
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
var _excluded = ["icon", "className", "onClick", "style", "primaryColor", "secondaryColor"];
import * as React from 'react';
import { generate, getSecondaryColor, isIconDefinition, warning, useInsertStyles } from "../utils";
var twoToneColorPalette = {
primaryColor: '#333',
secondaryColor: '#E6E6E6',
calculated: false
};
function setTwoToneColors(_ref) {
var primaryColor = _ref.primaryColor,
secondaryColor = _ref.secondaryColor;
twoToneColorPalette.primaryColor = primaryColor;
twoToneColorPalette.secondaryColor = secondaryColor || getSecondaryColor(primaryColor);
twoToneColorPalette.calculated = !!secondaryColor;
}
function getTwoToneColors() {
return _objectSpread({}, twoToneColorPalette);
}
var IconBase = function IconBase(props) {
var icon = props.icon,
className = props.className,
onClick = props.onClick,
style = props.style,
primaryColor = props.primaryColor,
secondaryColor = props.secondaryColor,
restProps = _objectWithoutProperties(props, _excluded);
var svgRef = React.useRef();
var colors = twoToneColorPalette;
if (primaryColor) {
colors = {
primaryColor: primaryColor,
secondaryColor: secondaryColor || getSecondaryColor(primaryColor)
};
}
useInsertStyles(svgRef);
warning(isIconDefinition(icon), "icon should be icon definiton, but got ".concat(icon));
if (!isIconDefinition(icon)) {
return null;
}
var target = icon;
if (target && typeof target.icon === 'function') {
target = _objectSpread(_objectSpread({}, target), {}, {
icon: target.icon(colors.primaryColor, colors.secondaryColor)
});
}
return generate(target.icon, "svg-".concat(target.name), _objectSpread(_objectSpread({
className: className,
onClick: onClick,
style: style,
'data-icon': target.name,
width: '1em',
height: '1em',
fill: 'currentColor',
'aria-hidden': 'true'
}, restProps), {}, {
ref: svgRef
}));
};
IconBase.displayName = 'IconReact';
IconBase.getTwoToneColors = getTwoToneColors;
IconBase.setTwoToneColors = setTwoToneColors;
export default IconBase;

View File

@@ -0,0 +1,10 @@
import * as React from 'react';
import type { IconBaseProps } from './Icon';
export interface CustomIconOptions {
scriptUrl?: string | string[];
extraCommonProps?: Record<string, unknown>;
}
export interface IconFontProps<T extends string = string> extends IconBaseProps {
type: T;
}
export default function create<T extends string = string>(options?: CustomIconOptions): React.FC<IconFontProps<T>>;

View File

@@ -0,0 +1,70 @@
import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
var _excluded = ["type", "children"];
import * as React from 'react';
import Icon from "./Icon";
var customCache = new Set();
function isValidCustomScriptUrl(scriptUrl) {
return Boolean(typeof scriptUrl === 'string' && scriptUrl.length && !customCache.has(scriptUrl));
}
function createScriptUrlElements(scriptUrls) {
var index = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
var currentScriptUrl = scriptUrls[index];
if (isValidCustomScriptUrl(currentScriptUrl)) {
var script = document.createElement('script');
script.setAttribute('src', currentScriptUrl);
script.setAttribute('data-namespace', currentScriptUrl);
if (scriptUrls.length > index + 1) {
script.onload = function () {
createScriptUrlElements(scriptUrls, index + 1);
};
script.onerror = function () {
createScriptUrlElements(scriptUrls, index + 1);
};
}
customCache.add(currentScriptUrl);
document.body.appendChild(script);
}
}
export default function create() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var scriptUrl = options.scriptUrl,
_options$extraCommonP = options.extraCommonProps,
extraCommonProps = _options$extraCommonP === void 0 ? {} : _options$extraCommonP;
/**
* DOM API required.
* Make sure in browser environment.
* The Custom Icon will create a <script/>
* that loads SVG symbols and insert the SVG Element into the document body.
*/
if (scriptUrl && typeof document !== 'undefined' && typeof window !== 'undefined' && typeof document.createElement === 'function') {
if (Array.isArray(scriptUrl)) {
// 因为iconfont资源会把svg插入before所以前加载相同type会覆盖后加载为了数组覆盖顺序倒叙插入
createScriptUrlElements(scriptUrl.reverse());
} else {
createScriptUrlElements([scriptUrl]);
}
}
var Iconfont = /*#__PURE__*/React.forwardRef(function (props, ref) {
var type = props.type,
children = props.children,
restProps = _objectWithoutProperties(props, _excluded);
// children > type
var content = null;
if (props.type) {
content = /*#__PURE__*/React.createElement("use", {
xlinkHref: "#".concat(type)
});
}
if (children) {
content = children;
}
return /*#__PURE__*/React.createElement(Icon, _extends({}, extraCommonProps, restProps, {
ref: ref
}), content);
});
Iconfont.displayName = 'Iconfont';
return Iconfont;
}

View File

@@ -0,0 +1,3 @@
export type TwoToneColor = string | [string, string];
export declare function setTwoToneColor(twoToneColor: TwoToneColor): void;
export declare function getTwoToneColor(): TwoToneColor;

View File

@@ -0,0 +1,20 @@
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
import ReactIcon from "./IconBase";
import { normalizeTwoToneColors } from "../utils";
export function setTwoToneColor(twoToneColor) {
var _normalizeTwoToneColo = normalizeTwoToneColors(twoToneColor),
_normalizeTwoToneColo2 = _slicedToArray(_normalizeTwoToneColo, 2),
primaryColor = _normalizeTwoToneColo2[0],
secondaryColor = _normalizeTwoToneColo2[1];
return ReactIcon.setTwoToneColors({
primaryColor: primaryColor,
secondaryColor: secondaryColor
});
}
export function getTwoToneColor() {
var colors = ReactIcon.getTwoToneColors();
if (!colors.calculated) {
return colors.primaryColor;
}
return [colors.primaryColor, colors.secondaryColor];
}