@arco-design/mobile-react 2.19.1-941e02b.7 → 2.19.1

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 (101) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/cjs/button/index.d.ts +6 -0
  3. package/cjs/button/index.js +3 -1
  4. package/cjs/grid/index.js +12 -13
  5. package/cjs/image/index.d.ts +1 -0
  6. package/cjs/image/index.js +7 -9
  7. package/cjs/image-preview/index.d.ts +2 -2
  8. package/cjs/index.d.ts +0 -1
  9. package/cjs/index.js +1 -5
  10. package/cjs/notify/index.d.ts +1 -0
  11. package/cjs/notify/index.js +12 -0
  12. package/cjs/notify/type.d.ts +1 -0
  13. package/cjs/steps/demo/style/css/mobile.css +1 -1
  14. package/cjs/steps/demo/style/mobile.less +1 -1
  15. package/cjs/steps/style/css/index.css +15 -5
  16. package/cjs/steps/style/index.less +10 -6
  17. package/cjs/style.d.ts +0 -1
  18. package/cjs/style.js +0 -2
  19. package/cjs/transition/index.js +4 -2
  20. package/dist/index.js +242 -538
  21. package/dist/index.min.js +5 -4
  22. package/dist/style.css +9 -120
  23. package/dist/style.min.css +1 -1
  24. package/esm/button/index.d.ts +6 -0
  25. package/esm/button/index.js +3 -1
  26. package/esm/grid/index.js +12 -13
  27. package/esm/image/index.d.ts +1 -0
  28. package/esm/image/index.js +8 -10
  29. package/esm/image-preview/index.d.ts +2 -2
  30. package/esm/index.d.ts +0 -1
  31. package/esm/index.js +0 -1
  32. package/esm/notify/index.d.ts +1 -0
  33. package/esm/notify/index.js +1 -0
  34. package/esm/notify/type.d.ts +1 -0
  35. package/esm/steps/demo/style/css/mobile.css +1 -1
  36. package/esm/steps/demo/style/mobile.less +1 -1
  37. package/esm/steps/style/css/index.css +15 -5
  38. package/esm/steps/style/index.less +10 -6
  39. package/esm/style.d.ts +0 -1
  40. package/esm/style.js +0 -1
  41. package/esm/transition/index.js +4 -2
  42. package/package.json +3 -3
  43. package/tokens/app/arcodesign/default/css-variables.less +2 -17
  44. package/tokens/app/arcodesign/default/index.d.ts +2 -17
  45. package/tokens/app/arcodesign/default/index.js +3 -18
  46. package/tokens/app/arcodesign/default/index.json +24 -140
  47. package/tokens/app/arcodesign/default/index.less +2 -17
  48. package/umd/button/index.d.ts +6 -0
  49. package/umd/button/index.js +3 -1
  50. package/umd/grid/index.js +12 -13
  51. package/umd/image/index.d.ts +1 -0
  52. package/umd/image/index.js +7 -9
  53. package/umd/image-preview/index.d.ts +2 -2
  54. package/umd/index.d.ts +0 -1
  55. package/umd/index.js +5 -7
  56. package/umd/notify/index.d.ts +1 -0
  57. package/umd/notify/index.js +13 -4
  58. package/umd/notify/type.d.ts +1 -0
  59. package/umd/steps/demo/style/css/mobile.css +1 -1
  60. package/umd/steps/demo/style/mobile.less +1 -1
  61. package/umd/steps/style/css/index.css +15 -5
  62. package/umd/steps/style/index.less +10 -6
  63. package/umd/style.d.ts +0 -1
  64. package/umd/style.js +4 -4
  65. package/umd/transition/index.js +4 -2
  66. package/cjs/image-picker/add-icon.d.ts +0 -2
  67. package/cjs/image-picker/add-icon.js +0 -22
  68. package/cjs/image-picker/demo/style/css/mobile.css +0 -40
  69. package/cjs/image-picker/demo/style/mobile.less +0 -42
  70. package/cjs/image-picker/index.d.ts +0 -181
  71. package/cjs/image-picker/index.js +0 -301
  72. package/cjs/image-picker/style/css/index.css +0 -147
  73. package/cjs/image-picker/style/css/index.d.ts +0 -2
  74. package/cjs/image-picker/style/css/index.js +0 -5
  75. package/cjs/image-picker/style/index.d.ts +0 -2
  76. package/cjs/image-picker/style/index.js +0 -5
  77. package/cjs/image-picker/style/index.less +0 -116
  78. package/esm/image-picker/add-icon.d.ts +0 -2
  79. package/esm/image-picker/add-icon.js +0 -14
  80. package/esm/image-picker/demo/style/css/mobile.css +0 -40
  81. package/esm/image-picker/demo/style/mobile.less +0 -42
  82. package/esm/image-picker/index.d.ts +0 -181
  83. package/esm/image-picker/index.js +0 -282
  84. package/esm/image-picker/style/css/index.css +0 -147
  85. package/esm/image-picker/style/css/index.d.ts +0 -2
  86. package/esm/image-picker/style/css/index.js +0 -2
  87. package/esm/image-picker/style/index.d.ts +0 -2
  88. package/esm/image-picker/style/index.js +0 -2
  89. package/esm/image-picker/style/index.less +0 -116
  90. package/umd/image-picker/add-icon.d.ts +0 -2
  91. package/umd/image-picker/add-icon.js +0 -35
  92. package/umd/image-picker/demo/style/css/mobile.css +0 -40
  93. package/umd/image-picker/demo/style/mobile.less +0 -42
  94. package/umd/image-picker/index.d.ts +0 -181
  95. package/umd/image-picker/index.js +0 -304
  96. package/umd/image-picker/style/css/index.css +0 -147
  97. package/umd/image-picker/style/css/index.d.ts +0 -2
  98. package/umd/image-picker/style/css/index.js +0 -15
  99. package/umd/image-picker/style/index.d.ts +0 -2
  100. package/umd/image-picker/style/index.js +0 -15
  101. package/umd/image-picker/style/index.less +0 -116
package/umd/style.js CHANGED
@@ -1,15 +1,15 @@
1
1
  (function (global, factory) {
2
2
  if (typeof define === "function" && define.amd) {
3
- define(["../style/public.less", "./action-sheet/style", "./cell/style", "./loading/style", "./badge/style", "./avatar/style", "./button/style", "./carousel/style", "./toast/style", "./switch/style", "./checkbox/style", "./circle-progress/style", "./collapse/style", "./tabs/style", "./context-provider/style", "./dialog/style", "./count-down/style", "./date-picker/style", "./dropdown/style", "./dropdown-menu/style", "./ellipsis/style", "./grid/style", "./image/style", "./show-monitor/style", "./image-picker/style", "./image-preview/style", "./input/style", "./load-more/style", "./masking/style", "./nav-bar/style", "./notice-bar/style", "./notify/style", "./pagination/style", "./picker/style", "./picker-view/style", "./popover/style", "./popup/style", "./popup-swiper/style", "./portal/style", "./progress/style", "./pull-refresh/style", "./radio/style", "./rate/style", "./slider/style", "./steps/style", "./sticky/style", "./swipe-load/style", "./tab-bar/style", "./tag/style", "./textarea/style", "./transition/style"], factory);
3
+ define(["../style/public.less", "./action-sheet/style", "./cell/style", "./loading/style", "./badge/style", "./avatar/style", "./button/style", "./carousel/style", "./toast/style", "./switch/style", "./checkbox/style", "./circle-progress/style", "./collapse/style", "./tabs/style", "./context-provider/style", "./dialog/style", "./count-down/style", "./date-picker/style", "./dropdown/style", "./dropdown-menu/style", "./ellipsis/style", "./grid/style", "./image/style", "./show-monitor/style", "./image-preview/style", "./input/style", "./load-more/style", "./masking/style", "./nav-bar/style", "./notice-bar/style", "./notify/style", "./pagination/style", "./picker/style", "./picker-view/style", "./popover/style", "./popup/style", "./popup-swiper/style", "./portal/style", "./progress/style", "./pull-refresh/style", "./radio/style", "./rate/style", "./slider/style", "./steps/style", "./sticky/style", "./swipe-load/style", "./tab-bar/style", "./tag/style", "./textarea/style", "./transition/style"], factory);
4
4
  } else if (typeof exports !== "undefined") {
5
- factory(require("../style/public.less"), require("./action-sheet/style"), require("./cell/style"), require("./loading/style"), require("./badge/style"), require("./avatar/style"), require("./button/style"), require("./carousel/style"), require("./toast/style"), require("./switch/style"), require("./checkbox/style"), require("./circle-progress/style"), require("./collapse/style"), require("./tabs/style"), require("./context-provider/style"), require("./dialog/style"), require("./count-down/style"), require("./date-picker/style"), require("./dropdown/style"), require("./dropdown-menu/style"), require("./ellipsis/style"), require("./grid/style"), require("./image/style"), require("./show-monitor/style"), require("./image-picker/style"), require("./image-preview/style"), require("./input/style"), require("./load-more/style"), require("./masking/style"), require("./nav-bar/style"), require("./notice-bar/style"), require("./notify/style"), require("./pagination/style"), require("./picker/style"), require("./picker-view/style"), require("./popover/style"), require("./popup/style"), require("./popup-swiper/style"), require("./portal/style"), require("./progress/style"), require("./pull-refresh/style"), require("./radio/style"), require("./rate/style"), require("./slider/style"), require("./steps/style"), require("./sticky/style"), require("./swipe-load/style"), require("./tab-bar/style"), require("./tag/style"), require("./textarea/style"), require("./transition/style"));
5
+ factory(require("../style/public.less"), require("./action-sheet/style"), require("./cell/style"), require("./loading/style"), require("./badge/style"), require("./avatar/style"), require("./button/style"), require("./carousel/style"), require("./toast/style"), require("./switch/style"), require("./checkbox/style"), require("./circle-progress/style"), require("./collapse/style"), require("./tabs/style"), require("./context-provider/style"), require("./dialog/style"), require("./count-down/style"), require("./date-picker/style"), require("./dropdown/style"), require("./dropdown-menu/style"), require("./ellipsis/style"), require("./grid/style"), require("./image/style"), require("./show-monitor/style"), require("./image-preview/style"), require("./input/style"), require("./load-more/style"), require("./masking/style"), require("./nav-bar/style"), require("./notice-bar/style"), require("./notify/style"), require("./pagination/style"), require("./picker/style"), require("./picker-view/style"), require("./popover/style"), require("./popup/style"), require("./popup-swiper/style"), require("./portal/style"), require("./progress/style"), require("./pull-refresh/style"), require("./radio/style"), require("./rate/style"), require("./slider/style"), require("./steps/style"), require("./sticky/style"), require("./swipe-load/style"), require("./tab-bar/style"), require("./tag/style"), require("./textarea/style"), require("./transition/style"));
6
6
  } else {
7
7
  var mod = {
8
8
  exports: {}
9
9
  };
10
- factory(global._public, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style);
10
+ factory(global._public, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style, global.style);
11
11
  global.style = mod.exports;
12
12
  }
13
- })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_public, _style, _style2, _style3, _style4, _style5, _style6, _style7, _style8, _style9, _style10, _style11, _style12, _style13, _style14, _style15, _style16, _style17, _style18, _style19, _style20, _style21, _style22, _style23, _style24, _style25, _style26, _style27, _style28, _style29, _style30, _style31, _style32, _style33, _style34, _style35, _style36, _style37, _style38, _style39, _style40, _style41, _style42, _style43, _style44, _style45, _style46, _style47, _style48, _style49, _style50) {
13
+ })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_public, _style, _style2, _style3, _style4, _style5, _style6, _style7, _style8, _style9, _style10, _style11, _style12, _style13, _style14, _style15, _style16, _style17, _style18, _style19, _style20, _style21, _style22, _style23, _style24, _style25, _style26, _style27, _style28, _style29, _style30, _style31, _style32, _style33, _style34, _style35, _style36, _style37, _style38, _style39, _style40, _style41, _style42, _style43, _style44, _style45, _style46, _style47, _style48, _style49) {
14
14
  "use strict";
15
15
  });
@@ -32,10 +32,12 @@
32
32
  * @name_en Transition
33
33
  */
34
34
  function Transition(props) {
35
- var children = props.children,
35
+ var _props$children = props.children,
36
+ children = _props$children === void 0 ? /*#__PURE__*/_react.default.createElement("div", null) : _props$children,
36
37
  type = props.type,
37
38
  transIn = props.in,
38
- timeout = props.timeout,
39
+ _props$timeout = props.timeout,
40
+ timeout = _props$timeout === void 0 ? 300 : _props$timeout,
39
41
  _props$mountOnEnter = props.mountOnEnter,
40
42
  mountOnEnter = _props$mountOnEnter === void 0 ? true : _props$mountOnEnter,
41
43
  _props$unmountOnExit = props.unmountOnExit,
@@ -1,2 +0,0 @@
1
- /// <reference types="react" />
2
- export default function AddIcon(): JSX.Element;
@@ -1,22 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- exports.__esModule = true;
6
- exports.default = AddIcon;
7
-
8
- var _react = _interopRequireDefault(require("react"));
9
-
10
- function AddIcon() {
11
- return /*#__PURE__*/_react.default.createElement("svg", {
12
- width: "30",
13
- height: "30",
14
- viewBox: "0 0 30 30",
15
- fill: "none"
16
- }, /*#__PURE__*/_react.default.createElement("path", {
17
- fillRule: "evenodd",
18
- clipRule: "evenodd",
19
- d: "M14.5 0C14.2239 0 14 0.223857 14 0.5V14H0.5C0.223858 14 0 14.2239 0 14.5V15.5C0 15.7761 0.223857 16 0.5 16H14V29.5C14 29.7761 14.2239 30 14.5 30H15.5C15.7761 30 16 29.7761 16 29.5V16H29.5C29.7761 16 30 15.7761 30 15.5V14.5C30 14.2239 29.7761 14 29.5 14H16V0.5C16 0.223858 15.7761 0 15.5 0H14.5Z",
20
- fill: "#C9CDD4"
21
- }));
22
- }
@@ -1,40 +0,0 @@
1
- #demo-image-picker .demo-space {
2
- font-size: 14px;
3
- line-height: 1;
4
- margin: 8px 0;
5
- }
6
- #demo-image-picker #demo-order-5 .custom-delete {
7
- top: 4px;
8
- right: 4px;
9
- font-size: 18px;
10
- position: absolute;
11
- border-radius: 50%;
12
- width: 18px;
13
- height: 18px;
14
- line-height: 16px;
15
- text-align: center;
16
- }
17
- #demo-image-picker #demo-order-5 .custom-delete-bg {
18
- background-color: #0000004d;
19
- }
20
- #demo-image-picker #demo-order-6 .loading,
21
- #demo-image-picker #demo-order-6 .loading1,
22
- #demo-image-picker #demo-order-6 .load-error,
23
- #demo-image-picker #demo-order-6 .load-error1 {
24
- background: rgba(0, 0, 0, 0.5);
25
- text-align: center;
26
- line-height: 1.5;
27
- font-size: 14px;
28
- color: #fff;
29
- width: 100%;
30
- height: 100%;
31
- display: -webkit-box;
32
- display: -webkit-flex;
33
- display: flex;
34
- -webkit-box-align: center;
35
- -webkit-align-items: center;
36
- align-items: center;
37
- -webkit-box-pack: center;
38
- -webkit-justify-content: center;
39
- justify-content: center;
40
- }
@@ -1,42 +0,0 @@
1
- @import '../../../../style/mixin.less';
2
-
3
- #demo-image-picker {
4
- .demo-space{
5
- font-size: 14px;
6
- line-height: 1;
7
- margin: 8px 0;
8
- }
9
- #demo-order-5 {
10
- .custom-delete {
11
- top: 4px;
12
- right: 4px;
13
- font-size: 18px;
14
- position: absolute;
15
- border-radius: 50%;
16
- width: 18px;
17
- height: 18px;
18
- line-height: 16px;
19
- text-align: center;
20
- }
21
- .custom-delete-bg {
22
- background-color: #0000004d;
23
- }
24
- }
25
- #demo-order-6 {
26
- .loading,
27
- .loading1,
28
- .load-error,
29
- .load-error1 {
30
- background: rgba(0, 0, 0, 0.5);
31
- text-align: center;
32
- line-height: 1.5;
33
- font-size: 14px;
34
- color: #fff;
35
- width: 100%;
36
- height: 100%;
37
- display: flex;
38
- align-items: center;
39
- justify-content: center;
40
- }
41
- }
42
- }
@@ -1,181 +0,0 @@
1
- import React, { InputHTMLAttributes } from 'react';
2
- import { ImageProps } from '../image';
3
- export interface ImagePickItem {
4
- /**
5
- * 图片地址
6
- * @en Image Url
7
- */
8
- url: string;
9
- /**
10
- * 图片文件
11
- * @en Image File
12
- */
13
- file?: File;
14
- /**
15
- * 图片状态
16
- * @en Image Status
17
- * @default 'loaded'
18
- */
19
- status: 'loaded' | 'loading' | 'error';
20
- }
21
- export interface AdapterFile {
22
- url?: string;
23
- size: number;
24
- name: string;
25
- }
26
- export interface SelectCallback {
27
- files: AdapterFile[];
28
- }
29
- export interface ImagePickerProps {
30
- /**
31
- * 自定义类名
32
- * @en Custom className
33
- */
34
- className?: string;
35
- /**
36
- * 自定义样式
37
- * @en Custom stylesheet
38
- */
39
- style?: React.CSSProperties;
40
- /**
41
- * 已选择图片列表
42
- * @en selected images list
43
- */
44
- images: ImagePickItem[];
45
- /**
46
- * 可以选择的文件类型
47
- * @en Available File Types
48
- * @default 'image/*'
49
- */
50
- accept?: string;
51
- /**
52
- * 是否支持多选
53
- * @en Whether To Support Multiple Selection
54
- */
55
- multiple?: boolean;
56
- /**
57
- * 图片选取模式 Image selection mode [capture MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/capture)
58
- * @en Whether To Support Multiple Selection [capture MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/capture)
59
- */
60
- capture?: InputHTMLAttributes<unknown>['capture'];
61
- /**
62
- * 一行展示图片张数
63
- * @en The Number Of Pictures Displayed In A Row
64
- * @default 3
65
- */
66
- columns?: number;
67
- /**
68
- * 格子间的间距
69
- * @en spacing between grids
70
- * @default 8
71
- */
72
- gutter?: number;
73
- /**
74
- * 最多选择图片张数,超出数量自动隐藏上传按钮,0表示不做限制
75
- * @en max Pictures Can Choose
76
- */
77
- limit?: number;
78
- /**
79
- * 文件大小限制,单位为K
80
- * @en File size limit, in K
81
- */
82
- maxSize?: number;
83
- /**
84
- * 是否隐藏删除Icon
85
- * @en Whether to hide delete Icon
86
- * @default false
87
- */
88
- hideDelete?: boolean;
89
- /**
90
- * 是否隐藏选择Icon
91
- * @en Whether to hide Select Icon
92
- * @default false
93
- */
94
- hideSelect?: boolean;
95
- /**
96
- * 是否总是展示选择Icon,默认情况下当图片数量超出limit值时会自动隐藏选择Icon
97
- * @en Whether to always show Select Icon
98
- * @default false
99
- */
100
- alwaysShowSelect?: boolean;
101
- /**
102
- * 禁用选择和删除图片
103
- * @en Disable Select & Delete Image
104
- */
105
- disabled?: boolean;
106
- /**
107
- * 自定义删除图标
108
- * @en Defined Delete Icon
109
- */
110
- deleteIcon?: React.ReactNode;
111
- /**
112
- * 自定义选择图标
113
- * @en Defined Select Icon
114
- */
115
- selectIcon?: React.ReactNode;
116
- /**
117
- * 透传给图片的属性
118
- * @en Attributes passed through to the image
119
- */
120
- imageProps?: ImageProps;
121
- /**
122
- * 自定义上传失败展示
123
- * @en Defined upload failed display
124
- */
125
- renderError?: (index?: number) => React.ReactNode | React.ReactNode;
126
- /**
127
- * 自定义上传中展示
128
- * @en Defined uploading display
129
- */
130
- renderLoading?: (index?: number) => React.ReactNode | React.ReactNode;
131
- /**
132
- * 上传方法
133
- * @en upload function
134
- */
135
- upload?: (file: ImagePickItem) => Promise<ImagePickItem | null>;
136
- onSelect?: (...args: any[]) => void;
137
- /**
138
- * 已选图片列表发生变化
139
- * @en The list of selected images changes
140
- */
141
- onChange?: (fileList: ImagePickItem[]) => Promise<void>;
142
- /**
143
- * 图片超过限制大小
144
- * @en Image exceeds size limit
145
- */
146
- onMaxSizeExceed?: (file: File) => void;
147
- /**
148
- * 选择张数超过限制
149
- * @en The number of pictures exceeds the limit
150
- */
151
- onLimitExceed?: (files: File[]) => void;
152
- /**
153
- * 图片点击
154
- * @en click event
155
- */
156
- onClick?: (e: React.MouseEvent<HTMLElement, MouseEvent>, image: ImagePickItem, index: number) => void;
157
- /**
158
- * 图片长按事件
159
- * @en long press event
160
- */
161
- onLongPress?: (e: React.MouseEvent<HTMLElement, MouseEvent>, image: ImagePickItem, index: number) => void;
162
- /**
163
- * 图片选择适配器
164
- * @en Select Adaptor
165
- */
166
- selectAdapter: () => Promise<SelectCallback>;
167
- }
168
- export interface ImagePickerRef {
169
- /** 最外层元素 DOM */
170
- dom: HTMLDivElement | null;
171
- }
172
- /**
173
- * 图片选择器组件
174
- * @en ImagePicker Component
175
- * @type 数据输入
176
- * @type_en Data Entry
177
- * @name 图片选择器
178
- * @name_en ImagePicker
179
- */
180
- declare const ImagePicker: React.ForwardRefExoticComponent<ImagePickerProps & React.RefAttributes<ImagePickerRef>>;
181
- export default ImagePicker;
@@ -1,301 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- exports.__esModule = true;
6
- exports.default = void 0;
7
-
8
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
-
10
- var _react = _interopRequireWildcard(require("react"));
11
-
12
- var _mobileUtils = require("@arco-design/mobile-utils");
13
-
14
- var _contextProvider = require("../context-provider");
15
-
16
- var _icon = require("../icon");
17
-
18
- var _image = _interopRequireDefault(require("../image"));
19
-
20
- var _grid = _interopRequireDefault(require("../grid"));
21
-
22
- var _addIcon = _interopRequireDefault(require("./add-icon"));
23
-
24
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
25
-
26
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
27
-
28
- /**
29
- * 图片选择器组件
30
- * @en ImagePicker Component
31
- * @type 数据输入
32
- * @type_en Data Entry
33
- * @name 图片选择器
34
- * @name_en ImagePicker
35
- */
36
- var ImagePicker = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
37
- var _props$className = props.className,
38
- className = _props$className === void 0 ? '' : _props$className,
39
- style = props.style,
40
- _props$accept = props.accept,
41
- accept = _props$accept === void 0 ? 'image/*' : _props$accept,
42
- _props$multiple = props.multiple,
43
- multiple = _props$multiple === void 0 ? false : _props$multiple,
44
- capture = props.capture,
45
- _props$columns = props.columns,
46
- columns = _props$columns === void 0 ? 3 : _props$columns,
47
- _props$gutter = props.gutter,
48
- gutter = _props$gutter === void 0 ? 8 : _props$gutter,
49
- _props$limit = props.limit,
50
- limit = _props$limit === void 0 ? 0 : _props$limit,
51
- _props$images = props.images,
52
- images = _props$images === void 0 ? [] : _props$images,
53
- maxSize = props.maxSize,
54
- disabled = props.disabled,
55
- deleteIcon = props.deleteIcon,
56
- selectIcon = props.selectIcon,
57
- _props$hideDelete = props.hideDelete,
58
- hideDelete = _props$hideDelete === void 0 ? false : _props$hideDelete,
59
- _props$hideSelect = props.hideSelect,
60
- hideSelect = _props$hideSelect === void 0 ? false : _props$hideSelect,
61
- _props$alwaysShowSele = props.alwaysShowSelect,
62
- alwaysShowSelect = _props$alwaysShowSele === void 0 ? false : _props$alwaysShowSele,
63
- imageProps = props.imageProps,
64
- renderLoading = props.renderLoading,
65
- renderError = props.renderError,
66
- onLongPress = props.onLongPress,
67
- onClick = props.onClick,
68
- _props$onChange = props.onChange,
69
- onChange = _props$onChange === void 0 ? function () {
70
- return null;
71
- } : _props$onChange,
72
- onMaxSizeExceed = props.onMaxSizeExceed,
73
- onLimitExceed = props.onLimitExceed,
74
- upload = props.upload,
75
- selectAdapter = props.selectAdapter;
76
- var domRef = (0, _react.useRef)(null);
77
- var fileRef = (0, _react.useRef)(null);
78
- (0, _react.useImperativeHandle)(ref, function () {
79
- return {
80
- dom: domRef.current
81
- };
82
- });
83
-
84
- var parseFile = function parseFile(file) {
85
- return new Promise(function (resolve, reject) {
86
- if (file.url) {
87
- resolve(file.url);
88
- } else {
89
- var reader = new FileReader();
90
-
91
- reader.onload = function (e) {
92
- var _e$target;
93
-
94
- var dataURL = (_e$target = e.target) == null ? void 0 : _e$target.result;
95
-
96
- if (!dataURL) {
97
- reject(new Error('file parse error'));
98
- }
99
-
100
- resolve(dataURL);
101
- };
102
-
103
- reader.onerror = function () {
104
- reject(new Error('file parse error'));
105
- };
106
-
107
- reader.readAsDataURL(file);
108
- }
109
- });
110
- };
111
-
112
- var handleChange = function handleChange(event) {
113
- var files = [].concat(event.target.files || []).filter(function (file) {
114
- // 过滤maxSize
115
- if (maxSize && file.size > maxSize * 1024) {
116
- onMaxSizeExceed && onMaxSizeExceed(file);
117
- return false;
118
- }
119
-
120
- return true;
121
- }) || [];
122
- event.target.value = ''; // 截断limit
123
-
124
- if (limit !== 0 && files.length + images.length > limit) {
125
- onLimitExceed && onLimitExceed(files);
126
- files.length = limit - images.length;
127
- } // 解析文件生成预览
128
-
129
-
130
- Promise.all(files.map(function (file) {
131
- return parseFile(file);
132
- })).then(function (parseFiles) {
133
- var res = parseFiles.map(function (url, index) {
134
- return {
135
- url: url,
136
- status: upload ? 'loading' : 'loaded',
137
- file: files[index]
138
- };
139
- });
140
- var cacheRes = [].concat(images, res);
141
- onChange(cacheRes); // 执行upload
142
-
143
- if (typeof upload === 'function') {
144
- var propsImageLength = images.length;
145
- files.forEach(function (_file, index) {
146
- upload(cacheRes[propsImageLength + index]).then(function (data) {
147
- cacheRes[propsImageLength + index] = (0, _extends2.default)({}, cacheRes[propsImageLength + index], data);
148
- }).catch(function () {
149
- cacheRes[propsImageLength + index].status = 'error';
150
- }).finally(function () {
151
- cacheRes[propsImageLength + index].status = 'loaded';
152
- onChange([].concat(cacheRes));
153
- });
154
- });
155
- }
156
- });
157
- };
158
-
159
- var handleDelete = function handleDelete(index) {
160
- onChange(images.filter(function (_i, j) {
161
- return j !== index;
162
- }));
163
- }; // click && longPress
164
-
165
-
166
- var timeOutEvent;
167
-
168
- var handleTouchStart = function handleTouchStart(e, image, index) {
169
- e.preventDefault();
170
- timeOutEvent = setTimeout(function () {
171
- timeOutEvent = 0;
172
- typeof onLongPress === 'function' && onLongPress(e, image, index);
173
- }, 750);
174
- };
175
-
176
- var handleTouchEnd = function handleTouchEnd(e, image, index) {
177
- clearTimeout(timeOutEvent);
178
-
179
- if (timeOutEvent !== 0) {
180
- typeof onClick === 'function' && onClick(e, image, index);
181
- }
182
- };
183
-
184
- var handleSelect = function handleSelect() {
185
- var _fileRef$current;
186
-
187
- selectAdapter ? selectAdapter().then(function (_ref) {
188
- var files = _ref.files;
189
- return handleChange({
190
- target: {
191
- files: files
192
- }
193
- });
194
- }) : (_fileRef$current = fileRef.current) == null ? void 0 : _fileRef$current.click();
195
- };
196
-
197
- var getGridData = function getGridData(prefixCls, locale) {
198
- var errorNode = function errorNode(index) {
199
- if (renderError) {
200
- return typeof renderError === 'function' ? renderError(index) : renderError;
201
- }
202
-
203
- return /*#__PURE__*/_react.default.createElement("div", {
204
- className: prefixCls + "-image-picker-error"
205
- }, /*#__PURE__*/_react.default.createElement("p", null, locale.ImagePicker.loadError));
206
- };
207
-
208
- var loadingNode = function loadingNode(index) {
209
- if (renderLoading) {
210
- return typeof renderLoading === 'function' ? renderLoading(index) : renderLoading;
211
- }
212
-
213
- return null;
214
- };
215
-
216
- var data = (limit && limit < images.length ? images.slice(0, limit) : images).map(function (image, index) {
217
- var url = image.url,
218
- status = image.status;
219
- return {
220
- img: /*#__PURE__*/_react.default.createElement("div", {
221
- key: index + "-" + url,
222
- className: prefixCls + "-image-picker-image"
223
- }, /*#__PURE__*/_react.default.createElement("div", {
224
- onTouchStart: function onTouchStart(e) {
225
- return handleTouchStart(e, image, index);
226
- },
227
- onTouchEnd: function onTouchEnd(e) {
228
- return handleTouchEnd(e, image, index);
229
- },
230
- className: prefixCls + "-image-picker-image-container"
231
- }, /*#__PURE__*/_react.default.createElement(_image.default, (0, _extends2.default)({
232
- showLoading: true,
233
- showError: true
234
- }, imageProps || {}, {
235
- src: url,
236
- errorArea: errorNode(index),
237
- loadingArea: loadingNode(index),
238
- status: status || (imageProps == null ? void 0 : imageProps.status)
239
- })), /*#__PURE__*/_react.default.createElement("div", {
240
- className: prefixCls + "-image-picker-image-mask"
241
- })), !hideDelete && /*#__PURE__*/_react.default.createElement("div", {
242
- className: prefixCls + "-image-picker-close",
243
- onClick: function onClick() {
244
- return handleDelete(index);
245
- }
246
- }, deleteIcon || /*#__PURE__*/_react.default.createElement("div", {
247
- className: prefixCls + "-image-picker-close-icon"
248
- }, /*#__PURE__*/_react.default.createElement(_icon.IconClose, null)))),
249
- title: ''
250
- };
251
- });
252
- var showSelect = !hideSelect && images.length < (limit || Infinity);
253
- var disableSelect = disabled || alwaysShowSelect && !showSelect;
254
-
255
- if (showSelect || alwaysShowSelect) {
256
- var _cls;
257
-
258
- data.push({
259
- img: /*#__PURE__*/_react.default.createElement("div", {
260
- className: (0, _mobileUtils.cls)(prefixCls + "-image-picker-add", (_cls = {}, _cls[prefixCls + "-image-picker-add-disabled"] = disableSelect, _cls)),
261
- onClick: handleSelect
262
- }, /*#__PURE__*/_react.default.createElement("div", {
263
- className: prefixCls + "-image-picker-add-container"
264
- }, selectIcon || /*#__PURE__*/_react.default.createElement("div", {
265
- className: prefixCls + "-image-picker-add-icon"
266
- }, /*#__PURE__*/_react.default.createElement(_addIcon.default, null)), !selectAdapter ? /*#__PURE__*/_react.default.createElement("input", {
267
- capture: capture,
268
- accept: accept,
269
- multiple: multiple,
270
- type: "file",
271
- onChange: handleChange,
272
- ref: fileRef
273
- }) : null)),
274
- title: ''
275
- });
276
- }
277
-
278
- return data;
279
- };
280
-
281
- return /*#__PURE__*/_react.default.createElement(_contextProvider.ContextLayout, null, function (_ref2) {
282
- var _cls2;
283
-
284
- var prefixCls = _ref2.prefixCls,
285
- _ref2$locale = _ref2.locale,
286
- locale = _ref2$locale === void 0 ? _mobileUtils.defaultLocale : _ref2$locale;
287
- return /*#__PURE__*/_react.default.createElement("div", {
288
- className: (0, _mobileUtils.cls)(prefixCls + "-image-picker", className, (_cls2 = {}, _cls2[prefixCls + "-image-picker-disabled"] = disabled, _cls2)),
289
- style: style,
290
- ref: domRef
291
- }, /*#__PURE__*/_react.default.createElement("div", {
292
- className: prefixCls + "-image-picker-container"
293
- }, /*#__PURE__*/_react.default.createElement(_grid.default, {
294
- data: getGridData(prefixCls, locale),
295
- gutter: gutter,
296
- columns: columns
297
- })));
298
- });
299
- });
300
- var _default = ImagePicker;
301
- exports.default = _default;