neko-ui 1.0.21 → 1.0.23
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/es/alpha-picker/index.d.ts +8 -0
- package/es/alpha-picker/index.global.less +70 -0
- package/es/alpha-picker/index.js +1 -0
- package/es/avatar/index.js +1 -1
- package/es/back-top/index.d.ts +3 -1
- package/es/back-top/index.js +1 -1
- package/es/button/index.js +1 -1
- package/es/capture-screen/index.js +1 -1
- package/es/color-palette/index.d.ts +8 -0
- package/es/color-palette/index.global.less +90 -0
- package/es/color-palette/index.js +1 -0
- package/es/cron-editor/index.js +1 -1
- package/es/get-prefix-cls/index.js +1 -1
- package/es/highlight-text/index.js +1 -1
- package/es/index.d.ts +6 -0
- package/es/index.js +1 -1
- package/es/input/index.js +1 -1
- package/es/markdown/index.d.ts +1 -1
- package/es/markdown/index.global.less +18 -34
- package/es/markdown/index.js +1 -1
- package/es/markdown/markdown-util.js +1 -1
- package/es/tooltip/index.d.ts +18 -4
- package/es/tooltip/index.global.less +113 -29
- package/es/tooltip/index.js +1 -1
- package/es/wave-circle/index.d.ts +2 -2
- package/es/wave-circle/index.js +1 -1
- package/lib/alpha-picker/index.d.ts +8 -0
- package/lib/alpha-picker/index.global.css +1 -0
- package/lib/alpha-picker/index.js +1 -0
- package/lib/avatar/index.js +1 -1
- package/lib/back-top/index.d.ts +3 -1
- package/lib/back-top/index.js +1 -1
- package/lib/button/index.js +1 -1
- package/lib/capture-screen/index.js +1 -1
- package/lib/color-palette/index.d.ts +8 -0
- package/lib/color-palette/index.global.css +1 -0
- package/lib/color-palette/index.js +1 -0
- package/lib/cron-editor/index.js +1 -1
- package/lib/get-prefix-cls/index.js +1 -1
- package/lib/highlight-text/index.js +1 -1
- package/lib/index.d.ts +6 -0
- package/lib/index.js +1 -1
- package/lib/input/index.js +1 -1
- package/lib/markdown/index.d.ts +1 -1
- package/lib/markdown/index.global.css +1 -1
- package/lib/markdown/index.js +1 -1
- package/lib/markdown/markdown-util.js +1 -1
- package/lib/tooltip/index.d.ts +18 -4
- package/lib/tooltip/index.global.css +1 -1
- package/lib/tooltip/index.js +1 -1
- package/lib/wave-circle/index.d.ts +2 -2
- package/lib/wave-circle/index.js +1 -1
- package/package.json +11 -7
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './index.global.less';
|
|
3
|
+
export interface AlphaPickerProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {
|
|
4
|
+
value?: number;
|
|
5
|
+
onChange?: (alpha: number) => void;
|
|
6
|
+
}
|
|
7
|
+
declare const AlphaPicker: React.FC<AlphaPickerProps>;
|
|
8
|
+
export default AlphaPicker;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
@alpha-mark-size: 4px;
|
|
2
|
+
|
|
3
|
+
.@{prefix-cls}-alpha-picker {
|
|
4
|
+
user-select: none;
|
|
5
|
+
width: 200px;
|
|
6
|
+
height: 20px;
|
|
7
|
+
|
|
8
|
+
&::after,
|
|
9
|
+
&::before {
|
|
10
|
+
content: '';
|
|
11
|
+
width: 0;
|
|
12
|
+
height: 0;
|
|
13
|
+
display: block;
|
|
14
|
+
opacity: 0;
|
|
15
|
+
margin-left: -3px;
|
|
16
|
+
transform: translateX(var(--offset-x, 0));
|
|
17
|
+
border-left-width: @alpha-mark-size;
|
|
18
|
+
border-right-width: @alpha-mark-size;
|
|
19
|
+
border-color: #999 transparent;
|
|
20
|
+
border-style: solid;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&::after {
|
|
24
|
+
border-bottom-width: @alpha-mark-size;
|
|
25
|
+
border-top-width: 0;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
&::before {
|
|
29
|
+
border-top-width: @alpha-mark-size;
|
|
30
|
+
border-bottom-width: 0;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&:hover {
|
|
34
|
+
&::after,
|
|
35
|
+
&::before {
|
|
36
|
+
opacity: 1;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.@{prefix-cls}-alpha-strip {
|
|
42
|
+
width: calc(100% - 2px);
|
|
43
|
+
height: 10px;
|
|
44
|
+
border: 1px solid var(--border-color-base);
|
|
45
|
+
border-radius: 6px;
|
|
46
|
+
background-image: linear-gradient(45deg,
|
|
47
|
+
#ccc 25%,
|
|
48
|
+
transparent 25%,
|
|
49
|
+
transparent 75%,
|
|
50
|
+
#ccc 75%,
|
|
51
|
+
#ccc),
|
|
52
|
+
linear-gradient(45deg,
|
|
53
|
+
#ccc 25%,
|
|
54
|
+
transparent 25%,
|
|
55
|
+
transparent 75%,
|
|
56
|
+
#ccc 75%,
|
|
57
|
+
#ccc);
|
|
58
|
+
background-size: 10px 10px;
|
|
59
|
+
background-position: 0 0, 5px 5px;
|
|
60
|
+
cursor: pointer;
|
|
61
|
+
|
|
62
|
+
&::after {
|
|
63
|
+
content: '';
|
|
64
|
+
display: block;
|
|
65
|
+
width: 100%;
|
|
66
|
+
height: 100%;
|
|
67
|
+
background-image: linear-gradient(to left, var(--offset-color, #fff), transparent);
|
|
68
|
+
border-radius: 6px;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr}function _iterableToArrayLimit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break}}catch(err){_d=true;_e=err}finally{try{if(!_n&&_i["return"]!=null)_i["return"]()}finally{if(_d)throw _e}}return _arr}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest()}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}import{classNames}from"@moneko/common";import React,{useCallback,useEffect,useRef,useState}from"react";import getPrefixCls from"../get-prefix-cls";import"./index.global.less";var AlphaPicker=function(param){var className=param.className,_value=param.value,value=_value===void 0?1:_value,onChange=param.onChange;var strip=useRef(null);var ref=_slicedToArray(useState(false),2),drag=ref[0],setDrag=ref[1];var ref1=_slicedToArray(useState(value),2),alpha=ref1[0],setAlpha=ref1[1];var handleChange=useCallback(function(param){var offsetX=param.offsetX;var ref,ref1;var v=offsetX/(((ref=strip.current)===null||ref===void 0?void 0:ref.offsetWidth)||1);setAlpha(v);(ref1=strip.current)===null||ref1===void 0?void 0:ref1.style.setProperty("--offset-x","".concat(offsetX,"px"))},[]);var handleMouseDown=useCallback(function(param){var offsetX=param.nativeEvent.offsetX;setDrag(true);handleChange({offsetX:offsetX})},[handleChange]);var handleMouseMove=useCallback(function(param){var offsetX=param.nativeEvent.offsetX;if(drag){handleChange({offsetX:offsetX})}},[drag,handleChange]);var handleMouseUp=useCallback(function(){setDrag(false)},[]);useEffect(function(){onChange===null||onChange===void 0?void 0:onChange(alpha)},[onChange,alpha]);return React.createElement("div",{ref:strip,className:classNames(getPrefixCls("alpha-picker"),className)},React.createElement("div",{className:getPrefixCls("alpha-strip"),onMouseDown:handleMouseDown,onMouseMove:handleMouseMove,onMouseUp:handleMouseUp,onMouseOut:handleMouseUp}))};export default AlphaPicker;
|
package/es/avatar/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key]}}}return target};return _extends.apply(this,arguments)}function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key]}}return target}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key]}return target}import React,{useMemo}from"react";import getPrefixCls from"../get-prefix-cls";import{classNames}from"@moneko/common";import"./index.global.less";var Avatar=function(_param){var className=_param.className,
|
|
1
|
+
function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key]}}}return target};return _extends.apply(this,arguments)}function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key]}}return target}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key]}return target}import React,{useMemo}from"react";import getPrefixCls from"../get-prefix-cls";import{classNames}from"@moneko/common";import"./index.global.less";var Avatar=function(_param){var className=_param.className,src=_param.src,alt=_param.alt,_imgProps=_param.imgProps,imgProps=_imgProps===void 0?{}:_imgProps,props=_objectWithoutProperties(_param,["className","src","alt","imgProps"]);var cls=useMemo(function(){return classNames(getPrefixCls("avatar"),className)},[className]);return React.createElement("div",_extends({className:cls},props),React.createElement("img",_extends({},imgProps,{src:src,alt:alt})))};export default Avatar;
|
package/es/back-top/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import './index.global.less';
|
|
3
3
|
export interface BackTopProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
4
|
-
/** 设置需要监听其滚动事件的元素,值为一个返回对应 DOM
|
|
4
|
+
/** 设置需要监听其滚动事件的元素,值为一个返回对应 DOM 元素 */
|
|
5
5
|
target?: () => HTMLElement;
|
|
6
|
+
/** 挂载到指定的元素,值为一个返回对应 DOM 元素 默认 document.body */
|
|
7
|
+
getPopupContainer?: (node?: HTMLElement) => HTMLElement;
|
|
6
8
|
/** 滚动高度达到此参数值才出现 BackTop */
|
|
7
9
|
visibilityHeight?: number;
|
|
8
10
|
}
|
package/es/back-top/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr}function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key]}}}return target};return _extends.apply(this,arguments)}function _iterableToArrayLimit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break}}catch(err){_d=true;_e=err}finally{try{if(!_n&&_i["return"]!=null)_i["return"]()}finally{if(_d)throw _e}}return _arr}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key]}}return target}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key]}return target}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest()}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}import React,{memo,useCallback,useEffect,useMemo,useRef,useState}from"react";import ReactDOM from"react-dom";import{classNames,getMaxZindex,getScrollTop,isEqual,isFunction}from"@moneko/common";import getPrefixCls from"../get-prefix-cls";import"./index.global.less";var BackTop=function(_param){var _target=_param.target,target=_target===void 0?function(){return window}:_target,_visibilityHeight=_param.visibilityHeight,visibilityHeight=_visibilityHeight===void 0?400:_visibilityHeight,className=_param.className,props=_objectWithoutProperties(_param,["target","visibilityHeight","className"]);var ref=useRef(null);var ref1=_slicedToArray(useState(null),2),show=ref1[0],setShow=ref1[1];var handleScrollY=useCallback(function(){var scrollTop=0;var offsetHeight=0;if(isFunction(target)){var ele=target();if(ele){scrollTop=getScrollTop(ele);offsetHeight=ele.offsetHeight}}var nextShow=scrollTop>offsetHeight/3||scrollTop>visibilityHeight;if(Boolean(show)!==nextShow){setShow(nextShow)}},[show,target,visibilityHeight]);var handleBackTop=useCallback(function(){var ref;(ref=target())===null||ref===void 0?void 0:ref.scrollTo({top:0,behavior:"smooth"})},[target]);useEffect(function(){if(show&&ref.current){ref.current.style.zIndex=getMaxZindex().toString()}},[show]);useEffect(function(){if(isFunction(target)){var ref;(ref=target())===null||ref===void 0?void 0:ref.addEventListener("scroll",handleScrollY,false)}return function(){if(isFunction(target)){var ref;(ref=target())===null||ref===void 0?void 0:ref.removeEventListener("scroll",handleScrollY,false)}}},[handleScrollY,target]);var cls=useMemo(function(){return classNames(
|
|
1
|
+
function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr}function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key]}}}return target};return _extends.apply(this,arguments)}function _iterableToArrayLimit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break}}catch(err){_d=true;_e=err}finally{try{if(!_n&&_i["return"]!=null)_i["return"]()}finally{if(_d)throw _e}}return _arr}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key]}}return target}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key]}return target}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest()}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}import React,{memo,useCallback,useEffect,useMemo,useRef,useState}from"react";import ReactDOM from"react-dom";import{classNames,getMaxZindex,getScrollTop,isEqual,isFunction}from"@moneko/common";import getPrefixCls from"../get-prefix-cls";import"./index.global.less";var BackTop=function(_param){var _target=_param.target,target=_target===void 0?function(){return window}:_target,getPopupContainer=_param.getPopupContainer,_visibilityHeight=_param.visibilityHeight,visibilityHeight=_visibilityHeight===void 0?400:_visibilityHeight,className=_param.className,props=_objectWithoutProperties(_param,["target","getPopupContainer","visibilityHeight","className"]);var ref=useRef(null);var ref1=_slicedToArray(useState(null),2),show=ref1[0],setShow=ref1[1];var handleScrollY=useCallback(function(){var scrollTop=0;var offsetHeight=0;if(isFunction(target)){var ele=target();if(ele){scrollTop=getScrollTop(ele);offsetHeight=ele.offsetHeight}}var nextShow=scrollTop>offsetHeight/3||scrollTop>visibilityHeight;if(Boolean(show)!==nextShow){setShow(nextShow)}},[show,target,visibilityHeight]);var handleBackTop=useCallback(function(){var ref;(ref=target())===null||ref===void 0?void 0:ref.scrollTo({top:0,behavior:"smooth"})},[target]);useEffect(function(){if(show&&ref.current){ref.current.style.zIndex=getMaxZindex().toString()}},[show]);useEffect(function(){if(isFunction(target)){var ref;(ref=target())===null||ref===void 0?void 0:ref.addEventListener("scroll",handleScrollY,false)}return function(){if(isFunction(target)){var ref;(ref=target())===null||ref===void 0?void 0:ref.removeEventListener("scroll",handleScrollY,false)}}},[handleScrollY,target]);var cls=useMemo(function(){return classNames(getPrefixCls("back-top"),className,!show&&getPrefixCls("back-top-out"))},[className,show]);var exit=useCallback(function(){if(show===false){setShow(null)}},[show]);var el=useMemo(function(){return React.createElement("div",_extends({},props,{ref:ref,onAnimationEnd:exit,className:cls,onClick:handleBackTop}))},[cls,exit,handleBackTop,props]);var container=useMemo(function(){return(getPopupContainer===null||getPopupContainer===void 0?void 0:getPopupContainer(target()))||document.body},[getPopupContainer,target]);return show===null?null:ReactDOM.createPortal(el,container)};export default memo(BackTop,isEqual);
|
package/es/button/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr}function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key]}}}return target};return _extends.apply(this,arguments)}function _iterableToArrayLimit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break}}catch(err){_d=true;_e=err}finally{try{if(!_n&&_i["return"]!=null)_i["return"]()}finally{if(_d)throw _e}}return _arr}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key]}}return target}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key]}return target}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest()}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}import React,{useCallback,useMemo,useRef}from"react";import getPrefixCls from"../get-prefix-cls";import{classNames,isFunction}from"@moneko/common";import"./index.global.less";var Button=function(_param){var infinite=_param.infinite,ghost=_param.ghost,fill=_param.fill,circle=_param.circle,dashed=_param.dashed,float=_param.float,link=_param.link,className=_param.className,children=_param.children,disabled=_param.disabled,onClick=_param.onClick,type=_param.type,props=_objectWithoutProperties(_param,["infinite","ghost","fill","circle","dashed","float","link","className","children","disabled","onClick","type"]);var ref=useRef(null);var ref1=_slicedToArray(React.useState(false),2),animating=ref1[0],setAnimating=ref1[1];var handleClick=useCallback(function(e){if(disabled)return;setAnimating(true);if(isFunction(onClick)){onClick(e)}},[disabled,onClick]);var cls=useMemo(function(){return classNames(
|
|
1
|
+
function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr}function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key]}}}return target};return _extends.apply(this,arguments)}function _iterableToArrayLimit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break}}catch(err){_d=true;_e=err}finally{try{if(!_n&&_i["return"]!=null)_i["return"]()}finally{if(_d)throw _e}}return _arr}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key]}}return target}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key]}return target}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest()}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}import React,{useCallback,useMemo,useRef}from"react";import getPrefixCls from"../get-prefix-cls";import{classNames,isFunction}from"@moneko/common";import"./index.global.less";var Button=function(_param){var infinite=_param.infinite,ghost=_param.ghost,fill=_param.fill,circle=_param.circle,dashed=_param.dashed,float=_param.float,link=_param.link,className=_param.className,children=_param.children,disabled=_param.disabled,onClick=_param.onClick,type=_param.type,props=_objectWithoutProperties(_param,["infinite","ghost","fill","circle","dashed","float","link","className","children","disabled","onClick","type"]);var ref=useRef(null);var ref1=_slicedToArray(React.useState(false),2),animating=ref1[0],setAnimating=ref1[1];var handleClick=useCallback(function(e){if(disabled)return;setAnimating(true);if(isFunction(onClick)){onClick(e)}},[disabled,onClick]);var cls=useMemo(function(){return classNames(getPrefixCls("btn"),type&&getPrefixCls("btn-".concat(type)),infinite&&getPrefixCls("btn-infinite"),ghost&&getPrefixCls("btn-ghost"),fill&&getPrefixCls("btn-fill"),circle&&getPrefixCls("btn-circle"),dashed&&getPrefixCls("btn-dashed"),float&&getPrefixCls("btn-float"),animating&&getPrefixCls("btn-without"),disabled&&getPrefixCls("btn-disabled"),link&&getPrefixCls("btn-link"),className)},[type,infinite,ghost,fill,circle,dashed,float,animating,disabled,link,className]);var handleAnimationEnd=useCallback(function(){setAnimating(false)},[]);return React.createElement("div",_extends({},props,{className:cls,onClick:handleClick,onAnimationEnd:handleAnimationEnd,ref:ref}),React.createElement("span",{className:getPrefixCls("btn-text")},children))};export default Button;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value}catch(error){reject(error);return}if(info.done){resolve(value)}else{Promise.resolve(value).then(_next,_throw)}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value)}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err)}_next(undefined)})}}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key]}}}return target};return _extends.apply(this,arguments)}function _iterableToArrayLimit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break}}catch(err){_d=true;_e=err}finally{try{if(!_n&&_i["return"]!=null)_i["return"]()}finally{if(_d)throw _e}}return _arr}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _objectSpread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};var ownKeys=Object.keys(source);if(typeof Object.getOwnPropertySymbols==="function"){ownKeys=ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym){return Object.getOwnPropertyDescriptor(source,sym).enumerable}))}ownKeys.forEach(function(key){_defineProperty(target,key,source[key])})}return target}function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key]}}return target}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key]}return target}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest()}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}var __generator=this&&this.__generator||function(thisArg,body){var f,y,t,g,_={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]};return g={next:verb(0),"throw":verb(1),"return":verb(2)},typeof Symbol==="function"&&(g[Symbol.iterator]=function(){return this}),g;function verb(n){return function(v){return step([n,v])}}function step(op){if(f)throw new TypeError("Generator is already executing.");while(_)try{if(f=1,y&&(t=op[0]&2?y["return"]:op[0]?y["throw"]||((t=y["return"])&&t.call(y),0):y.next)&&!(t=t.call(y,op[1])).done)return t;if(y=0,t)op=[op[0]&2,t.value];switch(op[0]){case 0:case 1:t=op;break;case 4:_.label++;return{value:op[1],done:false};case 5:_.label++;y=op[1];op=[0];continue;case 7:op=_.ops.pop();_.trys.pop();continue;default:if(!(t=_.trys,t=t.length>0&&t[t.length-1])&&(op[0]===6||op[0]===2)){_=0;continue}if(op[0]===3&&(!t||op[1]>t[0]&&op[1]<t[3])){_.label=op[1];break}if(op[0]===6&&_.label<t[1]){_.label=t[1];t=op;break}if(t&&_.label<t[2]){_.label=t[2];_.ops.push(op);break}if(t[2])_.ops.pop();_.trys.pop();continue}op=body.call(thisArg,_)}catch(e){op=[6,e];y=0}finally{f=t=0}if(op[0]&5)throw op[1];return{value:op[0]?op[1]:void 0,done:true}}};import React,{useCallback,useEffect,useMemo,useRef,useState}from"react";import Button from"../button";import getPrefixCls from"../get-prefix-cls";import{downloadBlob,isObject,isFunction,classNames}from"@moneko/common";import"./index.global.less";var displayMediaOptions={video:true,audio:{echoCancellation:true,noiseSuppression:true,sampleRate:44100}};var btnStatusDic={inactive:"primary",paused:"warning",recording:"success"};var CaptureScreen=function(_param){var _options=_param.options,options=_options===void 0?displayMediaOptions:_options,preview=_param.preview,controls=_param.controls,recorder=_param.recorder,className=_param.className,_captureScreenText=_param.captureScreenText,captureScreenText=_captureScreenText===void 0?"捕获屏幕":_captureScreenText,_stopCaptureText=_param.stopCaptureText,stopCaptureText=_stopCaptureText===void 0?"停止捕获":_stopCaptureText,_startRecorderText=_param.startRecorderText,startRecorderText=_startRecorderText===void 0?"开始录制":_startRecorderText,_stopRecorderText=_param.stopRecorderText,stopRecorderText=_stopRecorderText===void 0?"停止录制":_stopRecorderText,_pausedRecorderText=_param.pausedRecorderText,pausedRecorderText=_pausedRecorderText===void 0?"暂停录制":_pausedRecorderText,_recorderingText=_param.recorderingText,recorderingText=_recorderingText===void 0?"录制中":_recorderingText,_onRecorderError=_param.onRecorderError,onRecorderError=_onRecorderError===void 0?null:_onRecorderError,onStopRecorder=_param.onStopRecorder,onStartRecorder=_param.onStartRecorder,onStopCapture=_param.onStopCapture,onStartCapture=_param.onStartCapture,onRecorderDataAvailable=_param.onRecorderDataAvailable,onErrorCapture=_param.onErrorCapture,onSaveRecorder=_param.onSaveRecorder,props=_objectWithoutProperties(_param,["options","preview","controls","recorder","className","captureScreenText","stopCaptureText","startRecorderText","stopRecorderText","pausedRecorderText","recorderingText","onRecorderError","onStopRecorder","onStartRecorder","onStopCapture","onStartCapture","onRecorderDataAvailable","onErrorCapture","onSaveRecorder"]);var videoElem=useRef(null);var mediaRecorderRef=useRef(null);var mediaStreamRef=useRef(null);var chunks=useRef([]);var recorderRef=useRef(recorder);var ref=_slicedToArray(useState(null),2),mediaRecorder=ref[0],setMediaRecorder=ref[1];var ref1=_slicedToArray(useState(null),2),mediaStream=ref1[0],setMediaStream=ref1[1];var ref2=_slicedToArray(useState("inactive"),2),recordState=ref2[0],setRecordState=ref2[1];useEffect(function(){Object.assign(recorderRef,{current:recorder})},[recorder]);useEffect(function(){Object.assign(mediaStreamRef,{current:mediaStream})},[mediaStream]);useEffect(function(){Object.assign(mediaRecorderRef,{current:mediaRecorder})},[mediaRecorder]);var handleStartRecorder=useCallback(function(){if(mediaRecorderRef.current){if(isFunction(onStartRecorder)){onStartRecorder(mediaRecorderRef.current.state)}switch(mediaRecorderRef.current.state){case"inactive":mediaRecorderRef.current.start();break;case"paused":mediaRecorderRef.current.resume();break;case"recording":mediaRecorderRef.current.pause();break;default:break}setRecordState(mediaRecorderRef.current.state)}},[onStartRecorder]);var handleRecorderDataAvailable=useCallback(function(e){var ref;(ref=chunks.current)===null||ref===void 0?void 0:ref.push(e.data);if(isFunction(onRecorderDataAvailable)){onRecorderDataAvailable(e)}},[onRecorderDataAvailable]);var stopRecorder=useCallback(function(){if(mediaRecorderRef.current){if(mediaRecorderRef.current.state!=="inactive"){mediaRecorderRef.current.stop()}setRecordState(mediaRecorderRef.current.state)}if(isFunction(onStopRecorder)){onStopRecorder()}},[onStopRecorder]);var handleSaveRecorder=useCallback(function(){var ref,ref1,ref2;if(!((ref=chunks.current)===null||ref===void 0?void 0:ref.length))return;var blob=new Blob(chunks.current,{type:"video/webm"}),name=isObject(recorderRef.current)&&((ref1=recorderRef.current)===null||ref1===void 0?void 0:ref1.filename)||new Date().toISOString(),fileName=name+".webm";(ref2=chunks.current)===null||ref2===void 0?void 0:ref2.splice(0);if(isFunction(onSaveRecorder)){onSaveRecorder(blob,fileName)}else{downloadBlob(blob,fileName)}},[onSaveRecorder]);var stopCapture=useCallback(function(){stopRecorder();if(mediaStreamRef.current){var tracks=mediaStreamRef.current.getTracks();tracks===null||tracks===void 0?void 0:tracks.forEach(function(track){return track.stop()});setMediaStream(null)}if(isFunction(onStopCapture)){onStopCapture()}},[onStopCapture,stopRecorder]);var startCapture=useCallback(_asyncToGenerator(function(){var stream,err;return __generator(this,function(_state){switch(_state.label){case 0:stopCapture();_state.label=1;case 1:_state.trys.push([1,3,,4]);return[4,navigator.mediaDevices.getDisplayMedia(_objectSpread({},displayMediaOptions,options))];case 2:stream=_state.sent();if(stream){stream.addEventListener("inactive",stopCapture,false);setMediaStream(stream)}if(isFunction(onStartCapture)){onStartCapture(stream)}return[3,4];case 3:err=_state.sent();if(isFunction(onErrorCapture)){onErrorCapture(err)}return[3,4];case 4:return[2]}})}),[onErrorCapture,onStartCapture,options,stopCapture]);useEffect(function(){if(preview&&(videoElem===null||videoElem===void 0?void 0:videoElem.current)&&mediaStream){videoElem.current.srcObject=mediaStream}},[mediaStream,preview]);useEffect(function(){if((mediaStream===null||mediaStream===void 0?void 0:mediaStream.active)&&recorderRef.current){var recorderInstance=new MediaRecorder(mediaStream);recorderInstance.onstop=handleSaveRecorder;recorderInstance.onerror=onRecorderError;recorderInstance.ondataavailable=handleRecorderDataAvailable;setMediaRecorder(recorderInstance)}else{setMediaRecorder(null)}},[handleRecorderDataAvailable,handleSaveRecorder,mediaStream,onRecorderError]);useEffect(function(){var getMediaRecorderRef=function(){return mediaRecorderRef.current};var getMediaStreamRef=function(){return mediaStreamRef.current};return function(){var _mediaRecorderRef=getMediaRecorderRef();if(_mediaRecorderRef){if(_mediaRecorderRef.state!=="inactive"){_mediaRecorderRef.stop()}}var streamRef=getMediaStreamRef();if(streamRef){var tracks=streamRef.getTracks();tracks===null||tracks===void 0?void 0:tracks.forEach(function(track){return track.stop()})}}},[]);var recorderText=useMemo(function(){return({paused:pausedRecorderText,recording:recorderingText,inactive:startRecorderText})[recordState]},[pausedRecorderText,recordState,recorderingText,startRecorderText]);return React.createElement("div",_extends({className:classNames([getPrefixCls("capture-screen"),className])},props),React.createElement("div",{className:getPrefixCls("capture-screen-controller")},React.createElement(Button,{onClick:startCapture},captureScreenText),mediaStream&&React.createElement(React.Fragment,null,React.createElement(Button,{type:"error",onClick:stopCapture},stopCaptureText),recorder&&React.createElement("div",{className:getPrefixCls("capture-screen-controller-record")},React.createElement(Button,{type:btnStatusDic[recordState],onClick:handleStartRecorder},recorderText),recordState!=="inactive"&&React.createElement(Button,{type:"error",onClick:stopRecorder},stopRecorderText)))),preview&&mediaStream?React.createElement("div",{className:getPrefixCls("capture-screen-video")},React.createElement("span",{className:getPrefixCls("capture-screen-video-".concat(recordState))}),React.createElement("video",{ref:videoElem,autoPlay:true,controls:!!(mediaStream&&controls)})):null)};export default CaptureScreen;
|
|
1
|
+
function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value}catch(error){reject(error);return}if(info.done){resolve(value)}else{Promise.resolve(value).then(_next,_throw)}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value)}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err)}_next(undefined)})}}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key]}}}return target};return _extends.apply(this,arguments)}function _iterableToArrayLimit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break}}catch(err){_d=true;_e=err}finally{try{if(!_n&&_i["return"]!=null)_i["return"]()}finally{if(_d)throw _e}}return _arr}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _objectSpread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};var ownKeys=Object.keys(source);if(typeof Object.getOwnPropertySymbols==="function"){ownKeys=ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym){return Object.getOwnPropertyDescriptor(source,sym).enumerable}))}ownKeys.forEach(function(key){_defineProperty(target,key,source[key])})}return target}function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key]}}return target}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key]}return target}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest()}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}var __generator=this&&this.__generator||function(thisArg,body){var f,y,t,g,_={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]};return g={next:verb(0),"throw":verb(1),"return":verb(2)},typeof Symbol==="function"&&(g[Symbol.iterator]=function(){return this}),g;function verb(n){return function(v){return step([n,v])}}function step(op){if(f)throw new TypeError("Generator is already executing.");while(_)try{if(f=1,y&&(t=op[0]&2?y["return"]:op[0]?y["throw"]||((t=y["return"])&&t.call(y),0):y.next)&&!(t=t.call(y,op[1])).done)return t;if(y=0,t)op=[op[0]&2,t.value];switch(op[0]){case 0:case 1:t=op;break;case 4:_.label++;return{value:op[1],done:false};case 5:_.label++;y=op[1];op=[0];continue;case 7:op=_.ops.pop();_.trys.pop();continue;default:if(!(t=_.trys,t=t.length>0&&t[t.length-1])&&(op[0]===6||op[0]===2)){_=0;continue}if(op[0]===3&&(!t||op[1]>t[0]&&op[1]<t[3])){_.label=op[1];break}if(op[0]===6&&_.label<t[1]){_.label=t[1];t=op;break}if(t&&_.label<t[2]){_.label=t[2];_.ops.push(op);break}if(t[2])_.ops.pop();_.trys.pop();continue}op=body.call(thisArg,_)}catch(e){op=[6,e];y=0}finally{f=t=0}if(op[0]&5)throw op[1];return{value:op[0]?op[1]:void 0,done:true}}};import React,{useCallback,useEffect,useMemo,useRef,useState}from"react";import Button from"../button";import getPrefixCls from"../get-prefix-cls";import{downloadBlob,classNames,isObject}from"@moneko/common";import"./index.global.less";var displayMediaOptions={video:true,audio:{echoCancellation:true,noiseSuppression:true,sampleRate:44100}};var btnStatusDic={inactive:"primary",paused:"warning",recording:"success"};var CaptureScreen=function(_param){var _options=_param.options,options=_options===void 0?displayMediaOptions:_options,preview=_param.preview,controls=_param.controls,recorder=_param.recorder,className=_param.className,_captureScreenText=_param.captureScreenText,captureScreenText=_captureScreenText===void 0?"捕获屏幕":_captureScreenText,_stopCaptureText=_param.stopCaptureText,stopCaptureText=_stopCaptureText===void 0?"停止捕获":_stopCaptureText,_startRecorderText=_param.startRecorderText,startRecorderText=_startRecorderText===void 0?"开始录制":_startRecorderText,_stopRecorderText=_param.stopRecorderText,stopRecorderText=_stopRecorderText===void 0?"停止录制":_stopRecorderText,_pausedRecorderText=_param.pausedRecorderText,pausedRecorderText=_pausedRecorderText===void 0?"暂停录制":_pausedRecorderText,_recorderingText=_param.recorderingText,recorderingText=_recorderingText===void 0?"录制中":_recorderingText,_onRecorderError=_param.onRecorderError,onRecorderError=_onRecorderError===void 0?null:_onRecorderError,onStopRecorder=_param.onStopRecorder,onStartRecorder=_param.onStartRecorder,onStopCapture=_param.onStopCapture,onStartCapture=_param.onStartCapture,onRecorderDataAvailable=_param.onRecorderDataAvailable,onErrorCapture=_param.onErrorCapture,onSaveRecorder=_param.onSaveRecorder,props=_objectWithoutProperties(_param,["options","preview","controls","recorder","className","captureScreenText","stopCaptureText","startRecorderText","stopRecorderText","pausedRecorderText","recorderingText","onRecorderError","onStopRecorder","onStartRecorder","onStopCapture","onStartCapture","onRecorderDataAvailable","onErrorCapture","onSaveRecorder"]);var videoElem=useRef(null);var mediaRecorderRef=useRef(null);var mediaStreamRef=useRef(null);var chunks=useRef([]);var recorderRef=useRef(recorder);var ref=_slicedToArray(useState(null),2),mediaRecorder=ref[0],setMediaRecorder=ref[1];var ref1=_slicedToArray(useState(null),2),mediaStream=ref1[0],setMediaStream=ref1[1];var ref2=_slicedToArray(useState("inactive"),2),recordState=ref2[0],setRecordState=ref2[1];useEffect(function(){Object.assign(recorderRef,{current:recorder})},[recorder]);useEffect(function(){Object.assign(mediaStreamRef,{current:mediaStream})},[mediaStream]);useEffect(function(){Object.assign(mediaRecorderRef,{current:mediaRecorder})},[mediaRecorder]);var handleStartRecorder=useCallback(function(){if(mediaRecorderRef.current){onStartRecorder===null||onStartRecorder===void 0?void 0:onStartRecorder(mediaRecorderRef.current.state);switch(mediaRecorderRef.current.state){case"inactive":mediaRecorderRef.current.start();break;case"paused":mediaRecorderRef.current.resume();break;case"recording":default:mediaRecorderRef.current.pause();break}setRecordState(mediaRecorderRef.current.state)}},[onStartRecorder]);var handleRecorderDataAvailable=useCallback(function(e){var ref;(ref=chunks.current)===null||ref===void 0?void 0:ref.push(e.data);onRecorderDataAvailable===null||onRecorderDataAvailable===void 0?void 0:onRecorderDataAvailable(e)},[onRecorderDataAvailable]);var stopRecorder=useCallback(function(){if(mediaRecorderRef.current){if(mediaRecorderRef.current.state!=="inactive"){mediaRecorderRef.current.stop()}setRecordState(mediaRecorderRef.current.state)}onStopRecorder===null||onStopRecorder===void 0?void 0:onStopRecorder()},[onStopRecorder]);var handleSaveRecorder=useCallback(function(){var ref,ref1;if(!((ref=chunks.current)===null||ref===void 0?void 0:ref.length))return;var current=recorderRef.current;var blob=new Blob(chunks.current,{type:"video/webm"});var name=isObject(current)?current===null||current===void 0?void 0:current.filename:new Date().toISOString();var fileName=name+".webm";(ref1=chunks.current)===null||ref1===void 0?void 0:ref1.splice(0);if(onSaveRecorder){onSaveRecorder(blob,fileName)}else{downloadBlob(blob,fileName)}},[onSaveRecorder]);var stopCapture=useCallback(function(){stopRecorder();if(mediaStreamRef.current){var tracks=mediaStreamRef.current.getTracks();tracks===null||tracks===void 0?void 0:tracks.forEach(function(track){return track.stop()});setMediaStream(null)}onStopCapture===null||onStopCapture===void 0?void 0:onStopCapture()},[onStopCapture,stopRecorder]);var startCapture=useCallback(_asyncToGenerator(function(){var stream,err;return __generator(this,function(_state){switch(_state.label){case 0:stopCapture();_state.label=1;case 1:_state.trys.push([1,3,,4]);return[4,navigator.mediaDevices.getDisplayMedia(_objectSpread({},displayMediaOptions,options))];case 2:stream=_state.sent();if(stream){stream.addEventListener("inactive",stopCapture,false);setMediaStream(stream)}onStartCapture===null||onStartCapture===void 0?void 0:onStartCapture(stream);return[3,4];case 3:err=_state.sent();onErrorCapture===null||onErrorCapture===void 0?void 0:onErrorCapture(err);return[3,4];case 4:return[2]}})}),[onErrorCapture,onStartCapture,options,stopCapture]);useEffect(function(){if(preview&&(videoElem===null||videoElem===void 0?void 0:videoElem.current)&&mediaStream){videoElem.current.srcObject=mediaStream}},[mediaStream,preview]);useEffect(function(){if(mediaStream===null||mediaStream===void 0?void 0:mediaStream.active){var recorderInstance=new MediaRecorder(mediaStream);recorderInstance.onstop=handleSaveRecorder;recorderInstance.onerror=onRecorderError;recorderInstance.ondataavailable=handleRecorderDataAvailable;setMediaRecorder(recorderInstance)}else{setMediaRecorder(null)}},[handleRecorderDataAvailable,handleSaveRecorder,mediaStream,onRecorderError]);useEffect(function(){var getMediaRecorderRef=function(){return mediaRecorderRef.current};var getMediaStreamRef=function(){return mediaStreamRef.current};return function(){var _mediaRecorderRef=getMediaRecorderRef();if((_mediaRecorderRef===null||_mediaRecorderRef===void 0?void 0:_mediaRecorderRef.state)!=="inactive"){_mediaRecorderRef===null||_mediaRecorderRef===void 0?void 0:_mediaRecorderRef.stop()}var streamRef=getMediaStreamRef();if(streamRef){var tracks=streamRef.getTracks();tracks===null||tracks===void 0?void 0:tracks.forEach(function(track){return track.stop()})}}},[]);var recorderText=useMemo(function(){return({paused:pausedRecorderText,recording:recorderingText,inactive:startRecorderText})[recordState]},[pausedRecorderText,recordState,recorderingText,startRecorderText]);return React.createElement("div",_extends({className:classNames(getPrefixCls("capture-screen"),className)},props),React.createElement("div",{className:getPrefixCls("capture-screen-controller")},React.createElement(Button,{onClick:startCapture},captureScreenText),mediaStream&&React.createElement(React.Fragment,null,React.createElement(Button,{type:"error",onClick:stopCapture},stopCaptureText),recorder&&React.createElement("div",{className:getPrefixCls("capture-screen-controller-record")},React.createElement(Button,{type:btnStatusDic[recordState],onClick:handleStartRecorder},recorderText),recordState!=="inactive"&&React.createElement(Button,{type:"error",onClick:stopRecorder},stopRecorderText)))),preview&&mediaStream?React.createElement("div",{className:getPrefixCls("capture-screen-video")},React.createElement("span",{className:getPrefixCls("capture-screen-video-".concat(recordState))}),React.createElement("video",{ref:videoElem,autoPlay:true,controls:!!(mediaStream&&controls)})):null)};export default CaptureScreen;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './index.global.less';
|
|
3
|
+
export interface ColorPaletteProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {
|
|
4
|
+
value?: string;
|
|
5
|
+
onChange?: (color: string) => void;
|
|
6
|
+
}
|
|
7
|
+
declare const ColorPalette: React.FC<ColorPaletteProps>;
|
|
8
|
+
export default ColorPalette;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
.@{prefix-cls}-color-palette {
|
|
2
|
+
box-sizing: border-box;
|
|
3
|
+
user-select: none;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.@{prefix-cls}-color-input {
|
|
7
|
+
width: 50px;
|
|
8
|
+
height: 30px;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.@{prefix-cls}-color-picker {
|
|
12
|
+
position: relative;
|
|
13
|
+
display: block;
|
|
14
|
+
width: 200px;
|
|
15
|
+
height: 120px;
|
|
16
|
+
border-radius: var(--border-radius-base);
|
|
17
|
+
background-color: var(--component-background);
|
|
18
|
+
|
|
19
|
+
canvas {
|
|
20
|
+
width: 100%;
|
|
21
|
+
height: 100%;
|
|
22
|
+
border-radius: 5px;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&:hover {
|
|
26
|
+
cursor: crosshair;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&::after {
|
|
30
|
+
content: '';
|
|
31
|
+
width: 2px;
|
|
32
|
+
height: 2px;
|
|
33
|
+
border-radius: 50%;
|
|
34
|
+
border: 1px solid;
|
|
35
|
+
display: block;
|
|
36
|
+
position: absolute;
|
|
37
|
+
top: var(--offset-y);
|
|
38
|
+
left: var(--offset-x);
|
|
39
|
+
pointer-events: none;
|
|
40
|
+
transform: translate3d(-50%, -50%, 1px);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@strip-mark-size: 4px;
|
|
45
|
+
.@{prefix-cls}-color-strip {
|
|
46
|
+
margin-top: 4px;
|
|
47
|
+
width: 200px;
|
|
48
|
+
height: 20px;
|
|
49
|
+
display: flex;
|
|
50
|
+
flex-direction: column;
|
|
51
|
+
cursor: pointer;
|
|
52
|
+
|
|
53
|
+
canvas {
|
|
54
|
+
width: 100%;
|
|
55
|
+
height: 12px;
|
|
56
|
+
border-radius: 6px;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
&::after,
|
|
60
|
+
&::before {
|
|
61
|
+
width: 0;
|
|
62
|
+
height: 0;
|
|
63
|
+
content: '';
|
|
64
|
+
opacity: 0;
|
|
65
|
+
display: block;
|
|
66
|
+
margin-left: -3px;
|
|
67
|
+
transform: translateX(var(--offset-x, 0));
|
|
68
|
+
border-left-width: @strip-mark-size;
|
|
69
|
+
border-right-width: @strip-mark-size;
|
|
70
|
+
border-color: #999 transparent;
|
|
71
|
+
border-style: solid;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
&::after {
|
|
75
|
+
border-bottom-width: @strip-mark-size;
|
|
76
|
+
border-top-width: 0;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
&::before {
|
|
80
|
+
border-top-width: @strip-mark-size;
|
|
81
|
+
border-bottom-width: 0;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
&:hover {
|
|
85
|
+
&::after,
|
|
86
|
+
&::before {
|
|
87
|
+
opacity: 1;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr}function _iterableToArrayLimit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break}}catch(err){_d=true;_e=err}finally{try{if(!_n&&_i["return"]!=null)_i["return"]()}finally{if(_d)throw _e}}return _arr}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest()}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}import{classNames}from"@moneko/common";import React,{useCallback,useEffect,useRef,useState}from"react";import{AlphaPicker}from"..";import getPrefixCls from"../get-prefix-cls";import"./index.global.less";var ColorPalette=function(param){var className=param.className,_value=param.value,value=_value===void 0?"rgba(255,0,0,1)":_value,onChange=param.onChange;var colorPicker=useRef(null);var colorStrip=useRef(null);var ref=_slicedToArray(useState({r:255,g:0,b:0}),2),rgb=ref[0],setRgb=ref[1];var ref1=_slicedToArray(useState(false),2),drag=ref1[0],setDrag=ref1[1];var ref2=_slicedToArray(useState(false),2),dragColorStrip=ref2[0],setDragColorStrip=ref2[1];var ref3=_slicedToArray(useState(1),2),alpha=ref3[0],setAlpha=ref3[1];var fillGradient=useCallback(function(color){if(!colorPicker.current)return;var ctx1=colorPicker.current.getContext("2d");var width=colorPicker.current.width;var height=colorPicker.current.height;if(!ctx1)return;ctx1.fillStyle=color;ctx1.fillRect(0,0,width,height);if(!colorStrip.current)return;var ctx2=colorStrip.current.getContext("2d");if(!ctx2)return;var grdWhite=ctx2.createLinearGradient(0,0,colorStrip.current.width,0);grdWhite.addColorStop(0,"rgba(255,255,255,1)");grdWhite.addColorStop(1,"rgba(255,255,255,0)");ctx1.fillStyle=grdWhite;ctx1.fillRect(0,0,width,height);var grdBlack=ctx2.createLinearGradient(0,0,0,height);grdBlack.addColorStop(0,"rgba(0,0,0,0)");grdBlack.addColorStop(1,"rgba(0,0,0,1)");ctx1.fillStyle=grdBlack;ctx1.fillRect(0,0,width,height)},[]);var initColorPicker=useCallback(function(color){if(colorPicker.current){var ctx1=colorPicker.current.getContext("2d");if(ctx1){ctx1.rect(0,0,colorPicker.current.width||0,colorPicker.current.height||0);fillGradient(color)}}},[fillGradient]);var initColorStrip=useCallback(function(){if(colorStrip.current){var ctx2=colorStrip.current.getContext("2d");if(ctx2){ctx2.rect(0,0,colorStrip.current.width,colorStrip.current.height);var grd1=ctx2.createLinearGradient(0,0,colorStrip.current.width,0);grd1.addColorStop(0,"rgba(255, 0, 0, 1)");grd1.addColorStop(.17,"rgba(255, 255, 0, 1)");grd1.addColorStop(.34,"rgba(0, 255, 0, 1)");grd1.addColorStop(.51,"rgba(0, 255, 255, 1)");grd1.addColorStop(.68,"rgba(0, 0, 255, 1)");grd1.addColorStop(.85,"rgba(255, 0, 255, 1)");grd1.addColorStop(1,"rgba(255, 0, 0, 1)");ctx2.fillStyle=grd1;ctx2.fill()}}},[]);var changeColorStrip=useCallback(function(param){var offsetX=param.offsetX;if(colorStrip.current){var ref;var ctx2=(ref=colorStrip.current)===null||ref===void 0?void 0:ref.getContext("2d");var x=offsetX>=colorStrip.current.width?offsetX-1:offsetX;if(ctx2){var ref1,ref2,ref3,ref4,ref5;var _data=_slicedToArray(ctx2.getImageData(x,0,1,1).data,3),r=_data[0],g=_data[1],b=_data[2];setRgb({r:r,g:g,b:b});fillGradient("rgba(".concat(r,",").concat(g,",").concat(b,",1)"));(ref1=colorStrip.current)===null||ref1===void 0?void 0:(ref2=ref1.parentElement)===null||ref2===void 0?void 0:ref2.style.setProperty("--offset-x","".concat(x,"px"));(ref3=colorStrip.current)===null||ref3===void 0?void 0:(ref4=ref3.parentElement)===null||ref4===void 0?void 0:(ref5=ref4.parentElement)===null||ref5===void 0?void 0:ref5.style.setProperty("--offset-color","rgba(".concat(r,",").concat(g,",").concat(b,",1)"))}}},[fillGradient]);var colorStripMouseDown=useCallback(function(param){var _nativeEvent=param.nativeEvent,offsetX=_nativeEvent.offsetX,offsetY=_nativeEvent.offsetY;setDragColorStrip(true);changeColorStrip({offsetX:offsetX,offsetY:offsetY})},[changeColorStrip]);var colorStripMouseMove=useCallback(function(param){var _nativeEvent=param.nativeEvent,offsetX=_nativeEvent.offsetX,offsetY=_nativeEvent.offsetY;if(dragColorStrip){changeColorStrip({offsetX:offsetX,offsetY:offsetY})}},[changeColorStrip,dragColorStrip]);var colorStripMouseUp=useCallback(function(){setDragColorStrip(false)},[]);var changeColor=useCallback(function(param){var _nativeEvent=param.nativeEvent,offsetX=_nativeEvent.offsetX,offsetY=_nativeEvent.offsetY;var ref;var ctx1=(ref=colorPicker.current)===null||ref===void 0?void 0:ref.getContext("2d");if(ctx1){var ref1,ref2,ref3,ref4;var _data=_slicedToArray(ctx1.getImageData(offsetX,offsetY,1,1).data,3),r=_data[0],g=_data[1],b=_data[2];(ref1=colorPicker.current)===null||ref1===void 0?void 0:(ref2=ref1.parentElement)===null||ref2===void 0?void 0:ref2.style.setProperty("--offset-x","".concat(offsetX,"px"));(ref3=colorPicker.current)===null||ref3===void 0?void 0:(ref4=ref3.parentElement)===null||ref4===void 0?void 0:ref4.style.setProperty("--offset-y","".concat(offsetY,"px"));setRgb({r:r,g:g,b:b})}},[]);var colorPickerMouseDown=useCallback(function(e){setDrag(true);changeColor(e)},[changeColor]);var colorPickerMouseMove=useCallback(function(e){if(drag){changeColor(e)}},[changeColor,drag]);var colorPickerMouseUp=useCallback(function(){setDrag(false)},[]);useEffect(function(){initColorStrip()},[initColorStrip]);useEffect(function(){initColorPicker(value)},[]);useEffect(function(){onChange===null||onChange===void 0?void 0:onChange("rgba(".concat(rgb.r,",").concat(rgb.g,",").concat(rgb.b,",").concat(alpha,")"))},[rgb,alpha,onChange]);return React.createElement("div",{className:classNames(getPrefixCls("color-palette"),className)},React.createElement("article",{className:getPrefixCls("color-picker"),onMouseDown:colorPickerMouseDown,onMouseUp:colorPickerMouseUp,onMouseOut:colorPickerMouseUp,onMouseMove:colorPickerMouseMove},React.createElement("canvas",{ref:colorPicker,width:200})),React.createElement("article",{className:getPrefixCls("color-strip"),onMouseDown:colorStripMouseDown,onMouseUp:colorStripMouseUp,onMouseOut:colorStripMouseUp,onMouseMove:colorStripMouseMove},React.createElement("canvas",{ref:colorStrip,width:200})),React.createElement(AlphaPicker,{value:alpha,onChange:setAlpha}))};export default ColorPalette;
|
package/es/cron-editor/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{classNames}from"@moneko/common";import React from"react";import getPrefixCls from"../get-prefix-cls";var CornEditor=function(param){var className=param.className;return React.createElement("div",{className:classNames(
|
|
1
|
+
import{classNames}from"@moneko/common";import React from"react";import getPrefixCls from"../get-prefix-cls";var CornEditor=function(param){var className=param.className;return React.createElement("div",{className:classNames(getPrefixCls(""),className)},"CornEditor")};export default CornEditor;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import css from"./index.less";import{getPrefixCls as prefixCls}from"@moneko/common";var getPrefixCls=function(className){var prefix=arguments.length>1&&arguments[1]!==void 0?arguments[1]:
|
|
1
|
+
import css from"./index.less";import{getPrefixCls as prefixCls}from"@moneko/common";var _prefix=(css===null||css===void 0?void 0:css.prefixCls)||"neko";var getPrefixCls=function(className){var prefix=arguments.length>1&&arguments[1]!==void 0?arguments[1]:_prefix;return prefixCls(className,prefix)};export default getPrefixCls;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr}function _iterableToArrayLimit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break}}catch(err){_d=true;_e=err}finally{try{if(!_n&&_i["return"]!=null)_i["return"]()}finally{if(_d)throw _e}}return _arr}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest()}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}import React,{useEffect,useMemo,useState}from"react";import getPrefixCls from"../get-prefix-cls";import{classNames}from"@moneko/common";import"./index.global.less";export var RegExp_HighLight=/%c:(.+?):c%/i;export function strToHighlight(text){var str=text,strArr=RegExp_HighLight.exec(str);if(strArr){var textArr=[];for(;strArr!==null;strArr=RegExp_HighLight.exec(str)){var normalText=str.substring(0,strArr.index);if(normalText.trim().length){textArr.push({text:normalText})}textArr.push({hit:true,text:strArr[1]});str=str.substring(strArr[0].length+strArr.index);normalText=null}if(str.trim().length){textArr.push({text:str})}return textArr}return null}var HighlightText=function(param){var className=param.className,style=param.style,hitStyle=param.hitStyle,hitClassName=param.hitClassName,text=param.text,highlight=param.highlight,extra=param.extra,_flag=param.flag,flag=_flag===void 0?"g":_flag;var ref=_slicedToArray(useState(),2),texts=ref[0],setTexts=ref[1];var hitCls=useMemo(function(){return classNames(
|
|
1
|
+
function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr}function _iterableToArrayLimit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break}}catch(err){_d=true;_e=err}finally{try{if(!_n&&_i["return"]!=null)_i["return"]()}finally{if(_d)throw _e}}return _arr}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest()}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}import React,{useEffect,useMemo,useState}from"react";import getPrefixCls from"../get-prefix-cls";import{classNames}from"@moneko/common";import"./index.global.less";export var RegExp_HighLight=/%c:(.+?):c%/i;export function strToHighlight(text){var str=text,strArr=RegExp_HighLight.exec(str);if(strArr){var textArr=[];for(;strArr!==null;strArr=RegExp_HighLight.exec(str)){var normalText=str.substring(0,strArr.index);if(normalText.trim().length){textArr.push({text:normalText})}textArr.push({hit:true,text:strArr[1]});str=str.substring(strArr[0].length+strArr.index);normalText=null}if(str.trim().length){textArr.push({text:str})}return textArr}return null}var HighlightText=function(param){var className=param.className,style=param.style,hitStyle=param.hitStyle,hitClassName=param.hitClassName,text=param.text,highlight=param.highlight,extra=param.extra,_flag=param.flag,flag=_flag===void 0?"g":_flag;var ref=_slicedToArray(useState(),2),texts=ref[0],setTexts=ref[1];var hitCls=useMemo(function(){return classNames(getPrefixCls("hit"),hitClassName)},[hitClassName]);useEffect(function(){if(typeof text==="string"&&highlight){var str=text;if(Array.isArray(highlight)){for(var i=0,len=highlight.length;i<len;i++){var item=highlight[i];var isOne=typeof item==="string";var hitStr=isOne?item:item.highlight;var iFlag=isOne?flag:item.flag;if(hitStr.length){str=str.replace(new RegExp(hitStr,iFlag),"%c:".concat(hitStr,":c%"))}}}else if(highlight.length){str=str.replace(new RegExp(highlight,flag),"%c:".concat(highlight,":c%"))}setTexts(strToHighlight(str))}else{setTexts(null)}},[flag,highlight,text]);var hitNode=useMemo(function(){var ref;return(ref=texts===null||texts===void 0?void 0:texts.map(function(item,i){return item.hit?React.createElement("span",{key:item.text+i,className:hitCls,"data-text":item.text,style:hitStyle},item.text):item.text}))!==null&&ref!==void 0?ref:text},[hitCls,hitStyle,text,texts]);return React.createElement("div",{className:classNames(getPrefixCls("highlight-text"),className),style:style},hitNode,extra&&React.createElement("span",{className:hitCls,style:hitStyle},extra))};export default HighlightText;
|
package/es/index.d.ts
CHANGED
|
@@ -20,5 +20,11 @@ export { default as Button } from './button';
|
|
|
20
20
|
export type { ButtonProps, ButtonType } from './button';
|
|
21
21
|
export { default as Input } from './input';
|
|
22
22
|
export type { InputProps } from './input';
|
|
23
|
+
export { default as Tooltip } from './tooltip';
|
|
24
|
+
export type { TooltipProps, TooltipTriggerOption } from './tooltip';
|
|
25
|
+
export { default as ColorPalette } from './color-palette';
|
|
26
|
+
export type { ColorPaletteProps } from './color-palette';
|
|
27
|
+
export { default as AlphaPicker } from './alpha-picker';
|
|
28
|
+
export type { AlphaPickerProps } from './alpha-picker';
|
|
23
29
|
export { default as getPrefixCls } from './get-prefix-cls';
|
|
24
30
|
import './get-prefix-cls/index.less';
|
package/es/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{default as Markdown}from"./markdown";export{default as BackTop}from"./back-top";export{default as HighlightText}from"./highlight-text";export{default as useTheme}from"./use-theme";export{default as Avatar}from"./avatar";export{default as Marquee}from"./marquee";export{default as CaptureScreen}from"./capture-screen";export{default as WaveCircle}from"./wave-circle";export{default as CronEditor}from"./cron-editor";export{default as Button}from"./button";export{default as Input}from"./input";export{default as getPrefixCls}from"./get-prefix-cls";import"./get-prefix-cls/index.less";
|
|
1
|
+
export{default as Markdown}from"./markdown";export{default as BackTop}from"./back-top";export{default as HighlightText}from"./highlight-text";export{default as useTheme}from"./use-theme";export{default as Avatar}from"./avatar";export{default as Marquee}from"./marquee";export{default as CaptureScreen}from"./capture-screen";export{default as WaveCircle}from"./wave-circle";export{default as CronEditor}from"./cron-editor";export{default as Button}from"./button";export{default as Input}from"./input";export{default as Tooltip}from"./tooltip";export{default as ColorPalette}from"./color-palette";export{default as AlphaPicker}from"./alpha-picker";export{default as getPrefixCls}from"./get-prefix-cls";import"./get-prefix-cls/index.less";
|
package/es/input/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key]}}}return target};return _extends.apply(this,arguments)}function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key]}}return target}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key]}return target}import React from"react";import getPrefixCls from"../get-prefix-cls";import{classNames}from"@moneko/common";import"./index.global.less";var Input=function(_param){var className=_param.className,_type=_param.type,type=_type===void 0?"text":_type,suffix=_param.suffix,prefix=_param.prefix,value=_param.value,prpos=_objectWithoutProperties(_param,["className","type","suffix","prefix","value"]);return React.createElement("span",{className:classNames(
|
|
1
|
+
function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key]}}}return target};return _extends.apply(this,arguments)}function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key]}}return target}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key]}return target}import React from"react";import getPrefixCls from"../get-prefix-cls";import{classNames}from"@moneko/common";import"./index.global.less";var Input=function(_param){var className=_param.className,_type=_param.type,type=_type===void 0?"text":_type,suffix=_param.suffix,prefix=_param.prefix,value=_param.value,prpos=_objectWithoutProperties(_param,["className","type","suffix","prefix","value"]);return React.createElement("span",{className:classNames(getPrefixCls("input-wrapper"),getPrefixCls("input-".concat(type)),className)},prefix&&React.createElement("span",{className:getPrefixCls("input-prefix")},prefix),React.createElement("input",_extends({value:value,className:getPrefixCls("input"),type:type},prpos)),suffix&&React.createElement("span",{className:getPrefixCls("input-suffix")},suffix))};export default Input;
|
package/es/markdown/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import 'react-photo-view/dist/react-photo-view.css';
|
|
3
3
|
import './index.global.less';
|
|
4
4
|
export declare type CodeBlockToolType = Array<'copy'>;
|
|
5
|
-
export interface MarkdownProps {
|
|
5
|
+
export interface MarkdownProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
6
6
|
className?: string;
|
|
7
7
|
style?: React.CSSProperties;
|
|
8
8
|
/** md内容 */
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
@charset "utf-8";
|
|
2
2
|
|
|
3
3
|
[data-theme='dark'] {
|
|
4
|
-
--table-header-bg: #1d1d1d;
|
|
5
4
|
--table-row-hover-bg: #262626;
|
|
6
5
|
--blockquote-bg: rgba(40, 40, 40, 0.5);
|
|
7
6
|
--blockquote-icon-color: #6a483b;
|
|
@@ -228,12 +227,20 @@
|
|
|
228
227
|
}
|
|
229
228
|
|
|
230
229
|
.@{prefix-cls}-markdown-box {
|
|
231
|
-
|
|
232
|
-
|
|
230
|
+
border-radius: var(--border-radius-base, 0);
|
|
231
|
+
background-color: var(--component-background, #fff);
|
|
232
|
+
padding: 24px;
|
|
233
|
+
max-width: 1048px;
|
|
234
|
+
margin: 0 auto;
|
|
233
235
|
overflow-wrap: break-word;
|
|
234
236
|
|
|
237
|
+
transition-duration: @transition-duration;
|
|
238
|
+
transition-timing-function: @transition-timing-function;
|
|
239
|
+
transition-property: background-color;
|
|
240
|
+
|
|
235
241
|
.@{prefix-cls}-markdown-box {
|
|
236
242
|
margin: 0;
|
|
243
|
+
padding: 0;
|
|
237
244
|
}
|
|
238
245
|
|
|
239
246
|
& [data-prefix]::before {
|
|
@@ -476,7 +483,7 @@
|
|
|
476
483
|
th[role="gridcell"] {
|
|
477
484
|
padding: 10px;
|
|
478
485
|
color: var(--heading-color);
|
|
479
|
-
background-color: var(--
|
|
486
|
+
background-color: var(--border-color-base);
|
|
480
487
|
transition-property: background-color, color;
|
|
481
488
|
}
|
|
482
489
|
|
|
@@ -1151,7 +1158,7 @@ span {
|
|
|
1151
1158
|
}
|
|
1152
1159
|
}
|
|
1153
1160
|
|
|
1154
|
-
pre {
|
|
1161
|
+
pre:not(.sp-cm) {
|
|
1155
1162
|
position: relative;
|
|
1156
1163
|
display: block;
|
|
1157
1164
|
max-width: 100%;
|
|
@@ -1164,6 +1171,10 @@ pre {
|
|
|
1164
1171
|
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
|
1165
1172
|
transition-property: color, background-color, box-shadow;
|
|
1166
1173
|
|
|
1174
|
+
&:last-child {
|
|
1175
|
+
margin-bottom: 0;
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1167
1178
|
& .toolbar {
|
|
1168
1179
|
&::after {
|
|
1169
1180
|
position: absolute;
|
|
@@ -1198,9 +1209,9 @@ pre {
|
|
|
1198
1209
|
width: 4px;
|
|
1199
1210
|
height: 4px;
|
|
1200
1211
|
text-align: center;
|
|
1201
|
-
background-color: #444;
|
|
1202
1212
|
border-radius: 4px;
|
|
1203
|
-
|
|
1213
|
+
background-color: #fc625d;
|
|
1214
|
+
box-shadow: 0 0 0 4px #fc625d, 20px 0 0 4px #fdbc40, 40px 0 0 4px #35cd4b;
|
|
1204
1215
|
cursor: pointer;
|
|
1205
1216
|
content: '';
|
|
1206
1217
|
}
|
|
@@ -1300,11 +1311,6 @@ pre {
|
|
|
1300
1311
|
|
|
1301
1312
|
&:hover {
|
|
1302
1313
|
box-shadow: 0 2px 20px rgba(0, 0, 0, 0.2);
|
|
1303
|
-
|
|
1304
|
-
.toolbar::before {
|
|
1305
|
-
background-color: #fc625d;
|
|
1306
|
-
box-shadow: 0 0 0 4px #fc625d, 20px 0 0 4px #fdbc40, 40px 0 0 4px #35cd4b;
|
|
1307
|
-
}
|
|
1308
1314
|
}
|
|
1309
1315
|
}
|
|
1310
1316
|
|
|
@@ -1323,8 +1329,6 @@ pre,
|
|
|
1323
1329
|
}
|
|
1324
1330
|
@media (max-width: 1450px) {
|
|
1325
1331
|
.@{prefix-cls}-markdown-box {
|
|
1326
|
-
margin: 0 auto;
|
|
1327
|
-
|
|
1328
1332
|
> .markdown-toc {
|
|
1329
1333
|
transform: translateX(calc(100% - 10px)) translateZ(0);
|
|
1330
1334
|
|
|
@@ -1334,26 +1338,6 @@ pre,
|
|
|
1334
1338
|
}
|
|
1335
1339
|
}
|
|
1336
1340
|
}
|
|
1337
|
-
@media (max-width: 1110px) {
|
|
1338
|
-
.@{prefix-cls}-markdown-box {
|
|
1339
|
-
margin: 0 55px;
|
|
1340
|
-
}
|
|
1341
|
-
}
|
|
1342
|
-
@media (max-width: 880px) {
|
|
1343
|
-
.@{prefix-cls}-markdown-box {
|
|
1344
|
-
margin: 0 55px;
|
|
1345
|
-
}
|
|
1346
|
-
}
|
|
1347
|
-
@media (max-width: 700px) {
|
|
1348
|
-
.@{prefix-cls}-markdown-box {
|
|
1349
|
-
margin: 0 55px;
|
|
1350
|
-
}
|
|
1351
|
-
}
|
|
1352
|
-
@media (max-width: 580px) {
|
|
1353
|
-
.@{prefix-cls}-markdown-box {
|
|
1354
|
-
margin: 0 20px;
|
|
1355
|
-
}
|
|
1356
|
-
}
|
|
1357
1341
|
|
|
1358
1342
|
// pre-viewer
|
|
1359
1343
|
|
package/es/markdown/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr}function _iterableToArrayLimit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break}}catch(err){_d=true;_e=err}finally{try{if(!_n&&_i["return"]!=null)_i["return"]()}finally{if(_d)throw _e}}return _arr}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest()}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}import React,{Fragment,useCallback,useEffect,useMemo,useRef,useState}from"react";import getPrefixCls from"../get-prefix-cls";import{getScrollTop,setClipboard,classNames,isEqual,isSvgElement}from"@moneko/common";import{getMarkedImgList,markdownUtil}from"./markdown-util";import{PhotoSlider}from"react-photo-view";import"react-photo-view/dist/react-photo-view.css";import"./index.global.less";var toggleAnchor=function(anchor){var ref,ref1,ref2;(ref1=(ref=anchor.offsetParent)===null||ref===void 0?void 0:ref.querySelectorAll("li"))===null||ref1===void 0?void 0:ref1.forEach(function(a){a.classList.remove("active")});(ref2=anchor.parentElement)===null||ref2===void 0?void 0:ref2.classList.add("active")};var Markdown=function(
|
|
1
|
+
function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr}function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key]}}}return target};return _extends.apply(this,arguments)}function _iterableToArrayLimit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break}}catch(err){_d=true;_e=err}finally{try{if(!_n&&_i["return"]!=null)_i["return"]()}finally{if(_d)throw _e}}return _arr}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key]}}return target}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key]}return target}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest()}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}import React,{Fragment,useCallback,useEffect,useMemo,useRef,useState}from"react";import getPrefixCls from"../get-prefix-cls";import{getScrollTop,setClipboard,classNames,isEqual,isSvgElement}from"@moneko/common";import{getMarkedImgList,markdownUtil}from"./markdown-util";import{PhotoSlider}from"react-photo-view";import"react-photo-view/dist/react-photo-view.css";import"./index.global.less";var toggleAnchor=function(anchor){var ref,ref1,ref2;(ref1=(ref=anchor.offsetParent)===null||ref===void 0?void 0:ref.querySelectorAll("li"))===null||ref1===void 0?void 0:ref1.forEach(function(a){a.classList.remove("active")});(ref2=anchor.parentElement)===null||ref2===void 0?void 0:ref2.classList.add("active")};var Markdown=function(_param){var className=_param.className,style=_param.style,text=_param.text,_pictureViewer=_param.pictureViewer,pictureViewer=_pictureViewer===void 0?true:_pictureViewer,_langLineNumber=_param.langLineNumber,langLineNumber=_langLineNumber===void 0?true:_langLineNumber,_tools=_param.tools,tools=_tools===void 0?["copy"]:_tools,_getAnchorContainer=_param.getAnchorContainer,getAnchorContainer=_getAnchorContainer===void 0?function(){return window}:_getAnchorContainer,tex=_param.tex,props=_objectWithoutProperties(_param,["className","style","text","pictureViewer","langLineNumber","tools","getAnchorContainer","tex"]);var ref=useRef(null);var ref1=_slicedToArray(useState(false),2),visible=ref1[0],setVisible=ref1[1];var ref2=_slicedToArray(useState(0),2),photoIndex=ref2[0],setPhotoIndex=ref2[1];var ref3=_slicedToArray(useState(""),2),htmlString=ref3[0],setHtmlString=ref3[1];var ref4=_slicedToArray(useState([]),2),imgList=ref4[0],setImgList=ref4[1];var htmlStrRef=useRef(htmlString);var anchors=useRef([]);useMemo(function(){var str=htmlStrRef.current;if(text){str=markdownUtil(text,{langLineNumber:langLineNumber,langToolbar:tools})}else{str=""}if(str!==htmlStrRef.current){Object.assign(htmlStrRef,{current:str});setHtmlString(str)}},[text,langLineNumber,tools]);useEffect(function(){var timer=setTimeout(function(){window.Prism.highlightAll();if(typeof timer==="number")clearTimeout(timer)},0);if(pictureViewer){setImgList(getMarkedImgList(htmlString))}return function(){if(typeof timer==="number"){clearTimeout(timer)}}},[htmlString,pictureViewer]);var handleAnchor=function(e){var ref1,ref2,ref3;e.preventDefault();e.stopPropagation();toggleAnchor(e.target);(ref3=(ref1=ref.current)===null||ref1===void 0?void 0:ref1.querySelector(decodeURIComponent((ref2=e.target)===null||ref2===void 0?void 0:ref2.hash)))===null||ref3===void 0?void 0:ref3.scrollIntoView({behavior:"smooth",block:"center"})};useEffect(function(){var ref1,ref2;var _anchors=[];(ref2=(ref1=ref.current)===null||ref1===void 0?void 0:ref1.querySelectorAll(".markdown-toc li a"))===null||ref2===void 0?void 0:ref2.forEach(function(e){var ref1;var a=e;var _el=(ref1=ref.current)===null||ref1===void 0?void 0:ref1.querySelector(decodeURIComponent(a===null||a===void 0?void 0:a.hash));_anchors.push({anchor:a,top:_el.offsetTop});e.onclick=handleAnchor});Object.assign(anchors,{current:_anchors})},[htmlString]);var handleClick=useCallback(function(event){var target=event.target;if(isSvgElement(target))return;if(target.tagName==="IMG"&&pictureViewer){var ref1;var arr=(ref1=ref.current)===null||ref1===void 0?void 0:ref1.getElementsByTagName("img");for(var i=0,len=arr.length;i<len;i++){if(arr[i]===target){setPhotoIndex(i);setVisible(true)}}}else if(target.className.includes("toolbar-copy")){var offsetParent=target.offsetParent;if(!(offsetParent===null||offsetParent===void 0?void 0:offsetParent.hasAttribute("data-copy"))){setClipboard(offsetParent===null||offsetParent===void 0?void 0:offsetParent.innerText,offsetParent)}}},[pictureViewer]);var handleWheel=useCallback(function(event){var offsetParent=event.target.offsetParent;if(!offsetParent||offsetParent.tagName!=="PRE"){return}var rows=offsetParent===null||offsetParent===void 0?void 0:offsetParent.getElementsByClassName("line-numbers-rows");if(rows===null||rows===void 0?void 0:rows.length){var codeTag=offsetParent.getElementsByTagName("code")[0];if(codeTag.scrollHeight-codeTag.offsetHeight&&rows[0].scrollTop!==codeTag.scrollTop){rows[0].scrollTop=codeTag.scrollTop}}},[]);var handleScroll=useCallback(function(e){if(!anchors.current.length)return;var el=e.target;var top=getScrollTop(el);var anchor=null;anchors.current.forEach(function(a){if(top-a.top>-el.offsetHeight/2)anchor=a.anchor});if(anchor){toggleAnchor(anchor)}},[]);useEffect(function(){var ref;(ref=getAnchorContainer())===null||ref===void 0?void 0:ref.addEventListener("scroll",handleScroll);return function(){var ref;(ref=getAnchorContainer())===null||ref===void 0?void 0:ref.removeEventListener("scroll",handleScroll)}},[getAnchorContainer,handleScroll]);var cls=useMemo(function(){return classNames(getPrefixCls("markdown-box"),className)},[className]);useEffect(function(){if(tex){var ref1,ref2;require("katex/dist/katex.css");var katex=require("katex");(ref1=ref.current)===null||ref1===void 0?void 0:ref1.querySelectorAll(".m-katex-block").forEach(function(ele){if(ele.textContent){katex.render(ele.textContent,ele,{throwOnError:false,displayMode:true,strict:false,output:"html"})}});(ref2=ref.current)===null||ref2===void 0?void 0:ref2.querySelectorAll(".m-katex-inline").forEach(function(ele){if(ele.textContent){katex.render(ele.textContent,ele,{throwOnError:false,displayMode:false,strict:false,output:"html"})}})}},[tex,htmlString]);return React.createElement(Fragment,null,React.createElement("div",_extends({},props,{ref:ref,className:cls,style:style,dangerouslySetInnerHTML:{__html:htmlString},onClick:handleClick,onWheel:handleWheel})),imgList.length?React.createElement(PhotoSlider,{images:imgList,visible:visible,onClose:function(){return setVisible(false)},index:photoIndex,onIndexChange:setPhotoIndex}):null)};export default React.memo(Markdown,isEqual);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import marked from"marked-completed";import{entityToString}from"@moneko/common";import*as Prism from"./prism.js";marked.setOptions({highlight:function highlight(code,lang){var LANGUAGE_REGEX=/^diff-([\w-]+)/i;if(Prism.languages[lang]){return Prism.highlight(code,Prism.languages[lang],lang)}else if(LANGUAGE_REGEX.test(lang)){Prism.languages[lang]=Prism.languages.diff;return Prism.highlight(code,Prism.languages[lang],lang)}return Prism.highlight(code,Prism.languages.markup,"markup")},headerPrefix:"# ",langLineNumber:true,langToolbar:["copy"],breaks:true,pedantic:false,smartLists:true,smartypants:true,xhtml:true});export var markdownUtil=function(text,option){return marked(text,option)};export var getMarkedImgList=function(text){if(!text)return[];var imageList=text.match(/role=('|")dialog('|") src=('|")(.*?) alt=('|")(.*?)('|")/g);var imageArr=[];if(imageList){for(var i=0,len=imageList.length;i<len;i++){var params=new URLSearchParams(entityToString(imageList[i].replace(/('|")/g,"").replace(/ src=/,"&src=").replace(/ alt=/,"&alt=")));imageArr.push({intro:params.get("alt")||
|
|
1
|
+
import marked from"marked-completed";import{entityToString}from"@moneko/common";import*as Prism from"./prism.js";marked.setOptions({highlight:function highlight(code,lang){var LANGUAGE_REGEX=/^diff-([\w-]+)/i;if(Prism.languages[lang]){return Prism.highlight(code,Prism.languages[lang],lang)}else if(LANGUAGE_REGEX.test(lang)){Prism.languages[lang]=Prism.languages.diff;return Prism.highlight(code,Prism.languages[lang],lang)}return Prism.highlight(code,Prism.languages.markup,"markup")},headerPrefix:"# ",langLineNumber:true,langToolbar:["copy"],breaks:true,pedantic:false,smartLists:true,smartypants:true,xhtml:true});export var markdownUtil=function(text,option){return marked(text,option)};export var getMarkedImgList=function(text){if(!text)return[];var imageList=text.match(/role=('|")dialog('|") src=('|")(.*?) alt=('|")(.*?)('|")/g);var imageArr=[];if(imageList){for(var i=0,len=imageList.length;i<len;i++){var params=new URLSearchParams(entityToString(imageList[i].replace(/('|")/g,"").replace(/ src=/,"&src=").replace(/ alt=/,"&alt=")));imageArr.push({intro:params.get("alt")||i,src:params.get("src"),key:i})}}return imageArr};
|
package/es/tooltip/index.d.ts
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import './index.global.less';
|
|
3
|
-
export
|
|
4
|
-
|
|
3
|
+
export declare type TooltipTriggerOption = 'hover' | 'click' | 'focus' | 'contextMenu';
|
|
4
|
+
export interface TooltipProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'title'> {
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
title: React.ReactNode;
|
|
7
|
+
/** 挂载到指定的元素,值为一个返回对应 DOM 元素 默认 document.body */
|
|
8
|
+
getPopupContainer?: (node?: HTMLElement | null) => HTMLElement;
|
|
9
|
+
/** 触发行为,可使用数组设置多个触发行为 */
|
|
10
|
+
trigger?: TooltipTriggerOption | TooltipTriggerOption[];
|
|
11
|
+
visible?: boolean;
|
|
12
|
+
onVisibleChange?: (visible: boolean) => void;
|
|
13
|
+
overlayClassName?: string;
|
|
14
|
+
overlayStyle?: React.CSSProperties;
|
|
15
|
+
color?: string;
|
|
16
|
+
shadowColor?: string;
|
|
17
|
+
/** 关闭后是否销毁 Tooltip */
|
|
18
|
+
destroyInactive?: boolean;
|
|
5
19
|
}
|
|
6
|
-
declare const
|
|
7
|
-
export default
|
|
20
|
+
declare const Tooltip: React.FC<TooltipProps>;
|
|
21
|
+
export default Tooltip;
|