@feathery/react 2.4.99 → 2.4.101
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/Form/hooks/useTrackUserInteraction.d.ts +3 -0
- package/dist/Form/hooks/useTrackUserInteraction.d.ts.map +1 -0
- package/dist/Form/index.d.ts.map +1 -1
- package/dist/elements/fields/DropdownMultiField/DropdownMultiFieldSelectComponents.d.ts +9 -0
- package/dist/elements/fields/DropdownMultiField/DropdownMultiFieldSelectComponents.d.ts.map +1 -0
- package/dist/elements/fields/DropdownMultiField/createDropdownSelect.d.ts +191 -0
- package/dist/elements/fields/DropdownMultiField/createDropdownSelect.d.ts.map +1 -0
- package/dist/elements/fields/DropdownMultiField/index.d.ts.map +1 -1
- package/dist/elements/fields/DropdownMultiField/selectStyles.d.ts +13 -0
- package/dist/elements/fields/DropdownMultiField/selectStyles.d.ts.map +1 -0
- package/dist/elements/fields/DropdownMultiField/tests/test-utils.d.ts.map +1 -1
- package/dist/elements/fields/DropdownMultiField/types.d.ts +26 -0
- package/dist/elements/fields/DropdownMultiField/types.d.ts.map +1 -0
- package/dist/elements/fields/DropdownMultiField/useCollapsibleValues.d.ts +8 -0
- package/dist/elements/fields/DropdownMultiField/useCollapsibleValues.d.ts.map +1 -0
- package/dist/elements/fields/DropdownMultiField/useDropdownCollapse.d.ts +38 -0
- package/dist/elements/fields/DropdownMultiField/useDropdownCollapse.d.ts.map +1 -0
- package/dist/elements/fields/DropdownMultiField/useSelectionOrdering.d.ts +10 -0
- package/dist/elements/fields/DropdownMultiField/useSelectionOrdering.d.ts.map +1 -0
- package/dist/index.js +1 -1
- package/dist/utils/featheryClient/index.d.ts +3 -1
- package/dist/utils/featheryClient/index.d.ts.map +1 -1
- package/dist/utils/interactionState.d.ts +5 -0
- package/dist/utils/interactionState.d.ts.map +1 -0
- package/dist/utils/offlineRequestHandler.d.ts.map +1 -1
- package/package.json +1 -1
- package/umd/198.index.js +2 -0
- package/umd/198.index.js.LICENSE.txt +10 -0
- package/umd/551.index.js +1 -1
- package/umd/598.index.js +1 -1
- package/umd/index.js +1 -1
- package/umd/993.index.js +0 -2
- package/umd/993.index.js.LICENSE.txt +0 -5
package/umd/551.index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(this.webpackChunkFeathery=this.webpackChunkFeathery||[]).push([[551],{6551:(e,r,a)=>{function t(){return t=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var a=arguments[r];for(var t in a)Object.prototype.hasOwnProperty.call(a,t)&&(e[t]=a[t])}return e},t.apply(this,arguments)}function o(e,r){if(null==e)return{};var a,t,o={},n=Object.keys(e);for(t=0;t<n.length;t++)a=n[t],r.indexOf(a)>=0||(o[a]=e[a]);return o}a.r(r),a.d(r,{default:()=>_});var n=a(5430),s=255,l=100,i=e=>{var{r,g:a,b:t,a:o}=e,n=Math.max(r,a,t),i=n-Math.min(r,a,t),p=i?n===r?(a-t)/i:n===a?2+(t-r)/i:4+(r-a)/i:0;return{h:60*(p<0?p+6:p),s:n?i/n*l:0,v:n/s*l,a:o}},p=e=>{var{h:r,s:a,l:t,a:o}=c(e);return"hsla("+r+", "+a+"%, "+t+"%, "+o+")"},c=e=>{var{h:r,s:a,v:t,a:o}=e,n=(200-a)*t/l;return{h:r,s:n>0&&n<200?a*t/l/(n<=l?n:200-n)*l:0,l:n/2,a:o}},h=(Math.PI,e=>{var r,{r:a,g:t,b:o}=e;return"#"+(r=(a<<16|t<<8|o).toString(16),new Array(7-r.length).join("0")+r)}),d=e=>i(u(e)),u=e=>{var r=e.replace("#","");/^#?/.test(e)&&3===r.length&&(e="#"+r.charAt(0)+r.charAt(0)+r.charAt(1)+r.charAt(1)+r.charAt(2)+r.charAt(2));var a=new RegExp("[A-Za-z0-9]{2}","g"),[t,o,n=0,l]=e.match(a).map((e=>parseInt(e,16)));return{r:t,g:o,b:n,a:(null!=l?l:255)/s}},g=e=>{var{h:r,s:a,v:o,a:n}=e,i=r/60,p=a/l,c=o/l,h=Math.floor(i)%6,d=i-Math.floor(i),u=s*c*(1-p),g=s*c*(1-p*d),b=s*c*(1-p*(1-d));c*=s;var f={};switch(h){case 0:f.r=c,f.g=b,f.b=u;break;case 1:f.r=g,f.g=c,f.b=u;break;case 2:f.r=u,f.g=c,f.b=b;break;case 3:f.r=u,f.g=g,f.b=c;break;case 4:f.r=b,f.g=u,f.b=c;break;case 5:f.r=c,f.g=u,f.b=g}return f.r=Math.round(f.r),f.g=Math.round(f.g),f.b=Math.round(f.b),t({},f,{a:n})},b=e=>{var{r,g:a,b:t,a:o}=g(e);return"rgba("+r+", "+a+", "+t+", "+o+")"},f=e=>h(g(e)),v=e=>{var r,a,t,o,n,s,l,i,p;return"string"==typeof e&&x(e)?(s=d(e),i=e):"string"!=typeof e&&(s=e),s&&(t=(e=>{var{h:r,s:a,v:t}=e;return{h:r,s:a,v:t}})(s),n=c(s),p=(e=>{var{r,g:a,b:t,a:o}=e,n="number"==typeof o&&(255*o|256).toString(16).slice(1);return""+h({r,g:a,b:t})+(n||"")})(o=g(s)),i=f(s),a=(e=>{var{h:r,s:a,l:t}=e;return{h:r,s:a,l:t}})(n),l=(e=>{var{r,g:a,b:t}=e,o=function(e){return e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)},n=o(r/255),s=o(a/255),l=o(t/255),i={};return i.x=.4124*n+.3576*s+.1805*l,i.y=.2126*n+.7152*s+.0722*l,i.bri=.0193*n+.1192*s+.9505*l,i})(r=(e=>{var{r,g:a,b:t}=e;return{r,g:a,b:t}})(o))),{rgb:r,hsl:a,hsv:t,rgba:o,hsla:n,hsva:s,hex:i,hexa:p,xy:l}},x=e=>/^#?([A-Fa-f0-9]{3,4}){1,2}$/.test(e);function m(e){var r=(0,n.useRef)(e);return(0,n.useEffect)((()=>{r.current=e})),(0,n.useCallback)(((e,a)=>r.current&&r.current(e,a)),[])}var w=e=>"touches"in e,y=e=>{!w(e)&&e.preventDefault&&e.preventDefault()},C=function(e,r,a){return void 0===r&&(r=0),void 0===a&&(a=1),e>a?a:e<r?r:e},A=(e,r)=>{var a=e.getBoundingClientRect(),t=w(r)?r.touches[0]:r;return{left:C((t.pageX-(a.left+window.pageXOffset))/a.width),top:C((t.pageY-(a.top+window.pageYOffset))/a.height),width:a.width,height:a.height,x:t.pageX-(a.left+window.pageXOffset),y:t.pageY-(a.top+window.pageYOffset)}},k=a(2750),j=["prefixCls","className","onMove","onDown"],N=n.forwardRef(((e,r)=>{var{prefixCls:a="w-color-interactive",className:s,onMove:l,onDown:i}=e,p=o(e,j),c=(0,n.useRef)(null),h=(0,n.useRef)(!1),[d,u]=(0,n.useState)(!1),g=m(l),b=m(i),f=(0,n.useCallback)((e=>{y(e),c.current&&((w(e)?e.touches.length>0:e.buttons>0)?null==g||g(A(c.current,e),e):u(!1))}),[g]),v=(0,n.useCallback)((()=>u(!1)),[]),x=(0,n.useCallback)((e=>{e?(window.addEventListener(h.current?"touchmove":"mousemove",f),window.addEventListener(h.current?"touchend":"mouseup",v)):(window.removeEventListener("mousemove",f),window.removeEventListener("mouseup",v),window.removeEventListener("touchmove",f),window.removeEventListener("touchend",v))}),[f,v]);(0,n.useEffect)((()=>(x(d),()=>{x(!1)})),[d,f,v,x]);var C=(0,n.useCallback)((e=>{y(e.nativeEvent),(e=>!(h.current&&!w(e)||(h.current=w(e),0)))(e.nativeEvent)&&c.current&&(null==b||b(A(c.current,e.nativeEvent),e.nativeEvent),u(!0))}),[b]);return(0,k.jsx)("div",t({},p,{className:[a,s||""].filter(Boolean).join(" "),style:t({},p.style,{touchAction:"none"}),ref:c,tabIndex:0,onMouseDown:C,onTouchStart:C}))}));N.displayName="Interactive";const R=N;var B=e=>{var{className:r,color:a,left:t,top:o,prefixCls:s}=e,l={position:"absolute",top:o,left:t},i={"--saturation-pointer-box-shadow":"rgb(255 255 255) 0px 0px 0px 1.5px, rgb(0 0 0 / 30%) 0px 0px 1px 1px inset, rgb(0 0 0 / 40%) 0px 0px 1px 2px",width:6,height:6,transform:"translate(-3px, -3px)",boxShadow:"var(--saturation-pointer-box-shadow)",borderRadius:"50%",backgroundColor:a};return(0,n.useMemo)((()=>(0,k.jsx)("div",{className:s+"-pointer "+(r||""),style:l,children:(0,k.jsx)("div",{className:s+"-fill",style:i})})),[o,t,a,r,s])},E=["prefixCls","radius","pointer","className","hue","style","hsva","onChange"],S=n.forwardRef(((e,r)=>{var a,{prefixCls:s="w-color-saturation",radius:l=0,pointer:i,className:c,hue:h=0,style:d,hsva:u,onChange:g}=e,b=o(e,E),f=t({width:200,height:200,borderRadius:l},d,{position:"relative"}),v=(e,r)=>{g&&u&&g({h:u.h,s:100*e.left,v:100*(1-e.top),a:u.a})},x=(0,n.useMemo)((()=>{if(!u)return null;var e={top:100-u.v+"%",left:u.s+"%",color:p(u)};return i&&"function"==typeof i?i(t({prefixCls:s},e)):(0,k.jsx)(B,t({prefixCls:s},e))}),[u,i,s]);return(0,k.jsx)(R,t({className:[s,c||""].filter(Boolean).join(" ")},b,{style:t({position:"absolute",inset:0,cursor:"crosshair",backgroundImage:"linear-gradient(0deg, #000, transparent), linear-gradient(90deg, #fff, hsl("+(null!=(a=null==u?void 0:u.h)?a:h)+", 100%, 50%))"},f),ref:r,onMove:v,onDown:v,children:x}))}));S.displayName="Saturation";const P=S;var L=["className","prefixCls","left","top","style","fillProps"],D=e=>{var{className:r,prefixCls:a,left:n,top:s,style:l,fillProps:i}=e,p=o(e,L),c=t({},l,{position:"absolute",left:n,top:s}),h=t({width:18,height:18,boxShadow:"var(--alpha-pointer-box-shadow)",borderRadius:"50%",backgroundColor:"var(--alpha-pointer-background-color)"},null==i?void 0:i.style,{transform:n?"translate(-9px, -1px)":"translate(-1px, -9px)"});return(0,k.jsx)("div",t({className:a+"-pointer "+(r||""),style:c},p,{children:(0,k.jsx)("div",t({className:a+"-fill"},i,{style:h}))}))},M=["prefixCls","className","hsva","background","bgProps","innerProps","pointerProps","radius","width","height","direction","style","onChange","pointer"],z=n.forwardRef(((e,r)=>{var{prefixCls:a="w-color-alpha",className:n,hsva:s,background:l,bgProps:i={},innerProps:c={},pointerProps:h={},radius:d=0,width:u,height:g=16,direction:b="horizontal",style:f,onChange:v,pointer:x}=e,m=o(e,M),w=e=>{v&&v(t({},s,{a:"horizontal"===b?e.left:e.top}),e)},y=p(Object.assign({},s,{a:1})),C="linear-gradient(to "+("horizontal"===b?"right":"bottom")+", rgba(244, 67, 54, 0) 0%, "+y+" 100%)",A={};"horizontal"===b?A.left=100*s.a+"%":A.top=100*s.a+"%";var j=t({"--alpha-background-color":"#fff","--alpha-pointer-background-color":"rgb(248, 248, 248)","--alpha-pointer-box-shadow":"rgb(0 0 0 / 37%) 0px 1px 4px 0px",borderRadius:d,background:"url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAMUlEQVQ4T2NkYGAQYcAP3uCTZhw1gGGYhAGBZIA/nYDCgBDAm9BGDWAAJyRCgLaBCAAgXwixzAS0pgAAAABJRU5ErkJggg==) left center",backgroundColor:"var(--alpha-background-color)"},{width:u,height:g},f,{position:"relative"}),N=x&&"function"==typeof x?x(t({prefixCls:a},h,A)):(0,k.jsx)(D,t({},h,{prefixCls:a},A));return(0,k.jsxs)("div",t({},m,{className:[a,a+"-"+b,n||""].filter(Boolean).join(" "),style:j,ref:r,children:[(0,k.jsx)("div",t({},i,{style:t({inset:0,position:"absolute",background:l||C,borderRadius:d},i.style)})),(0,k.jsx)(R,t({},c,{style:t({},c.style,{inset:0,zIndex:1,position:"absolute"}),onMove:w,onDown:w,children:N}))]}))}));z.displayName="Alpha";const F=z;var I=["prefixCls","placement","label","value","className","style","labelStyle","inputStyle","onChange","onBlur","renderInput"],O=n.forwardRef(((e,r)=>{var{prefixCls:a="w-color-editable-input",placement:s="bottom",label:l,value:i,className:p,style:c,labelStyle:h,inputStyle:d,onChange:u,onBlur:g,renderInput:b}=e,f=o(e,I),[v,x]=(0,n.useState)(i),m=(0,n.useRef)(!1);(0,n.useEffect)((()=>{e.value!==v&&(m.current||x(e.value))}),[e.value]);var w={};"bottom"===s&&(w.flexDirection="column"),"top"===s&&(w.flexDirection="column-reverse"),"left"===s&&(w.flexDirection="row-reverse");var y=t({"--editable-input-label-color":"rgb(153, 153, 153)","--editable-input-box-shadow":"rgb(204 204 204) 0px 0px 0px 1px inset","--editable-input-color":"#666",position:"relative",alignItems:"center",display:"flex",fontSize:11},w,c),C=t({width:"100%",paddingTop:2,paddingBottom:2,paddingLeft:3,paddingRight:3,fontSize:11,background:"transparent",boxSizing:"border-box",border:"none",color:"var(--editable-input-color)",boxShadow:"var(--editable-input-box-shadow)"},d),A=t({value:v,onChange:function(e,r){var a=(r||e.target.value).trim().replace(/^#/,"");/^#?([A-Fa-f0-9]{3,4}){1,2}$/.test(a)&&u&&u(e,a);var t=(e=>Number(String(e).replace(/%/g,"")))(a);isNaN(t)||u&&u(e,t),x(a)},onBlur:function(r){m.current=!1,x(e.value),g&&g(r)},autoComplete:"off",onFocus:()=>m.current=!0},f,{style:C});return(0,k.jsxs)("div",{className:[a,p||""].filter(Boolean).join(" "),style:y,children:[b?b(A,r):(0,k.jsx)("input",t({ref:r},A)),l&&(0,k.jsx)("span",{style:t({color:"var(--editable-input-label-color)",textTransform:"capitalize"},h),children:l})]})}));O.displayName="EditableInput";const T=O;var Y=["prefixCls","hsva","placement","rProps","gProps","bProps","aProps","className","style","onChange"],G=n.forwardRef(((e,r)=>{var{prefixCls:a="w-color-editable-input-rgba",hsva:n,placement:s="bottom",rProps:l={},gProps:p={},bProps:c={},aProps:h={},className:d,style:u,onChange:b}=e,f=o(e,Y),x=n?g(n):{};function m(e){var r=Number(e.target.value);r&&r>255&&(e.target.value="255"),r&&r<0&&(e.target.value="0")}var w=(e,r,a)=>{"number"==typeof e&&("a"===r&&(e<0&&(e=0),e>100&&(e=100),b&&b(v(i(t({},x,{a:e/100}))))),e>255&&(e=255,a.target.value="255"),e<0&&(e=0,a.target.value="0"),"r"===r&&b&&b(v(i(t({},x,{r:e})))),"g"===r&&b&&b(v(i(t({},x,{g:e})))),"b"===r&&b&&b(v(i(t({},x,{b:e})))))};return(0,k.jsxs)("div",t({ref:r,className:[a,d||""].filter(Boolean).join(" ")},f,{style:t({fontSize:11,display:"flex"},u),children:[(0,k.jsx)(T,t({label:"R",value:x.r||0,onBlur:m,placement:s,onChange:(e,r)=>w(r,"r",e)},l,{style:t({},l.style)})),(0,k.jsx)(T,t({label:"G",value:x.g||0,onBlur:m,placement:s,onChange:(e,r)=>w(r,"g",e)},p,{style:t({marginLeft:5},l.style)})),(0,k.jsx)(T,t({label:"B",value:x.b||0,onBlur:m,placement:s,onChange:(e,r)=>w(r,"b",e)},c,{style:t({marginLeft:5},c.style)})),h&&(0,k.jsx)(T,t({label:"A",value:x.a?parseInt(String(100*x.a),10):0,onBlur:m,placement:s,onChange:(e,r)=>w(r,"a",e)},h,{style:t({marginLeft:5},h.style)}))]}))}));G.displayName="EditableInputRGBA";const U=G;var V=["prefixCls","className","hue","onChange","direction"],X=n.forwardRef(((e,r)=>{var{prefixCls:a="w-color-hue",className:n,hue:s=0,onChange:l,direction:i="horizontal"}=e,p=o(e,V);return(0,k.jsx)(F,t({ref:r,className:a+" "+(n||"")},p,{direction:i,background:"linear-gradient(to "+("horizontal"===i?"right":"bottom")+", rgb(255, 0, 0) 0%, rgb(255, 255, 0) 17%, rgb(0, 255, 0) 33%, rgb(0, 255, 255) 50%, rgb(0, 0, 255) 67%, rgb(255, 0, 255) 83%, rgb(255, 0, 0) 100%)",hsva:{h:s,s:100,v:100,a:s/360},onChange:(e,r)=>{l&&l({h:"horizontal"===i?360*r.left:360*r.top})}}))}));X.displayName="Hue";const Q=X;var J=["prefixCls","className","color","colors","style","rectProps","onChange","addonAfter","addonBefore","rectRender"],W=n.forwardRef(((e,r)=>{var{prefixCls:a="w-color-swatch",className:s,color:l,colors:i=[],style:p,rectProps:c={},onChange:h,addonAfter:u,addonBefore:g,rectRender:b}=e,f=o(e,J),x=t({"--swatch-background-color":"rgb(144, 19, 254)",background:"var(--swatch-background-color)",height:15,width:15,marginRight:5,marginBottom:5,cursor:"pointer",position:"relative",outline:"none",borderRadius:2},c.style),m=(e,r)=>{h&&h(d(e),v(d(e)),r)};return(0,k.jsxs)("div",t({ref:r},f,{className:[a,s||""].filter(Boolean).join(" "),style:t({display:"flex",flexWrap:"wrap",position:"relative"},p),children:[g&&n.isValidElement(g)&&g,i&&Array.isArray(i)&&i.map(((e,r)=>{var a="",o="";"string"==typeof e&&(a=e,o=e),"object"==typeof e&&e.color&&(a=e.title||e.color,o=e.color);var s=l&&l.toLocaleLowerCase()===o.toLocaleLowerCase(),i=b&&b({title:a,color:o,checked:!!s,style:t({},x,{background:o}),onClick:e=>m(o,e)});if(i)return(0,k.jsx)(n.Fragment,{children:i},r);var p=c.children&&n.isValidElement(c.children)?n.cloneElement(c.children,{color:o,checked:s}):null;return(0,k.jsx)("div",t({tabIndex:0,title:a,onClick:e=>m(o,e)},c,{children:p,style:t({},x,{background:o})}),r)})),u&&n.isValidElement(u)&&u]}))}));W.displayName="Swatch";const Z=W;var H=["prefixCls","className","onChange","width","presetColors","color","editableDisable","disableAlpha","style"],$=["#D0021B","#F5A623","#f8e61b","#8B572A","#7ED321","#417505","#BD10E0","#9013FE","#4A90E2","#50E3C2","#B8E986","#000000","#4A4A4A","#9B9B9B","#FFFFFF"],K=e=>(0,k.jsx)("div",{style:{boxShadow:"rgb(0 0 0 / 60%) 0px 0px 2px",width:4,top:1,bottom:1,left:e.left,borderRadius:1,position:"absolute",backgroundColor:"#fff"}}),q=n.forwardRef(((e,r)=>{var{prefixCls:a="w-color-sketch",className:s,onChange:l,width:i=218,presetColors:p=$,color:c,editableDisable:h=!0,disableAlpha:u=!1,style:g}=e,m=o(e,H),[w,y]=(0,n.useState)({h:209,s:36,v:90,a:1});(0,n.useEffect)((()=>{"string"==typeof c&&x(c)&&y(d(c)),"object"==typeof c&&y(c)}),[c]);var C=e=>{y(e),l&&l(v(e))},A=t({"--sketch-background":"rgb(255, 255, 255)","--sketch-box-shadow":"rgb(0 0 0 / 15%) 0px 0px 0px 1px, rgb(0 0 0 / 15%) 0px 8px 16px","--sketch-swatch-box-shadow":"rgb(0 0 0 / 15%) 0px 0px 0px 1px inset","--sketch-alpha-box-shadow":"rgb(0 0 0 / 15%) 0px 0px 0px 1px inset, rgb(0 0 0 / 25%) 0px 0px 4px inset","--sketch-swatch-border-top":"1px solid rgb(238, 238, 238)",background:"var(--sketch-background)",borderRadius:4,boxShadow:"var(--sketch-box-shadow)",width:i},g),j={borderRadius:2,background:b(w),boxShadow:"var(--sketch-alpha-box-shadow)"};return(0,k.jsxs)("div",t({},m,{className:a+" "+(s||""),ref:r,style:A,children:[(0,k.jsxs)("div",{style:{padding:"10px 10px 8px"},children:[(0,k.jsx)(P,{hsva:w,style:{width:"auto",height:150},onChange:e=>C(t({},w,e,{a:w.a}))}),(0,k.jsxs)("div",{style:{display:"flex",marginTop:4},children:[(0,k.jsxs)("div",{style:{flex:1},children:[(0,k.jsx)(Q,{width:"auto",height:10,hue:w.h,pointer:K,innerProps:{style:{marginLeft:1,marginRight:5}},onChange:e=>C(t({},w,e))}),!u&&(0,k.jsx)(F,{width:"auto",height:10,hsva:w,pointer:K,style:{marginTop:4},innerProps:{style:{marginLeft:1,marginRight:5}},onChange:e=>C(t({},w,{a:e.a}))})]}),!u&&(0,k.jsx)(F,{width:24,height:24,hsva:w,radius:2,style:{marginLeft:4},bgProps:{style:{background:"transparent"}},innerProps:{style:j},pointer:()=>(0,k.jsx)(n.Fragment,{})})]})]}),h&&(0,k.jsxs)("div",{style:{display:"flex",margin:"0 10px 3px 10px"},children:[(0,k.jsx)(T,{label:"Hex",value:f(w).replace(/^#/,"").toLocaleUpperCase(),onChange:(e,r)=>{var a;"string"==typeof(a=r)&&x(a)&&/(3|6)/.test(String(a.length))&&C(d(a))},style:{minWidth:58}}),(0,k.jsx)(U,{hsva:w,style:{marginLeft:6},aProps:!u&&{},onChange:e=>C(e.hsva)})]}),p&&p.length>0&&(0,k.jsx)(Z,{style:{borderTop:"var(--sketch-swatch-border-top)",paddingTop:10,paddingLeft:10},colors:p,color:f(w),onChange:e=>C(e),rectProps:{style:{marginRight:10,marginBottom:10,borderRadius:3,boxShadow:"var(--sketch-swatch-box-shadow)"}}})]}))}));q.displayName="Sketch";const _=q}}]);
|
|
1
|
+
"use strict";(this.webpackChunkFeathery=this.webpackChunkFeathery||[]).push([[551],{6551:(e,r,a)=>{function t(){return t=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var a=arguments[r];for(var t in a)Object.prototype.hasOwnProperty.call(a,t)&&(e[t]=a[t])}return e},t.apply(this,arguments)}function o(e,r){if(null==e)return{};var a,t,o={},n=Object.keys(e);for(t=0;t<n.length;t++)a=n[t],r.indexOf(a)>=0||(o[a]=e[a]);return o}a.r(r),a.d(r,{default:()=>_});var n=a(7294),s=255,l=100,i=e=>{var{r,g:a,b:t,a:o}=e,n=Math.max(r,a,t),i=n-Math.min(r,a,t),p=i?n===r?(a-t)/i:n===a?2+(t-r)/i:4+(r-a)/i:0;return{h:60*(p<0?p+6:p),s:n?i/n*l:0,v:n/s*l,a:o}},p=e=>{var{h:r,s:a,l:t,a:o}=c(e);return"hsla("+r+", "+a+"%, "+t+"%, "+o+")"},c=e=>{var{h:r,s:a,v:t,a:o}=e,n=(200-a)*t/l;return{h:r,s:n>0&&n<200?a*t/l/(n<=l?n:200-n)*l:0,l:n/2,a:o}},h=(Math.PI,e=>{var r,{r:a,g:t,b:o}=e;return"#"+(r=(a<<16|t<<8|o).toString(16),new Array(7-r.length).join("0")+r)}),d=e=>i(u(e)),u=e=>{var r=e.replace("#","");/^#?/.test(e)&&3===r.length&&(e="#"+r.charAt(0)+r.charAt(0)+r.charAt(1)+r.charAt(1)+r.charAt(2)+r.charAt(2));var a=new RegExp("[A-Za-z0-9]{2}","g"),[t,o,n=0,l]=e.match(a).map((e=>parseInt(e,16)));return{r:t,g:o,b:n,a:(null!=l?l:255)/s}},g=e=>{var{h:r,s:a,v:o,a:n}=e,i=r/60,p=a/l,c=o/l,h=Math.floor(i)%6,d=i-Math.floor(i),u=s*c*(1-p),g=s*c*(1-p*d),b=s*c*(1-p*(1-d));c*=s;var f={};switch(h){case 0:f.r=c,f.g=b,f.b=u;break;case 1:f.r=g,f.g=c,f.b=u;break;case 2:f.r=u,f.g=c,f.b=b;break;case 3:f.r=u,f.g=g,f.b=c;break;case 4:f.r=b,f.g=u,f.b=c;break;case 5:f.r=c,f.g=u,f.b=g}return f.r=Math.round(f.r),f.g=Math.round(f.g),f.b=Math.round(f.b),t({},f,{a:n})},b=e=>{var{r,g:a,b:t,a:o}=g(e);return"rgba("+r+", "+a+", "+t+", "+o+")"},f=e=>h(g(e)),v=e=>{var r,a,t,o,n,s,l,i,p;return"string"==typeof e&&x(e)?(s=d(e),i=e):"string"!=typeof e&&(s=e),s&&(t=(e=>{var{h:r,s:a,v:t}=e;return{h:r,s:a,v:t}})(s),n=c(s),p=(e=>{var{r,g:a,b:t,a:o}=e,n="number"==typeof o&&(255*o|256).toString(16).slice(1);return""+h({r,g:a,b:t})+(n||"")})(o=g(s)),i=f(s),a=(e=>{var{h:r,s:a,l:t}=e;return{h:r,s:a,l:t}})(n),l=(e=>{var{r,g:a,b:t}=e,o=function(e){return e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)},n=o(r/255),s=o(a/255),l=o(t/255),i={};return i.x=.4124*n+.3576*s+.1805*l,i.y=.2126*n+.7152*s+.0722*l,i.bri=.0193*n+.1192*s+.9505*l,i})(r=(e=>{var{r,g:a,b:t}=e;return{r,g:a,b:t}})(o))),{rgb:r,hsl:a,hsv:t,rgba:o,hsla:n,hsva:s,hex:i,hexa:p,xy:l}},x=e=>/^#?([A-Fa-f0-9]{3,4}){1,2}$/.test(e);function m(e){var r=(0,n.useRef)(e);return(0,n.useEffect)((()=>{r.current=e})),(0,n.useCallback)(((e,a)=>r.current&&r.current(e,a)),[])}var w=e=>"touches"in e,y=e=>{!w(e)&&e.preventDefault&&e.preventDefault()},C=function(e,r,a){return void 0===r&&(r=0),void 0===a&&(a=1),e>a?a:e<r?r:e},A=(e,r)=>{var a=e.getBoundingClientRect(),t=w(r)?r.touches[0]:r;return{left:C((t.pageX-(a.left+window.pageXOffset))/a.width),top:C((t.pageY-(a.top+window.pageYOffset))/a.height),width:a.width,height:a.height,x:t.pageX-(a.left+window.pageXOffset),y:t.pageY-(a.top+window.pageYOffset)}},k=a(5893),j=["prefixCls","className","onMove","onDown"],N=n.forwardRef(((e,r)=>{var{prefixCls:a="w-color-interactive",className:s,onMove:l,onDown:i}=e,p=o(e,j),c=(0,n.useRef)(null),h=(0,n.useRef)(!1),[d,u]=(0,n.useState)(!1),g=m(l),b=m(i),f=(0,n.useCallback)((e=>{y(e),c.current&&((w(e)?e.touches.length>0:e.buttons>0)?null==g||g(A(c.current,e),e):u(!1))}),[g]),v=(0,n.useCallback)((()=>u(!1)),[]),x=(0,n.useCallback)((e=>{e?(window.addEventListener(h.current?"touchmove":"mousemove",f),window.addEventListener(h.current?"touchend":"mouseup",v)):(window.removeEventListener("mousemove",f),window.removeEventListener("mouseup",v),window.removeEventListener("touchmove",f),window.removeEventListener("touchend",v))}),[f,v]);(0,n.useEffect)((()=>(x(d),()=>{x(!1)})),[d,f,v,x]);var C=(0,n.useCallback)((e=>{y(e.nativeEvent),(e=>!(h.current&&!w(e)||(h.current=w(e),0)))(e.nativeEvent)&&c.current&&(null==b||b(A(c.current,e.nativeEvent),e.nativeEvent),u(!0))}),[b]);return(0,k.jsx)("div",t({},p,{className:[a,s||""].filter(Boolean).join(" "),style:t({},p.style,{touchAction:"none"}),ref:c,tabIndex:0,onMouseDown:C,onTouchStart:C}))}));N.displayName="Interactive";const R=N;var B=e=>{var{className:r,color:a,left:t,top:o,prefixCls:s}=e,l={position:"absolute",top:o,left:t},i={"--saturation-pointer-box-shadow":"rgb(255 255 255) 0px 0px 0px 1.5px, rgb(0 0 0 / 30%) 0px 0px 1px 1px inset, rgb(0 0 0 / 40%) 0px 0px 1px 2px",width:6,height:6,transform:"translate(-3px, -3px)",boxShadow:"var(--saturation-pointer-box-shadow)",borderRadius:"50%",backgroundColor:a};return(0,n.useMemo)((()=>(0,k.jsx)("div",{className:s+"-pointer "+(r||""),style:l,children:(0,k.jsx)("div",{className:s+"-fill",style:i})})),[o,t,a,r,s])},E=["prefixCls","radius","pointer","className","hue","style","hsva","onChange"],S=n.forwardRef(((e,r)=>{var a,{prefixCls:s="w-color-saturation",radius:l=0,pointer:i,className:c,hue:h=0,style:d,hsva:u,onChange:g}=e,b=o(e,E),f=t({width:200,height:200,borderRadius:l},d,{position:"relative"}),v=(e,r)=>{g&&u&&g({h:u.h,s:100*e.left,v:100*(1-e.top),a:u.a})},x=(0,n.useMemo)((()=>{if(!u)return null;var e={top:100-u.v+"%",left:u.s+"%",color:p(u)};return i&&"function"==typeof i?i(t({prefixCls:s},e)):(0,k.jsx)(B,t({prefixCls:s},e))}),[u,i,s]);return(0,k.jsx)(R,t({className:[s,c||""].filter(Boolean).join(" ")},b,{style:t({position:"absolute",inset:0,cursor:"crosshair",backgroundImage:"linear-gradient(0deg, #000, transparent), linear-gradient(90deg, #fff, hsl("+(null!=(a=null==u?void 0:u.h)?a:h)+", 100%, 50%))"},f),ref:r,onMove:v,onDown:v,children:x}))}));S.displayName="Saturation";const P=S;var L=["className","prefixCls","left","top","style","fillProps"],D=e=>{var{className:r,prefixCls:a,left:n,top:s,style:l,fillProps:i}=e,p=o(e,L),c=t({},l,{position:"absolute",left:n,top:s}),h=t({width:18,height:18,boxShadow:"var(--alpha-pointer-box-shadow)",borderRadius:"50%",backgroundColor:"var(--alpha-pointer-background-color)"},null==i?void 0:i.style,{transform:n?"translate(-9px, -1px)":"translate(-1px, -9px)"});return(0,k.jsx)("div",t({className:a+"-pointer "+(r||""),style:c},p,{children:(0,k.jsx)("div",t({className:a+"-fill"},i,{style:h}))}))},M=["prefixCls","className","hsva","background","bgProps","innerProps","pointerProps","radius","width","height","direction","style","onChange","pointer"],z=n.forwardRef(((e,r)=>{var{prefixCls:a="w-color-alpha",className:n,hsva:s,background:l,bgProps:i={},innerProps:c={},pointerProps:h={},radius:d=0,width:u,height:g=16,direction:b="horizontal",style:f,onChange:v,pointer:x}=e,m=o(e,M),w=e=>{v&&v(t({},s,{a:"horizontal"===b?e.left:e.top}),e)},y=p(Object.assign({},s,{a:1})),C="linear-gradient(to "+("horizontal"===b?"right":"bottom")+", rgba(244, 67, 54, 0) 0%, "+y+" 100%)",A={};"horizontal"===b?A.left=100*s.a+"%":A.top=100*s.a+"%";var j=t({"--alpha-background-color":"#fff","--alpha-pointer-background-color":"rgb(248, 248, 248)","--alpha-pointer-box-shadow":"rgb(0 0 0 / 37%) 0px 1px 4px 0px",borderRadius:d,background:"url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAMUlEQVQ4T2NkYGAQYcAP3uCTZhw1gGGYhAGBZIA/nYDCgBDAm9BGDWAAJyRCgLaBCAAgXwixzAS0pgAAAABJRU5ErkJggg==) left center",backgroundColor:"var(--alpha-background-color)"},{width:u,height:g},f,{position:"relative"}),N=x&&"function"==typeof x?x(t({prefixCls:a},h,A)):(0,k.jsx)(D,t({},h,{prefixCls:a},A));return(0,k.jsxs)("div",t({},m,{className:[a,a+"-"+b,n||""].filter(Boolean).join(" "),style:j,ref:r,children:[(0,k.jsx)("div",t({},i,{style:t({inset:0,position:"absolute",background:l||C,borderRadius:d},i.style)})),(0,k.jsx)(R,t({},c,{style:t({},c.style,{inset:0,zIndex:1,position:"absolute"}),onMove:w,onDown:w,children:N}))]}))}));z.displayName="Alpha";const F=z;var I=["prefixCls","placement","label","value","className","style","labelStyle","inputStyle","onChange","onBlur","renderInput"],O=n.forwardRef(((e,r)=>{var{prefixCls:a="w-color-editable-input",placement:s="bottom",label:l,value:i,className:p,style:c,labelStyle:h,inputStyle:d,onChange:u,onBlur:g,renderInput:b}=e,f=o(e,I),[v,x]=(0,n.useState)(i),m=(0,n.useRef)(!1);(0,n.useEffect)((()=>{e.value!==v&&(m.current||x(e.value))}),[e.value]);var w={};"bottom"===s&&(w.flexDirection="column"),"top"===s&&(w.flexDirection="column-reverse"),"left"===s&&(w.flexDirection="row-reverse");var y=t({"--editable-input-label-color":"rgb(153, 153, 153)","--editable-input-box-shadow":"rgb(204 204 204) 0px 0px 0px 1px inset","--editable-input-color":"#666",position:"relative",alignItems:"center",display:"flex",fontSize:11},w,c),C=t({width:"100%",paddingTop:2,paddingBottom:2,paddingLeft:3,paddingRight:3,fontSize:11,background:"transparent",boxSizing:"border-box",border:"none",color:"var(--editable-input-color)",boxShadow:"var(--editable-input-box-shadow)"},d),A=t({value:v,onChange:function(e,r){var a=(r||e.target.value).trim().replace(/^#/,"");/^#?([A-Fa-f0-9]{3,4}){1,2}$/.test(a)&&u&&u(e,a);var t=(e=>Number(String(e).replace(/%/g,"")))(a);isNaN(t)||u&&u(e,t),x(a)},onBlur:function(r){m.current=!1,x(e.value),g&&g(r)},autoComplete:"off",onFocus:()=>m.current=!0},f,{style:C});return(0,k.jsxs)("div",{className:[a,p||""].filter(Boolean).join(" "),style:y,children:[b?b(A,r):(0,k.jsx)("input",t({ref:r},A)),l&&(0,k.jsx)("span",{style:t({color:"var(--editable-input-label-color)",textTransform:"capitalize"},h),children:l})]})}));O.displayName="EditableInput";const T=O;var Y=["prefixCls","hsva","placement","rProps","gProps","bProps","aProps","className","style","onChange"],G=n.forwardRef(((e,r)=>{var{prefixCls:a="w-color-editable-input-rgba",hsva:n,placement:s="bottom",rProps:l={},gProps:p={},bProps:c={},aProps:h={},className:d,style:u,onChange:b}=e,f=o(e,Y),x=n?g(n):{};function m(e){var r=Number(e.target.value);r&&r>255&&(e.target.value="255"),r&&r<0&&(e.target.value="0")}var w=(e,r,a)=>{"number"==typeof e&&("a"===r&&(e<0&&(e=0),e>100&&(e=100),b&&b(v(i(t({},x,{a:e/100}))))),e>255&&(e=255,a.target.value="255"),e<0&&(e=0,a.target.value="0"),"r"===r&&b&&b(v(i(t({},x,{r:e})))),"g"===r&&b&&b(v(i(t({},x,{g:e})))),"b"===r&&b&&b(v(i(t({},x,{b:e})))))};return(0,k.jsxs)("div",t({ref:r,className:[a,d||""].filter(Boolean).join(" ")},f,{style:t({fontSize:11,display:"flex"},u),children:[(0,k.jsx)(T,t({label:"R",value:x.r||0,onBlur:m,placement:s,onChange:(e,r)=>w(r,"r",e)},l,{style:t({},l.style)})),(0,k.jsx)(T,t({label:"G",value:x.g||0,onBlur:m,placement:s,onChange:(e,r)=>w(r,"g",e)},p,{style:t({marginLeft:5},l.style)})),(0,k.jsx)(T,t({label:"B",value:x.b||0,onBlur:m,placement:s,onChange:(e,r)=>w(r,"b",e)},c,{style:t({marginLeft:5},c.style)})),h&&(0,k.jsx)(T,t({label:"A",value:x.a?parseInt(String(100*x.a),10):0,onBlur:m,placement:s,onChange:(e,r)=>w(r,"a",e)},h,{style:t({marginLeft:5},h.style)}))]}))}));G.displayName="EditableInputRGBA";const U=G;var V=["prefixCls","className","hue","onChange","direction"],X=n.forwardRef(((e,r)=>{var{prefixCls:a="w-color-hue",className:n,hue:s=0,onChange:l,direction:i="horizontal"}=e,p=o(e,V);return(0,k.jsx)(F,t({ref:r,className:a+" "+(n||"")},p,{direction:i,background:"linear-gradient(to "+("horizontal"===i?"right":"bottom")+", rgb(255, 0, 0) 0%, rgb(255, 255, 0) 17%, rgb(0, 255, 0) 33%, rgb(0, 255, 255) 50%, rgb(0, 0, 255) 67%, rgb(255, 0, 255) 83%, rgb(255, 0, 0) 100%)",hsva:{h:s,s:100,v:100,a:s/360},onChange:(e,r)=>{l&&l({h:"horizontal"===i?360*r.left:360*r.top})}}))}));X.displayName="Hue";const Q=X;var J=["prefixCls","className","color","colors","style","rectProps","onChange","addonAfter","addonBefore","rectRender"],W=n.forwardRef(((e,r)=>{var{prefixCls:a="w-color-swatch",className:s,color:l,colors:i=[],style:p,rectProps:c={},onChange:h,addonAfter:u,addonBefore:g,rectRender:b}=e,f=o(e,J),x=t({"--swatch-background-color":"rgb(144, 19, 254)",background:"var(--swatch-background-color)",height:15,width:15,marginRight:5,marginBottom:5,cursor:"pointer",position:"relative",outline:"none",borderRadius:2},c.style),m=(e,r)=>{h&&h(d(e),v(d(e)),r)};return(0,k.jsxs)("div",t({ref:r},f,{className:[a,s||""].filter(Boolean).join(" "),style:t({display:"flex",flexWrap:"wrap",position:"relative"},p),children:[g&&n.isValidElement(g)&&g,i&&Array.isArray(i)&&i.map(((e,r)=>{var a="",o="";"string"==typeof e&&(a=e,o=e),"object"==typeof e&&e.color&&(a=e.title||e.color,o=e.color);var s=l&&l.toLocaleLowerCase()===o.toLocaleLowerCase(),i=b&&b({title:a,color:o,checked:!!s,style:t({},x,{background:o}),onClick:e=>m(o,e)});if(i)return(0,k.jsx)(n.Fragment,{children:i},r);var p=c.children&&n.isValidElement(c.children)?n.cloneElement(c.children,{color:o,checked:s}):null;return(0,k.jsx)("div",t({tabIndex:0,title:a,onClick:e=>m(o,e)},c,{children:p,style:t({},x,{background:o})}),r)})),u&&n.isValidElement(u)&&u]}))}));W.displayName="Swatch";const Z=W;var H=["prefixCls","className","onChange","width","presetColors","color","editableDisable","disableAlpha","style"],$=["#D0021B","#F5A623","#f8e61b","#8B572A","#7ED321","#417505","#BD10E0","#9013FE","#4A90E2","#50E3C2","#B8E986","#000000","#4A4A4A","#9B9B9B","#FFFFFF"],K=e=>(0,k.jsx)("div",{style:{boxShadow:"rgb(0 0 0 / 60%) 0px 0px 2px",width:4,top:1,bottom:1,left:e.left,borderRadius:1,position:"absolute",backgroundColor:"#fff"}}),q=n.forwardRef(((e,r)=>{var{prefixCls:a="w-color-sketch",className:s,onChange:l,width:i=218,presetColors:p=$,color:c,editableDisable:h=!0,disableAlpha:u=!1,style:g}=e,m=o(e,H),[w,y]=(0,n.useState)({h:209,s:36,v:90,a:1});(0,n.useEffect)((()=>{"string"==typeof c&&x(c)&&y(d(c)),"object"==typeof c&&y(c)}),[c]);var C=e=>{y(e),l&&l(v(e))},A=t({"--sketch-background":"rgb(255, 255, 255)","--sketch-box-shadow":"rgb(0 0 0 / 15%) 0px 0px 0px 1px, rgb(0 0 0 / 15%) 0px 8px 16px","--sketch-swatch-box-shadow":"rgb(0 0 0 / 15%) 0px 0px 0px 1px inset","--sketch-alpha-box-shadow":"rgb(0 0 0 / 15%) 0px 0px 0px 1px inset, rgb(0 0 0 / 25%) 0px 0px 4px inset","--sketch-swatch-border-top":"1px solid rgb(238, 238, 238)",background:"var(--sketch-background)",borderRadius:4,boxShadow:"var(--sketch-box-shadow)",width:i},g),j={borderRadius:2,background:b(w),boxShadow:"var(--sketch-alpha-box-shadow)"};return(0,k.jsxs)("div",t({},m,{className:a+" "+(s||""),ref:r,style:A,children:[(0,k.jsxs)("div",{style:{padding:"10px 10px 8px"},children:[(0,k.jsx)(P,{hsva:w,style:{width:"auto",height:150},onChange:e=>C(t({},w,e,{a:w.a}))}),(0,k.jsxs)("div",{style:{display:"flex",marginTop:4},children:[(0,k.jsxs)("div",{style:{flex:1},children:[(0,k.jsx)(Q,{width:"auto",height:10,hue:w.h,pointer:K,innerProps:{style:{marginLeft:1,marginRight:5}},onChange:e=>C(t({},w,e))}),!u&&(0,k.jsx)(F,{width:"auto",height:10,hsva:w,pointer:K,style:{marginTop:4},innerProps:{style:{marginLeft:1,marginRight:5}},onChange:e=>C(t({},w,{a:e.a}))})]}),!u&&(0,k.jsx)(F,{width:24,height:24,hsva:w,radius:2,style:{marginLeft:4},bgProps:{style:{background:"transparent"}},innerProps:{style:j},pointer:()=>(0,k.jsx)(n.Fragment,{})})]})]}),h&&(0,k.jsxs)("div",{style:{display:"flex",margin:"0 10px 3px 10px"},children:[(0,k.jsx)(T,{label:"Hex",value:f(w).replace(/^#/,"").toLocaleUpperCase(),onChange:(e,r)=>{var a;"string"==typeof(a=r)&&x(a)&&/(3|6)/.test(String(a.length))&&C(d(a))},style:{minWidth:58}}),(0,k.jsx)(U,{hsva:w,style:{marginLeft:6},aProps:!u&&{},onChange:e=>C(e.hsva)})]}),p&&p.length>0&&(0,k.jsx)(Z,{style:{borderTop:"var(--sketch-swatch-border-top)",paddingTop:10,paddingLeft:10},colors:p,color:f(w),onChange:e=>C(e),rectProps:{style:{marginRight:10,marginBottom:10,borderRadius:3,boxShadow:"var(--sketch-swatch-box-shadow)"}}})]}))}));q.displayName="Sketch";const _=q}}]);
|
package/umd/598.index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see 598.index.js.LICENSE.txt */
|
|
2
|
-
(this.webpackChunkFeathery=this.webpackChunkFeathery||[]).push([[598],{1400:function(t){t.exports=function(t){function e(o){if(n[o])return n[o].exports;var i=n[o]={exports:{},id:o,loaded:!1};return t[o].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e){"use strict";function n(t,e,n,o){return function(t,e,n,o){return{red:o[4*(n*e+t)],green:o[4*(n*e+t)+1],blue:o[4*(n*e+t)+2],alpha:o[4*(n*e+t)+3]}}(t,e,n,o).alpha}function o(t,e,o,i){for(var r=t?1:-1,a=t?0:o-1;t?a<o:a>-1;a+=r)for(var s=0;s<e;s++)if(n(s,a,e,i))return a;return null}function i(t,e,o,i){for(var r=t?1:-1,a=t?0:e-1;t?a<e:a>-1;a+=r)for(var s=0;s<o;s++)if(n(a,s,e,i))return a;return null}Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t){var e=t.getContext("2d"),n=t.width,r=t.height,a=e.getImageData(0,0,n,r).data,s=o(!0,n,r,a),h=o(!1,n,r,a),c=i(!0,n,r,a),u=i(!1,n,r,a)-c+1,l=h-s+1,d=e.getImageData(c,s,u,l);return t.width=u,t.height=l,e.clearRect(0,0,u,l),e.putImageData(d,0,0),t}}])},3598:(t,e,n)=>{"use strict";function o(){return o=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)({}).hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},o.apply(null,arguments)}function i(t,e){if(null==t)return{};var n,o,i=function(t,e){if(null==t)return{};var n={};for(var o in t)if({}.hasOwnProperty.call(t,o)){if(-1!==e.indexOf(o))continue;n[o]=t[o]}return n}(t,e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);for(o=0;o<r.length;o++)n=r[o],-1===e.indexOf(n)&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(t)}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){return s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},s(t,e)}function h(t){return h=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},h(t)}function c(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(c=function(){return!!t})()}function u(t,e){if(e&&("object"==r(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}n.r(e),n.d(e,{SignatureCanvas:()=>m,default:()=>m});var l=n(5697),d=n(5430);function f(t,e,n){this.x=t,this.y=e,this.time=n||(new Date).getTime()}function p(t,e,n,o){this.startPoint=t,this.control1=e,this.control2=n,this.endPoint=o}function v(t,e){var n=this,o=e||{};this.velocityFilterWeight=o.velocityFilterWeight||.7,this.minWidth=o.minWidth||.5,this.maxWidth=o.maxWidth||2.5,this.throttle="throttle"in o?o.throttle:16,this.minDistance="minDistance"in o?o.minDistance:5,this.throttle?this._strokeMoveUpdate=function(t,e,n){var o,i,r,a=null,s=0;n||(n={});var h=function(){s=!1===n.leading?0:Date.now(),a=null,r=t.apply(o,i),a||(o=i=null)};return function(){var c=Date.now();s||!1!==n.leading||(s=c);var u=e-(c-s);return o=this,i=arguments,u<=0||u>e?(a&&(clearTimeout(a),a=null),s=c,r=t.apply(o,i),a||(o=i=null)):a||!1===n.trailing||(a=setTimeout(h,u)),r}}(v.prototype._strokeUpdate,this.throttle):this._strokeMoveUpdate=v.prototype._strokeUpdate,this.dotSize=o.dotSize||function(){return(this.minWidth+this.maxWidth)/2},this.penColor=o.penColor||"black",this.backgroundColor=o.backgroundColor||"rgba(0,0,0,0)",this.onBegin=o.onBegin,this.onEnd=o.onEnd,this._canvas=t,this._ctx=t.getContext("2d"),this.clear(),this._handleMouseDown=function(t){1===t.which&&(n._mouseButtonDown=!0,n._strokeBegin(t))},this._handleMouseMove=function(t){n._mouseButtonDown&&n._strokeMoveUpdate(t)},this._handleMouseUp=function(t){1===t.which&&n._mouseButtonDown&&(n._mouseButtonDown=!1,n._strokeEnd(t))},this._handleTouchStart=function(t){if(1===t.targetTouches.length){var e=t.changedTouches[0];n._strokeBegin(e)}},this._handleTouchMove=function(t){t.preventDefault();var e=t.targetTouches[0];n._strokeMoveUpdate(e)},this._handleTouchEnd=function(t){t.target===n._canvas&&(t.preventDefault(),n._strokeEnd(t))},this.on()}f.prototype.velocityFrom=function(t){return this.time!==t.time?this.distanceTo(t)/(this.time-t.time):1},f.prototype.distanceTo=function(t){return Math.sqrt(Math.pow(this.x-t.x,2)+Math.pow(this.y-t.y,2))},f.prototype.equals=function(t){return this.x===t.x&&this.y===t.y&&this.time===t.time},p.prototype.length=function(){for(var t=0,e=void 0,n=void 0,o=0;o<=10;o+=1){var i=o/10,r=this._point(i,this.startPoint.x,this.control1.x,this.control2.x,this.endPoint.x),a=this._point(i,this.startPoint.y,this.control1.y,this.control2.y,this.endPoint.y);if(o>0){var s=r-e,h=a-n;t+=Math.sqrt(s*s+h*h)}e=r,n=a}return t},p.prototype._point=function(t,e,n,o,i){return e*(1-t)*(1-t)*(1-t)+3*n*(1-t)*(1-t)*t+3*o*(1-t)*t*t+i*t*t*t},v.prototype.clear=function(){var t=this._ctx,e=this._canvas;t.fillStyle=this.backgroundColor,t.clearRect(0,0,e.width,e.height),t.fillRect(0,0,e.width,e.height),this._data=[],this._reset(),this._isEmpty=!0},v.prototype.fromDataURL=function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=new Image,i=n.ratio||window.devicePixelRatio||1,r=n.width||this._canvas.width/i,a=n.height||this._canvas.height/i;this._reset(),o.src=t,o.onload=function(){e._ctx.drawImage(o,0,0,r,a)},this._isEmpty=!1},v.prototype.toDataURL=function(t){var e;if("image/svg+xml"===t)return this._toSVG();for(var n=arguments.length,o=Array(n>1?n-1:0),i=1;i<n;i++)o[i-1]=arguments[i];return(e=this._canvas).toDataURL.apply(e,[t].concat(o))},v.prototype.on=function(){this._handleMouseEvents(),this._handleTouchEvents()},v.prototype.off=function(){this._canvas.removeEventListener("mousedown",this._handleMouseDown),this._canvas.removeEventListener("mousemove",this._handleMouseMove),document.removeEventListener("mouseup",this._handleMouseUp),this._canvas.removeEventListener("touchstart",this._handleTouchStart),this._canvas.removeEventListener("touchmove",this._handleTouchMove),this._canvas.removeEventListener("touchend",this._handleTouchEnd)},v.prototype.isEmpty=function(){return this._isEmpty},v.prototype._strokeBegin=function(t){this._data.push([]),this._reset(),this._strokeUpdate(t),"function"==typeof this.onBegin&&this.onBegin(t)},v.prototype._strokeUpdate=function(t){var e=t.clientX,n=t.clientY,o=this._createPoint(e,n),i=this._data[this._data.length-1],r=i&&i[i.length-1],a=r&&o.distanceTo(r)<this.minDistance;if(!r||!a){var s=this._addPoint(o),h=s.curve,c=s.widths;h&&c&&this._drawCurve(h,c.start,c.end),this._data[this._data.length-1].push({x:o.x,y:o.y,time:o.time,color:this.penColor})}},v.prototype._strokeEnd=function(t){var e=this.points.length>2,n=this.points[0];if(!e&&n&&this._drawDot(n),n){var o=this._data[this._data.length-1],i=o[o.length-1];n.equals(i)||o.push({x:n.x,y:n.y,time:n.time,color:this.penColor})}"function"==typeof this.onEnd&&this.onEnd(t)},v.prototype._handleMouseEvents=function(){this._mouseButtonDown=!1,this._canvas.addEventListener("mousedown",this._handleMouseDown),this._canvas.addEventListener("mousemove",this._handleMouseMove),document.addEventListener("mouseup",this._handleMouseUp)},v.prototype._handleTouchEvents=function(){this._canvas.style.msTouchAction="none",this._canvas.style.touchAction="none",this._canvas.addEventListener("touchstart",this._handleTouchStart),this._canvas.addEventListener("touchmove",this._handleTouchMove),this._canvas.addEventListener("touchend",this._handleTouchEnd)},v.prototype._reset=function(){this.points=[],this._lastVelocity=0,this._lastWidth=(this.minWidth+this.maxWidth)/2,this._ctx.fillStyle=this.penColor},v.prototype._createPoint=function(t,e,n){var o=this._canvas.getBoundingClientRect();return new f(t-o.left,e-o.top,n||(new Date).getTime())},v.prototype._addPoint=function(t){var e=this.points;if(e.push(t),e.length>2){3===e.length&&e.unshift(e[0]);var n=this._calculateCurveControlPoints(e[0],e[1],e[2]).c2,o=this._calculateCurveControlPoints(e[1],e[2],e[3]).c1,i=new p(e[1],n,o,e[2]),r=this._calculateCurveWidths(i);return e.shift(),{curve:i,widths:r}}return{}},v.prototype._calculateCurveControlPoints=function(t,e,n){var o=t.x-e.x,i=t.y-e.y,r=e.x-n.x,a=e.y-n.y,s=(t.x+e.x)/2,h=(t.y+e.y)/2,c=(e.x+n.x)/2,u=(e.y+n.y)/2,l=Math.sqrt(o*o+i*i),d=Math.sqrt(r*r+a*a),p=d/(l+d),v=c+(s-c)*p,_=u+(h-u)*p,y=e.x-v,g=e.y-_;return{c1:new f(s+y,h+g),c2:new f(c+y,u+g)}},v.prototype._calculateCurveWidths=function(t){var e=t.startPoint,n=t.endPoint,o={start:null,end:null},i=this.velocityFilterWeight*n.velocityFrom(e)+(1-this.velocityFilterWeight)*this._lastVelocity,r=this._strokeWidth(i);return o.start=this._lastWidth,o.end=r,this._lastVelocity=i,this._lastWidth=r,o},v.prototype._strokeWidth=function(t){return Math.max(this.maxWidth/(t+1),this.minWidth)},v.prototype._drawPoint=function(t,e,n){var o=this._ctx;o.moveTo(t,e),o.arc(t,e,n,0,2*Math.PI,!1),this._isEmpty=!1},v.prototype._drawCurve=function(t,e,n){var o=this._ctx,i=n-e,r=Math.floor(t.length());o.beginPath();for(var a=0;a<r;a+=1){var s=a/r,h=s*s,c=h*s,u=1-s,l=u*u,d=l*u,f=d*t.startPoint.x;f+=3*l*s*t.control1.x,f+=3*u*h*t.control2.x,f+=c*t.endPoint.x;var p=d*t.startPoint.y;p+=3*l*s*t.control1.y,p+=3*u*h*t.control2.y,p+=c*t.endPoint.y;var v=e+c*i;this._drawPoint(f,p,v)}o.closePath(),o.fill()},v.prototype._drawDot=function(t){var e=this._ctx,n="function"==typeof this.dotSize?this.dotSize():this.dotSize;e.beginPath(),this._drawPoint(t.x,t.y,n),e.closePath(),e.fill()},v.prototype._fromData=function(t,e,n){for(var o=0;o<t.length;o+=1){var i=t[o];if(i.length>1)for(var r=0;r<i.length;r+=1){var a=i[r],s=new f(a.x,a.y,a.time),h=a.color;if(0===r)this.penColor=h,this._reset(),this._addPoint(s);else if(r!==i.length-1){var c=this._addPoint(s),u=c.curve,l=c.widths;u&&l&&e(u,l,h)}}else this._reset(),n(i[0])}},v.prototype._toSVG=function(){var t=this,e=this._data,n=this._canvas,o=Math.max(window.devicePixelRatio||1,1),i=n.width/o,r=n.height/o,a=document.createElementNS("http://www.w3.org/2000/svg","svg");a.setAttributeNS(null,"width",n.width),a.setAttributeNS(null,"height",n.height),this._fromData(e,(function(t,e,n){var o=document.createElement("path");if(!(isNaN(t.control1.x)||isNaN(t.control1.y)||isNaN(t.control2.x)||isNaN(t.control2.y))){var i="M "+t.startPoint.x.toFixed(3)+","+t.startPoint.y.toFixed(3)+" C "+t.control1.x.toFixed(3)+","+t.control1.y.toFixed(3)+" "+t.control2.x.toFixed(3)+","+t.control2.y.toFixed(3)+" "+t.endPoint.x.toFixed(3)+","+t.endPoint.y.toFixed(3);o.setAttribute("d",i),o.setAttribute("stroke-width",(2.25*e.end).toFixed(3)),o.setAttribute("stroke",n),o.setAttribute("fill","none"),o.setAttribute("stroke-linecap","round"),a.appendChild(o)}}),(function(e){var n=document.createElement("circle"),o="function"==typeof t.dotSize?t.dotSize():t.dotSize;n.setAttribute("r",o),n.setAttribute("cx",e.x),n.setAttribute("cy",e.y),n.setAttribute("fill",e.color),a.appendChild(n)}));var s='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 '+i+" "+r+'" width="'+i+'" height="'+r+'">',h=a.innerHTML;if(void 0===h){var c=document.createElement("dummy"),u=a.childNodes;c.innerHTML="";for(var l=0;l<u.length;l+=1)c.appendChild(u[l].cloneNode(!0));h=c.innerHTML}return"data:image/svg+xml;base64,"+btoa(s+h+"</svg>")},v.prototype.fromData=function(t){var e=this;this.clear(),this._fromData(t,(function(t,n){return e._drawCurve(t,n.start,n.end)}),(function(t){return e._drawDot(t)})),this._data=t},v.prototype.toData=function(){return this._data};const _=v;var y=n(1400),g=["canvasProps","clearOnResize"],m=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&s(t,e)}(f,t);var e,n,r,l=(e=f,n=c(),function(){var t,o=h(e);if(n){var i=h(this).constructor;t=Reflect.construct(o,arguments,i)}else t=o.apply(this,arguments);return u(this,t)});function f(){var t;a(this,f);for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return(t=l.call.apply(l,[this].concat(n))).staticThis=t.constructor,t._sigPad=null,t._canvas=null,t.setRef=function(e){t._canvas=e,null===t._canvas&&(t._sigPad=null)},t._excludeOurProps=function(){var e=t.props;return e.canvasProps,e.clearOnResize,i(e,g)},t.componentDidMount=function(){var e=t.getCanvas();t._sigPad=new _(e,t._excludeOurProps()),t._resizeCanvas(),t.on()},t.componentWillUnmount=function(){t.off()},t.componentDidUpdate=function(){Object.assign(t._sigPad,t._excludeOurProps())},t.getCanvas=function(){if(null===t._canvas)throw t.staticThis.refNullError;return t._canvas},t.getTrimmedCanvas=function(){var e=t.getCanvas(),n=document.createElement("canvas");return n.width=e.width,n.height=e.height,n.getContext("2d").drawImage(e,0,0),y(n)},t.getSignaturePad=function(){if(null===t._sigPad)throw t.staticThis.refNullError;return t._sigPad},t._checkClearOnResize=function(){t.props.clearOnResize&&t._resizeCanvas()},t._resizeCanvas=function(){var e,n,o=null!==(e=t.props.canvasProps)&&void 0!==e?e:{},i=o.width,r=o.height;if(void 0===i||void 0===r){var a=t.getCanvas(),s=Math.max(null!==(n=window.devicePixelRatio)&&void 0!==n?n:1,1);void 0===i&&(a.width=a.offsetWidth*s),void 0===r&&(a.height=a.offsetHeight*s),a.getContext("2d").scale(s,s),t.clear()}},t.render=function(){var e=t.props.canvasProps;return d.createElement("canvas",o({ref:t.setRef},e))},t.on=function(){return window.addEventListener("resize",t._checkClearOnResize),t.getSignaturePad().on()},t.off=function(){return window.removeEventListener("resize",t._checkClearOnResize),t.getSignaturePad().off()},t.clear=function(){return t.getSignaturePad().clear()},t.isEmpty=function(){return t.getSignaturePad().isEmpty()},t.fromDataURL=function(e,n){return t.getSignaturePad().fromDataURL(e,n)},t.toDataURL=function(e,n){return t.getSignaturePad().toDataURL(e,n)},t.fromData=function(e){return t.getSignaturePad().fromData(e)},t.toData=function(){return t.getSignaturePad().toData()},t}return r=f,Object.defineProperty(r,"prototype",{writable:!1}),r}(d.Component);m.propTypes={velocityFilterWeight:l.number,minWidth:l.number,maxWidth:l.number,minDistance:l.number,dotSize:l.oneOfType([l.number,l.func]),penColor:l.string,throttle:l.number,onEnd:l.func,onBegin:l.func,canvasProps:l.object,clearOnResize:l.bool},m.defaultProps={clearOnResize:!0},m.refNullError=new Error("react-signature-canvas is currently mounting or unmounting: React refs are null during this phase.")}}]);
|
|
2
|
+
(this.webpackChunkFeathery=this.webpackChunkFeathery||[]).push([[598],{1400:function(t){t.exports=function(t){function e(o){if(n[o])return n[o].exports;var i=n[o]={exports:{},id:o,loaded:!1};return t[o].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e){"use strict";function n(t,e,n,o){return function(t,e,n,o){return{red:o[4*(n*e+t)],green:o[4*(n*e+t)+1],blue:o[4*(n*e+t)+2],alpha:o[4*(n*e+t)+3]}}(t,e,n,o).alpha}function o(t,e,o,i){for(var r=t?1:-1,a=t?0:o-1;t?a<o:a>-1;a+=r)for(var s=0;s<e;s++)if(n(s,a,e,i))return a;return null}function i(t,e,o,i){for(var r=t?1:-1,a=t?0:e-1;t?a<e:a>-1;a+=r)for(var s=0;s<o;s++)if(n(a,s,e,i))return a;return null}Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t){var e=t.getContext("2d"),n=t.width,r=t.height,a=e.getImageData(0,0,n,r).data,s=o(!0,n,r,a),h=o(!1,n,r,a),c=i(!0,n,r,a),u=i(!1,n,r,a)-c+1,l=h-s+1,d=e.getImageData(c,s,u,l);return t.width=u,t.height=l,e.clearRect(0,0,u,l),e.putImageData(d,0,0),t}}])},3598:(t,e,n)=>{"use strict";function o(){return o=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)({}).hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},o.apply(null,arguments)}function i(t,e){if(null==t)return{};var n,o,i=function(t,e){if(null==t)return{};var n={};for(var o in t)if({}.hasOwnProperty.call(t,o)){if(-1!==e.indexOf(o))continue;n[o]=t[o]}return n}(t,e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);for(o=0;o<r.length;o++)n=r[o],-1===e.indexOf(n)&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(t)}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){return s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},s(t,e)}function h(t){return h=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},h(t)}function c(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(c=function(){return!!t})()}function u(t,e){if(e&&("object"==r(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}n.r(e),n.d(e,{SignatureCanvas:()=>m,default:()=>m});var l=n(5697),d=n(7294);function f(t,e,n){this.x=t,this.y=e,this.time=n||(new Date).getTime()}function p(t,e,n,o){this.startPoint=t,this.control1=e,this.control2=n,this.endPoint=o}function v(t,e){var n=this,o=e||{};this.velocityFilterWeight=o.velocityFilterWeight||.7,this.minWidth=o.minWidth||.5,this.maxWidth=o.maxWidth||2.5,this.throttle="throttle"in o?o.throttle:16,this.minDistance="minDistance"in o?o.minDistance:5,this.throttle?this._strokeMoveUpdate=function(t,e,n){var o,i,r,a=null,s=0;n||(n={});var h=function(){s=!1===n.leading?0:Date.now(),a=null,r=t.apply(o,i),a||(o=i=null)};return function(){var c=Date.now();s||!1!==n.leading||(s=c);var u=e-(c-s);return o=this,i=arguments,u<=0||u>e?(a&&(clearTimeout(a),a=null),s=c,r=t.apply(o,i),a||(o=i=null)):a||!1===n.trailing||(a=setTimeout(h,u)),r}}(v.prototype._strokeUpdate,this.throttle):this._strokeMoveUpdate=v.prototype._strokeUpdate,this.dotSize=o.dotSize||function(){return(this.minWidth+this.maxWidth)/2},this.penColor=o.penColor||"black",this.backgroundColor=o.backgroundColor||"rgba(0,0,0,0)",this.onBegin=o.onBegin,this.onEnd=o.onEnd,this._canvas=t,this._ctx=t.getContext("2d"),this.clear(),this._handleMouseDown=function(t){1===t.which&&(n._mouseButtonDown=!0,n._strokeBegin(t))},this._handleMouseMove=function(t){n._mouseButtonDown&&n._strokeMoveUpdate(t)},this._handleMouseUp=function(t){1===t.which&&n._mouseButtonDown&&(n._mouseButtonDown=!1,n._strokeEnd(t))},this._handleTouchStart=function(t){if(1===t.targetTouches.length){var e=t.changedTouches[0];n._strokeBegin(e)}},this._handleTouchMove=function(t){t.preventDefault();var e=t.targetTouches[0];n._strokeMoveUpdate(e)},this._handleTouchEnd=function(t){t.target===n._canvas&&(t.preventDefault(),n._strokeEnd(t))},this.on()}f.prototype.velocityFrom=function(t){return this.time!==t.time?this.distanceTo(t)/(this.time-t.time):1},f.prototype.distanceTo=function(t){return Math.sqrt(Math.pow(this.x-t.x,2)+Math.pow(this.y-t.y,2))},f.prototype.equals=function(t){return this.x===t.x&&this.y===t.y&&this.time===t.time},p.prototype.length=function(){for(var t=0,e=void 0,n=void 0,o=0;o<=10;o+=1){var i=o/10,r=this._point(i,this.startPoint.x,this.control1.x,this.control2.x,this.endPoint.x),a=this._point(i,this.startPoint.y,this.control1.y,this.control2.y,this.endPoint.y);if(o>0){var s=r-e,h=a-n;t+=Math.sqrt(s*s+h*h)}e=r,n=a}return t},p.prototype._point=function(t,e,n,o,i){return e*(1-t)*(1-t)*(1-t)+3*n*(1-t)*(1-t)*t+3*o*(1-t)*t*t+i*t*t*t},v.prototype.clear=function(){var t=this._ctx,e=this._canvas;t.fillStyle=this.backgroundColor,t.clearRect(0,0,e.width,e.height),t.fillRect(0,0,e.width,e.height),this._data=[],this._reset(),this._isEmpty=!0},v.prototype.fromDataURL=function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=new Image,i=n.ratio||window.devicePixelRatio||1,r=n.width||this._canvas.width/i,a=n.height||this._canvas.height/i;this._reset(),o.src=t,o.onload=function(){e._ctx.drawImage(o,0,0,r,a)},this._isEmpty=!1},v.prototype.toDataURL=function(t){var e;if("image/svg+xml"===t)return this._toSVG();for(var n=arguments.length,o=Array(n>1?n-1:0),i=1;i<n;i++)o[i-1]=arguments[i];return(e=this._canvas).toDataURL.apply(e,[t].concat(o))},v.prototype.on=function(){this._handleMouseEvents(),this._handleTouchEvents()},v.prototype.off=function(){this._canvas.removeEventListener("mousedown",this._handleMouseDown),this._canvas.removeEventListener("mousemove",this._handleMouseMove),document.removeEventListener("mouseup",this._handleMouseUp),this._canvas.removeEventListener("touchstart",this._handleTouchStart),this._canvas.removeEventListener("touchmove",this._handleTouchMove),this._canvas.removeEventListener("touchend",this._handleTouchEnd)},v.prototype.isEmpty=function(){return this._isEmpty},v.prototype._strokeBegin=function(t){this._data.push([]),this._reset(),this._strokeUpdate(t),"function"==typeof this.onBegin&&this.onBegin(t)},v.prototype._strokeUpdate=function(t){var e=t.clientX,n=t.clientY,o=this._createPoint(e,n),i=this._data[this._data.length-1],r=i&&i[i.length-1],a=r&&o.distanceTo(r)<this.minDistance;if(!r||!a){var s=this._addPoint(o),h=s.curve,c=s.widths;h&&c&&this._drawCurve(h,c.start,c.end),this._data[this._data.length-1].push({x:o.x,y:o.y,time:o.time,color:this.penColor})}},v.prototype._strokeEnd=function(t){var e=this.points.length>2,n=this.points[0];if(!e&&n&&this._drawDot(n),n){var o=this._data[this._data.length-1],i=o[o.length-1];n.equals(i)||o.push({x:n.x,y:n.y,time:n.time,color:this.penColor})}"function"==typeof this.onEnd&&this.onEnd(t)},v.prototype._handleMouseEvents=function(){this._mouseButtonDown=!1,this._canvas.addEventListener("mousedown",this._handleMouseDown),this._canvas.addEventListener("mousemove",this._handleMouseMove),document.addEventListener("mouseup",this._handleMouseUp)},v.prototype._handleTouchEvents=function(){this._canvas.style.msTouchAction="none",this._canvas.style.touchAction="none",this._canvas.addEventListener("touchstart",this._handleTouchStart),this._canvas.addEventListener("touchmove",this._handleTouchMove),this._canvas.addEventListener("touchend",this._handleTouchEnd)},v.prototype._reset=function(){this.points=[],this._lastVelocity=0,this._lastWidth=(this.minWidth+this.maxWidth)/2,this._ctx.fillStyle=this.penColor},v.prototype._createPoint=function(t,e,n){var o=this._canvas.getBoundingClientRect();return new f(t-o.left,e-o.top,n||(new Date).getTime())},v.prototype._addPoint=function(t){var e=this.points;if(e.push(t),e.length>2){3===e.length&&e.unshift(e[0]);var n=this._calculateCurveControlPoints(e[0],e[1],e[2]).c2,o=this._calculateCurveControlPoints(e[1],e[2],e[3]).c1,i=new p(e[1],n,o,e[2]),r=this._calculateCurveWidths(i);return e.shift(),{curve:i,widths:r}}return{}},v.prototype._calculateCurveControlPoints=function(t,e,n){var o=t.x-e.x,i=t.y-e.y,r=e.x-n.x,a=e.y-n.y,s=(t.x+e.x)/2,h=(t.y+e.y)/2,c=(e.x+n.x)/2,u=(e.y+n.y)/2,l=Math.sqrt(o*o+i*i),d=Math.sqrt(r*r+a*a),p=d/(l+d),v=c+(s-c)*p,_=u+(h-u)*p,y=e.x-v,g=e.y-_;return{c1:new f(s+y,h+g),c2:new f(c+y,u+g)}},v.prototype._calculateCurveWidths=function(t){var e=t.startPoint,n=t.endPoint,o={start:null,end:null},i=this.velocityFilterWeight*n.velocityFrom(e)+(1-this.velocityFilterWeight)*this._lastVelocity,r=this._strokeWidth(i);return o.start=this._lastWidth,o.end=r,this._lastVelocity=i,this._lastWidth=r,o},v.prototype._strokeWidth=function(t){return Math.max(this.maxWidth/(t+1),this.minWidth)},v.prototype._drawPoint=function(t,e,n){var o=this._ctx;o.moveTo(t,e),o.arc(t,e,n,0,2*Math.PI,!1),this._isEmpty=!1},v.prototype._drawCurve=function(t,e,n){var o=this._ctx,i=n-e,r=Math.floor(t.length());o.beginPath();for(var a=0;a<r;a+=1){var s=a/r,h=s*s,c=h*s,u=1-s,l=u*u,d=l*u,f=d*t.startPoint.x;f+=3*l*s*t.control1.x,f+=3*u*h*t.control2.x,f+=c*t.endPoint.x;var p=d*t.startPoint.y;p+=3*l*s*t.control1.y,p+=3*u*h*t.control2.y,p+=c*t.endPoint.y;var v=e+c*i;this._drawPoint(f,p,v)}o.closePath(),o.fill()},v.prototype._drawDot=function(t){var e=this._ctx,n="function"==typeof this.dotSize?this.dotSize():this.dotSize;e.beginPath(),this._drawPoint(t.x,t.y,n),e.closePath(),e.fill()},v.prototype._fromData=function(t,e,n){for(var o=0;o<t.length;o+=1){var i=t[o];if(i.length>1)for(var r=0;r<i.length;r+=1){var a=i[r],s=new f(a.x,a.y,a.time),h=a.color;if(0===r)this.penColor=h,this._reset(),this._addPoint(s);else if(r!==i.length-1){var c=this._addPoint(s),u=c.curve,l=c.widths;u&&l&&e(u,l,h)}}else this._reset(),n(i[0])}},v.prototype._toSVG=function(){var t=this,e=this._data,n=this._canvas,o=Math.max(window.devicePixelRatio||1,1),i=n.width/o,r=n.height/o,a=document.createElementNS("http://www.w3.org/2000/svg","svg");a.setAttributeNS(null,"width",n.width),a.setAttributeNS(null,"height",n.height),this._fromData(e,(function(t,e,n){var o=document.createElement("path");if(!(isNaN(t.control1.x)||isNaN(t.control1.y)||isNaN(t.control2.x)||isNaN(t.control2.y))){var i="M "+t.startPoint.x.toFixed(3)+","+t.startPoint.y.toFixed(3)+" C "+t.control1.x.toFixed(3)+","+t.control1.y.toFixed(3)+" "+t.control2.x.toFixed(3)+","+t.control2.y.toFixed(3)+" "+t.endPoint.x.toFixed(3)+","+t.endPoint.y.toFixed(3);o.setAttribute("d",i),o.setAttribute("stroke-width",(2.25*e.end).toFixed(3)),o.setAttribute("stroke",n),o.setAttribute("fill","none"),o.setAttribute("stroke-linecap","round"),a.appendChild(o)}}),(function(e){var n=document.createElement("circle"),o="function"==typeof t.dotSize?t.dotSize():t.dotSize;n.setAttribute("r",o),n.setAttribute("cx",e.x),n.setAttribute("cy",e.y),n.setAttribute("fill",e.color),a.appendChild(n)}));var s='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 '+i+" "+r+'" width="'+i+'" height="'+r+'">',h=a.innerHTML;if(void 0===h){var c=document.createElement("dummy"),u=a.childNodes;c.innerHTML="";for(var l=0;l<u.length;l+=1)c.appendChild(u[l].cloneNode(!0));h=c.innerHTML}return"data:image/svg+xml;base64,"+btoa(s+h+"</svg>")},v.prototype.fromData=function(t){var e=this;this.clear(),this._fromData(t,(function(t,n){return e._drawCurve(t,n.start,n.end)}),(function(t){return e._drawDot(t)})),this._data=t},v.prototype.toData=function(){return this._data};const _=v;var y=n(1400),g=["canvasProps","clearOnResize"],m=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&s(t,e)}(f,t);var e,n,r,l=(e=f,n=c(),function(){var t,o=h(e);if(n){var i=h(this).constructor;t=Reflect.construct(o,arguments,i)}else t=o.apply(this,arguments);return u(this,t)});function f(){var t;a(this,f);for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return(t=l.call.apply(l,[this].concat(n))).staticThis=t.constructor,t._sigPad=null,t._canvas=null,t.setRef=function(e){t._canvas=e,null===t._canvas&&(t._sigPad=null)},t._excludeOurProps=function(){var e=t.props;return e.canvasProps,e.clearOnResize,i(e,g)},t.componentDidMount=function(){var e=t.getCanvas();t._sigPad=new _(e,t._excludeOurProps()),t._resizeCanvas(),t.on()},t.componentWillUnmount=function(){t.off()},t.componentDidUpdate=function(){Object.assign(t._sigPad,t._excludeOurProps())},t.getCanvas=function(){if(null===t._canvas)throw t.staticThis.refNullError;return t._canvas},t.getTrimmedCanvas=function(){var e=t.getCanvas(),n=document.createElement("canvas");return n.width=e.width,n.height=e.height,n.getContext("2d").drawImage(e,0,0),y(n)},t.getSignaturePad=function(){if(null===t._sigPad)throw t.staticThis.refNullError;return t._sigPad},t._checkClearOnResize=function(){t.props.clearOnResize&&t._resizeCanvas()},t._resizeCanvas=function(){var e,n,o=null!==(e=t.props.canvasProps)&&void 0!==e?e:{},i=o.width,r=o.height;if(void 0===i||void 0===r){var a=t.getCanvas(),s=Math.max(null!==(n=window.devicePixelRatio)&&void 0!==n?n:1,1);void 0===i&&(a.width=a.offsetWidth*s),void 0===r&&(a.height=a.offsetHeight*s),a.getContext("2d").scale(s,s),t.clear()}},t.render=function(){var e=t.props.canvasProps;return d.createElement("canvas",o({ref:t.setRef},e))},t.on=function(){return window.addEventListener("resize",t._checkClearOnResize),t.getSignaturePad().on()},t.off=function(){return window.removeEventListener("resize",t._checkClearOnResize),t.getSignaturePad().off()},t.clear=function(){return t.getSignaturePad().clear()},t.isEmpty=function(){return t.getSignaturePad().isEmpty()},t.fromDataURL=function(e,n){return t.getSignaturePad().fromDataURL(e,n)},t.toDataURL=function(e,n){return t.getSignaturePad().toDataURL(e,n)},t.fromData=function(e){return t.getSignaturePad().fromData(e)},t.toData=function(){return t.getSignaturePad().toData()},t}return r=f,Object.defineProperty(r,"prototype",{writable:!1}),r}(d.Component);m.propTypes={velocityFilterWeight:l.number,minWidth:l.number,maxWidth:l.number,minDistance:l.number,dotSize:l.oneOfType([l.number,l.func]),penColor:l.string,throttle:l.number,onEnd:l.func,onBegin:l.func,canvasProps:l.object,clearOnResize:l.bool},m.defaultProps={clearOnResize:!0},m.refNullError=new Error("react-signature-canvas is currently mounting or unmounting: React refs are null during this phase.")}}]);
|