shineout 3.9.18 → 3.10.0-beta.2

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/dist/shineout.js CHANGED
@@ -373,6 +373,13 @@ return /******/ (function() { // webpackBootstrap
373
373
 
374
374
 
375
375
 
376
+ /***/ }),
377
+
378
+ /***/ 6640:
379
+ /***/ (function() {
380
+
381
+
382
+
376
383
  /***/ }),
377
384
 
378
385
  /***/ 4689:
@@ -6401,6 +6408,7 @@ __webpack_require__.d(__webpack_exports__, {
6401
6408
  Tree: function() { return /* reexport */ src_tree_0; },
6402
6409
  TreeSelect: function() { return /* reexport */ src_tree_select_0; },
6403
6410
  Upload: function() { return /* reexport */ src_upload_0; },
6411
+ Watermark: function() { return /* reexport */ src_watermark_0; },
6404
6412
  color: function() { return /* reexport */ color; },
6405
6413
  config: function() { return /* reexport */ src_config_config; },
6406
6414
  "default": function() { return /* binding */ src_0; },
@@ -6678,7 +6686,8 @@ __webpack_require__.d(src_type_namespaceObject, {
6678
6686
  Transfer: function() { return transfer_interface; },
6679
6687
  Tree: function() { return tree_interface; },
6680
6688
  TreeSelect: function() { return tree_select_interface; },
6681
- Upload: function() { return upload_interface; }
6689
+ Upload: function() { return upload_interface; },
6690
+ Watermark: function() { return watermark_interface; }
6682
6691
  });
6683
6692
 
6684
6693
  // EXTERNAL MODULE: ../../node_modules/.pnpm/@babel+runtime@7.23.6/node_modules/@babel/runtime/helpers/objectSpread2.js
@@ -12327,7 +12336,7 @@ var handleStyle = function handleStyle(style) {
12327
12336
  };
12328
12337
  /* harmony default export */ var jss_style_handleStyle = (handleStyle);
12329
12338
  ;// CONCATENATED MODULE: ../shineout-style/src/version.ts
12330
- /* harmony default export */ var version = ('3.9.18');
12339
+ /* harmony default export */ var version = ('3.10.0-beta.2');
12331
12340
  ;// CONCATENATED MODULE: ../shineout-style/src/jss-style/index.tsx
12332
12341
 
12333
12342
 
@@ -30465,6 +30474,21 @@ var uploadStyle = {
30465
30474
  var useUploadStyle = styled(upload_upload, 'upload');
30466
30475
 
30467
30476
  /* harmony default export */ var shineout_style_src_upload = ((/* unused pure expression or super */ null && (useUploadStyle)));
30477
+ ;// CONCATENATED MODULE: ../shineout-style/src/watermark/watermark.ts
30478
+ var watermarkStyle = {
30479
+ rootClass: {},
30480
+ wrapper: {
30481
+ position: 'relative',
30482
+ overflow: 'hidden'
30483
+ }
30484
+ };
30485
+ /* harmony default export */ var watermark = (watermarkStyle);
30486
+ ;// CONCATENATED MODULE: ../shineout-style/src/watermark/index.ts
30487
+
30488
+
30489
+ var useWatermarkStyle = styled(watermark, 'watermark');
30490
+
30491
+ /* harmony default export */ var src_watermark = ((/* unused pure expression or super */ null && (useWatermarkStyle)));
30468
30492
  ;// CONCATENATED MODULE: ../shineout-style/src/index.ts
30469
30493
 
30470
30494
 
@@ -30520,6 +30544,7 @@ var useUploadStyle = styled(upload_upload, 'upload');
30520
30544
 
30521
30545
 
30522
30546
 
30547
+
30523
30548
 
30524
30549
 
30525
30550
  /* harmony default export */ var shineout_style_src = ({});
@@ -51253,6 +51278,28 @@ var method = function method(type, jssStyle) {
51253
51278
  type: method,
51254
51279
  closeAll: closeAll
51255
51280
  });
51281
+ ;// CONCATENATED MODULE: ../base/src/watermark/context.ts
51282
+ 'use client';
51283
+
51284
+
51285
+ var context_noop = function noop() {};
51286
+ var DisabledWatermarkContext = {
51287
+ add: context_noop,
51288
+ remove: context_noop
51289
+ };
51290
+ var WatermarkContext = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.createContext)(DisabledWatermarkContext);
51291
+ function useWatermarkTarget(getElement) {
51292
+ var context = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useContext)(WatermarkContext);
51293
+ (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
51294
+ var element = getElement();
51295
+ if (!element) return undefined;
51296
+ context.add(element);
51297
+ return function () {
51298
+ return context.remove(element);
51299
+ };
51300
+ }, [context, getElement]);
51301
+ }
51302
+ /* harmony default export */ var watermark_context = (WatermarkContext);
51256
51303
  ;// CONCATENATED MODULE: ../base/src/modal/modal.tsx
51257
51304
 
51258
51305
 
@@ -51263,7 +51310,18 @@ var method = function method(type, jssStyle) {
51263
51310
 
51264
51311
 
51265
51312
 
51313
+
51314
+
51315
+
51266
51316
  var modal_devUseWarning = devUseWarning;
51317
+ var WatermarkPortalTarget = function WatermarkPortalTarget(_ref) {
51318
+ var root = _ref.root;
51319
+ var getTarget = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useCallback)(function () {
51320
+ return root.firstElementChild;
51321
+ }, [root]);
51322
+ useWatermarkTarget(getTarget);
51323
+ return null;
51324
+ };
51267
51325
  var modal_Modal = function Modal(props) {
51268
51326
  var _props$jssStyle, _props$jssStyle$modal;
51269
51327
  // inject jssStyle
@@ -51315,7 +51373,11 @@ var modal_Modal = function Modal(props) {
51315
51373
  }));
51316
51374
  var root = getRoot();
51317
51375
  if (!root) return null;
51318
- return /*#__PURE__*/external_root_ReactDOM_commonjs2_react_dom_commonjs_react_dom_amd_react_dom_default().createPortal(Content, root);
51376
+ return /*#__PURE__*/external_root_ReactDOM_commonjs2_react_dom_commonjs_react_dom_amd_react_dom_default().createPortal( /*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment, {
51377
+ children: [Content, /*#__PURE__*/(0,jsx_runtime.jsx)(WatermarkPortalTarget, {
51378
+ root: root
51379
+ })]
51380
+ }), root);
51319
51381
  };
51320
51382
  /* harmony default export */ var src_modal_modal = (modal_Modal);
51321
51383
  ;// CONCATENATED MODULE: ./src/modal/modal.tsx
@@ -55704,7 +55766,7 @@ var image_PLACEHOLDER = 0;
55704
55766
  var image_SRC = 1;
55705
55767
  var image_ALT = 2;
55706
55768
  var image_ERROR = 3;
55707
- var Image = function Image(props) {
55769
+ var image_Image = function Image(props) {
55708
55770
  var _jssStyle$image;
55709
55771
  var fit = props.fit,
55710
55772
  alt = props.alt,
@@ -55910,8 +55972,8 @@ var Image = function Image(props) {
55910
55972
  }))
55911
55973
  );
55912
55974
  };
55913
- Image.Group = image_group;
55914
- /* harmony default export */ var base_src_image_image = (Image);
55975
+ image_Image.Group = image_group;
55976
+ /* harmony default export */ var base_src_image_image = (image_Image);
55915
55977
  ;// CONCATENATED MODULE: ./src/image/image.tsx
55916
55978
 
55917
55979
 
@@ -55922,12 +55984,12 @@ var image_jssStyle = {
55922
55984
  image: useImageStyle,
55923
55985
  spin: useSpinStyle
55924
55986
  };
55925
- var image_Image = function Image(props) {
55987
+ var image_image_Image = function Image(props) {
55926
55988
  return /*#__PURE__*/(0,jsx_runtime.jsx)(base_src_image_image, objectSpread2_default()(objectSpread2_default()({}, props), {}, {
55927
55989
  jssStyle: image_jssStyle
55928
55990
  }));
55929
55991
  };
55930
- /* harmony default export */ var src_image_image_0 = (image_Image);
55992
+ /* harmony default export */ var src_image_image_0 = (image_image_Image);
55931
55993
  ;// CONCATENATED MODULE: ./src/image/group.tsx
55932
55994
 
55933
55995
 
@@ -59752,8 +59814,9 @@ function Select(props0) {
59752
59814
  var isEmpty = !(filterData !== null && filterData !== void 0 && filterData.length);
59753
59815
  var options = 'treeData' in props ? renderTreeList() : renderList();
59754
59816
  if (renderOptionList) {
59755
- return renderOptionList(isEmpty ? renderEmpty() : options, {
59756
- loading: loading
59817
+ return renderOptionList(isEmpty ? null : options, {
59818
+ loading: loading,
59819
+ empty: isEmpty
59757
59820
  });
59758
59821
  }
59759
59822
  if (isEmpty) return renderEmpty();
@@ -72110,7 +72173,9 @@ var TreeSelect = function TreeSelect(props0) {
72110
72173
  }))
72111
72174
  });
72112
72175
  if (renderOptionList) {
72113
- return renderOptionList(isEmpty ? renderEmpty() : tree);
72176
+ return renderOptionList(isEmpty ? null : tree, {
72177
+ empty: isEmpty
72178
+ });
72114
72179
  }
72115
72180
  if (isEmpty) return renderEmpty();
72116
72181
  return tree;
@@ -74807,6 +74872,699 @@ UploadComp.Image = UploadImageComp;
74807
74872
  UploadComp.Button = UploadButtonComp;
74808
74873
  UploadComp.Dragger = UploadDraggerComp;
74809
74874
  /* harmony default export */ var src_upload_0 = (UploadComp);
74875
+ ;// CONCATENATED MODULE: ../base/src/watermark/utils.ts
74876
+
74877
+
74878
+
74879
+
74880
+
74881
+ var FontGap = 3;
74882
+ var DefaultImageWidth = 120;
74883
+ var DefaultImageHeight = 64;
74884
+ function getCanvasFont(font) {
74885
+ var ratio = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
74886
+ var fontStyle = font.fontStyle === 'none' ? 'normal' : font.fontStyle;
74887
+ return "".concat(fontStyle, " normal ").concat(font.fontWeight, " ").concat(font.fontSize * ratio, "px ").concat(font.fontFamily);
74888
+ }
74889
+ function measureLine(context, line) {
74890
+ var ratio = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
74891
+ context.font = getCanvasFont(line.font, ratio);
74892
+ var textMetrics = context.measureText(line.text);
74893
+ var measuredHeight = textMetrics.fontBoundingBoxAscent + textMetrics.fontBoundingBoxDescent;
74894
+ var fallbackHeight = line.font.fontSize * ratio;
74895
+ return {
74896
+ width: Number.isFinite(textMetrics.width) && textMetrics.width > 0 ? textMetrics.width : 0,
74897
+ height: Number.isFinite(measuredHeight) && measuredHeight > 0 ? measuredHeight : Number.isFinite(fallbackHeight) && fallbackHeight > 0 ? fallbackHeight : 0
74898
+ };
74899
+ }
74900
+ function mergeFont(font, customFont) {
74901
+ if (!customFont) return font;
74902
+ return Object.entries(customFont).reduce(function (merged, _ref) {
74903
+ var _ref2 = slicedToArray_default()(_ref, 2),
74904
+ key = _ref2[0],
74905
+ value = _ref2[1];
74906
+ return value === undefined ? merged : objectSpread2_default()(objectSpread2_default()({}, merged), {}, defineProperty_default()({}, key, value));
74907
+ }, objectSpread2_default()({}, font));
74908
+ }
74909
+ function getContentLines(content, font) {
74910
+ if (content === undefined || content === null) return [];
74911
+ var lines = Array.isArray(content) ? content : [content];
74912
+ return lines.map(function (line) {
74913
+ if (typeof line === 'string') return {
74914
+ text: line,
74915
+ font: font
74916
+ };
74917
+ if (!line || typeof_default()(line) !== 'object') return {
74918
+ text: '',
74919
+ font: font
74920
+ };
74921
+ return {
74922
+ text: typeof line.text === 'string' ? line.text : '',
74923
+ font: mergeFont(font, line.font)
74924
+ };
74925
+ });
74926
+ }
74927
+ function getMarkSize(context, content, image, width, height) {
74928
+ if (image) {
74929
+ return [width !== null && width !== void 0 ? width : DefaultImageWidth, height !== null && height !== void 0 ? height : DefaultImageHeight];
74930
+ }
74931
+ var metrics = content.map(function (line) {
74932
+ return measureLine(context, line);
74933
+ });
74934
+ var measuredWidth = metrics.reduce(function (max, metric) {
74935
+ return Math.max(max, metric.width);
74936
+ }, 0);
74937
+ var measuredHeight = metrics.reduce(function (total, metric, index) {
74938
+ return total + metric.height + (index === 0 ? 0 : FontGap);
74939
+ }, 0);
74940
+ return [width !== null && width !== void 0 ? width : measuredWidth, height !== null && height !== void 0 ? height : measuredHeight];
74941
+ }
74942
+ var GeometryEpsilon = 1e-10;
74943
+ function prepareCanvas(width, height) {
74944
+ var ratio = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
74945
+ var realWidth = Math.ceil(width * ratio);
74946
+ var realHeight = Math.ceil(height * ratio);
74947
+ if (!Number.isFinite(realWidth) || !Number.isFinite(realHeight) || realWidth <= 0 || realHeight <= 0) {
74948
+ return null;
74949
+ }
74950
+ var canvas = document.createElement('canvas');
74951
+ canvas.width = realWidth;
74952
+ canvas.height = realHeight;
74953
+ var context = canvas.getContext('2d');
74954
+ context === null || context === void 0 || context.save();
74955
+ return {
74956
+ canvas: canvas,
74957
+ context: context,
74958
+ realWidth: realWidth,
74959
+ realHeight: realHeight
74960
+ };
74961
+ }
74962
+ function snapToInteger(value) {
74963
+ var integer = Math.round(value);
74964
+ return Math.abs(value - integer) < GeometryEpsilon ? integer : value;
74965
+ }
74966
+ function getRotatePosition(x, y, angle) {
74967
+ return [snapToInteger(x * Math.cos(angle) - y * Math.sin(angle)), snapToInteger(x * Math.sin(angle) + y * Math.cos(angle))];
74968
+ }
74969
+ function getRotatedSize(width, height, angle) {
74970
+ var halfWidth = width / 2;
74971
+ var halfHeight = height / 2;
74972
+ var points = [getRotatePosition(-halfWidth, -halfHeight, angle), getRotatePosition(halfWidth, -halfHeight, angle), getRotatePosition(halfWidth, halfHeight, angle), getRotatePosition(-halfWidth, halfHeight, angle)];
74973
+ var xCoordinates = points.map(function (_ref3) {
74974
+ var _ref4 = slicedToArray_default()(_ref3, 1),
74975
+ x = _ref4[0];
74976
+ return x;
74977
+ });
74978
+ var yCoordinates = points.map(function (_ref5) {
74979
+ var _ref6 = slicedToArray_default()(_ref5, 2),
74980
+ y = _ref6[1];
74981
+ return y;
74982
+ });
74983
+ return [snapToInteger(Math.max.apply(Math, toConsumableArray_default()(xCoordinates)) - Math.min.apply(Math, toConsumableArray_default()(xCoordinates))), snapToInteger(Math.max.apply(Math, toConsumableArray_default()(yCoordinates)) - Math.min.apply(Math, toConsumableArray_default()(yCoordinates)))];
74984
+ }
74985
+ function drawWatermark(content, rotate, ratio, width, height, gapX, gapY) {
74986
+ if (![rotate, ratio, width, height, gapX, gapY].every(Number.isFinite)) return null;
74987
+ if (ratio <= 0 || width <= 0 || height <= 0) return null;
74988
+ var contentCanvas = prepareCanvas(width, height, ratio);
74989
+ if (!(contentCanvas !== null && contentCanvas !== void 0 && contentCanvas.context)) return null;
74990
+ var canvas = contentCanvas.canvas,
74991
+ context = contentCanvas.context,
74992
+ realWidth = contentCanvas.realWidth,
74993
+ realHeight = contentCanvas.realHeight;
74994
+ if (Array.isArray(content)) {
74995
+ context.textBaseline = 'top';
74996
+ var top = 0;
74997
+ content.forEach(function (line) {
74998
+ var lineSize = measureLine(context, line, ratio);
74999
+ context.fillStyle = line.font.color;
75000
+ context.textAlign = line.font.textAlign;
75001
+ var textLeft = realWidth / 2;
75002
+ if (line.font.textAlign === 'left' || line.font.textAlign === 'start') textLeft = 0;
75003
+ if (line.font.textAlign === 'right' || line.font.textAlign === 'end') {
75004
+ textLeft = realWidth;
75005
+ }
75006
+ context.fillText(line.text, textLeft, top);
75007
+ top += lineSize.height + FontGap * ratio;
75008
+ });
75009
+ } else {
75010
+ context.drawImage(content, 0, 0, realWidth, realHeight);
75011
+ }
75012
+ var angle = Math.PI * rotate / 180;
75013
+ var _getRotatedSize = getRotatedSize(realWidth, realHeight, angle),
75014
+ _getRotatedSize2 = slicedToArray_default()(_getRotatedSize, 2),
75015
+ rotatedWidth = _getRotatedSize2[0],
75016
+ rotatedHeight = _getRotatedSize2[1];
75017
+ var rotatedCanvas = prepareCanvas(rotatedWidth, rotatedHeight);
75018
+ if (!(rotatedCanvas !== null && rotatedCanvas !== void 0 && rotatedCanvas.context)) return null;
75019
+ var markCanvas = rotatedCanvas.canvas,
75020
+ markContext = rotatedCanvas.context,
75021
+ markWidth = rotatedCanvas.realWidth,
75022
+ markHeight = rotatedCanvas.realHeight;
75023
+ markContext.translate(markWidth / 2, markHeight / 2);
75024
+ markContext.rotate(angle);
75025
+ markContext.drawImage(canvas, 0, 0, realWidth, realHeight, -realWidth / 2, -realHeight / 2, realWidth, realHeight);
75026
+ var realGapX = gapX * ratio;
75027
+ var realGapY = gapY * ratio;
75028
+ var tileWidth = (markWidth + realGapX) * 2;
75029
+ var tileHeight = markHeight + realGapY;
75030
+ if (!Number.isFinite(tileWidth) || !Number.isFinite(tileHeight) || tileWidth <= 0 || tileHeight <= 0) {
75031
+ return null;
75032
+ }
75033
+ var tileCanvas = prepareCanvas(tileWidth, tileHeight);
75034
+ if (!(tileCanvas !== null && tileCanvas !== void 0 && tileCanvas.context)) return null;
75035
+ var drawMark = function drawMark(targetX, targetY) {
75036
+ tileCanvas.context.drawImage(markCanvas, 0, 0, markWidth, markHeight, targetX, targetY, markWidth, markHeight);
75037
+ };
75038
+ var markLeft = (tileCanvas.realWidth / 2 - markWidth) / 2;
75039
+ var markTop = (tileCanvas.realHeight - markHeight) / 2;
75040
+ var secondColumnLeft = markLeft + tileCanvas.realWidth / 2;
75041
+ drawMark(markLeft, markTop);
75042
+ drawMark(secondColumnLeft, markTop - tileCanvas.realHeight / 2);
75043
+ drawMark(secondColumnLeft, markTop + tileCanvas.realHeight / 2);
75044
+ return {
75045
+ dataURL: tileCanvas.canvas.toDataURL(),
75046
+ width: tileCanvas.realWidth / ratio,
75047
+ height: tileCanvas.realHeight / ratio
75048
+ };
75049
+ }
75050
+ function getStyleString(style) {
75051
+ return Object.entries(style).map(function (_ref7) {
75052
+ var _ref8 = slicedToArray_default()(_ref7, 2),
75053
+ key = _ref8[0],
75054
+ value = _ref8[1];
75055
+ var property = key.replace(/[A-Z]/g, function (character) {
75056
+ return "-".concat(character.toLowerCase());
75057
+ });
75058
+ if (property.startsWith('ms-')) property = "-".concat(property);
75059
+ return "".concat(property, ": ").concat(value, ";");
75060
+ }).join(' ');
75061
+ }
75062
+ ;// CONCATENATED MODULE: ../base/src/watermark/watermark.tsx
75063
+ 'use client';
75064
+
75065
+
75066
+
75067
+
75068
+
75069
+
75070
+
75071
+
75072
+ var DefaultFont = {
75073
+ color: 'rgba(0, 0, 0, 0.15)',
75074
+ fontSize: 16,
75075
+ fontWeight: 'normal',
75076
+ fontStyle: 'normal',
75077
+ fontFamily: 'sans-serif',
75078
+ textAlign: 'center'
75079
+ };
75080
+ var DefaultGap = [100, 100];
75081
+ var DefaultRotate = -22;
75082
+ var DefaultZIndex = 999;
75083
+ var ObserverOptions = {
75084
+ attributes: true,
75085
+ childList: true,
75086
+ subtree: true,
75087
+ attributeFilter: ['style', 'class', 'hidden', 'aria-hidden']
75088
+ };
75089
+ function normalizeDpr() {
75090
+ var ratio = window.devicePixelRatio;
75091
+ return Number.isFinite(ratio) && ratio > 0 ? ratio : 1;
75092
+ }
75093
+ function createDrawingSignature(props, ratio) {
75094
+ var gap = props.gap || DefaultGap;
75095
+ var font = mergeFont(DefaultFont, props.font);
75096
+ var content = getContentLines(props.content, font);
75097
+ var signature = [props.image, props.rotate, props.width, props.height, gap[0], gap[1], ratio, content.length];
75098
+ content.forEach(function (line) {
75099
+ signature.push(line.text, line.font.color, line.font.fontSize, line.font.fontWeight, line.font.fontStyle, line.font.fontFamily, line.font.textAlign);
75100
+ });
75101
+ return signature;
75102
+ }
75103
+ function createStyleSignature(props) {
75104
+ var gap = props.gap || DefaultGap;
75105
+ var offset = props.offset || [gap[0] / 2, gap[1] / 2];
75106
+ return [gap[0], gap[1], offset[0], offset[1], props.zIndex];
75107
+ }
75108
+ function signaturesEqual(first, second) {
75109
+ if (!first || first.length !== second.length) return false;
75110
+ return first.every(function (value, index) {
75111
+ return value === second[index] || Number.isNaN(value) && Number.isNaN(second[index]);
75112
+ });
75113
+ }
75114
+ function restoreAttribute(element, name, value) {
75115
+ if (value === null) {
75116
+ if (element.hasAttribute(name)) element.removeAttribute(name);
75117
+ return;
75118
+ }
75119
+ if (element.getAttribute(name) !== value) element.setAttribute(name, value);
75120
+ }
75121
+ function createOverlayStyle(props, tile) {
75122
+ var gap = props.gap || DefaultGap;
75123
+ var offset = props.offset || [gap[0] / 2, gap[1] / 2];
75124
+ var horizontalOffset = offset[0] - gap[0] / 2;
75125
+ var verticalOffset = offset[1] - gap[1] / 2;
75126
+ if (![gap[0], gap[1], offset[0], offset[1], horizontalOffset, verticalOffset, tile.width, tile.height].every(Number.isFinite)) {
75127
+ return null;
75128
+ }
75129
+ return {
75130
+ position: 'absolute',
75131
+ left: "".concat(Math.max(horizontalOffset, 0), "px"),
75132
+ top: "".concat(Math.max(verticalOffset, 0), "px"),
75133
+ width: horizontalOffset > 0 ? "calc(100% - ".concat(horizontalOffset, "px)") : '100%',
75134
+ height: verticalOffset > 0 ? "calc(100% - ".concat(verticalOffset, "px)") : '100%',
75135
+ zIndex: props.zIndex,
75136
+ pointerEvents: 'none',
75137
+ backgroundImage: "url(\"".concat(tile.dataURL, "\")"),
75138
+ backgroundRepeat: 'repeat',
75139
+ backgroundSize: "".concat(tile.width, "px ").concat(tile.height, "px"),
75140
+ backgroundPosition: "".concat(Math.min(horizontalOffset, 0), "px ").concat(Math.min(verticalOffset, 0), "px"),
75141
+ visibility: 'visible !important'
75142
+ };
75143
+ }
75144
+ var Watermark = function Watermark(props) {
75145
+ var _props$rotate, _props$jssStyle, _props$inherit;
75146
+ var rootRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
75147
+ var rootAttributeBaselineRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
75148
+ var targetsRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(new Set());
75149
+ var targetRegistrationCountsRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(new Map());
75150
+ var overlaysRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(new Map());
75151
+ var latestTileRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
75152
+ var latestStyleRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
75153
+ var requestedDrawingSignatureRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
75154
+ var renderedDrawingSignatureRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
75155
+ var styleSignatureRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
75156
+ var renderTokenRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(0);
75157
+ var imageTokenRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(0);
75158
+ var pendingFrameRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
75159
+ var pendingImageRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
75160
+ var observerRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
75161
+ var observerPauseDepthRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(0);
75162
+ var repairMutationsRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(function () {
75163
+ return undefined;
75164
+ });
75165
+ var mountedRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(false);
75166
+ var latestProps = useLatestObj({
75167
+ content: props.content,
75168
+ font: props.font,
75169
+ gap: props.gap,
75170
+ height: props.height,
75171
+ image: props.image,
75172
+ offset: props.offset,
75173
+ onRemove: props.onRemove,
75174
+ rotate: (_props$rotate = props.rotate) !== null && _props$rotate !== void 0 ? _props$rotate : DefaultRotate,
75175
+ width: props.width,
75176
+ zIndex: typeof props.zIndex === 'number' && Number.isFinite(props.zIndex) ? props.zIndex : DefaultZIndex
75177
+ });
75178
+ var withObserverPaused = usePersistFn(function (callback) {
75179
+ var ignoreRootAttributeRecords = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
75180
+ var observer = observerRef.current;
75181
+ var ownsPause = Boolean(observer && observerPauseDepthRef.current === 0);
75182
+ var pendingRecords = ownsPause ? (observer === null || observer === void 0 ? void 0 : observer.takeRecords()) || [] : [];
75183
+ if (ownsPause) observer === null || observer === void 0 || observer.disconnect();
75184
+ observerPauseDepthRef.current += 1;
75185
+ try {
75186
+ var root = rootRef.current;
75187
+ var records = ignoreRootAttributeRecords ? pendingRecords.filter(function (record) {
75188
+ return !(record.type === 'attributes' && record.target === root && (record.attributeName === 'class' || record.attributeName === 'style'));
75189
+ }) : pendingRecords;
75190
+ if (records.length) repairMutationsRef.current(records);
75191
+ callback();
75192
+ } finally {
75193
+ observerPauseDepthRef.current -= 1;
75194
+ if (ownsPause && mountedRef.current && observerRef.current === observer) {
75195
+ targetsRef.current.forEach(function (target) {
75196
+ return observer === null || observer === void 0 ? void 0 : observer.observe(target, ObserverOptions);
75197
+ });
75198
+ }
75199
+ }
75200
+ });
75201
+ var clearOverlays = usePersistFn(function () {
75202
+ withObserverPaused(function () {
75203
+ overlaysRef.current.forEach(function (overlay) {
75204
+ return overlay.remove();
75205
+ });
75206
+ });
75207
+ });
75208
+ var releasePendingImage = usePersistFn(function () {
75209
+ var cancelRequest = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
75210
+ var image = pendingImageRef.current;
75211
+ if (!image) return;
75212
+ pendingImageRef.current = null;
75213
+ image.onload = null;
75214
+ image.onerror = null;
75215
+ if (cancelRequest) {
75216
+ try {
75217
+ image.src = '';
75218
+ } catch (_error) {
75219
+ // Ignore a source implementation that rejects cancellation.
75220
+ }
75221
+ }
75222
+ });
75223
+ var writeOverlay = usePersistFn(function (target, style) {
75224
+ var overlay = overlaysRef.current.get(target);
75225
+ if (!overlay) {
75226
+ overlay = document.createElement('div');
75227
+ overlaysRef.current.set(target, overlay);
75228
+ }
75229
+ overlay.removeAttribute('class');
75230
+ overlay.removeAttribute('hidden');
75231
+ overlay.setAttribute('aria-hidden', 'true');
75232
+ overlay.setAttribute('style', getStyleString(style));
75233
+ while (overlay.firstChild) overlay.removeChild(overlay.firstChild);
75234
+ if (overlay.parentElement !== target) target.appendChild(overlay);
75235
+ });
75236
+ var applyLatestStyle = usePersistFn(function () {
75237
+ var tile = latestTileRef.current;
75238
+ if (!tile) return;
75239
+ var style = createOverlayStyle(latestProps, tile);
75240
+ latestStyleRef.current = style;
75241
+ if (!style) {
75242
+ clearOverlays();
75243
+ return;
75244
+ }
75245
+ withObserverPaused(function () {
75246
+ targetsRef.current.forEach(function (target) {
75247
+ return writeOverlay(target, style);
75248
+ });
75249
+ });
75250
+ });
75251
+ var drawLatest = usePersistFn(function () {
75252
+ var ratio = normalizeDpr();
75253
+ var drawingSignature = createDrawingSignature(latestProps, ratio);
75254
+ var gap = latestProps.gap || DefaultGap;
75255
+ var font = mergeFont(DefaultFont, latestProps.font);
75256
+ var content = getContentLines(latestProps.content, font);
75257
+ var isEmptyContent = !latestProps.image && (content.length === 0 || content.every(function (line) {
75258
+ return line.text.length === 0;
75259
+ }));
75260
+ if (signaturesEqual(renderedDrawingSignatureRef.current, drawingSignature) && (latestTileRef.current || isEmptyContent)) {
75261
+ applyLatestStyle();
75262
+ return;
75263
+ }
75264
+ if (isEmptyContent) {
75265
+ latestTileRef.current = null;
75266
+ latestStyleRef.current = null;
75267
+ clearOverlays();
75268
+ renderedDrawingSignatureRef.current = drawingSignature;
75269
+ return;
75270
+ }
75271
+ var imageToken = ++imageTokenRef.current;
75272
+ var isCurrentDrawing = function isCurrentDrawing() {
75273
+ return mountedRef.current && imageToken === imageTokenRef.current;
75274
+ };
75275
+ var clearFailedDrawing = function clearFailedDrawing() {
75276
+ if (!isCurrentDrawing()) return;
75277
+ requestedDrawingSignatureRef.current = null;
75278
+ latestTileRef.current = null;
75279
+ latestStyleRef.current = null;
75280
+ clearOverlays();
75281
+ };
75282
+ try {
75283
+ var measureCanvas = document.createElement('canvas');
75284
+ var context = measureCanvas.getContext('2d');
75285
+ if (!context) {
75286
+ clearFailedDrawing();
75287
+ return;
75288
+ }
75289
+ var image = latestProps.image;
75290
+ var rotate = latestProps.rotate;
75291
+ var _getMarkSize = getMarkSize(context, content, image, latestProps.width, latestProps.height),
75292
+ _getMarkSize2 = slicedToArray_default()(_getMarkSize, 2),
75293
+ width = _getMarkSize2[0],
75294
+ height = _getMarkSize2[1];
75295
+ var drawContent = function drawContent(drawnContent) {
75296
+ if (!isCurrentDrawing()) return false;
75297
+ try {
75298
+ var tile = drawWatermark(drawnContent, rotate, ratio, width, height, gap[0], gap[1]);
75299
+ if (!tile || !isCurrentDrawing()) return false;
75300
+ latestTileRef.current = tile;
75301
+ renderedDrawingSignatureRef.current = drawingSignature;
75302
+ applyLatestStyle();
75303
+ return true;
75304
+ } catch (_error) {
75305
+ return false;
75306
+ }
75307
+ };
75308
+ var drawFallback = function drawFallback() {
75309
+ if (!isCurrentDrawing()) return;
75310
+ var isEmptyFallback = content.length === 0 || content.every(function (line) {
75311
+ return line.text.length === 0;
75312
+ });
75313
+ if (isEmptyFallback || !drawContent(content)) clearFailedDrawing();
75314
+ };
75315
+ if (!image) {
75316
+ if (!drawContent(content)) clearFailedDrawing();
75317
+ return;
75318
+ }
75319
+ if (typeof Image === 'undefined') {
75320
+ drawFallback();
75321
+ return;
75322
+ }
75323
+ try {
75324
+ var imageElement = new Image();
75325
+ pendingImageRef.current = imageElement;
75326
+ var releaseImage = function releaseImage() {
75327
+ imageElement.onload = null;
75328
+ imageElement.onerror = null;
75329
+ if (pendingImageRef.current === imageElement) pendingImageRef.current = null;
75330
+ };
75331
+ imageElement.onload = function () {
75332
+ if (!isCurrentDrawing()) {
75333
+ releaseImage();
75334
+ return;
75335
+ }
75336
+ var drawn = drawContent(imageElement);
75337
+ releaseImage();
75338
+ if (!drawn) drawFallback();
75339
+ };
75340
+ imageElement.onerror = function () {
75341
+ if (!isCurrentDrawing()) {
75342
+ releaseImage();
75343
+ return;
75344
+ }
75345
+ releaseImage();
75346
+ drawFallback();
75347
+ };
75348
+ imageElement.crossOrigin = 'anonymous';
75349
+ imageElement.referrerPolicy = 'no-referrer';
75350
+ imageElement.src = image;
75351
+ } catch (_error) {
75352
+ releasePendingImage();
75353
+ drawFallback();
75354
+ }
75355
+ } catch (_error) {
75356
+ clearFailedDrawing();
75357
+ }
75358
+ });
75359
+ var cancelPendingFrame = usePersistFn(function () {
75360
+ var pendingFrame = pendingFrameRef.current;
75361
+ renderTokenRef.current += 1;
75362
+ pendingFrameRef.current = null;
75363
+ if (!pendingFrame) return;
75364
+ if (pendingFrame.type === 'animation-frame') {
75365
+ if (typeof window.cancelAnimationFrame === 'function') {
75366
+ window.cancelAnimationFrame(pendingFrame.id);
75367
+ }
75368
+ return;
75369
+ }
75370
+ window.clearTimeout(pendingFrame.id);
75371
+ });
75372
+ var scheduleRender = usePersistFn(function () {
75373
+ if (!mountedRef.current || pendingFrameRef.current) return;
75374
+ var token = ++renderTokenRef.current;
75375
+ var run = function run() {
75376
+ pendingFrameRef.current = null;
75377
+ if (!mountedRef.current || token !== renderTokenRef.current) return;
75378
+ drawLatest();
75379
+ };
75380
+ if (typeof window.requestAnimationFrame === 'function') {
75381
+ var _id = window.requestAnimationFrame(run);
75382
+ pendingFrameRef.current = {
75383
+ id: _id,
75384
+ token: token,
75385
+ type: 'animation-frame'
75386
+ };
75387
+ return;
75388
+ }
75389
+ var id = window.setTimeout(run, 16);
75390
+ pendingFrameRef.current = {
75391
+ id: id,
75392
+ token: token,
75393
+ type: 'timeout'
75394
+ };
75395
+ });
75396
+ var addTarget = usePersistFn(function (target) {
75397
+ var registrations = targetRegistrationCountsRef.current;
75398
+ registrations.set(target, (registrations.get(target) || 0) + 1);
75399
+ targetsRef.current.add(target);
75400
+ var tile = latestTileRef.current;
75401
+ var style = latestStyleRef.current;
75402
+ if (tile && style) {
75403
+ withObserverPaused(function () {
75404
+ return writeOverlay(target, style);
75405
+ });
75406
+ } else if (observerRef.current && mountedRef.current) {
75407
+ withObserverPaused(function () {
75408
+ return undefined;
75409
+ });
75410
+ }
75411
+ });
75412
+ var removeTarget = usePersistFn(function (target) {
75413
+ var registrations = targetRegistrationCountsRef.current;
75414
+ var count = registrations.get(target) || 0;
75415
+ if (count > 1) {
75416
+ registrations.set(target, count - 1);
75417
+ return;
75418
+ }
75419
+ registrations.delete(target);
75420
+ if (target === rootRef.current) return;
75421
+ withObserverPaused(function () {
75422
+ targetsRef.current.delete(target);
75423
+ var overlay = overlaysRef.current.get(target);
75424
+ overlay === null || overlay === void 0 || overlay.remove();
75425
+ overlaysRef.current.delete(target);
75426
+ });
75427
+ });
75428
+ var handleMutations = usePersistFn(function (mutations) {
75429
+ var _latestProps$onRemove;
75430
+ var root = rootRef.current;
75431
+ var restoreTargets = new Set();
75432
+ var restoreRoot = false;
75433
+ var removedOverlay = false;
75434
+ mutations.forEach(function (mutation) {
75435
+ if (mutation.type === 'attributes' && mutation.target === root && (mutation.attributeName === 'class' || mutation.attributeName === 'style')) {
75436
+ restoreRoot = true;
75437
+ }
75438
+ overlaysRef.current.forEach(function (overlay, target) {
75439
+ if ((mutation.type === 'attributes' || mutation.type === 'childList') && mutation.target === overlay) {
75440
+ restoreTargets.add(target);
75441
+ }
75442
+ if (mutation.type === 'childList' && Array.from(mutation.removedNodes).includes(overlay)) {
75443
+ restoreTargets.add(target);
75444
+ removedOverlay = true;
75445
+ }
75446
+ });
75447
+ });
75448
+ withObserverPaused(function () {
75449
+ var baseline = rootAttributeBaselineRef.current;
75450
+ if (restoreRoot && root && baseline) {
75451
+ restoreAttribute(root, 'class', baseline.className);
75452
+ restoreAttribute(root, 'style', baseline.style);
75453
+ }
75454
+ var style = latestStyleRef.current;
75455
+ if (style) restoreTargets.forEach(function (target) {
75456
+ return writeOverlay(target, style);
75457
+ });
75458
+ });
75459
+ if (removedOverlay) (_latestProps$onRemove = latestProps.onRemove) === null || _latestProps$onRemove === void 0 || _latestProps$onRemove.call(latestProps);
75460
+ });
75461
+ repairMutationsRef.current = handleMutations;
75462
+ var contextValue = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function () {
75463
+ return {
75464
+ add: addTarget,
75465
+ remove: removeTarget
75466
+ };
75467
+ }, [addTarget, removeTarget]);
75468
+ (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
75469
+ mountedRef.current = true;
75470
+ if (rootRef.current) targetsRef.current.add(rootRef.current);
75471
+ if (typeof MutationObserver !== 'undefined') {
75472
+ try {
75473
+ observerRef.current = new MutationObserver(handleMutations);
75474
+ targetsRef.current.forEach(function (target) {
75475
+ var _observerRef$current;
75476
+ return (_observerRef$current = observerRef.current) === null || _observerRef$current === void 0 ? void 0 : _observerRef$current.observe(target, ObserverOptions);
75477
+ });
75478
+ } catch (_error) {
75479
+ observerRef.current = null;
75480
+ }
75481
+ }
75482
+ return function () {
75483
+ var _observerRef$current2;
75484
+ mountedRef.current = false;
75485
+ imageTokenRef.current += 1;
75486
+ releasePendingImage(true);
75487
+ (_observerRef$current2 = observerRef.current) === null || _observerRef$current2 === void 0 || _observerRef$current2.disconnect();
75488
+ observerRef.current = null;
75489
+ cancelPendingFrame();
75490
+ overlaysRef.current.forEach(function (overlay) {
75491
+ return overlay.remove();
75492
+ });
75493
+ targetsRef.current.clear();
75494
+ targetRegistrationCountsRef.current.clear();
75495
+ overlaysRef.current.clear();
75496
+ latestTileRef.current = null;
75497
+ latestStyleRef.current = null;
75498
+ requestedDrawingSignatureRef.current = null;
75499
+ renderedDrawingSignatureRef.current = null;
75500
+ styleSignatureRef.current = null;
75501
+ };
75502
+ }, [cancelPendingFrame, handleMutations, releasePendingImage]);
75503
+ (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
75504
+ var drawingSignature = createDrawingSignature(latestProps, normalizeDpr());
75505
+ var styleSignature = createStyleSignature(latestProps);
75506
+ var drawingChanged = !signaturesEqual(requestedDrawingSignatureRef.current, drawingSignature);
75507
+ var styleChanged = !signaturesEqual(styleSignatureRef.current, styleSignature);
75508
+ requestedDrawingSignatureRef.current = drawingSignature;
75509
+ styleSignatureRef.current = styleSignature;
75510
+ if (drawingChanged) {
75511
+ imageTokenRef.current += 1;
75512
+ releasePendingImage(true);
75513
+ scheduleRender();
75514
+ } else if (styleChanged) {
75515
+ applyLatestStyle();
75516
+ }
75517
+ });
75518
+ var watermarkClasses = (_props$jssStyle = props.jssStyle) === null || _props$jssStyle === void 0 ? void 0 : _props$jssStyle.watermark();
75519
+ var providerValue = ((_props$inherit = props.inherit) !== null && _props$inherit !== void 0 ? _props$inherit : true) ? contextValue : DisabledWatermarkContext;
75520
+ var rootClassName = classnames_default()(watermarkClasses === null || watermarkClasses === void 0 ? void 0 : watermarkClasses.rootClass, watermarkClasses === null || watermarkClasses === void 0 ? void 0 : watermarkClasses.wrapper, props.className);
75521
+ var rootAttributeSignature = "".concat(rootClassName, "\0").concat(getStyleString(props.style || {}));
75522
+ var saveRoot = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useCallback)(function (root) {
75523
+ if (!root) {
75524
+ if (rootRef.current) withObserverPaused(function () {
75525
+ return undefined;
75526
+ });
75527
+ rootRef.current = null;
75528
+ return;
75529
+ }
75530
+ rootRef.current = root;
75531
+ withObserverPaused(function () {
75532
+ rootAttributeBaselineRef.current = {
75533
+ className: root.getAttribute('class'),
75534
+ style: root.getAttribute('style')
75535
+ };
75536
+ }, true);
75537
+ }, [rootAttributeSignature, withObserverPaused]);
75538
+ return /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
75539
+ ref: saveRoot,
75540
+ className: rootClassName,
75541
+ style: props.style,
75542
+ children: /*#__PURE__*/(0,jsx_runtime.jsx)(watermark_context.Provider, {
75543
+ value: providerValue,
75544
+ children: props.children
75545
+ })
75546
+ });
75547
+ };
75548
+ /* harmony default export */ var watermark_watermark = (Watermark);
75549
+ ;// CONCATENATED MODULE: ./src/watermark/watermark.tsx
75550
+
75551
+
75552
+
75553
+
75554
+
75555
+ var watermark_jssStyle = {
75556
+ watermark: useWatermarkStyle
75557
+ };
75558
+ /* harmony default export */ var src_watermark_watermark = (function (props) {
75559
+ return /*#__PURE__*/(0,jsx_runtime.jsx)(watermark_watermark, objectSpread2_default()(objectSpread2_default()({}, props), {}, {
75560
+ jssStyle: watermark_jssStyle
75561
+ }));
75562
+ });
75563
+ ;// CONCATENATED MODULE: ./src/watermark/index.ts
75564
+
75565
+ var WatermarkComp = src_watermark_watermark;
75566
+ WatermarkComp.displayName = 'ShineoutWatermark';
75567
+ /* harmony default export */ var src_watermark_0 = (WatermarkComp);
74810
75568
  ;// CONCATENATED MODULE: ../theme/src/hooks/useToken/use-token.ts
74811
75569
 
74812
75570
 
@@ -76973,6 +77731,8 @@ var tree_interface = __webpack_require__(8517);
76973
77731
  var tree_select_interface = __webpack_require__(3347);
76974
77732
  // EXTERNAL MODULE: ./src/upload/interface.ts
76975
77733
  var upload_interface = __webpack_require__(8821);
77734
+ // EXTERNAL MODULE: ./src/watermark/interface.ts
77735
+ var watermark_interface = __webpack_require__(6640);
76976
77736
  ;// CONCATENATED MODULE: ./src/type.ts
76977
77737
 
76978
77738
 
@@ -77073,6 +77833,8 @@ var upload_interface = __webpack_require__(8821);
77073
77833
 
77074
77834
 
77075
77835
 
77836
+
77837
+
77076
77838
 
77077
77839
 
77078
77840
 
@@ -77138,10 +77900,11 @@ var upload_interface = __webpack_require__(8821);
77138
77900
 
77139
77901
 
77140
77902
 
77903
+
77141
77904
 
77142
77905
 
77143
77906
  /* harmony default export */ var src_0 = ({
77144
- version: '3.9.18'
77907
+ version: '3.10.0-beta.2'
77145
77908
  });
77146
77909
  }();
77147
77910
  /******/ return __webpack_exports__;