@aozi6666/bee-design 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/README.md +73 -0
  2. package/build/App.d.ts +4 -0
  3. package/build/App.js +137 -0
  4. package/build/components/AutoComplete/autoComplete.d.ts +13 -0
  5. package/build/components/AutoComplete/autoComplete.js +123 -0
  6. package/build/components/AutoComplete/autoComplete.types.d.ts +19 -0
  7. package/build/components/AutoComplete/autoComplete.types.js +1 -0
  8. package/build/components/AutoComplete/autoCompleteDropdown.d.ts +13 -0
  9. package/build/components/AutoComplete/autoCompleteDropdown.js +17 -0
  10. package/build/components/AutoComplete/index.d.ts +4 -0
  11. package/build/components/AutoComplete/index.js +3 -0
  12. package/build/components/Button/button.d.ts +6 -0
  13. package/build/components/Button/button.js +43 -0
  14. package/build/components/Button/button.types.d.ts +24 -0
  15. package/build/components/Button/button.types.js +19 -0
  16. package/build/components/Button/index.d.ts +2 -0
  17. package/build/components/Button/index.js +2 -0
  18. package/build/components/Icon/icon.d.ts +16 -0
  19. package/build/components/Icon/icon.js +24 -0
  20. package/build/components/Icon/icon.types.d.ts +6 -0
  21. package/build/components/Icon/icon.types.js +2 -0
  22. package/build/components/Icon/index.d.ts +2 -0
  23. package/build/components/Icon/index.js +2 -0
  24. package/build/components/Input/index.d.ts +4 -0
  25. package/build/components/Input/index.js +3 -0
  26. package/build/components/Input/input.d.ts +5 -0
  27. package/build/components/Input/input.js +32 -0
  28. package/build/components/Input/input.types.d.ts +16 -0
  29. package/build/components/Input/input.types.js +1 -0
  30. package/build/components/Menu/index.d.ts +10 -0
  31. package/build/components/Menu/index.js +9 -0
  32. package/build/components/Menu/menu.d.ts +34 -0
  33. package/build/components/Menu/menu.js +48 -0
  34. package/build/components/Menu/menuItem.d.ts +14 -0
  35. package/build/components/Menu/menuItem.js +20 -0
  36. package/build/components/Menu/subMenu.d.ts +11 -0
  37. package/build/components/Menu/subMenu.js +56 -0
  38. package/build/components/Progress/index.d.ts +2 -0
  39. package/build/components/Progress/index.js +2 -0
  40. package/build/components/Progress/progress.d.ts +4 -0
  41. package/build/components/Progress/progress.js +6 -0
  42. package/build/components/Progress/progress.types.d.ts +9 -0
  43. package/build/components/Progress/progress.types.js +2 -0
  44. package/build/components/Transition/index.d.ts +3 -0
  45. package/build/components/Transition/index.js +2 -0
  46. package/build/components/Transition/transition.d.ts +4 -0
  47. package/build/components/Transition/transition.js +18 -0
  48. package/build/components/Transition/transition.types.d.ts +10 -0
  49. package/build/components/Transition/transition.types.js +1 -0
  50. package/build/components/Upload/dragger.d.ts +7 -0
  51. package/build/components/Upload/dragger.js +42 -0
  52. package/build/components/Upload/index.d.ts +2 -0
  53. package/build/components/Upload/index.js +2 -0
  54. package/build/components/Upload/native/axios-react.d.ts +2 -0
  55. package/build/components/Upload/native/axios-react.js +99 -0
  56. package/build/components/Upload/native/from-html.d.ts +2 -0
  57. package/build/components/Upload/native/from-html.js +5 -0
  58. package/build/components/Upload/upload.d.ts +13 -0
  59. package/build/components/Upload/upload.js +192 -0
  60. package/build/components/Upload/upload.types.d.ts +48 -0
  61. package/build/components/Upload/upload.types.js +3 -0
  62. package/build/components/Upload/uploadList.d.ts +8 -0
  63. package/build/components/Upload/uploadList.js +13 -0
  64. package/build/hooks/useClickOutside.d.ts +3 -0
  65. package/build/hooks/useClickOutside.js +18 -0
  66. package/build/hooks/useDebounce.d.ts +2 -0
  67. package/build/hooks/useDebounce.js +14 -0
  68. package/build/index.css +856 -0
  69. package/build/index.css.map +1 -0
  70. package/build/index.d.ts +9 -0
  71. package/build/index.js +12 -0
  72. package/build/main.d.ts +1 -0
  73. package/build/main.js +7 -0
  74. package/build/setupTests.d.ts +1 -0
  75. package/build/setupTests.js +1 -0
  76. package/package.json +109 -0
@@ -0,0 +1,16 @@
1
+ import type { ChangeEvent, InputHTMLAttributes, ReactElement } from 'react';
2
+ import type { IconProp } from '@fortawesome/fontawesome-svg-core';
3
+ export type InputSize = 'lg' | 'sm';
4
+ export interface InputProps extends Omit<InputHTMLAttributes<HTMLElement>, 'size'> {
5
+ /** 是否禁用 Input */
6
+ disabled?: boolean;
7
+ /** 设置 input 大小,支持 lg 或者是 sm */
8
+ size?: InputSize;
9
+ /** 添加图标,在右侧悬浮添加一个图标,用于提示 */
10
+ icon?: IconProp;
11
+ /** 添加前缀 用于配置一些固定组合 */
12
+ prepend?: string | ReactElement;
13
+ /** 添加后缀 用于配置一些固定组合 */
14
+ append?: string | ReactElement;
15
+ onChange?: (e: ChangeEvent<HTMLInputElement>) => void;
16
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
1
+ import type { FC } from 'react';
2
+ import { type MenuProps } from './menu';
3
+ import { type SubMenuProps } from './subMenu';
4
+ import { type MenuItemProps } from './menuItem';
5
+ export type IMenuComponent = FC<MenuProps> & {
6
+ Item: FC<MenuItemProps>;
7
+ SubMenu: FC<SubMenuProps>;
8
+ };
9
+ declare const TransMenu: IMenuComponent;
10
+ export default TransMenu;
@@ -0,0 +1,9 @@
1
+ import Menu, {} from './menu';
2
+ import SubMenu, {} from './subMenu';
3
+ import MenuItem, {} from './menuItem';
4
+ // Menu 做类型转换
5
+ const TransMenu = Menu;
6
+ // 把子组件挂到 Menu 上
7
+ TransMenu.Item = MenuItem;
8
+ TransMenu.SubMenu = SubMenu;
9
+ export default TransMenu;
@@ -0,0 +1,34 @@
1
+ import React from 'react';
2
+ import type { FC, CSSProperties, ReactNode } from 'react';
3
+ type MenuMode = 'horizontal' | 'vertical';
4
+ export interface MenuProps {
5
+ /**默认 active 的菜单项的索引值 */
6
+ defaultIndex?: string;
7
+ className?: string;
8
+ /**菜单类型 横向或者纵向 */
9
+ mode?: MenuMode;
10
+ style?: CSSProperties;
11
+ /**点击菜单项触发的回掉函数 */
12
+ onSelect?: (selectedIndex: string) => void;
13
+ /**设置子菜单的默认打开 只在纵向模式下生效 */
14
+ defaultOpenSubMenus?: string[];
15
+ children?: ReactNode;
16
+ }
17
+ interface IMenuContext {
18
+ index: string;
19
+ onSelect?: (selectedIndex: string) => void;
20
+ mode?: MenuMode;
21
+ defaultOpenSubMenus?: string[];
22
+ }
23
+ export declare const MenuContext: React.Context<IMenuContext>;
24
+ /**
25
+ * 为网站提供导航功能的菜单。支持横向纵向两种模式,支持下拉菜单。
26
+ *
27
+ * ```javascript
28
+ * import { Menu } from 'vikingship'
29
+ *
30
+ * //然后可以使用 Menu.Item 和 Menu.Submenu 访问选项和子下拉菜单组件
31
+ * ```
32
+ */
33
+ export declare const Menu: FC<MenuProps>;
34
+ export default Menu;
@@ -0,0 +1,48 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import React, { useState, createContext } from 'react';
3
+ import classNames from 'classnames';
4
+ export const MenuContext = createContext({ index: '0' });
5
+ /**
6
+ * 为网站提供导航功能的菜单。支持横向纵向两种模式,支持下拉菜单。
7
+ *
8
+ * ```javascript
9
+ * import { Menu } from 'vikingship'
10
+ *
11
+ * //然后可以使用 Menu.Item 和 Menu.Submenu 访问选项和子下拉菜单组件
12
+ * ```
13
+ */
14
+ export const Menu = ({ className, mode = 'horizontal', style, children, defaultIndex = '0', onSelect, defaultOpenSubMenus = [], }) => {
15
+ const [currentActive, setActive] = useState(defaultIndex);
16
+ const classes = classNames('viking-menu', className, {
17
+ 'menu-vertical': mode === 'vertical',
18
+ 'menu-horizontal': mode !== 'vertical',
19
+ });
20
+ const handleClick = (index) => {
21
+ setActive(index);
22
+ if (onSelect) {
23
+ onSelect(index);
24
+ }
25
+ };
26
+ const passedContext = {
27
+ index: currentActive ? currentActive : '0',
28
+ onSelect: handleClick,
29
+ mode,
30
+ defaultOpenSubMenus,
31
+ };
32
+ const renderChildren = () => {
33
+ return React.Children.map(children, (child, index) => {
34
+ const childElement = child;
35
+ const { displayName } = childElement.type;
36
+ if (displayName === 'MenuItem' || displayName === 'SubMenu') {
37
+ return React.cloneElement(childElement, {
38
+ index: index.toString()
39
+ });
40
+ }
41
+ else {
42
+ console.error("Warning: Menu has a child which is not a MenuItem component");
43
+ }
44
+ });
45
+ };
46
+ return (_jsx("ul", { className: classes, style: style, "data-testid": "test-menu", children: _jsx(MenuContext.Provider, { value: passedContext, children: renderChildren() }) }));
47
+ };
48
+ export default Menu;
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import type { FC, ReactNode } from 'react';
3
+ export interface MenuItemProps {
4
+ index?: string;
5
+ /**选项是否被禁用 */
6
+ disabled?: boolean;
7
+ /**选项扩展的 className */
8
+ className?: string;
9
+ /**选项的自定义 style */
10
+ style?: React.CSSProperties;
11
+ children?: ReactNode;
12
+ }
13
+ export declare const MenuItem: FC<MenuItemProps>;
14
+ export default MenuItem;
@@ -0,0 +1,20 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import React, { useContext } from 'react';
3
+ import classNames from 'classnames';
4
+ import { MenuContext } from './menu';
5
+ export const MenuItem = (props) => {
6
+ const { index, disabled, className, style, children } = props;
7
+ const context = useContext(MenuContext);
8
+ const classes = classNames('menu-item', className, {
9
+ 'is-disabled': disabled,
10
+ 'is-active': context.index === index
11
+ });
12
+ const handleClick = () => {
13
+ if (context.onSelect && !disabled && (typeof index === 'string')) {
14
+ context.onSelect(index);
15
+ }
16
+ };
17
+ return (_jsx("li", { className: classes, style: style, onClick: handleClick, children: children }));
18
+ };
19
+ MenuItem.displayName = 'MenuItem';
20
+ export default MenuItem;
@@ -0,0 +1,11 @@
1
+ import type { FC, ReactNode } from 'react';
2
+ export interface SubMenuProps {
3
+ index?: string;
4
+ /**下拉菜单选项的文字 */
5
+ title: string;
6
+ /**下拉菜单选型的扩展类名 */
7
+ className?: string;
8
+ children?: ReactNode;
9
+ }
10
+ export declare const SubMenu: FC<SubMenuProps>;
11
+ export default SubMenu;
@@ -0,0 +1,56 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import React, { useContext, useState } from 'react';
3
+ import classNames from 'classnames';
4
+ import { MenuContext } from './menu';
5
+ import Icon from '../Icon/icon';
6
+ import Transition from '../Transition/transition';
7
+ export const SubMenu = ({ index, title, children, className }) => {
8
+ const context = useContext(MenuContext);
9
+ const openedSubMenus = context.defaultOpenSubMenus;
10
+ const isOpend = (index && context.mode === 'vertical') ? openedSubMenus.includes(index) : false;
11
+ const [menuOpen, setOpen] = useState(isOpend);
12
+ const classes = classNames('menu-item submenu-item', className, {
13
+ 'is-active': context.index === index,
14
+ 'is-opened': menuOpen,
15
+ 'is-vertical': context.mode === 'vertical'
16
+ });
17
+ const handleClick = (e) => {
18
+ e.preventDefault();
19
+ setOpen(!menuOpen);
20
+ };
21
+ let timer;
22
+ const handleMouse = (e, toggle) => {
23
+ clearTimeout(timer);
24
+ e.preventDefault();
25
+ timer = setTimeout(() => {
26
+ setOpen(toggle);
27
+ }, 300);
28
+ };
29
+ const clickEvents = context.mode === 'vertical' ? {
30
+ onClick: handleClick
31
+ } : {};
32
+ const hoverEvents = context.mode !== 'vertical' ? {
33
+ onMouseEnter: (e) => { handleMouse(e, true); },
34
+ onMouseLeave: (e) => { handleMouse(e, false); }
35
+ } : {};
36
+ const renderChildren = () => {
37
+ const subMenuClasses = classNames('viking-submenu', {
38
+ 'menu-opened': menuOpen
39
+ });
40
+ const childrenComponent = React.Children.map(children, (child, i) => {
41
+ const childElement = child;
42
+ if (childElement.type.displayName === 'MenuItem') {
43
+ return React.cloneElement(childElement, {
44
+ index: `${index}-${i}`
45
+ });
46
+ }
47
+ else {
48
+ console.error("Warning: SubMenu has a child which is not a MenuItem component");
49
+ }
50
+ });
51
+ return (_jsx(Transition, { in: menuOpen, timeout: 300, animation: "zoom-in-top", children: _jsx("ul", { className: subMenuClasses, children: childrenComponent }) }));
52
+ };
53
+ return (_jsxs("li", { className: classes, ...hoverEvents, children: [_jsxs("div", { className: "submenu-title", ...clickEvents, children: [title, _jsx(Icon, { icon: "angle-down", className: "arrow-icon" })] }), renderChildren()] }, index));
54
+ };
55
+ SubMenu.displayName = 'SubMenu';
56
+ export default SubMenu;
@@ -0,0 +1,2 @@
1
+ import Progress from './progress';
2
+ export default Progress;
@@ -0,0 +1,2 @@
1
+ import Progress from './progress';
2
+ export default Progress;
@@ -0,0 +1,4 @@
1
+ import type { FC } from 'react';
2
+ import type { ProgressProps } from './progress.types';
3
+ declare const Progress: FC<ProgressProps>;
4
+ export default Progress;
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ const Progress = (props) => {
3
+ const { percent, strokeHeight = 15, showText = true, styles, theme = 'primary', } = props;
4
+ return (_jsx("div", { className: "viking-progress-bar", style: styles, children: _jsx("div", { className: "viking-progress-bar-outer", style: { height: `${strokeHeight}px` }, children: _jsx("div", { className: `viking-progress-bar-inner color-${theme}`, style: { width: `${percent}%` }, children: showText && _jsx("span", { className: "inner-text", children: `${percent}%` }) }) }) }));
5
+ };
6
+ export default Progress;
@@ -0,0 +1,9 @@
1
+ import type { CSSProperties } from 'react';
2
+ import type { ThemeProps } from '../Icon/icon.types';
3
+ export interface ProgressProps {
4
+ percent: number;
5
+ strokeHeight?: number;
6
+ showText?: boolean;
7
+ styles?: CSSProperties;
8
+ theme?: ThemeProps;
9
+ }
@@ -0,0 +1,2 @@
1
+ // Progress 组件的类型定义,单独拆分成文件,便于复用
2
+ export {};
@@ -0,0 +1,3 @@
1
+ import Transition from './transition';
2
+ export default Transition;
3
+ export type { AnimationName, TransitionProps } from './transition';
@@ -0,0 +1,2 @@
1
+ import Transition from './transition';
2
+ export default Transition;
@@ -0,0 +1,4 @@
1
+ import type { TransitionProps } from './transition.types';
2
+ export type { AnimationName, TransitionProps } from './transition.types';
3
+ declare const Transition: (props: TransitionProps) => import("react/jsx-runtime").JSX.Element;
4
+ export default Transition;
@@ -0,0 +1,18 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useRef } from 'react';
3
+ import { CSSTransition } from 'react-transition-group';
4
+ const Transition = (props) => {
5
+ const { children, classNames: classNamesProp, animation, wrapper = false, unmountOnExit = true, appear = true, addEndListener, ...restProps } = props;
6
+ const cls = animation ? animation : classNamesProp;
7
+ const nodeRef = useRef(null);
8
+ const transitionProps = {
9
+ classNames: cls,
10
+ unmountOnExit,
11
+ appear,
12
+ ...restProps,
13
+ };
14
+ if (addEndListener)
15
+ transitionProps.addEndListener = addEndListener;
16
+ return (_jsx(CSSTransition, { nodeRef: nodeRef, ...transitionProps, children: _jsx("div", { ref: nodeRef, "data-transition-wrapper": wrapper ? 'true' : 'false', children: children }) }));
17
+ };
18
+ export default Transition;
@@ -0,0 +1,10 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { CSSTransitionProps } from 'react-transition-group/CSSTransition';
3
+ export type AnimationName = 'zoom-in-top' | 'zoom-in-left' | 'zoom-in-bottom' | 'zoom-in-right';
4
+ export type TransitionProps = Omit<CSSTransitionProps<HTMLElement>, 'addEndListener' | 'timeout'> & {
5
+ animation?: AnimationName;
6
+ wrapper?: boolean;
7
+ children?: ReactNode;
8
+ timeout: CSSTransitionProps<HTMLElement>['timeout'];
9
+ addEndListener?: (node: HTMLElement, done: () => void) => void;
10
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ import type { FC, ReactNode } from 'react';
2
+ interface DraggerProps {
3
+ onFile: (files: FileList) => void;
4
+ children?: ReactNode;
5
+ }
6
+ export declare const Dragger: FC<DraggerProps>;
7
+ export default Dragger;
@@ -0,0 +1,42 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /* Dragger 是专门处理拖拽上传逻辑的子组件:
3
+ - 只负责获取拖拽的文件
4
+ - 上传文件还是靠 Upload
5
+ 监听浏览器拖拽事件 → 拿到拖进来的文件 → 传回 Upload 组件
6
+
7
+ 浏览器 Drag & Drop API 事件:
8
+ dragenter → 进入区域
9
+ dragover → 在区域上方拖动
10
+ dragleave → 离开区域
11
+ drop → 松手放下文件(包含拖进来的文件)
12
+ */
13
+ import { useState } from 'react';
14
+ import classNames from 'classnames';
15
+ export const Dragger = (props) => {
16
+ const { onFile, children } = props;
17
+ // 负责拖拽样式
18
+ const [dragOver, setDragOver] = useState(false);
19
+ // 使用 `classNames` 拼 `className`:
20
+ const klass = classNames('viking-uploader-dragger', {
21
+ // 如果 `dragOver === true` 时,再加一个:`is-dragover`
22
+ 'is-dragover': dragOver
23
+ });
24
+ // 上传流程
25
+ const handleDrop = (e) => {
26
+ e.preventDefault(); // 阻止默认行为
27
+ setDragOver(false); // 拖拽结束:改变拖拽样式
28
+ // dataTransfer: 浏览器 drop-API 的对象
29
+ // 包含: files(文件列表FileList)、items、types
30
+ // 通过 onFile回调 传回 Upload 处理
31
+ onFile(e.dataTransfer.files);
32
+ };
33
+ // 回调: 控制拖拽状态(改变样式)
34
+ const handleDrag = (e, over) => {
35
+ e.preventDefault();
36
+ setDragOver(over);
37
+ };
38
+ return (_jsx("div", { className: klass,
39
+ // e: 监听DragEvent拖拽事件对象
40
+ onDragOver: e => { handleDrag(e, true); }, onDragLeave: e => { handleDrag(e, false); }, onDrop: handleDrop, children: children }));
41
+ };
42
+ export default Dragger;
@@ -0,0 +1,2 @@
1
+ import Upload from './upload';
2
+ export default Upload;
@@ -0,0 +1,2 @@
1
+ import Upload from './upload';
2
+ export default Upload;
@@ -0,0 +1,2 @@
1
+ declare const AxiosReact: React.FC;
2
+ export default AxiosReact;
@@ -0,0 +1,99 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import axios from 'axios';
3
+ const AxiosReact = () => {
4
+ /*
5
+ e: 这次变化事件的事件对象 -- “事件说明单”
6
+ e = {
7
+ 谁触发的这次变化,
8
+ 发生了什么,
9
+ 当前 input 里有什么值
10
+ }
11
+
12
+ e.target: 触发这次事件的那个 DOM 元素(input 节点本身)
13
+ e: React.ChangeEvent<HTMLInputElement>: 给参数 e 标注类型
14
+ - React 里的 ChangeEvent
15
+ - 这个事件来自 <HTMLInputElement> 泛型参数
16
+
17
+ 提前告诉大家:e 是“来自 input 元素的 change 事件对象” (贴标签)
18
+ - 放心大胆用:e.target.files
19
+ */
20
+ const handleFileChange = (e) => {
21
+ // 1)取出 用户上传的 文件
22
+ /*
23
+ input type="file" 文件类型输入框:
24
+ - 有一个特殊属性 files: 用户当前选中的 文件列表 FileList
25
+ - 用户一次性可以选3个文件
26
+ FileList {
27
+ // File对象
28
+ 0: File {
29
+ name: "a.png",
30
+ size: 12345,
31
+ type: "image/png"
32
+
33
+ // 内部隐藏
34
+ [[BinaryData]]: <文件二进制>0100110101...
35
+ },
36
+
37
+ 1: File {
38
+ name: "b.jpg",
39
+ size: 23456,
40
+ type: "image/jpeg"
41
+ },
42
+
43
+ 2: File {
44
+ name: "c.pdf",
45
+ size: 34567,
46
+ type: "application/pdf"
47
+ },
48
+
49
+ length: 3
50
+ }
51
+ */
52
+ // 获取 文件列表
53
+ const files = e.target.files;
54
+ if (files) {
55
+ // 从文件列表中取出 第一个 File 对象 : 文件信息 + 文件内容(二进制)
56
+ const uploadedFile = files[0];
57
+ // 2)将 本次文件 放进 formData
58
+ const formData = new FormData();
59
+ // key-value 形式
60
+ formData.append("file", uploadedFile);
61
+ // 3)使用 Axios 发送请求
62
+ /*
63
+ 常见参数: axios.post(url, data, config)
64
+ - url:地址
65
+ - data: 请求体body (这次 POST 请求要携带的数据)
66
+ - config配置项 对象:
67
+ */
68
+ axios.post("https://jsonplaceholder.typicode.com/posts",
69
+ // Axios 发出去的不是 FormData 对象本身
70
+ /*
71
+ FormData 里装的是一个 File 对象引用
72
+ -> 当 Axios / fetch 看到: body: formData
73
+ -> 浏览器会开始做“编码
74
+ -> 先遍历 FormData 里的每一项
75
+ -> 变成 HTTP body 里的某一个 "part"
76
+ -> 每一个"part"包含:(文件相关的描述信息 + 二进制内容)
77
+ ------WebKitBoundary123【包裹边界】
78
+ Content-Disposition: form-data; name="file"; filename="a.png"
79
+ Content-Type: image/png
80
+
81
+ <文件二进制内容>
82
+ ------WebKitBoundary123--【结束边界】
83
+ */
84
+ formData, {
85
+ // 设置 请求头信息
86
+ headers: {
87
+ // 表单文件数据
88
+ 'Content-Type': 'multipart/form-data'
89
+ }
90
+ }).then(resp => {
91
+ console.log(resp);
92
+ });
93
+ }
94
+ };
95
+ return (_jsx("div", { className: "AxiosReact", style: { marginTop: '100px', marginLeft: '100px' }, children: _jsx("input", { type: "file",
96
+ // {/* 原生必须传,自定义不用传 name="myFile" */}
97
+ onChange: handleFileChange }) }));
98
+ };
99
+ export default AxiosReact;
@@ -0,0 +1,2 @@
1
+ declare const FromHtml: React.FC;
2
+ export default FromHtml;
@@ -0,0 +1,5 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ const FromHtml = () => {
3
+ return (_jsx("div", { className: "App", style: { marginTop: '100px', marginLeft: '100px' }, children: _jsxs("form", { method: "post", encType: "multipart/form-data", action: "https://jsonplaceholder.typicode.com/posts", children: [_jsx("input", { type: "file", name: "myFile" }), _jsx("button", { type: "submit", children: "Submit" })] }) }));
4
+ };
5
+ export default FromHtml;
@@ -0,0 +1,13 @@
1
+ import type { FC } from 'react';
2
+ import type { UploadProps } from './upload.types';
3
+ /**
4
+ * 通过点击或者拖拽上传文件
5
+ * ### 引用方法
6
+ *
7
+ * ~~~js
8
+ * import { Upload } from 'vikingship'
9
+ * ~~~
10
+ */
11
+ export declare const Upload: FC<UploadProps>;
12
+ export default Upload;
13
+ export type { UploadProps };