shineout 3.10.0-beta.20 → 3.10.0-beta.21

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.
package/cjs/index.js CHANGED
@@ -545,5 +545,5 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
545
545
  // 此文件由脚本自动生成,请勿直接修改。
546
546
  // This file was generated automatically by a script. Please do not modify it directly.
547
547
  var _default = exports.default = {
548
- version: '3.10.0-beta.20'
548
+ version: '3.10.0-beta.21'
549
549
  };
@@ -1,4 +1,4 @@
1
- export type { UploadProps as Props, Validator } from './upload.type';
1
+ export type { UploadProps as Props, Validator, UploadRef as Ref } from './upload.type';
2
2
  export type { UploadImageProps as ImageProps } from './image.type';
3
3
  export type { UploadDraggerProps as DraggerProps } from './dragger.type';
4
4
  export type { UploadOptions as Options } from '@sheinx/hooks';
@@ -1,6 +1,7 @@
1
- import { UploadProps as UnStyledUploadProps } from '@sheinx/base';
1
+ import { UploadProps as UnStyledUploadProps, UploadRef } from '@sheinx/base';
2
2
  import { GetWithFieldProps } from '../hooks/use-field-common';
3
3
  import type { UploadOptions as _UploadOptions } from '@sheinx/hooks';
4
+ export type { UploadRef };
4
5
  export type BaseUploadProps<T> = Omit<UnStyledUploadProps<T>, 'jssStyle'>;
5
6
  /**
6
7
  * @title Upload
package/dist/shineout.js CHANGED
@@ -13686,7 +13686,7 @@ var handleStyle = function handleStyle(style) {
13686
13686
  };
13687
13687
  /* harmony default export */ var jss_style_handleStyle = (handleStyle);
13688
13688
  ;// CONCATENATED MODULE: ../shineout-style/src/version.ts
13689
- /* harmony default export */ var version = ('3.10.0-beta.20');
13689
+ /* harmony default export */ var version = ('3.10.0-beta.21');
13690
13690
  ;// CONCATENATED MODULE: ../shineout-style/src/jss-style/index.tsx
13691
13691
 
13692
13692
 
@@ -75962,6 +75962,8 @@ function castImmutable(value) {
75962
75962
 
75963
75963
 
75964
75964
 
75965
+
75966
+
75965
75967
  var Upload = function Upload(props0) {
75966
75968
  var _props$jssStyle, _props$jssStyle$uploa, _props$imageStyle, _props$imageStyle2;
75967
75969
  var props = use_with_form_config(props0);
@@ -75971,6 +75973,8 @@ var Upload = function Upload(props0) {
75971
75973
  showUploadList = _props$showUploadList === void 0 ? true : _props$showUploadList,
75972
75974
  _props$drop = props.drop,
75973
75975
  drop = _props$drop === void 0 ? false : _props$drop,
75976
+ _props$paste = props.paste,
75977
+ paste = _props$paste === void 0 ? false : _props$paste,
75974
75978
  _props$limit = props.limit,
75975
75979
  limit = _props$limit === void 0 ? 100 : _props$limit,
75976
75980
  _props$renderResult = props.renderResult,
@@ -76036,6 +76040,83 @@ var Upload = function Upload(props0) {
76036
76040
  validateHook(uploadValidate);
76037
76041
  }
76038
76042
  }, []);
76043
+
76044
+ // 暴露 getComponentRef
76045
+ (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
76046
+ var getComponentRef = props.getComponentRef;
76047
+ if (!getComponentRef) return;
76048
+ var ref = {
76049
+ addFiles: function addFiles(files) {
76050
+ return func.addFiles(files);
76051
+ }
76052
+ };
76053
+ if (isFunc(getComponentRef)) {
76054
+ getComponentRef(ref);
76055
+ } else {
76056
+ getComponentRef.current = ref;
76057
+ }
76058
+ }, []);
76059
+
76060
+ // paste 处理:document 级别监听,因为 Upload 没有可聚焦的空白区域
76061
+ (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
76062
+ if (!paste) return;
76063
+ var handlePaste = /*#__PURE__*/function () {
76064
+ var _ref2 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee(e) {
76065
+ var files, _e$clipboardData, filtered, toAdd;
76066
+ return regeneratorRuntime_default()().wrap(function _callee$(_context) {
76067
+ while (1) switch (_context.prev = _context.next) {
76068
+ case 0:
76069
+ if (!props.disabled) {
76070
+ _context.next = 2;
76071
+ break;
76072
+ }
76073
+ return _context.abrupt("return");
76074
+ case 2:
76075
+ if (!(props.beforePaste && isFunc(props.beforePaste))) {
76076
+ _context.next = 8;
76077
+ break;
76078
+ }
76079
+ _context.next = 5;
76080
+ return props.beforePaste(e);
76081
+ case 5:
76082
+ files = _context.sent;
76083
+ _context.next = 9;
76084
+ break;
76085
+ case 8:
76086
+ files = (_e$clipboardData = e.clipboardData) === null || _e$clipboardData === void 0 ? void 0 : _e$clipboardData.files;
76087
+ case 9:
76088
+ if (!(!files || files.length === 0)) {
76089
+ _context.next = 11;
76090
+ break;
76091
+ }
76092
+ return _context.abrupt("return");
76093
+ case 11:
76094
+ filtered = accept ? Array.from(files).filter(function (f) {
76095
+ return attrAccept(f, accept);
76096
+ }) : Array.from(files);
76097
+ if (!(filtered.length === 0)) {
76098
+ _context.next = 14;
76099
+ break;
76100
+ }
76101
+ return _context.abrupt("return");
76102
+ case 14:
76103
+ toAdd = props.multiple || limit > 1 ? filtered : [filtered[0]];
76104
+ func.addFiles(toAdd);
76105
+ case 16:
76106
+ case "end":
76107
+ return _context.stop();
76108
+ }
76109
+ }, _callee);
76110
+ }));
76111
+ return function handlePaste(_x) {
76112
+ return _ref2.apply(this, arguments);
76113
+ };
76114
+ }();
76115
+ document.addEventListener('paste', handlePaste);
76116
+ return function () {
76117
+ return document.removeEventListener('paste', handlePaste);
76118
+ };
76119
+ }, [paste, props.disabled]);
76039
76120
  var handleReplace = function handleReplace(files, index) {
76040
76121
  onChange(dist_immer_produce(value, function (draft) {
76041
76122
  // 删除原来的位置的数据
@@ -79546,7 +79627,7 @@ var watermark_interface = __webpack_require__(6640);
79546
79627
 
79547
79628
 
79548
79629
  /* harmony default export */ var src_0 = ({
79549
- version: '3.10.0-beta.20'
79630
+ version: '3.10.0-beta.21'
79550
79631
  });
79551
79632
  }();
79552
79633
  /******/ return __webpack_exports__;