@sheinx/base 3.10.0-beta.21 → 3.10.0-beta.22

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.
@@ -346,7 +346,7 @@ var Cascader = function Cascader(props0) {
346
346
  _path = _path || [];
347
347
  handlePathChange(lastValue, null, _path);
348
348
  } catch (e) {
349
- console.error(e);
349
+ _hooks.util.devUseWarning.error("".concat(e));
350
350
  }
351
351
  };
352
352
  var handleKeyDown = function handleKeyDown(e) {
@@ -13,6 +13,7 @@ var Arrow = /*#__PURE__*/(0, _jsxRuntime.jsx)("svg", {
13
13
  viewBox: "0 0 40 100",
14
14
  xmlns: "http://www.w3.org/2000/svg",
15
15
  preserveAspectRatio: "none",
16
+ "aria-hidden": "true",
16
17
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
17
18
  d: "M 0 0 L 40 50 L 0 100",
18
19
  fill: "currentColor"
@@ -1 +1 @@
1
- {"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["upload.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAgC,MAAM,eAAe,CAAC;AAY1E,QAAA,MAAM,MAAM,wEAwTX,CAAC;AAEF,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["upload.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAgC,MAAM,eAAe,CAAC;AAY1E,QAAA,MAAM,MAAM,wEAqVX,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -118,7 +118,7 @@ var Upload = function Upload(props0) {
118
118
  if (!getComponentRef) return;
119
119
  var ref = {
120
120
  addFiles: function addFiles(files) {
121
- return func.addFiles(files);
121
+ func.addFiles(files);
122
122
  }
123
123
  };
124
124
  if (_hooks.util.isFunc(getComponentRef)) {
@@ -126,14 +126,22 @@ var Upload = function Upload(props0) {
126
126
  } else {
127
127
  getComponentRef.current = ref;
128
128
  }
129
- }, []);
129
+ return function () {
130
+ if (_hooks.util.isFunc(getComponentRef)) {
131
+ getComponentRef(null);
132
+ } else {
133
+ getComponentRef.current = null;
134
+ }
135
+ };
136
+ }, [props.getComponentRef]);
130
137
 
131
138
  // paste 处理:document 级别监听,因为 Upload 没有可聚焦的空白区域
139
+ // 仅当粘贴事件来自非可编辑区域时才触发,避免干扰 input/textarea 等正常粘贴行为
132
140
  (0, _react.useEffect)(function () {
133
141
  if (!paste) return;
134
142
  var handlePaste = /*#__PURE__*/function () {
135
143
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(e) {
136
- var files, _e$clipboardData, filtered, toAdd;
144
+ var target, tagName, files, _e$clipboardData, filtered, toAdd;
137
145
  return _regeneratorRuntime().wrap(function _callee$(_context) {
138
146
  while (1) switch (_context.prev = _context.next) {
139
147
  case 0:
@@ -143,41 +151,63 @@ var Upload = function Upload(props0) {
143
151
  }
144
152
  return _context.abrupt("return");
145
153
  case 2:
154
+ // 过滤掉来自可编辑元素的粘贴事件,避免与 input/textarea/contentEditable 冲突
155
+ target = e.target;
156
+ if (!target) {
157
+ _context.next = 7;
158
+ break;
159
+ }
160
+ tagName = target.tagName;
161
+ if (!(tagName === 'INPUT' || tagName === 'TEXTAREA' || target.isContentEditable)) {
162
+ _context.next = 7;
163
+ break;
164
+ }
165
+ return _context.abrupt("return");
166
+ case 7:
146
167
  if (!(props.beforePaste && _hooks.util.isFunc(props.beforePaste))) {
147
- _context.next = 8;
168
+ _context.next = 20;
148
169
  break;
149
170
  }
150
- _context.next = 5;
171
+ _context.prev = 8;
172
+ _context.next = 11;
151
173
  return props.beforePaste(e);
152
- case 5:
174
+ case 11:
153
175
  files = _context.sent;
154
- _context.next = 9;
176
+ _context.next = 18;
177
+ break;
178
+ case 14:
179
+ _context.prev = 14;
180
+ _context.t0 = _context["catch"](8);
181
+ _hooks.util.devUseWarning.error("beforePaste callback error: ".concat(_context.t0));
182
+ return _context.abrupt("return");
183
+ case 18:
184
+ _context.next = 21;
155
185
  break;
156
- case 8:
186
+ case 20:
157
187
  files = (_e$clipboardData = e.clipboardData) === null || _e$clipboardData === void 0 ? void 0 : _e$clipboardData.files;
158
- case 9:
188
+ case 21:
159
189
  if (!(!files || files.length === 0)) {
160
- _context.next = 11;
190
+ _context.next = 23;
161
191
  break;
162
192
  }
163
193
  return _context.abrupt("return");
164
- case 11:
194
+ case 23:
165
195
  filtered = accept ? Array.from(files).filter(function (f) {
166
196
  return _hooks.util.attrAccept(f, accept);
167
197
  }) : Array.from(files);
168
198
  if (!(filtered.length === 0)) {
169
- _context.next = 14;
199
+ _context.next = 26;
170
200
  break;
171
201
  }
172
202
  return _context.abrupt("return");
173
- case 14:
203
+ case 26:
174
204
  toAdd = props.multiple || limit > 1 ? filtered : [filtered[0]];
175
205
  func.addFiles(toAdd);
176
- case 16:
206
+ case 28:
177
207
  case "end":
178
208
  return _context.stop();
179
209
  }
180
- }, _callee);
210
+ }, _callee, null, [[8, 14]]);
181
211
  }));
182
212
  return function handlePaste(_x) {
183
213
  return _ref2.apply(this, arguments);
@@ -187,7 +217,7 @@ var Upload = function Upload(props0) {
187
217
  return function () {
188
218
  return document.removeEventListener('paste', handlePaste);
189
219
  };
190
- }, [paste, props.disabled]);
220
+ }, [paste, props.disabled, accept, props.multiple, limit, props.beforePaste]);
191
221
  var handleReplace = function handleReplace(files, index) {
192
222
  onChange((0, _immer.produce)(value, function (draft) {
193
223
  // 删除原来的位置的数据
@@ -339,7 +339,7 @@ var Cascader = function Cascader(props0) {
339
339
  _path = _path || [];
340
340
  handlePathChange(lastValue, null, _path);
341
341
  } catch (e) {
342
- console.error(e);
342
+ util.devUseWarning.error("".concat(e));
343
343
  }
344
344
  };
345
345
  var handleKeyDown = function handleKeyDown(e) {
@@ -7,6 +7,7 @@ var Arrow = /*#__PURE__*/_jsx("svg", {
7
7
  viewBox: "0 0 40 100",
8
8
  xmlns: "http://www.w3.org/2000/svg",
9
9
  preserveAspectRatio: "none",
10
+ "aria-hidden": "true",
10
11
  children: /*#__PURE__*/_jsx("path", {
11
12
  d: "M 0 0 L 40 50 L 0 100",
12
13
  fill: "currentColor"
@@ -1 +1 @@
1
- {"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["upload.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAgC,MAAM,eAAe,CAAC;AAY1E,QAAA,MAAM,MAAM,wEAwTX,CAAC;AAEF,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["upload.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAgC,MAAM,eAAe,CAAC;AAY1E,QAAA,MAAM,MAAM,wEAqVX,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -112,7 +112,7 @@ var Upload = function Upload(props0) {
112
112
  if (!getComponentRef) return;
113
113
  var ref = {
114
114
  addFiles: function addFiles(files) {
115
- return func.addFiles(files);
115
+ func.addFiles(files);
116
116
  }
117
117
  };
118
118
  if (util.isFunc(getComponentRef)) {
@@ -120,14 +120,22 @@ var Upload = function Upload(props0) {
120
120
  } else {
121
121
  getComponentRef.current = ref;
122
122
  }
123
- }, []);
123
+ return function () {
124
+ if (util.isFunc(getComponentRef)) {
125
+ getComponentRef(null);
126
+ } else {
127
+ getComponentRef.current = null;
128
+ }
129
+ };
130
+ }, [props.getComponentRef]);
124
131
 
125
132
  // paste 处理:document 级别监听,因为 Upload 没有可聚焦的空白区域
133
+ // 仅当粘贴事件来自非可编辑区域时才触发,避免干扰 input/textarea 等正常粘贴行为
126
134
  useEffect(function () {
127
135
  if (!paste) return;
128
136
  var handlePaste = /*#__PURE__*/function () {
129
137
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(e) {
130
- var files, _e$clipboardData, filtered, toAdd;
138
+ var target, tagName, files, _e$clipboardData, filtered, toAdd;
131
139
  return _regeneratorRuntime().wrap(function _callee$(_context) {
132
140
  while (1) switch (_context.prev = _context.next) {
133
141
  case 0:
@@ -137,41 +145,63 @@ var Upload = function Upload(props0) {
137
145
  }
138
146
  return _context.abrupt("return");
139
147
  case 2:
148
+ // 过滤掉来自可编辑元素的粘贴事件,避免与 input/textarea/contentEditable 冲突
149
+ target = e.target;
150
+ if (!target) {
151
+ _context.next = 7;
152
+ break;
153
+ }
154
+ tagName = target.tagName;
155
+ if (!(tagName === 'INPUT' || tagName === 'TEXTAREA' || target.isContentEditable)) {
156
+ _context.next = 7;
157
+ break;
158
+ }
159
+ return _context.abrupt("return");
160
+ case 7:
140
161
  if (!(props.beforePaste && util.isFunc(props.beforePaste))) {
141
- _context.next = 8;
162
+ _context.next = 20;
142
163
  break;
143
164
  }
144
- _context.next = 5;
165
+ _context.prev = 8;
166
+ _context.next = 11;
145
167
  return props.beforePaste(e);
146
- case 5:
168
+ case 11:
147
169
  files = _context.sent;
148
- _context.next = 9;
170
+ _context.next = 18;
171
+ break;
172
+ case 14:
173
+ _context.prev = 14;
174
+ _context.t0 = _context["catch"](8);
175
+ util.devUseWarning.error("beforePaste callback error: ".concat(_context.t0));
176
+ return _context.abrupt("return");
177
+ case 18:
178
+ _context.next = 21;
149
179
  break;
150
- case 8:
180
+ case 20:
151
181
  files = (_e$clipboardData = e.clipboardData) === null || _e$clipboardData === void 0 ? void 0 : _e$clipboardData.files;
152
- case 9:
182
+ case 21:
153
183
  if (!(!files || files.length === 0)) {
154
- _context.next = 11;
184
+ _context.next = 23;
155
185
  break;
156
186
  }
157
187
  return _context.abrupt("return");
158
- case 11:
188
+ case 23:
159
189
  filtered = accept ? Array.from(files).filter(function (f) {
160
190
  return util.attrAccept(f, accept);
161
191
  }) : Array.from(files);
162
192
  if (!(filtered.length === 0)) {
163
- _context.next = 14;
193
+ _context.next = 26;
164
194
  break;
165
195
  }
166
196
  return _context.abrupt("return");
167
- case 14:
197
+ case 26:
168
198
  toAdd = props.multiple || limit > 1 ? filtered : [filtered[0]];
169
199
  func.addFiles(toAdd);
170
- case 16:
200
+ case 28:
171
201
  case "end":
172
202
  return _context.stop();
173
203
  }
174
- }, _callee);
204
+ }, _callee, null, [[8, 14]]);
175
205
  }));
176
206
  return function handlePaste(_x) {
177
207
  return _ref2.apply(this, arguments);
@@ -181,7 +211,7 @@ var Upload = function Upload(props0) {
181
211
  return function () {
182
212
  return document.removeEventListener('paste', handlePaste);
183
213
  };
184
- }, [paste, props.disabled]);
214
+ }, [paste, props.disabled, accept, props.multiple, limit, props.beforePaste]);
185
215
  var handleReplace = function handleReplace(files, index) {
186
216
  onChange(produce(value, function (draft) {
187
217
  // 删除原来的位置的数据
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sheinx/base",
3
- "version": "3.10.0-beta.21",
3
+ "version": "3.10.0-beta.22",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "MIT",
@@ -10,7 +10,7 @@
10
10
  "module": "./esm/index.js",
11
11
  "typings": "./cjs/index.d.ts",
12
12
  "dependencies": {
13
- "@sheinx/hooks": "3.10.0-beta.21",
13
+ "@sheinx/hooks": "3.10.0-beta.22",
14
14
  "immer": "^10.0.0",
15
15
  "classnames": "^2.0.0",
16
16
  "@shined/reactive": "^0.3.3"