@epa-wg/custom-element-dist 0.0.22 → 0.0.24
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/README.md +4 -4
- package/coverage/coverage-final.json +13 -15
- package/coverage/index.html +30 -30
- package/coverage/src/custom-element/coverage.svg +1 -1
- package/coverage/src/custom-element/custom-element.js/coverage.svg +1 -1
- package/coverage/src/custom-element/custom-element.js.html +336 -312
- package/coverage/src/custom-element/http-request.js.html +10 -10
- package/coverage/src/custom-element/index.html +19 -49
- package/coverage/src/custom-element/local-storage.js.html +5 -5
- package/coverage/src/custom-element/location-element.js.html +1 -1
- package/coverage/src/index.html +1 -1
- package/coverage/src/mocks/handlers.ts.html +1 -1
- package/coverage/src/mocks/index.html +1 -1
- package/coverage/src/stories/attributes.test.stories.ts/coverage.svg +1 -1
- package/coverage/src/stories/attributes.test.stories.ts.html +85 -91
- package/coverage/src/stories/coverage.svg +1 -1
- package/coverage/src/stories/css.test.stories.ts/coverage.svg +1 -1
- package/coverage/src/stories/css.test.stories.ts.html +75 -78
- package/coverage/src/stories/dom-merge.test.stories.ts/coverage.svg +1 -1
- package/coverage/src/stories/dom-merge.test.stories.ts.html +302 -74
- package/coverage/src/stories/external-template.test.stories.ts/coverage.svg +1 -1
- package/coverage/src/stories/external-template.test.stories.ts.html +154 -154
- package/coverage/src/stories/form.test.stories.ts/coverage.svg +1 -1
- package/coverage/src/stories/form.test.stories.ts.html +83 -86
- package/coverage/src/stories/http-request.stories.ts.html +1 -1
- package/coverage/src/stories/index.html +104 -104
- package/coverage/src/stories/local-storage.test.stories.ts/coverage.svg +1 -1
- package/coverage/src/stories/local-storage.test.stories.ts.html +444 -444
- package/coverage/src/stories/location-element.test.stories.ts/coverage.svg +1 -1
- package/coverage/src/stories/location-element.test.stories.ts.html +96 -96
- package/coverage/src/stories/slice-events.test.stories.ts/coverage.svg +1 -1
- package/coverage/src/stories/slice-events.test.stories.ts.html +141 -141
- package/coverage/src/stories/slots.test.stories.ts/coverage.svg +1 -1
- package/coverage/src/stories/slots.test.stories.ts.html +120 -123
- package/coverage/src/stories/{renderPlay.ts.html → testStoryBook.ts.html} +45 -24
- package/coverage/src/sum.ts.html +1 -1
- package/dist/{custom-element-N-sWiqGK.cjs → custom-element-BDK7dcJN.cjs} +8 -8
- package/dist/{custom-element-BISbI4SU.js → custom-element-DqtzLkTG.js} +74 -66
- package/dist/custom-element-bundle.cjs +1 -1
- package/dist/custom-element-bundle.js +23 -22
- package/package.json +3 -3
- package/src/custom-element/custom-element.js +9 -1
- package/src/custom-element/demo/form.html +92 -46
- package/src/custom-element/demo/s.xml +9 -17
- package/src/custom-element/ide/web-types-dce.json +1 -1
- package/src/custom-element/ide/web-types-xsl.json +1 -1
- package/src/stories/attributes.test.stories.ts +9 -11
- package/src/stories/css.test.stories.ts +6 -7
- package/src/stories/dom-merge.test.stories.ts +81 -5
- package/src/stories/external-template.test.stories.ts +6 -6
- package/src/stories/form.test.stories.ts +6 -7
- package/src/stories/local-storage.test.stories.ts +7 -7
- package/src/stories/location-element.test.stories.ts +6 -6
- package/src/stories/slice-events.test.stories.ts +6 -6
- package/src/stories/slots.test.stories.ts +6 -7
- package/src/stories/testStoryBook.ts +28 -0
- package/storybook-static/assets/{Color-PRSJMWNM-e4s261EJ.js → Color-PRSJMWNM-y4ZsI1hY.js} +1 -1
- package/storybook-static/assets/{Configure-DWut7txe.js → Configure-CyLVkwlf.js} +1 -1
- package/storybook-static/assets/{DocsRenderer-K4EAMTCU-CaXVGjCl.js → DocsRenderer-K4EAMTCU-VRGUwRrq.js} +2 -2
- package/storybook-static/assets/{WithTooltip-KJL26V4Q--B8vdnMi.js → WithTooltip-KJL26V4Q-xdXH9Ztt.js} +1 -1
- package/storybook-static/assets/{attributes.test.stories-IuwazrdL.js → attributes.test.stories-BckCcyrF.js} +3 -2
- package/storybook-static/assets/{css.test.stories-D9WaxrEv.js → css.test.stories-B-QcObCF.js} +1 -1
- package/storybook-static/assets/{custom-element-BV8-hRQS.js → custom-element-BIxkVg7K.js} +5 -5
- package/storybook-static/assets/dom-merge.test.stories-CjXhjTQY.js +258 -0
- package/storybook-static/assets/{external-template.test.stories-Bpr_wxBo.js → external-template.test.stories-BBqyi0az.js} +1 -1
- package/storybook-static/assets/{form.test.stories-3tURbEdv.js → form.test.stories-DsIo1B4n.js} +1 -1
- package/storybook-static/assets/{formatter-2WMMO6ZP-SJtgH3vM.js → formatter-2WMMO6ZP-CThVcQxM.js} +1 -1
- package/storybook-static/assets/{http-request.stories-8K_qSs8C.js → http-request.stories-sXA_Y-VM.js} +1 -1
- package/storybook-static/assets/{iframe-CM82WlGY.js → iframe-DcDTQOmA.js} +2 -2
- package/storybook-static/assets/{index-DNL-IEpS.js → index-CUFHd5VD.js} +1 -1
- package/storybook-static/assets/{index-CEZitmnt.js → index-DPPi9iZu.js} +5 -5
- package/storybook-static/assets/{index-D1MP-Zis.js → index-VWixWKZ7.js} +1 -1
- package/storybook-static/assets/{local-storage.test.stories-CtisAQBB.js → local-storage.test.stories-Cs2v3QTS.js} +1 -1
- package/storybook-static/assets/{location-element.test.stories-5O_t_m4Y.js → location-element.test.stories-WkrQDzJJ.js} +1 -1
- package/storybook-static/assets/{preview-5Y0XiZgz.js → preview-p-Bwze-K.js} +2 -2
- package/storybook-static/assets/{slice-events.test.stories-BSXCLIA5.js → slice-events.test.stories-BRBBc0JT.js} +1 -1
- package/storybook-static/assets/{slots.test.stories-B1vqfHmN.js → slots.test.stories-r-i91k3y.js} +1 -1
- package/storybook-static/assets/{syntaxhighlighter-BP7B2CQK-BWFH_0wQ.js → syntaxhighlighter-BP7B2CQK-OnioRcs9.js} +1 -1
- package/storybook-static/iframe.html +1 -1
- package/storybook-static/index.json +1 -1
- package/storybook-static/project.json +1 -1
- package/tsconfig.json +31 -21
- package/coverage/src/custom-element/custom-element1-1.js/coverage.svg +0 -10
- package/coverage/src/custom-element/custom-element1-1.js.html +0 -2374
- package/coverage/src/custom-element/custom-element1.js/coverage.svg +0 -10
- package/coverage/src/custom-element/custom-element1.js.html +0 -2374
- package/src/custom-element/custom-element1-1.js +0 -763
- package/src/custom-element/custom-element1.js +0 -763
- package/src/custom-element/custom-element1.js0 +0 -750
- package/src/custom-element/custom-element2.js0 +0 -759
- package/src/custom-element/custom-element3.js0 +0 -763
- package/src/stories/renderPlay.ts +0 -21
- package/storybook-static/assets/dom-merge.test.stories-BhbNeum_.js +0 -137
- /package/coverage/src/stories/{renderPlay.ts → testStoryBook.ts}/coverage.svg +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{R as h,d as b,n as C,e as ue,T as Me,F as Ce,M as $e,g as Oe}from"./index-CEZitmnt.js";import{g as fe,_ as Ne,i as J,b as Ie}from"./index-Cc7K62zD.js";import"./iframe-CM82WlGY.js";import"../sb-preview/runtime.js";import"./index-DXimoRZY.js";import"./index-DrFu-skq.js";function $(){return($=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function Q(e,t){if(e==null)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)t.indexOf(n=a[r])>=0||(o[n]=e[n]);return o}function K(e){var t=b.useRef(e),n=b.useRef(function(r){t.current&&t.current(r)});return t.current=e,n.current}var I=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=1),e>n?n:e<t?t:e},F=function(e){return"touches"in e},V=function(e){return e&&e.ownerDocument.defaultView||self},ne=function(e,t,n){var r=e.getBoundingClientRect(),o=F(t)?function(a,l){for(var s=0;s<a.length;s++)if(a[s].identifier===l)return a[s];return a[0]}(t.touches,n):t;return{left:I((o.pageX-(r.left+V(e).pageXOffset))/r.width),top:I((o.pageY-(r.top+V(e).pageYOffset))/r.height)}},re=function(e){!F(e)&&e.preventDefault()},Z=h.memo(function(e){var t=e.onMove,n=e.onKey,r=Q(e,["onMove","onKey"]),o=b.useRef(null),a=K(t),l=K(n),s=b.useRef(null),c=b.useRef(!1),i=b.useMemo(function(){var w=function(p){re(p),(F(p)?p.touches.length>0:p.buttons>0)&&o.current?a(ne(o.current,p,s.current)):E(!1)},S=function(){return E(!1)};function E(p){var m=c.current,k=V(o.current),y=p?k.addEventListener:k.removeEventListener;y(m?"touchmove":"mousemove",w),y(m?"touchend":"mouseup",S)}return[function(p){var m=p.nativeEvent,k=o.current;if(k&&(re(m),!function(R,T){return T&&!F(R)}(m,c.current)&&k)){if(F(m)){c.current=!0;var y=m.changedTouches||[];y.length&&(s.current=y[0].identifier)}k.focus(),a(ne(k,m,s.current)),E(!0)}},function(p){var m=p.which||p.keyCode;m<37||m>40||(p.preventDefault(),l({left:m===39?.05:m===37?-.05:0,top:m===40?.05:m===38?-.05:0}))},E]},[l,a]),d=i[0],f=i[1],g=i[2];return b.useEffect(function(){return g},[g]),h.createElement("div",$({},r,{onTouchStart:d,onMouseDown:d,className:"react-colorful__interactive",ref:o,onKeyDown:f,tabIndex:0,role:"slider"}))}),H=function(e){return e.filter(Boolean).join(" ")},ee=function(e){var t=e.color,n=e.left,r=e.top,o=r===void 0?.5:r,a=H(["react-colorful__pointer",e.className]);return h.createElement("div",{className:a,style:{top:100*o+"%",left:100*n+"%"}},h.createElement("div",{className:"react-colorful__pointer-fill",style:{backgroundColor:t}}))},x=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=Math.pow(10,t)),Math.round(n*e)/n},Se={grad:.9,turn:360,rad:360/(2*Math.PI)},Re=function(e){return ge(A(e))},A=function(e){return e[0]==="#"&&(e=e.substring(1)),e.length<6?{r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16),a:e.length===4?x(parseInt(e[3]+e[3],16)/255,2):1}:{r:parseInt(e.substring(0,2),16),g:parseInt(e.substring(2,4),16),b:parseInt(e.substring(4,6),16),a:e.length===8?x(parseInt(e.substring(6,8),16)/255,2):1}},Te=function(e,t){return t===void 0&&(t="deg"),Number(e)*(Se[t]||1)},je=function(e){var t=/hsla?\(?\s*(-?\d*\.?\d+)(deg|rad|grad|turn)?[,\s]+(-?\d*\.?\d+)%?[,\s]+(-?\d*\.?\d+)%?,?\s*[/\s]*(-?\d*\.?\d+)?(%)?\s*\)?/i.exec(e);return t?Fe({h:Te(t[1],t[2]),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)}):{h:0,s:0,v:0,a:1}},Fe=function(e){var t=e.s,n=e.l;return{h:e.h,s:(t*=(n<50?n:100-n)/100)>0?2*t/(n+t)*100:0,v:n+t,a:e.a}},ze=function(e){return Pe(de(e))},he=function(e){var t=e.s,n=e.v,r=e.a,o=(200-t)*n/100;return{h:x(e.h),s:x(o>0&&o<200?t*n/100/(o<=100?o:200-o)*100:0),l:x(o/2),a:x(r,2)}},G=function(e){var t=he(e);return"hsl("+t.h+", "+t.s+"%, "+t.l+"%)"},B=function(e){var t=he(e);return"hsla("+t.h+", "+t.s+"%, "+t.l+"%, "+t.a+")"},de=function(e){var t=e.h,n=e.s,r=e.v,o=e.a;t=t/360*6,n/=100,r/=100;var a=Math.floor(t),l=r*(1-n),s=r*(1-(t-a)*n),c=r*(1-(1-t+a)*n),i=a%6;return{r:x(255*[r,s,l,l,c,r][i]),g:x(255*[c,r,r,s,l,l][i]),b:x(255*[l,l,c,r,r,s][i]),a:x(o,2)}},He=function(e){var t=/rgba?\(?\s*(-?\d*\.?\d+)(%)?[,\s]+(-?\d*\.?\d+)(%)?[,\s]+(-?\d*\.?\d+)(%)?,?\s*[/\s]*(-?\d*\.?\d+)?(%)?\s*\)?/i.exec(e);return t?ge({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):{h:0,s:0,v:0,a:1}},P=function(e){var t=e.toString(16);return t.length<2?"0"+t:t},Pe=function(e){var t=e.r,n=e.g,r=e.b,o=e.a,a=o<1?P(x(255*o)):"";return"#"+P(t)+P(n)+P(r)+a},ge=function(e){var t=e.r,n=e.g,r=e.b,o=e.a,a=Math.max(t,n,r),l=a-Math.min(t,n,r),s=l?a===t?(n-r)/l:a===n?2+(r-t)/l:4+(t-n)/l:0;return{h:x(60*(s<0?s+6:s)),s:x(a?l/a*100:0),v:x(a/255*100),a:o}},be=h.memo(function(e){var t=e.hue,n=e.onChange,r=H(["react-colorful__hue",e.className]);return h.createElement("div",{className:r},h.createElement(Z,{onMove:function(o){n({h:360*o.left})},onKey:function(o){n({h:I(t+360*o.left,0,360)})},"aria-label":"Hue","aria-valuenow":x(t),"aria-valuemax":"360","aria-valuemin":"0"},h.createElement(ee,{className:"react-colorful__hue-pointer",left:t/360,color:G({h:t,s:100,v:100,a:1})})))}),me=h.memo(function(e){var t=e.hsva,n=e.onChange,r={backgroundColor:G({h:t.h,s:100,v:100,a:1})};return h.createElement("div",{className:"react-colorful__saturation",style:r},h.createElement(Z,{onMove:function(o){n({s:100*o.left,v:100-100*o.top})},onKey:function(o){n({s:I(t.s+100*o.left,0,100),v:I(t.v-100*o.top,0,100)})},"aria-label":"Color","aria-valuetext":"Saturation "+x(t.s)+"%, Brightness "+x(t.v)+"%"},h.createElement(ee,{className:"react-colorful__saturation-pointer",top:1-t.v/100,left:t.s/100,color:G(t)})))}),ve=function(e,t){if(e===t)return!0;for(var n in e)if(e[n]!==t[n])return!1;return!0},pe=function(e,t){return e.replace(/\s/g,"")===t.replace(/\s/g,"")},Le=function(e,t){return e.toLowerCase()===t.toLowerCase()||ve(A(e),A(t))};function ye(e,t,n){var r=K(n),o=b.useState(function(){return e.toHsva(t)}),a=o[0],l=o[1],s=b.useRef({color:t,hsva:a});b.useEffect(function(){if(!e.equal(t,s.current.color)){var i=e.toHsva(t);s.current={hsva:i,color:t},l(i)}},[t,e]),b.useEffect(function(){var i;ve(a,s.current.hsva)||e.equal(i=e.fromHsva(a),s.current.color)||(s.current={hsva:a,color:i},r(i))},[a,e,r]);var c=b.useCallback(function(i){l(function(d){return Object.assign({},d,i)})},[]);return[a,c]}var qe=typeof window<"u"?b.useLayoutEffect:b.useEffect,Be=function(){return typeof __webpack_nonce__<"u"?__webpack_nonce__:void 0},oe=new Map,xe=function(e){qe(function(){var t=e.current?e.current.ownerDocument:document;if(t!==void 0&&!oe.has(t)){var n=t.createElement("style");n.innerHTML=`.react-colorful{position:relative;display:flex;flex-direction:column;width:200px;height:200px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:default}.react-colorful__saturation{position:relative;flex-grow:1;border-color:transparent;border-bottom:12px solid #000;border-radius:8px 8px 0 0;background-image:linear-gradient(0deg,#000,transparent),linear-gradient(90deg,#fff,hsla(0,0%,100%,0))}.react-colorful__alpha-gradient,.react-colorful__pointer-fill{content:"";position:absolute;left:0;top:0;right:0;bottom:0;pointer-events:none;border-radius:inherit}.react-colorful__alpha-gradient,.react-colorful__saturation{box-shadow:inset 0 0 0 1px rgba(0,0,0,.05)}.react-colorful__alpha,.react-colorful__hue{position:relative;height:24px}.react-colorful__hue{background:linear-gradient(90deg,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red)}.react-colorful__last-control{border-radius:0 0 8px 8px}.react-colorful__interactive{position:absolute;left:0;top:0;right:0;bottom:0;border-radius:inherit;outline:none;touch-action:none}.react-colorful__pointer{position:absolute;z-index:1;box-sizing:border-box;width:28px;height:28px;transform:translate(-50%,-50%);background-color:#fff;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 4px rgba(0,0,0,.2)}.react-colorful__interactive:focus .react-colorful__pointer{transform:translate(-50%,-50%) scale(1.1)}.react-colorful__alpha,.react-colorful__alpha-pointer{background-color:#fff;background-image:url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill-opacity=".05"><path d="M8 0h8v8H8zM0 8h8v8H0z"/></svg>')}.react-colorful__saturation-pointer{z-index:3}.react-colorful__hue-pointer{z-index:2}`,oe.set(t,n);var r=Be();r&&n.setAttribute("nonce",r),t.head.appendChild(n)}},[])},We=function(e){var t=e.className,n=e.colorModel,r=e.color,o=r===void 0?n.defaultColor:r,a=e.onChange,l=Q(e,["className","colorModel","color","onChange"]),s=b.useRef(null);xe(s);var c=ye(n,o,a),i=c[0],d=c[1],f=H(["react-colorful",t]);return h.createElement("div",$({},l,{ref:s,className:f}),h.createElement(me,{hsva:i,onChange:d}),h.createElement(be,{hue:i.h,onChange:d,className:"react-colorful__last-control"}))},Xe={defaultColor:"000",toHsva:Re,fromHsva:function(e){return ze({h:e.h,s:e.s,v:e.v,a:1})},equal:Le},De=function(e){return h.createElement(We,$({},e,{colorModel:Xe}))},Ke=function(e){var t=e.className,n=e.hsva,r=e.onChange,o={backgroundImage:"linear-gradient(90deg, "+B(Object.assign({},n,{a:0}))+", "+B(Object.assign({},n,{a:1}))+")"},a=H(["react-colorful__alpha",t]),l=x(100*n.a);return h.createElement("div",{className:a},h.createElement("div",{className:"react-colorful__alpha-gradient",style:o}),h.createElement(Z,{onMove:function(s){r({a:s.left})},onKey:function(s){r({a:I(n.a+s.left)})},"aria-label":"Alpha","aria-valuetext":l+"%","aria-valuenow":l,"aria-valuemin":"0","aria-valuemax":"100"},h.createElement(ee,{className:"react-colorful__alpha-pointer",left:n.a,color:B(n)})))},we=function(e){var t=e.className,n=e.colorModel,r=e.color,o=r===void 0?n.defaultColor:r,a=e.onChange,l=Q(e,["className","colorModel","color","onChange"]),s=b.useRef(null);xe(s);var c=ye(n,o,a),i=c[0],d=c[1],f=H(["react-colorful",t]);return h.createElement("div",$({},l,{ref:s,className:f}),h.createElement(me,{hsva:i,onChange:d}),h.createElement(be,{hue:i.h,onChange:d}),h.createElement(Ke,{hsva:i,onChange:d,className:"react-colorful__last-control"}))},Ve={defaultColor:"hsla(0, 0%, 0%, 1)",toHsva:je,fromHsva:B,equal:pe},Ae=function(e){return h.createElement(we,$({},e,{colorModel:Ve}))},Ge={defaultColor:"rgba(0, 0, 0, 1)",toHsva:He,fromHsva:function(e){var t=de(e);return"rgba("+t.r+", "+t.g+", "+t.b+", "+t.a+")"},equal:pe},Ue=function(e){return h.createElement(we,$({},e,{colorModel:Ge}))},Ye={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};const z=Ye,ke={};for(const e of Object.keys(z))ke[z[e]]=e;const u={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};var _e=u;for(const e of Object.keys(u)){if(!("channels"in u[e]))throw new Error("missing channels property: "+e);if(!("labels"in u[e]))throw new Error("missing channel labels property: "+e);if(u[e].labels.length!==u[e].channels)throw new Error("channel and label counts mismatch: "+e);const{channels:t,labels:n}=u[e];delete u[e].channels,delete u[e].labels,Object.defineProperty(u[e],"channels",{value:t}),Object.defineProperty(u[e],"labels",{value:n})}u.rgb.hsl=function(e){const t=e[0]/255,n=e[1]/255,r=e[2]/255,o=Math.min(t,n,r),a=Math.max(t,n,r),l=a-o;let s,c;a===o?s=0:t===a?s=(n-r)/l:n===a?s=2+(r-t)/l:r===a&&(s=4+(t-n)/l),s=Math.min(s*60,360),s<0&&(s+=360);const i=(o+a)/2;return a===o?c=0:i<=.5?c=l/(a+o):c=l/(2-a-o),[s,c*100,i*100]};u.rgb.hsv=function(e){let t,n,r,o,a;const l=e[0]/255,s=e[1]/255,c=e[2]/255,i=Math.max(l,s,c),d=i-Math.min(l,s,c),f=function(g){return(i-g)/6/d+1/2};return d===0?(o=0,a=0):(a=d/i,t=f(l),n=f(s),r=f(c),l===i?o=r-n:s===i?o=1/3+t-r:c===i&&(o=2/3+n-t),o<0?o+=1:o>1&&(o-=1)),[o*360,a*100,i*100]};u.rgb.hwb=function(e){const t=e[0],n=e[1];let r=e[2];const o=u.rgb.hsl(e)[0],a=1/255*Math.min(t,Math.min(n,r));return r=1-1/255*Math.max(t,Math.max(n,r)),[o,a*100,r*100]};u.rgb.cmyk=function(e){const t=e[0]/255,n=e[1]/255,r=e[2]/255,o=Math.min(1-t,1-n,1-r),a=(1-t-o)/(1-o)||0,l=(1-n-o)/(1-o)||0,s=(1-r-o)/(1-o)||0;return[a*100,l*100,s*100,o*100]};function Je(e,t){return(e[0]-t[0])**2+(e[1]-t[1])**2+(e[2]-t[2])**2}u.rgb.keyword=function(e){const t=ke[e];if(t)return t;let n=1/0,r;for(const o of Object.keys(z)){const a=z[o],l=Je(e,a);l<n&&(n=l,r=o)}return r};u.keyword.rgb=function(e){return z[e]};u.rgb.xyz=function(e){let t=e[0]/255,n=e[1]/255,r=e[2]/255;t=t>.04045?((t+.055)/1.055)**2.4:t/12.92,n=n>.04045?((n+.055)/1.055)**2.4:n/12.92,r=r>.04045?((r+.055)/1.055)**2.4:r/12.92;const o=t*.4124+n*.3576+r*.1805,a=t*.2126+n*.7152+r*.0722,l=t*.0193+n*.1192+r*.9505;return[o*100,a*100,l*100]};u.rgb.lab=function(e){const t=u.rgb.xyz(e);let n=t[0],r=t[1],o=t[2];n/=95.047,r/=100,o/=108.883,n=n>.008856?n**(1/3):7.787*n+16/116,r=r>.008856?r**(1/3):7.787*r+16/116,o=o>.008856?o**(1/3):7.787*o+16/116;const a=116*r-16,l=500*(n-r),s=200*(r-o);return[a,l,s]};u.hsl.rgb=function(e){const t=e[0]/360,n=e[1]/100,r=e[2]/100;let o,a,l;if(n===0)return l=r*255,[l,l,l];r<.5?o=r*(1+n):o=r+n-r*n;const s=2*r-o,c=[0,0,0];for(let i=0;i<3;i++)a=t+1/3*-(i-1),a<0&&a++,a>1&&a--,6*a<1?l=s+(o-s)*6*a:2*a<1?l=o:3*a<2?l=s+(o-s)*(2/3-a)*6:l=s,c[i]=l*255;return c};u.hsl.hsv=function(e){const t=e[0];let n=e[1]/100,r=e[2]/100,o=n;const a=Math.max(r,.01);r*=2,n*=r<=1?r:2-r,o*=a<=1?a:2-a;const l=(r+n)/2,s=r===0?2*o/(a+o):2*n/(r+n);return[t,s*100,l*100]};u.hsv.rgb=function(e){const t=e[0]/60,n=e[1]/100;let r=e[2]/100;const o=Math.floor(t)%6,a=t-Math.floor(t),l=255*r*(1-n),s=255*r*(1-n*a),c=255*r*(1-n*(1-a));switch(r*=255,o){case 0:return[r,c,l];case 1:return[s,r,l];case 2:return[l,r,c];case 3:return[l,s,r];case 4:return[c,l,r];case 5:return[r,l,s]}};u.hsv.hsl=function(e){const t=e[0],n=e[1]/100,r=e[2]/100,o=Math.max(r,.01);let a,l;l=(2-n)*r;const s=(2-n)*o;return a=n*o,a/=s<=1?s:2-s,a=a||0,l/=2,[t,a*100,l*100]};u.hwb.rgb=function(e){const t=e[0]/360;let n=e[1]/100,r=e[2]/100;const o=n+r;let a;o>1&&(n/=o,r/=o);const l=Math.floor(6*t),s=1-r;a=6*t-l,l&1&&(a=1-a);const c=n+a*(s-n);let i,d,f;switch(l){default:case 6:case 0:i=s,d=c,f=n;break;case 1:i=c,d=s,f=n;break;case 2:i=n,d=s,f=c;break;case 3:i=n,d=c,f=s;break;case 4:i=c,d=n,f=s;break;case 5:i=s,d=n,f=c;break}return[i*255,d*255,f*255]};u.cmyk.rgb=function(e){const t=e[0]/100,n=e[1]/100,r=e[2]/100,o=e[3]/100,a=1-Math.min(1,t*(1-o)+o),l=1-Math.min(1,n*(1-o)+o),s=1-Math.min(1,r*(1-o)+o);return[a*255,l*255,s*255]};u.xyz.rgb=function(e){const t=e[0]/100,n=e[1]/100,r=e[2]/100;let o,a,l;return o=t*3.2406+n*-1.5372+r*-.4986,a=t*-.9689+n*1.8758+r*.0415,l=t*.0557+n*-.204+r*1.057,o=o>.0031308?1.055*o**(1/2.4)-.055:o*12.92,a=a>.0031308?1.055*a**(1/2.4)-.055:a*12.92,l=l>.0031308?1.055*l**(1/2.4)-.055:l*12.92,o=Math.min(Math.max(0,o),1),a=Math.min(Math.max(0,a),1),l=Math.min(Math.max(0,l),1),[o*255,a*255,l*255]};u.xyz.lab=function(e){let t=e[0],n=e[1],r=e[2];t/=95.047,n/=100,r/=108.883,t=t>.008856?t**(1/3):7.787*t+16/116,n=n>.008856?n**(1/3):7.787*n+16/116,r=r>.008856?r**(1/3):7.787*r+16/116;const o=116*n-16,a=500*(t-n),l=200*(n-r);return[o,a,l]};u.lab.xyz=function(e){const t=e[0],n=e[1],r=e[2];let o,a,l;a=(t+16)/116,o=n/500+a,l=a-r/200;const s=a**3,c=o**3,i=l**3;return a=s>.008856?s:(a-16/116)/7.787,o=c>.008856?c:(o-16/116)/7.787,l=i>.008856?i:(l-16/116)/7.787,o*=95.047,a*=100,l*=108.883,[o,a,l]};u.lab.lch=function(e){const t=e[0],n=e[1],r=e[2];let o;o=Math.atan2(r,n)*360/2/Math.PI,o<0&&(o+=360);const l=Math.sqrt(n*n+r*r);return[t,l,o]};u.lch.lab=function(e){const t=e[0],n=e[1],o=e[2]/360*2*Math.PI,a=n*Math.cos(o),l=n*Math.sin(o);return[t,a,l]};u.rgb.ansi16=function(e,t=null){const[n,r,o]=e;let a=t===null?u.rgb.hsv(e)[2]:t;if(a=Math.round(a/50),a===0)return 30;let l=30+(Math.round(o/255)<<2|Math.round(r/255)<<1|Math.round(n/255));return a===2&&(l+=60),l};u.hsv.ansi16=function(e){return u.rgb.ansi16(u.hsv.rgb(e),e[2])};u.rgb.ansi256=function(e){const t=e[0],n=e[1],r=e[2];return t===n&&n===r?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(n/255*5)+Math.round(r/255*5)};u.ansi16.rgb=function(e){let t=e%10;if(t===0||t===7)return e>50&&(t+=3.5),t=t/10.5*255,[t,t,t];const n=(~~(e>50)+1)*.5,r=(t&1)*n*255,o=(t>>1&1)*n*255,a=(t>>2&1)*n*255;return[r,o,a]};u.ansi256.rgb=function(e){if(e>=232){const a=(e-232)*10+8;return[a,a,a]}e-=16;let t;const n=Math.floor(e/36)/5*255,r=Math.floor((t=e%36)/6)/5*255,o=t%6/5*255;return[n,r,o]};u.rgb.hex=function(e){const n=(((Math.round(e[0])&255)<<16)+((Math.round(e[1])&255)<<8)+(Math.round(e[2])&255)).toString(16).toUpperCase();return"000000".substring(n.length)+n};u.hex.rgb=function(e){const t=e.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!t)return[0,0,0];let n=t[0];t[0].length===3&&(n=n.split("").map(s=>s+s).join(""));const r=parseInt(n,16),o=r>>16&255,a=r>>8&255,l=r&255;return[o,a,l]};u.rgb.hcg=function(e){const t=e[0]/255,n=e[1]/255,r=e[2]/255,o=Math.max(Math.max(t,n),r),a=Math.min(Math.min(t,n),r),l=o-a;let s,c;return l<1?s=a/(1-l):s=0,l<=0?c=0:o===t?c=(n-r)/l%6:o===n?c=2+(r-t)/l:c=4+(t-n)/l,c/=6,c%=1,[c*360,l*100,s*100]};u.hsl.hcg=function(e){const t=e[1]/100,n=e[2]/100,r=n<.5?2*t*n:2*t*(1-n);let o=0;return r<1&&(o=(n-.5*r)/(1-r)),[e[0],r*100,o*100]};u.hsv.hcg=function(e){const t=e[1]/100,n=e[2]/100,r=t*n;let o=0;return r<1&&(o=(n-r)/(1-r)),[e[0],r*100,o*100]};u.hcg.rgb=function(e){const t=e[0]/360,n=e[1]/100,r=e[2]/100;if(n===0)return[r*255,r*255,r*255];const o=[0,0,0],a=t%1*6,l=a%1,s=1-l;let c=0;switch(Math.floor(a)){case 0:o[0]=1,o[1]=l,o[2]=0;break;case 1:o[0]=s,o[1]=1,o[2]=0;break;case 2:o[0]=0,o[1]=1,o[2]=l;break;case 3:o[0]=0,o[1]=s,o[2]=1;break;case 4:o[0]=l,o[1]=0,o[2]=1;break;default:o[0]=1,o[1]=0,o[2]=s}return c=(1-n)*r,[(n*o[0]+c)*255,(n*o[1]+c)*255,(n*o[2]+c)*255]};u.hcg.hsv=function(e){const t=e[1]/100,n=e[2]/100,r=t+n*(1-t);let o=0;return r>0&&(o=t/r),[e[0],o*100,r*100]};u.hcg.hsl=function(e){const t=e[1]/100,r=e[2]/100*(1-t)+.5*t;let o=0;return r>0&&r<.5?o=t/(2*r):r>=.5&&r<1&&(o=t/(2*(1-r))),[e[0],o*100,r*100]};u.hcg.hwb=function(e){const t=e[1]/100,n=e[2]/100,r=t+n*(1-t);return[e[0],(r-t)*100,(1-r)*100]};u.hwb.hcg=function(e){const t=e[1]/100,r=1-e[2]/100,o=r-t;let a=0;return o<1&&(a=(r-o)/(1-o)),[e[0],o*100,a*100]};u.apple.rgb=function(e){return[e[0]/65535*255,e[1]/65535*255,e[2]/65535*255]};u.rgb.apple=function(e){return[e[0]/255*65535,e[1]/255*65535,e[2]/255*65535]};u.gray.rgb=function(e){return[e[0]/100*255,e[0]/100*255,e[0]/100*255]};u.gray.hsl=function(e){return[0,0,e[0]]};u.gray.hsv=u.gray.hsl;u.gray.hwb=function(e){return[0,100,e[0]]};u.gray.cmyk=function(e){return[0,0,0,e[0]]};u.gray.lab=function(e){return[e[0],0,0]};u.gray.hex=function(e){const t=Math.round(e[0]/100*255)&255,r=((t<<16)+(t<<8)+t).toString(16).toUpperCase();return"000000".substring(r.length)+r};u.rgb.gray=function(e){return[(e[0]+e[1]+e[2])/3/255*100]};const W=_e;function Qe(){const e={},t=Object.keys(W);for(let n=t.length,r=0;r<n;r++)e[t[r]]={distance:-1,parent:null};return e}function Ze(e){const t=Qe(),n=[e];for(t[e].distance=0;n.length;){const r=n.pop(),o=Object.keys(W[r]);for(let a=o.length,l=0;l<a;l++){const s=o[l],c=t[s];c.distance===-1&&(c.distance=t[r].distance+1,c.parent=r,n.unshift(s))}}return t}function et(e,t){return function(n){return t(e(n))}}function tt(e,t){const n=[t[e].parent,e];let r=W[t[e].parent][e],o=t[e].parent;for(;t[o].parent;)n.unshift(t[o].parent),r=et(W[t[o].parent][o],r),o=t[o].parent;return r.conversion=n,r}var nt=function(e){const t=Ze(e),n={},r=Object.keys(t);for(let o=r.length,a=0;a<o;a++){const l=r[a];t[l].parent!==null&&(n[l]=tt(l,t))}return n};const U=_e,rt=nt,O={},ot=Object.keys(U);function at(e){const t=function(...n){const r=n[0];return r==null?r:(r.length>1&&(n=r),e(n))};return"conversion"in e&&(t.conversion=e.conversion),t}function lt(e){const t=function(...n){const r=n[0];if(r==null)return r;r.length>1&&(n=r);const o=e(n);if(typeof o=="object")for(let a=o.length,l=0;l<a;l++)o[l]=Math.round(o[l]);return o};return"conversion"in e&&(t.conversion=e.conversion),t}ot.forEach(e=>{O[e]={},Object.defineProperty(O[e],"channels",{value:U[e].channels}),Object.defineProperty(O[e],"labels",{value:U[e].labels});const t=rt(e);Object.keys(t).forEach(r=>{const o=t[r];O[e][r]=lt(o),O[e][r].raw=at(o)})});var st=O;const _=fe(st);var ct=Ne,it=function(){return ct.Date.now()},ut=it,ft=/\s/;function ht(e){for(var t=e.length;t--&&ft.test(e.charAt(t)););return t}var dt=ht,gt=dt,bt=/^\s+/;function mt(e){return e&&e.slice(0,gt(e)+1).replace(bt,"")}var vt=mt,pt=vt,ae=J,yt=Ie,le=NaN,xt=/^[-+]0x[0-9a-f]+$/i,wt=/^0b[01]+$/i,kt=/^0o[0-7]+$/i,_t=parseInt;function Et(e){if(typeof e=="number")return e;if(yt(e))return le;if(ae(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=ae(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=pt(e);var n=wt.test(e);return n||kt.test(e)?_t(e.slice(2),n?2:8):xt.test(e)?le:+e}var Mt=Et,Ct=J,D=ut,se=Mt,$t="Expected a function",Ot=Math.max,Nt=Math.min;function It(e,t,n){var r,o,a,l,s,c,i=0,d=!1,f=!1,g=!0;if(typeof e!="function")throw new TypeError($t);t=se(t)||0,Ct(n)&&(d=!!n.leading,f="maxWait"in n,a=f?Ot(se(n.maxWait)||0,t):a,g="trailing"in n?!!n.trailing:g);function w(v){var M=r,j=o;return r=o=void 0,i=v,l=e.apply(j,M),l}function S(v){return i=v,s=setTimeout(m,t),d?w(v):l}function E(v){var M=v-c,j=v-i,te=t-M;return f?Nt(te,a-j):te}function p(v){var M=v-c,j=v-i;return c===void 0||M>=t||M<0||f&&j>=a}function m(){var v=D();if(p(v))return k(v);s=setTimeout(m,E(v))}function k(v){return s=void 0,g&&r?w(v):(r=o=void 0,l)}function y(){s!==void 0&&clearTimeout(s),i=0,r=c=o=s=void 0}function R(){return s===void 0?l:k(D())}function T(){var v=D(),M=p(v);if(r=arguments,o=this,c=v,M){if(s===void 0)return S(c);if(f)return clearTimeout(s),s=setTimeout(m,t),w(c)}return s===void 0&&(s=setTimeout(m,t)),l}return T.cancel=y,T.flush=R,T}var St=It,Rt=St,Tt=J,jt="Expected a function";function Ft(e,t,n){var r=!0,o=!0;if(typeof e!="function")throw new TypeError(jt);return Tt(n)&&(r="leading"in n?!!n.leading:r,o="trailing"in n?!!n.trailing:o),Rt(e,t,{leading:r,maxWait:t,trailing:o})}var zt=Ft;const Ht=fe(zt);var Pt=C.div({position:"relative",maxWidth:250,'&[aria-readonly="true"]':{opacity:.5}}),Lt=C(ue)({position:"absolute",zIndex:1,top:4,left:4,"[aria-readonly=true] &":{cursor:"not-allowed"}}),qt=C.div({width:200,margin:5,".react-colorful__saturation":{borderRadius:"4px 4px 0 0"},".react-colorful__hue":{boxShadow:"inset 0 0 0 1px rgb(0 0 0 / 5%)"},".react-colorful__last-control":{borderRadius:"0 0 4px 4px"}}),Bt=C(Me)(({theme:e})=>({fontFamily:e.typography.fonts.base})),Wt=C.div({display:"grid",gridTemplateColumns:"repeat(9, 16px)",gap:6,padding:3,marginTop:5,width:200}),Xt=C.div(({theme:e,active:t})=>({width:16,height:16,boxShadow:t?`${e.appBorderColor} 0 0 0 1px inset, ${e.textMutedColor}50 0 0 0 4px`:`${e.appBorderColor} 0 0 0 1px inset`,borderRadius:e.appBorderRadius})),Dt=`url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill-opacity=".05"><path d="M8 0h8v8H8zM0 8h8v8H0z"/></svg>')`,ce=({value:e,style:t,...n})=>{let r=`linear-gradient(${e}, ${e}), ${Dt}, linear-gradient(#fff, #fff)`;return h.createElement(Xt,{...n,style:{...t,backgroundImage:r}})},Kt=C(Ce.Input)(({theme:e,readOnly:t})=>({width:"100%",paddingLeft:30,paddingRight:30,boxSizing:"border-box",fontFamily:e.typography.fonts.base})),Vt=C($e)(({theme:e})=>({position:"absolute",zIndex:1,top:6,right:7,width:20,height:20,padding:4,boxSizing:"border-box",cursor:"pointer",color:e.input.color})),Ee=(e=>(e.RGB="rgb",e.HSL="hsl",e.HEX="hex",e))(Ee||{}),L=Object.values(Ee),At=/\(([0-9]+),\s*([0-9]+)%?,\s*([0-9]+)%?,?\s*([0-9.]+)?\)/,Gt=/^\s*rgba?\(([0-9]+),\s*([0-9]+),\s*([0-9]+),?\s*([0-9.]+)?\)\s*$/i,Ut=/^\s*hsla?\(([0-9]+),\s*([0-9]+)%,\s*([0-9]+)%,?\s*([0-9.]+)?\)\s*$/i,Y=/^\s*#?([0-9a-f]{3}|[0-9a-f]{6})\s*$/i,Yt=/^\s*#?([0-9a-f]{3})\s*$/i,Jt={hex:De,rgb:Ue,hsl:Ae},q={hex:"transparent",rgb:"rgba(0, 0, 0, 0)",hsl:"hsla(0, 0%, 0%, 0)"},ie=e=>{let t=e?.match(At);if(!t)return[0,0,0,1];let[,n,r,o,a=1]=t;return[n,r,o,a].map(Number)},N=e=>{if(!e)return;let t=!0;if(Gt.test(e)){let[l,s,c,i]=ie(e),[d,f,g]=_.rgb.hsl([l,s,c])||[0,0,0];return{valid:t,value:e,keyword:_.rgb.keyword([l,s,c]),colorSpace:"rgb",rgb:e,hsl:`hsla(${d}, ${f}%, ${g}%, ${i})`,hex:`#${_.rgb.hex([l,s,c]).toLowerCase()}`}}if(Ut.test(e)){let[l,s,c,i]=ie(e),[d,f,g]=_.hsl.rgb([l,s,c])||[0,0,0];return{valid:t,value:e,keyword:_.hsl.keyword([l,s,c]),colorSpace:"hsl",rgb:`rgba(${d}, ${f}, ${g}, ${i})`,hsl:e,hex:`#${_.hsl.hex([l,s,c]).toLowerCase()}`}}let n=e.replace("#",""),r=_.keyword.rgb(n)||_.hex.rgb(n),o=_.rgb.hsl(r),a=e;if(/[^#a-f0-9]/i.test(e)?a=n:Y.test(e)&&(a=`#${n}`),a.startsWith("#"))t=Y.test(a);else try{_.keyword.hex(a)}catch{t=!1}return{valid:t,value:a,keyword:_.rgb.keyword(r),colorSpace:"hex",rgb:`rgba(${r[0]}, ${r[1]}, ${r[2]}, 1)`,hsl:`hsla(${o[0]}, ${o[1]}%, ${o[2]}%, 1)`,hex:a}},Qt=(e,t,n)=>{if(!e||!t?.valid)return q[n];if(n!=="hex")return t?.[n]||q[n];if(!t.hex.startsWith("#"))try{return`#${_.keyword.hex(t.hex)}`}catch{return q.hex}let r=t.hex.match(Yt);if(!r)return Y.test(t.hex)?t.hex:q.hex;let[o,a,l]=r[1].split("");return`#${o}${o}${a}${a}${l}${l}`},Zt=(e,t)=>{let[n,r]=b.useState(e||""),[o,a]=b.useState(()=>N(n)),[l,s]=b.useState(o?.colorSpace||"hex");b.useEffect(()=>{let f=e||"",g=N(f);r(f),a(g),s(g?.colorSpace||"hex")},[e]);let c=b.useMemo(()=>Qt(n,o,l).toLowerCase(),[n,o,l]),i=b.useCallback(f=>{let g=N(f),w=g?.value||f||"";r(w),w===""&&(a(void 0),t(void 0)),g&&(a(g),s(g.colorSpace),t(g.value))},[t]),d=b.useCallback(()=>{let f=L.indexOf(l)+1;f>=L.length&&(f=0),s(L[f]);let g=o?.[L[f]]||"";r(g),t(g)},[o,l,t]);return{value:n,realValue:c,updateValue:i,color:o,colorSpace:l,cycleColorSpace:d}},X=e=>e.replace(/\s*/,"").toLowerCase(),en=(e,t,n)=>{let[r,o]=b.useState(t?.valid?[t]:[]);b.useEffect(()=>{t===void 0&&o([])},[t]);let a=b.useMemo(()=>(e||[]).map(s=>typeof s=="string"?N(s):s.title?{...N(s.color),keyword:s.title}:N(s.color)).concat(r).filter(Boolean).slice(-27),[e,r]),l=b.useCallback(s=>{s?.valid&&(a.some(c=>X(c[n])===X(s[n]))||o(c=>c.concat(s)))},[n,a]);return{presets:a,addPreset:l}},tn=({name:e,value:t,onChange:n,onFocus:r,onBlur:o,presetColors:a,startOpen:l=!1,argType:s})=>{let c=b.useCallback(Ht(n,200),[n]),{value:i,realValue:d,updateValue:f,color:g,colorSpace:w,cycleColorSpace:S}=Zt(t,c),{presets:E,addPreset:p}=en(a,g,w),m=Jt[w],k=!!s?.table?.readonly;return h.createElement(Pt,{"aria-readonly":k},h.createElement(Lt,{startOpen:l,trigger:k?[null]:void 0,closeOnOutsideClick:!0,onVisibleChange:()=>p(g),tooltip:h.createElement(qt,null,h.createElement(m,{color:d==="transparent"?"#000000":d,onChange:f,onFocus:r,onBlur:o}),E.length>0&&h.createElement(Wt,null,E.map((y,R)=>h.createElement(ue,{key:`${y.value}-${R}`,hasChrome:!1,tooltip:h.createElement(Bt,{note:y.keyword||y.value})},h.createElement(ce,{value:y[w],active:g&&X(y[w])===X(g[w]),onClick:()=>f(y.value)})))))},h.createElement(ce,{value:d,style:{margin:4}})),h.createElement(Kt,{id:Oe(e),value:i,onChange:y=>f(y.target.value),onFocus:y=>y.target.select(),readOnly:k,placeholder:"Choose color..."}),i?h.createElement(Vt,{onClick:S}):null)},cn=tn;export{tn as ColorControl,cn as default};
|
|
1
|
+
import{R as h,d as b,n as C,e as ue,T as Me,F as Ce,M as $e,g as Oe}from"./index-DPPi9iZu.js";import{g as fe,_ as Ne,i as J,b as Ie}from"./index-Cc7K62zD.js";import"./iframe-DcDTQOmA.js";import"../sb-preview/runtime.js";import"./index-DXimoRZY.js";import"./index-DrFu-skq.js";function $(){return($=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function Q(e,t){if(e==null)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)t.indexOf(n=a[r])>=0||(o[n]=e[n]);return o}function K(e){var t=b.useRef(e),n=b.useRef(function(r){t.current&&t.current(r)});return t.current=e,n.current}var I=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=1),e>n?n:e<t?t:e},F=function(e){return"touches"in e},V=function(e){return e&&e.ownerDocument.defaultView||self},ne=function(e,t,n){var r=e.getBoundingClientRect(),o=F(t)?function(a,l){for(var s=0;s<a.length;s++)if(a[s].identifier===l)return a[s];return a[0]}(t.touches,n):t;return{left:I((o.pageX-(r.left+V(e).pageXOffset))/r.width),top:I((o.pageY-(r.top+V(e).pageYOffset))/r.height)}},re=function(e){!F(e)&&e.preventDefault()},Z=h.memo(function(e){var t=e.onMove,n=e.onKey,r=Q(e,["onMove","onKey"]),o=b.useRef(null),a=K(t),l=K(n),s=b.useRef(null),c=b.useRef(!1),i=b.useMemo(function(){var w=function(p){re(p),(F(p)?p.touches.length>0:p.buttons>0)&&o.current?a(ne(o.current,p,s.current)):E(!1)},S=function(){return E(!1)};function E(p){var m=c.current,k=V(o.current),y=p?k.addEventListener:k.removeEventListener;y(m?"touchmove":"mousemove",w),y(m?"touchend":"mouseup",S)}return[function(p){var m=p.nativeEvent,k=o.current;if(k&&(re(m),!function(R,T){return T&&!F(R)}(m,c.current)&&k)){if(F(m)){c.current=!0;var y=m.changedTouches||[];y.length&&(s.current=y[0].identifier)}k.focus(),a(ne(k,m,s.current)),E(!0)}},function(p){var m=p.which||p.keyCode;m<37||m>40||(p.preventDefault(),l({left:m===39?.05:m===37?-.05:0,top:m===40?.05:m===38?-.05:0}))},E]},[l,a]),d=i[0],f=i[1],g=i[2];return b.useEffect(function(){return g},[g]),h.createElement("div",$({},r,{onTouchStart:d,onMouseDown:d,className:"react-colorful__interactive",ref:o,onKeyDown:f,tabIndex:0,role:"slider"}))}),H=function(e){return e.filter(Boolean).join(" ")},ee=function(e){var t=e.color,n=e.left,r=e.top,o=r===void 0?.5:r,a=H(["react-colorful__pointer",e.className]);return h.createElement("div",{className:a,style:{top:100*o+"%",left:100*n+"%"}},h.createElement("div",{className:"react-colorful__pointer-fill",style:{backgroundColor:t}}))},x=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=Math.pow(10,t)),Math.round(n*e)/n},Se={grad:.9,turn:360,rad:360/(2*Math.PI)},Re=function(e){return ge(A(e))},A=function(e){return e[0]==="#"&&(e=e.substring(1)),e.length<6?{r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16),a:e.length===4?x(parseInt(e[3]+e[3],16)/255,2):1}:{r:parseInt(e.substring(0,2),16),g:parseInt(e.substring(2,4),16),b:parseInt(e.substring(4,6),16),a:e.length===8?x(parseInt(e.substring(6,8),16)/255,2):1}},Te=function(e,t){return t===void 0&&(t="deg"),Number(e)*(Se[t]||1)},je=function(e){var t=/hsla?\(?\s*(-?\d*\.?\d+)(deg|rad|grad|turn)?[,\s]+(-?\d*\.?\d+)%?[,\s]+(-?\d*\.?\d+)%?,?\s*[/\s]*(-?\d*\.?\d+)?(%)?\s*\)?/i.exec(e);return t?Fe({h:Te(t[1],t[2]),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)}):{h:0,s:0,v:0,a:1}},Fe=function(e){var t=e.s,n=e.l;return{h:e.h,s:(t*=(n<50?n:100-n)/100)>0?2*t/(n+t)*100:0,v:n+t,a:e.a}},ze=function(e){return Pe(de(e))},he=function(e){var t=e.s,n=e.v,r=e.a,o=(200-t)*n/100;return{h:x(e.h),s:x(o>0&&o<200?t*n/100/(o<=100?o:200-o)*100:0),l:x(o/2),a:x(r,2)}},G=function(e){var t=he(e);return"hsl("+t.h+", "+t.s+"%, "+t.l+"%)"},B=function(e){var t=he(e);return"hsla("+t.h+", "+t.s+"%, "+t.l+"%, "+t.a+")"},de=function(e){var t=e.h,n=e.s,r=e.v,o=e.a;t=t/360*6,n/=100,r/=100;var a=Math.floor(t),l=r*(1-n),s=r*(1-(t-a)*n),c=r*(1-(1-t+a)*n),i=a%6;return{r:x(255*[r,s,l,l,c,r][i]),g:x(255*[c,r,r,s,l,l][i]),b:x(255*[l,l,c,r,r,s][i]),a:x(o,2)}},He=function(e){var t=/rgba?\(?\s*(-?\d*\.?\d+)(%)?[,\s]+(-?\d*\.?\d+)(%)?[,\s]+(-?\d*\.?\d+)(%)?,?\s*[/\s]*(-?\d*\.?\d+)?(%)?\s*\)?/i.exec(e);return t?ge({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):{h:0,s:0,v:0,a:1}},P=function(e){var t=e.toString(16);return t.length<2?"0"+t:t},Pe=function(e){var t=e.r,n=e.g,r=e.b,o=e.a,a=o<1?P(x(255*o)):"";return"#"+P(t)+P(n)+P(r)+a},ge=function(e){var t=e.r,n=e.g,r=e.b,o=e.a,a=Math.max(t,n,r),l=a-Math.min(t,n,r),s=l?a===t?(n-r)/l:a===n?2+(r-t)/l:4+(t-n)/l:0;return{h:x(60*(s<0?s+6:s)),s:x(a?l/a*100:0),v:x(a/255*100),a:o}},be=h.memo(function(e){var t=e.hue,n=e.onChange,r=H(["react-colorful__hue",e.className]);return h.createElement("div",{className:r},h.createElement(Z,{onMove:function(o){n({h:360*o.left})},onKey:function(o){n({h:I(t+360*o.left,0,360)})},"aria-label":"Hue","aria-valuenow":x(t),"aria-valuemax":"360","aria-valuemin":"0"},h.createElement(ee,{className:"react-colorful__hue-pointer",left:t/360,color:G({h:t,s:100,v:100,a:1})})))}),me=h.memo(function(e){var t=e.hsva,n=e.onChange,r={backgroundColor:G({h:t.h,s:100,v:100,a:1})};return h.createElement("div",{className:"react-colorful__saturation",style:r},h.createElement(Z,{onMove:function(o){n({s:100*o.left,v:100-100*o.top})},onKey:function(o){n({s:I(t.s+100*o.left,0,100),v:I(t.v-100*o.top,0,100)})},"aria-label":"Color","aria-valuetext":"Saturation "+x(t.s)+"%, Brightness "+x(t.v)+"%"},h.createElement(ee,{className:"react-colorful__saturation-pointer",top:1-t.v/100,left:t.s/100,color:G(t)})))}),ve=function(e,t){if(e===t)return!0;for(var n in e)if(e[n]!==t[n])return!1;return!0},pe=function(e,t){return e.replace(/\s/g,"")===t.replace(/\s/g,"")},Le=function(e,t){return e.toLowerCase()===t.toLowerCase()||ve(A(e),A(t))};function ye(e,t,n){var r=K(n),o=b.useState(function(){return e.toHsva(t)}),a=o[0],l=o[1],s=b.useRef({color:t,hsva:a});b.useEffect(function(){if(!e.equal(t,s.current.color)){var i=e.toHsva(t);s.current={hsva:i,color:t},l(i)}},[t,e]),b.useEffect(function(){var i;ve(a,s.current.hsva)||e.equal(i=e.fromHsva(a),s.current.color)||(s.current={hsva:a,color:i},r(i))},[a,e,r]);var c=b.useCallback(function(i){l(function(d){return Object.assign({},d,i)})},[]);return[a,c]}var qe=typeof window<"u"?b.useLayoutEffect:b.useEffect,Be=function(){return typeof __webpack_nonce__<"u"?__webpack_nonce__:void 0},oe=new Map,xe=function(e){qe(function(){var t=e.current?e.current.ownerDocument:document;if(t!==void 0&&!oe.has(t)){var n=t.createElement("style");n.innerHTML=`.react-colorful{position:relative;display:flex;flex-direction:column;width:200px;height:200px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:default}.react-colorful__saturation{position:relative;flex-grow:1;border-color:transparent;border-bottom:12px solid #000;border-radius:8px 8px 0 0;background-image:linear-gradient(0deg,#000,transparent),linear-gradient(90deg,#fff,hsla(0,0%,100%,0))}.react-colorful__alpha-gradient,.react-colorful__pointer-fill{content:"";position:absolute;left:0;top:0;right:0;bottom:0;pointer-events:none;border-radius:inherit}.react-colorful__alpha-gradient,.react-colorful__saturation{box-shadow:inset 0 0 0 1px rgba(0,0,0,.05)}.react-colorful__alpha,.react-colorful__hue{position:relative;height:24px}.react-colorful__hue{background:linear-gradient(90deg,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red)}.react-colorful__last-control{border-radius:0 0 8px 8px}.react-colorful__interactive{position:absolute;left:0;top:0;right:0;bottom:0;border-radius:inherit;outline:none;touch-action:none}.react-colorful__pointer{position:absolute;z-index:1;box-sizing:border-box;width:28px;height:28px;transform:translate(-50%,-50%);background-color:#fff;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 4px rgba(0,0,0,.2)}.react-colorful__interactive:focus .react-colorful__pointer{transform:translate(-50%,-50%) scale(1.1)}.react-colorful__alpha,.react-colorful__alpha-pointer{background-color:#fff;background-image:url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill-opacity=".05"><path d="M8 0h8v8H8zM0 8h8v8H0z"/></svg>')}.react-colorful__saturation-pointer{z-index:3}.react-colorful__hue-pointer{z-index:2}`,oe.set(t,n);var r=Be();r&&n.setAttribute("nonce",r),t.head.appendChild(n)}},[])},We=function(e){var t=e.className,n=e.colorModel,r=e.color,o=r===void 0?n.defaultColor:r,a=e.onChange,l=Q(e,["className","colorModel","color","onChange"]),s=b.useRef(null);xe(s);var c=ye(n,o,a),i=c[0],d=c[1],f=H(["react-colorful",t]);return h.createElement("div",$({},l,{ref:s,className:f}),h.createElement(me,{hsva:i,onChange:d}),h.createElement(be,{hue:i.h,onChange:d,className:"react-colorful__last-control"}))},Xe={defaultColor:"000",toHsva:Re,fromHsva:function(e){return ze({h:e.h,s:e.s,v:e.v,a:1})},equal:Le},De=function(e){return h.createElement(We,$({},e,{colorModel:Xe}))},Ke=function(e){var t=e.className,n=e.hsva,r=e.onChange,o={backgroundImage:"linear-gradient(90deg, "+B(Object.assign({},n,{a:0}))+", "+B(Object.assign({},n,{a:1}))+")"},a=H(["react-colorful__alpha",t]),l=x(100*n.a);return h.createElement("div",{className:a},h.createElement("div",{className:"react-colorful__alpha-gradient",style:o}),h.createElement(Z,{onMove:function(s){r({a:s.left})},onKey:function(s){r({a:I(n.a+s.left)})},"aria-label":"Alpha","aria-valuetext":l+"%","aria-valuenow":l,"aria-valuemin":"0","aria-valuemax":"100"},h.createElement(ee,{className:"react-colorful__alpha-pointer",left:n.a,color:B(n)})))},we=function(e){var t=e.className,n=e.colorModel,r=e.color,o=r===void 0?n.defaultColor:r,a=e.onChange,l=Q(e,["className","colorModel","color","onChange"]),s=b.useRef(null);xe(s);var c=ye(n,o,a),i=c[0],d=c[1],f=H(["react-colorful",t]);return h.createElement("div",$({},l,{ref:s,className:f}),h.createElement(me,{hsva:i,onChange:d}),h.createElement(be,{hue:i.h,onChange:d}),h.createElement(Ke,{hsva:i,onChange:d,className:"react-colorful__last-control"}))},Ve={defaultColor:"hsla(0, 0%, 0%, 1)",toHsva:je,fromHsva:B,equal:pe},Ae=function(e){return h.createElement(we,$({},e,{colorModel:Ve}))},Ge={defaultColor:"rgba(0, 0, 0, 1)",toHsva:He,fromHsva:function(e){var t=de(e);return"rgba("+t.r+", "+t.g+", "+t.b+", "+t.a+")"},equal:pe},Ue=function(e){return h.createElement(we,$({},e,{colorModel:Ge}))},Ye={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};const z=Ye,ke={};for(const e of Object.keys(z))ke[z[e]]=e;const u={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};var _e=u;for(const e of Object.keys(u)){if(!("channels"in u[e]))throw new Error("missing channels property: "+e);if(!("labels"in u[e]))throw new Error("missing channel labels property: "+e);if(u[e].labels.length!==u[e].channels)throw new Error("channel and label counts mismatch: "+e);const{channels:t,labels:n}=u[e];delete u[e].channels,delete u[e].labels,Object.defineProperty(u[e],"channels",{value:t}),Object.defineProperty(u[e],"labels",{value:n})}u.rgb.hsl=function(e){const t=e[0]/255,n=e[1]/255,r=e[2]/255,o=Math.min(t,n,r),a=Math.max(t,n,r),l=a-o;let s,c;a===o?s=0:t===a?s=(n-r)/l:n===a?s=2+(r-t)/l:r===a&&(s=4+(t-n)/l),s=Math.min(s*60,360),s<0&&(s+=360);const i=(o+a)/2;return a===o?c=0:i<=.5?c=l/(a+o):c=l/(2-a-o),[s,c*100,i*100]};u.rgb.hsv=function(e){let t,n,r,o,a;const l=e[0]/255,s=e[1]/255,c=e[2]/255,i=Math.max(l,s,c),d=i-Math.min(l,s,c),f=function(g){return(i-g)/6/d+1/2};return d===0?(o=0,a=0):(a=d/i,t=f(l),n=f(s),r=f(c),l===i?o=r-n:s===i?o=1/3+t-r:c===i&&(o=2/3+n-t),o<0?o+=1:o>1&&(o-=1)),[o*360,a*100,i*100]};u.rgb.hwb=function(e){const t=e[0],n=e[1];let r=e[2];const o=u.rgb.hsl(e)[0],a=1/255*Math.min(t,Math.min(n,r));return r=1-1/255*Math.max(t,Math.max(n,r)),[o,a*100,r*100]};u.rgb.cmyk=function(e){const t=e[0]/255,n=e[1]/255,r=e[2]/255,o=Math.min(1-t,1-n,1-r),a=(1-t-o)/(1-o)||0,l=(1-n-o)/(1-o)||0,s=(1-r-o)/(1-o)||0;return[a*100,l*100,s*100,o*100]};function Je(e,t){return(e[0]-t[0])**2+(e[1]-t[1])**2+(e[2]-t[2])**2}u.rgb.keyword=function(e){const t=ke[e];if(t)return t;let n=1/0,r;for(const o of Object.keys(z)){const a=z[o],l=Je(e,a);l<n&&(n=l,r=o)}return r};u.keyword.rgb=function(e){return z[e]};u.rgb.xyz=function(e){let t=e[0]/255,n=e[1]/255,r=e[2]/255;t=t>.04045?((t+.055)/1.055)**2.4:t/12.92,n=n>.04045?((n+.055)/1.055)**2.4:n/12.92,r=r>.04045?((r+.055)/1.055)**2.4:r/12.92;const o=t*.4124+n*.3576+r*.1805,a=t*.2126+n*.7152+r*.0722,l=t*.0193+n*.1192+r*.9505;return[o*100,a*100,l*100]};u.rgb.lab=function(e){const t=u.rgb.xyz(e);let n=t[0],r=t[1],o=t[2];n/=95.047,r/=100,o/=108.883,n=n>.008856?n**(1/3):7.787*n+16/116,r=r>.008856?r**(1/3):7.787*r+16/116,o=o>.008856?o**(1/3):7.787*o+16/116;const a=116*r-16,l=500*(n-r),s=200*(r-o);return[a,l,s]};u.hsl.rgb=function(e){const t=e[0]/360,n=e[1]/100,r=e[2]/100;let o,a,l;if(n===0)return l=r*255,[l,l,l];r<.5?o=r*(1+n):o=r+n-r*n;const s=2*r-o,c=[0,0,0];for(let i=0;i<3;i++)a=t+1/3*-(i-1),a<0&&a++,a>1&&a--,6*a<1?l=s+(o-s)*6*a:2*a<1?l=o:3*a<2?l=s+(o-s)*(2/3-a)*6:l=s,c[i]=l*255;return c};u.hsl.hsv=function(e){const t=e[0];let n=e[1]/100,r=e[2]/100,o=n;const a=Math.max(r,.01);r*=2,n*=r<=1?r:2-r,o*=a<=1?a:2-a;const l=(r+n)/2,s=r===0?2*o/(a+o):2*n/(r+n);return[t,s*100,l*100]};u.hsv.rgb=function(e){const t=e[0]/60,n=e[1]/100;let r=e[2]/100;const o=Math.floor(t)%6,a=t-Math.floor(t),l=255*r*(1-n),s=255*r*(1-n*a),c=255*r*(1-n*(1-a));switch(r*=255,o){case 0:return[r,c,l];case 1:return[s,r,l];case 2:return[l,r,c];case 3:return[l,s,r];case 4:return[c,l,r];case 5:return[r,l,s]}};u.hsv.hsl=function(e){const t=e[0],n=e[1]/100,r=e[2]/100,o=Math.max(r,.01);let a,l;l=(2-n)*r;const s=(2-n)*o;return a=n*o,a/=s<=1?s:2-s,a=a||0,l/=2,[t,a*100,l*100]};u.hwb.rgb=function(e){const t=e[0]/360;let n=e[1]/100,r=e[2]/100;const o=n+r;let a;o>1&&(n/=o,r/=o);const l=Math.floor(6*t),s=1-r;a=6*t-l,l&1&&(a=1-a);const c=n+a*(s-n);let i,d,f;switch(l){default:case 6:case 0:i=s,d=c,f=n;break;case 1:i=c,d=s,f=n;break;case 2:i=n,d=s,f=c;break;case 3:i=n,d=c,f=s;break;case 4:i=c,d=n,f=s;break;case 5:i=s,d=n,f=c;break}return[i*255,d*255,f*255]};u.cmyk.rgb=function(e){const t=e[0]/100,n=e[1]/100,r=e[2]/100,o=e[3]/100,a=1-Math.min(1,t*(1-o)+o),l=1-Math.min(1,n*(1-o)+o),s=1-Math.min(1,r*(1-o)+o);return[a*255,l*255,s*255]};u.xyz.rgb=function(e){const t=e[0]/100,n=e[1]/100,r=e[2]/100;let o,a,l;return o=t*3.2406+n*-1.5372+r*-.4986,a=t*-.9689+n*1.8758+r*.0415,l=t*.0557+n*-.204+r*1.057,o=o>.0031308?1.055*o**(1/2.4)-.055:o*12.92,a=a>.0031308?1.055*a**(1/2.4)-.055:a*12.92,l=l>.0031308?1.055*l**(1/2.4)-.055:l*12.92,o=Math.min(Math.max(0,o),1),a=Math.min(Math.max(0,a),1),l=Math.min(Math.max(0,l),1),[o*255,a*255,l*255]};u.xyz.lab=function(e){let t=e[0],n=e[1],r=e[2];t/=95.047,n/=100,r/=108.883,t=t>.008856?t**(1/3):7.787*t+16/116,n=n>.008856?n**(1/3):7.787*n+16/116,r=r>.008856?r**(1/3):7.787*r+16/116;const o=116*n-16,a=500*(t-n),l=200*(n-r);return[o,a,l]};u.lab.xyz=function(e){const t=e[0],n=e[1],r=e[2];let o,a,l;a=(t+16)/116,o=n/500+a,l=a-r/200;const s=a**3,c=o**3,i=l**3;return a=s>.008856?s:(a-16/116)/7.787,o=c>.008856?c:(o-16/116)/7.787,l=i>.008856?i:(l-16/116)/7.787,o*=95.047,a*=100,l*=108.883,[o,a,l]};u.lab.lch=function(e){const t=e[0],n=e[1],r=e[2];let o;o=Math.atan2(r,n)*360/2/Math.PI,o<0&&(o+=360);const l=Math.sqrt(n*n+r*r);return[t,l,o]};u.lch.lab=function(e){const t=e[0],n=e[1],o=e[2]/360*2*Math.PI,a=n*Math.cos(o),l=n*Math.sin(o);return[t,a,l]};u.rgb.ansi16=function(e,t=null){const[n,r,o]=e;let a=t===null?u.rgb.hsv(e)[2]:t;if(a=Math.round(a/50),a===0)return 30;let l=30+(Math.round(o/255)<<2|Math.round(r/255)<<1|Math.round(n/255));return a===2&&(l+=60),l};u.hsv.ansi16=function(e){return u.rgb.ansi16(u.hsv.rgb(e),e[2])};u.rgb.ansi256=function(e){const t=e[0],n=e[1],r=e[2];return t===n&&n===r?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(n/255*5)+Math.round(r/255*5)};u.ansi16.rgb=function(e){let t=e%10;if(t===0||t===7)return e>50&&(t+=3.5),t=t/10.5*255,[t,t,t];const n=(~~(e>50)+1)*.5,r=(t&1)*n*255,o=(t>>1&1)*n*255,a=(t>>2&1)*n*255;return[r,o,a]};u.ansi256.rgb=function(e){if(e>=232){const a=(e-232)*10+8;return[a,a,a]}e-=16;let t;const n=Math.floor(e/36)/5*255,r=Math.floor((t=e%36)/6)/5*255,o=t%6/5*255;return[n,r,o]};u.rgb.hex=function(e){const n=(((Math.round(e[0])&255)<<16)+((Math.round(e[1])&255)<<8)+(Math.round(e[2])&255)).toString(16).toUpperCase();return"000000".substring(n.length)+n};u.hex.rgb=function(e){const t=e.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!t)return[0,0,0];let n=t[0];t[0].length===3&&(n=n.split("").map(s=>s+s).join(""));const r=parseInt(n,16),o=r>>16&255,a=r>>8&255,l=r&255;return[o,a,l]};u.rgb.hcg=function(e){const t=e[0]/255,n=e[1]/255,r=e[2]/255,o=Math.max(Math.max(t,n),r),a=Math.min(Math.min(t,n),r),l=o-a;let s,c;return l<1?s=a/(1-l):s=0,l<=0?c=0:o===t?c=(n-r)/l%6:o===n?c=2+(r-t)/l:c=4+(t-n)/l,c/=6,c%=1,[c*360,l*100,s*100]};u.hsl.hcg=function(e){const t=e[1]/100,n=e[2]/100,r=n<.5?2*t*n:2*t*(1-n);let o=0;return r<1&&(o=(n-.5*r)/(1-r)),[e[0],r*100,o*100]};u.hsv.hcg=function(e){const t=e[1]/100,n=e[2]/100,r=t*n;let o=0;return r<1&&(o=(n-r)/(1-r)),[e[0],r*100,o*100]};u.hcg.rgb=function(e){const t=e[0]/360,n=e[1]/100,r=e[2]/100;if(n===0)return[r*255,r*255,r*255];const o=[0,0,0],a=t%1*6,l=a%1,s=1-l;let c=0;switch(Math.floor(a)){case 0:o[0]=1,o[1]=l,o[2]=0;break;case 1:o[0]=s,o[1]=1,o[2]=0;break;case 2:o[0]=0,o[1]=1,o[2]=l;break;case 3:o[0]=0,o[1]=s,o[2]=1;break;case 4:o[0]=l,o[1]=0,o[2]=1;break;default:o[0]=1,o[1]=0,o[2]=s}return c=(1-n)*r,[(n*o[0]+c)*255,(n*o[1]+c)*255,(n*o[2]+c)*255]};u.hcg.hsv=function(e){const t=e[1]/100,n=e[2]/100,r=t+n*(1-t);let o=0;return r>0&&(o=t/r),[e[0],o*100,r*100]};u.hcg.hsl=function(e){const t=e[1]/100,r=e[2]/100*(1-t)+.5*t;let o=0;return r>0&&r<.5?o=t/(2*r):r>=.5&&r<1&&(o=t/(2*(1-r))),[e[0],o*100,r*100]};u.hcg.hwb=function(e){const t=e[1]/100,n=e[2]/100,r=t+n*(1-t);return[e[0],(r-t)*100,(1-r)*100]};u.hwb.hcg=function(e){const t=e[1]/100,r=1-e[2]/100,o=r-t;let a=0;return o<1&&(a=(r-o)/(1-o)),[e[0],o*100,a*100]};u.apple.rgb=function(e){return[e[0]/65535*255,e[1]/65535*255,e[2]/65535*255]};u.rgb.apple=function(e){return[e[0]/255*65535,e[1]/255*65535,e[2]/255*65535]};u.gray.rgb=function(e){return[e[0]/100*255,e[0]/100*255,e[0]/100*255]};u.gray.hsl=function(e){return[0,0,e[0]]};u.gray.hsv=u.gray.hsl;u.gray.hwb=function(e){return[0,100,e[0]]};u.gray.cmyk=function(e){return[0,0,0,e[0]]};u.gray.lab=function(e){return[e[0],0,0]};u.gray.hex=function(e){const t=Math.round(e[0]/100*255)&255,r=((t<<16)+(t<<8)+t).toString(16).toUpperCase();return"000000".substring(r.length)+r};u.rgb.gray=function(e){return[(e[0]+e[1]+e[2])/3/255*100]};const W=_e;function Qe(){const e={},t=Object.keys(W);for(let n=t.length,r=0;r<n;r++)e[t[r]]={distance:-1,parent:null};return e}function Ze(e){const t=Qe(),n=[e];for(t[e].distance=0;n.length;){const r=n.pop(),o=Object.keys(W[r]);for(let a=o.length,l=0;l<a;l++){const s=o[l],c=t[s];c.distance===-1&&(c.distance=t[r].distance+1,c.parent=r,n.unshift(s))}}return t}function et(e,t){return function(n){return t(e(n))}}function tt(e,t){const n=[t[e].parent,e];let r=W[t[e].parent][e],o=t[e].parent;for(;t[o].parent;)n.unshift(t[o].parent),r=et(W[t[o].parent][o],r),o=t[o].parent;return r.conversion=n,r}var nt=function(e){const t=Ze(e),n={},r=Object.keys(t);for(let o=r.length,a=0;a<o;a++){const l=r[a];t[l].parent!==null&&(n[l]=tt(l,t))}return n};const U=_e,rt=nt,O={},ot=Object.keys(U);function at(e){const t=function(...n){const r=n[0];return r==null?r:(r.length>1&&(n=r),e(n))};return"conversion"in e&&(t.conversion=e.conversion),t}function lt(e){const t=function(...n){const r=n[0];if(r==null)return r;r.length>1&&(n=r);const o=e(n);if(typeof o=="object")for(let a=o.length,l=0;l<a;l++)o[l]=Math.round(o[l]);return o};return"conversion"in e&&(t.conversion=e.conversion),t}ot.forEach(e=>{O[e]={},Object.defineProperty(O[e],"channels",{value:U[e].channels}),Object.defineProperty(O[e],"labels",{value:U[e].labels});const t=rt(e);Object.keys(t).forEach(r=>{const o=t[r];O[e][r]=lt(o),O[e][r].raw=at(o)})});var st=O;const _=fe(st);var ct=Ne,it=function(){return ct.Date.now()},ut=it,ft=/\s/;function ht(e){for(var t=e.length;t--&&ft.test(e.charAt(t)););return t}var dt=ht,gt=dt,bt=/^\s+/;function mt(e){return e&&e.slice(0,gt(e)+1).replace(bt,"")}var vt=mt,pt=vt,ae=J,yt=Ie,le=NaN,xt=/^[-+]0x[0-9a-f]+$/i,wt=/^0b[01]+$/i,kt=/^0o[0-7]+$/i,_t=parseInt;function Et(e){if(typeof e=="number")return e;if(yt(e))return le;if(ae(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=ae(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=pt(e);var n=wt.test(e);return n||kt.test(e)?_t(e.slice(2),n?2:8):xt.test(e)?le:+e}var Mt=Et,Ct=J,D=ut,se=Mt,$t="Expected a function",Ot=Math.max,Nt=Math.min;function It(e,t,n){var r,o,a,l,s,c,i=0,d=!1,f=!1,g=!0;if(typeof e!="function")throw new TypeError($t);t=se(t)||0,Ct(n)&&(d=!!n.leading,f="maxWait"in n,a=f?Ot(se(n.maxWait)||0,t):a,g="trailing"in n?!!n.trailing:g);function w(v){var M=r,j=o;return r=o=void 0,i=v,l=e.apply(j,M),l}function S(v){return i=v,s=setTimeout(m,t),d?w(v):l}function E(v){var M=v-c,j=v-i,te=t-M;return f?Nt(te,a-j):te}function p(v){var M=v-c,j=v-i;return c===void 0||M>=t||M<0||f&&j>=a}function m(){var v=D();if(p(v))return k(v);s=setTimeout(m,E(v))}function k(v){return s=void 0,g&&r?w(v):(r=o=void 0,l)}function y(){s!==void 0&&clearTimeout(s),i=0,r=c=o=s=void 0}function R(){return s===void 0?l:k(D())}function T(){var v=D(),M=p(v);if(r=arguments,o=this,c=v,M){if(s===void 0)return S(c);if(f)return clearTimeout(s),s=setTimeout(m,t),w(c)}return s===void 0&&(s=setTimeout(m,t)),l}return T.cancel=y,T.flush=R,T}var St=It,Rt=St,Tt=J,jt="Expected a function";function Ft(e,t,n){var r=!0,o=!0;if(typeof e!="function")throw new TypeError(jt);return Tt(n)&&(r="leading"in n?!!n.leading:r,o="trailing"in n?!!n.trailing:o),Rt(e,t,{leading:r,maxWait:t,trailing:o})}var zt=Ft;const Ht=fe(zt);var Pt=C.div({position:"relative",maxWidth:250,'&[aria-readonly="true"]':{opacity:.5}}),Lt=C(ue)({position:"absolute",zIndex:1,top:4,left:4,"[aria-readonly=true] &":{cursor:"not-allowed"}}),qt=C.div({width:200,margin:5,".react-colorful__saturation":{borderRadius:"4px 4px 0 0"},".react-colorful__hue":{boxShadow:"inset 0 0 0 1px rgb(0 0 0 / 5%)"},".react-colorful__last-control":{borderRadius:"0 0 4px 4px"}}),Bt=C(Me)(({theme:e})=>({fontFamily:e.typography.fonts.base})),Wt=C.div({display:"grid",gridTemplateColumns:"repeat(9, 16px)",gap:6,padding:3,marginTop:5,width:200}),Xt=C.div(({theme:e,active:t})=>({width:16,height:16,boxShadow:t?`${e.appBorderColor} 0 0 0 1px inset, ${e.textMutedColor}50 0 0 0 4px`:`${e.appBorderColor} 0 0 0 1px inset`,borderRadius:e.appBorderRadius})),Dt=`url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill-opacity=".05"><path d="M8 0h8v8H8zM0 8h8v8H0z"/></svg>')`,ce=({value:e,style:t,...n})=>{let r=`linear-gradient(${e}, ${e}), ${Dt}, linear-gradient(#fff, #fff)`;return h.createElement(Xt,{...n,style:{...t,backgroundImage:r}})},Kt=C(Ce.Input)(({theme:e,readOnly:t})=>({width:"100%",paddingLeft:30,paddingRight:30,boxSizing:"border-box",fontFamily:e.typography.fonts.base})),Vt=C($e)(({theme:e})=>({position:"absolute",zIndex:1,top:6,right:7,width:20,height:20,padding:4,boxSizing:"border-box",cursor:"pointer",color:e.input.color})),Ee=(e=>(e.RGB="rgb",e.HSL="hsl",e.HEX="hex",e))(Ee||{}),L=Object.values(Ee),At=/\(([0-9]+),\s*([0-9]+)%?,\s*([0-9]+)%?,?\s*([0-9.]+)?\)/,Gt=/^\s*rgba?\(([0-9]+),\s*([0-9]+),\s*([0-9]+),?\s*([0-9.]+)?\)\s*$/i,Ut=/^\s*hsla?\(([0-9]+),\s*([0-9]+)%,\s*([0-9]+)%,?\s*([0-9.]+)?\)\s*$/i,Y=/^\s*#?([0-9a-f]{3}|[0-9a-f]{6})\s*$/i,Yt=/^\s*#?([0-9a-f]{3})\s*$/i,Jt={hex:De,rgb:Ue,hsl:Ae},q={hex:"transparent",rgb:"rgba(0, 0, 0, 0)",hsl:"hsla(0, 0%, 0%, 0)"},ie=e=>{let t=e?.match(At);if(!t)return[0,0,0,1];let[,n,r,o,a=1]=t;return[n,r,o,a].map(Number)},N=e=>{if(!e)return;let t=!0;if(Gt.test(e)){let[l,s,c,i]=ie(e),[d,f,g]=_.rgb.hsl([l,s,c])||[0,0,0];return{valid:t,value:e,keyword:_.rgb.keyword([l,s,c]),colorSpace:"rgb",rgb:e,hsl:`hsla(${d}, ${f}%, ${g}%, ${i})`,hex:`#${_.rgb.hex([l,s,c]).toLowerCase()}`}}if(Ut.test(e)){let[l,s,c,i]=ie(e),[d,f,g]=_.hsl.rgb([l,s,c])||[0,0,0];return{valid:t,value:e,keyword:_.hsl.keyword([l,s,c]),colorSpace:"hsl",rgb:`rgba(${d}, ${f}, ${g}, ${i})`,hsl:e,hex:`#${_.hsl.hex([l,s,c]).toLowerCase()}`}}let n=e.replace("#",""),r=_.keyword.rgb(n)||_.hex.rgb(n),o=_.rgb.hsl(r),a=e;if(/[^#a-f0-9]/i.test(e)?a=n:Y.test(e)&&(a=`#${n}`),a.startsWith("#"))t=Y.test(a);else try{_.keyword.hex(a)}catch{t=!1}return{valid:t,value:a,keyword:_.rgb.keyword(r),colorSpace:"hex",rgb:`rgba(${r[0]}, ${r[1]}, ${r[2]}, 1)`,hsl:`hsla(${o[0]}, ${o[1]}%, ${o[2]}%, 1)`,hex:a}},Qt=(e,t,n)=>{if(!e||!t?.valid)return q[n];if(n!=="hex")return t?.[n]||q[n];if(!t.hex.startsWith("#"))try{return`#${_.keyword.hex(t.hex)}`}catch{return q.hex}let r=t.hex.match(Yt);if(!r)return Y.test(t.hex)?t.hex:q.hex;let[o,a,l]=r[1].split("");return`#${o}${o}${a}${a}${l}${l}`},Zt=(e,t)=>{let[n,r]=b.useState(e||""),[o,a]=b.useState(()=>N(n)),[l,s]=b.useState(o?.colorSpace||"hex");b.useEffect(()=>{let f=e||"",g=N(f);r(f),a(g),s(g?.colorSpace||"hex")},[e]);let c=b.useMemo(()=>Qt(n,o,l).toLowerCase(),[n,o,l]),i=b.useCallback(f=>{let g=N(f),w=g?.value||f||"";r(w),w===""&&(a(void 0),t(void 0)),g&&(a(g),s(g.colorSpace),t(g.value))},[t]),d=b.useCallback(()=>{let f=L.indexOf(l)+1;f>=L.length&&(f=0),s(L[f]);let g=o?.[L[f]]||"";r(g),t(g)},[o,l,t]);return{value:n,realValue:c,updateValue:i,color:o,colorSpace:l,cycleColorSpace:d}},X=e=>e.replace(/\s*/,"").toLowerCase(),en=(e,t,n)=>{let[r,o]=b.useState(t?.valid?[t]:[]);b.useEffect(()=>{t===void 0&&o([])},[t]);let a=b.useMemo(()=>(e||[]).map(s=>typeof s=="string"?N(s):s.title?{...N(s.color),keyword:s.title}:N(s.color)).concat(r).filter(Boolean).slice(-27),[e,r]),l=b.useCallback(s=>{s?.valid&&(a.some(c=>X(c[n])===X(s[n]))||o(c=>c.concat(s)))},[n,a]);return{presets:a,addPreset:l}},tn=({name:e,value:t,onChange:n,onFocus:r,onBlur:o,presetColors:a,startOpen:l=!1,argType:s})=>{let c=b.useCallback(Ht(n,200),[n]),{value:i,realValue:d,updateValue:f,color:g,colorSpace:w,cycleColorSpace:S}=Zt(t,c),{presets:E,addPreset:p}=en(a,g,w),m=Jt[w],k=!!s?.table?.readonly;return h.createElement(Pt,{"aria-readonly":k},h.createElement(Lt,{startOpen:l,trigger:k?[null]:void 0,closeOnOutsideClick:!0,onVisibleChange:()=>p(g),tooltip:h.createElement(qt,null,h.createElement(m,{color:d==="transparent"?"#000000":d,onChange:f,onFocus:r,onBlur:o}),E.length>0&&h.createElement(Wt,null,E.map((y,R)=>h.createElement(ue,{key:`${y.value}-${R}`,hasChrome:!1,tooltip:h.createElement(Bt,{note:y.keyword||y.value})},h.createElement(ce,{value:y[w],active:g&&X(y[w])===X(g[w]),onClick:()=>f(y.value)})))))},h.createElement(ce,{value:d,style:{margin:4}})),h.createElement(Kt,{id:Oe(e),value:i,onChange:y=>f(y.target.value),onFocus:y=>y.target.select(),readOnly:k,placeholder:"Choose color..."}),i?h.createElement(Vt,{onClick:S}):null)},cn=tn;export{tn as ColorControl,cn as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{d as p,f as x}from"./index-
|
|
1
|
+
import{d as p,f as x}from"./index-DPPi9iZu.js";import{u as c}from"./index-VWixWKZ7.js";import"./iframe-DcDTQOmA.js";import"../sb-preview/runtime.js";import"./index-Cc7K62zD.js";import"./index-DXimoRZY.js";import"./index-DrFu-skq.js";var h={exports:{}},n={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__fileDeps=["./index-
|
|
2
|
-
import{_ as l}from"./iframe-
|
|
1
|
+
const __vite__fileDeps=["./index-CUFHd5VD.js","./index-VWixWKZ7.js","./index-DPPi9iZu.js","./iframe-DcDTQOmA.js","./index-Cc7K62zD.js","./index-DXimoRZY.js","./index-DrFu-skq.js"],__vite__mapDeps=i=>i.map(i=>__vite__fileDeps[i]);
|
|
2
|
+
import{_ as l}from"./iframe-DcDTQOmA.js";import{r as h,R as o,d as m,C as E,A as R,H as x,D as y}from"./index-DPPi9iZu.js";import"../sb-preview/runtime.js";import"./index-Cc7K62zD.js";import"./index-DXimoRZY.js";import"./index-DrFu-skq.js";var u={},i=h;u.createRoot=i.createRoot,u.hydrateRoot=i.hydrateRoot;var n=new Map,D=({callback:e,children:r})=>{let t=m.useRef();return m.useLayoutEffect(()=>{t.current!==e&&(t.current=e,e())},[e]),r},v=async(e,r,t)=>{let s=await _(r,t);return new Promise(a=>{s.render(o.createElement(D,{callback:()=>a(null)},e))})},w=(e,r)=>{let t=n.get(e);t&&(t.unmount(),n.delete(e))},_=async(e,r)=>{let t=n.get(e);return t||(t=u.createRoot(e,r),n.set(e,t)),t},f={code:E,a:R,...x},g=class extends m.Component{constructor(){super(...arguments),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){let{showException:r}=this.props;r(e)}render(){let{hasError:e}=this.state,{children:r}=this.props;return e?null:o.createElement(o.Fragment,null,r)}},L=class{constructor(){this.render=async(e,r,t)=>{let s={...f,...r?.components},a=y;return new Promise((d,p)=>{l(async()=>{const{MDXProvider:c}=await import("./index-CUFHd5VD.js");return{MDXProvider:c}},__vite__mapDeps([0,1,2,3,4,5,6]),import.meta.url).then(({MDXProvider:c})=>v(o.createElement(g,{showException:p,key:Math.random()},o.createElement(c,{components:s},o.createElement(a,{context:e,docsParameter:r}))),t)).then(()=>d())})},this.unmount=e=>{w(e)}}};export{L as DocsRenderer,f as defaultComponents};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{W as a,W as T,b as e}from"./index-
|
|
1
|
+
import{W as a,W as T,b as e}from"./index-DPPi9iZu.js";import"./iframe-DcDTQOmA.js";import"../sb-preview/runtime.js";import"./index-Cc7K62zD.js";import"./index-DXimoRZY.js";import"./index-DrFu-skq.js";export{a as WithToolTipState,T as WithTooltip,e as WithTooltipPure};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{w as o,e}from"./custom-element-
|
|
1
|
+
import{w as o,e}from"./custom-element-BIxkVg7K.js";import"./index-CVRyq5ci.js";function s(a){return new Promise(i=>setTimeout(i,a))}function r(a){const{title:i,body:t}=a;return`
|
|
2
2
|
<fieldset>
|
|
3
3
|
<legend>${i}</legend>
|
|
4
4
|
${t}
|
|
@@ -47,7 +47,7 @@ import{w as o,e}from"./custom-element-BV8-hRQS.js";import"./index-CVRyq5ci.js";f
|
|
|
47
47
|
</template>
|
|
48
48
|
</custom-element>
|
|
49
49
|
<dce-link3 id="dce3" p1="123" p3="qwe"></dce-link3> |
|
|
50
|
-
`},play:async({canvasElement:a})=>{d.args.title;const i=o(a),t=async c=>(await i.findByTestId(c)).textContent.trim();await s(20),e(await t("p1")).toEqual("123"),e(await t("p2")).toEqual("always_p2"),e(await t("p3")).toEqual("qwe")}};d.parameters={...d.parameters,docs:{...d.parameters?.docs,source:{originalSource:`{
|
|
50
|
+
`},play:async({canvasElement:a})=>{d.args.title;const i=o(a),t=async c=>(await i.findByTestId(c)).textContent.trim();debugger;await s(20),e(await t("p1")).toEqual("123"),e(await t("p2")).toEqual("always_p2"),e(await t("p3")).toEqual("qwe")}};d.parameters={...d.parameters,docs:{...d.parameters?.docs,source:{originalSource:`{
|
|
51
51
|
args: {
|
|
52
52
|
title: 'Attributes definition',
|
|
53
53
|
body: \`
|
|
@@ -143,6 +143,7 @@ import{w as o,e}from"./custom-element-BV8-hRQS.js";import"./index-CVRyq5ci.js";f
|
|
|
143
143
|
const titleText = (AttributeDefaults.args!.title as string);
|
|
144
144
|
const canvas = within(canvasElement),
|
|
145
145
|
code = async id => (await canvas.findByTestId(id)).textContent.trim();
|
|
146
|
+
debugger;
|
|
146
147
|
await sleep(20);
|
|
147
148
|
expect(await code('p1')).toEqual('123');
|
|
148
149
|
expect(await code('p2')).toEqual('always_p2');
|
package/storybook-static/assets/{css.test.stories-D9WaxrEv.js → css.test.stories-B-QcObCF.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{w as i,e as t}from"./custom-element-
|
|
1
|
+
import{w as i,e as t}from"./custom-element-BIxkVg7K.js";import"./index-CVRyq5ci.js";const g={title:"",tag:"",style:"",slot:"",payload:""};function p(n){const{title:e,tag:o,style:s,slot:a,payload:l}={...g,...n};return`
|
|
2
2
|
<fieldset>
|
|
3
3
|
<legend>${e}</legend>
|
|
4
4
|
<custom-element ${o?`tag="${o}"`:""} >
|
|
@@ -164,7 +164,7 @@ Unable to find an `+(n===!1?"accessible ":"")+'element with the role "'+t+'"'+l+
|
|
|
164
164
|
`)),a+=d+n[l+1]}),a}var uC=sC,Ko=Jo({...wu},{intercept:(e,t)=>t[0]==="fireEvent"||e.startsWith("find")||e.startsWith("waitFor")});Ko.screen=new Proxy(Ko.screen,{get(e,t,r){return jd.warn(uC`
|
|
165
165
|
You are using Testing Library's \`screen\` object. Use \`within(canvasElement)\` instead.
|
|
166
166
|
More info: https://storybook.js.org/docs/react/essentials/interactions
|
|
167
|
-
`),Reflect.get(e,t,r)}});var{buildQueries:
|
|
167
|
+
`),Reflect.get(e,t,r)}});var{buildQueries:TC,configure:OC,createEvent:jC,fireEvent:MC,findAllByAltText:IC,findAllByDisplayValue:NC,findAllByLabelText:BC,findAllByPlaceholderText:kC,findAllByRole:$C,findAllByTestId:DC,findAllByText:LC,findAllByTitle:FC,findByAltText:UC,findByDisplayValue:HC,findByLabelText:VC,findByPlaceholderText:zC,findByRole:WC,findByTestId:GC,findByText:KC,findByTitle:YC,getAllByAltText:XC,getAllByDisplayValue:JC,getAllByLabelText:QC,getAllByPlaceholderText:ZC,getAllByRole:eP,getAllByTestId:tP,getAllByText:rP,getAllByTitle:nP,getByAltText:oP,getByDisplayValue:aP,getByLabelText:iP,getByPlaceholderText:lP,getByRole:sP,getByTestId:uP,getByText:cP,getByTitle:dP,getConfig:fP,getDefaultNormalizer:pP,getElementError:mP,getNodeText:hP,getQueriesForElement:yP,getRoles:bP,getSuggestedQuery:gP,isInaccessible:vP,logDOM:_P,logRoles:wP,prettyDOM:EP,queries:xP,queryAllByAltText:CP,queryAllByAttribute:PP,queryAllByDisplayValue:SP,queryAllByLabelText:RP,queryAllByPlaceholderText:qP,queryAllByRole:AP,queryAllByTestId:TP,queryAllByText:OP,queryAllByTitle:jP,queryByAltText:MP,queryByAttribute:IP,queryByDisplayValue:NP,queryByLabelText:BP,queryByPlaceholderText:kP,queryByRole:$P,queryByTestId:DP,queryByText:LP,queryByTitle:FP,queryHelpers:UP,screen:HP,waitFor:VP,waitForElementToBeRemoved:zP,within:WP,prettyFormat:GP}=Ko,{userEvent:KP}=Jo({userEvent:lC},{intercept:!0}),{expect:YP}=Jo({expect:_u},{getKeys:(e,t)=>{let r=["assert","__methods","__flags","_obj"];if(e.constructor===Ob.Assertion){let n=Object.keys(Object.getPrototypeOf(e)).filter(o=>!r.includes(o));return t>2?n:[...n,"not"]}return Object.keys(e)},intercept:e=>e!=="expect"}),cC=({parameters:e})=>{e?.test?.mockReset===!0?I_():e?.test?.clearMocks===!0?M_():e?.test?.restoreMocks!==!1&&N_()},Yo=(e,t=0,r)=>{if(t>5||e==null)return e;if(gs(e))return r&&e.mockName(r),e;if(typeof e=="function"&&"isAction"in e&&e.isAction&&!("implicit"in e&&e.implicit)){let n=O_(e);return r&&n.mockName(r),n}if(Array.isArray(e))return t++,e.map(n=>Yo(n,t));if(typeof e=="object"&&e.constructor===Object){t++;for(let[n,o]of Object.entries(e))Object.getOwnPropertyDescriptor(e,n)?.writable&&(e[n]=Yo(o,t,n));return e}return e},dC=({initialArgs:e})=>{Yo(e)};os.__STORYBOOK_TEST_LOADERS__=[cC,dC];os.__STORYBOOK_TEST_ON_MOCK_CALL__=T_;const Xo="http://www.w3.org/1999/XSL/Transform",bn="http://www.w3.org/1999/xhtml",fC="http://exslt.org/common",Ee=(e,t)=>e.getAttribute?.(t),cl=e=>e.nodeType===3,pC=e=>typeof e=="string",mC=e=>e&&typeof e.nodeType=="number",Xe=(e,t="",r=document)=>(n=>(t&&n.append(jt(r.ownerDocument||r,t)),n))((r.ownerDocument||r).createElement(e)),jt=(e,t)=>(e.ownerDocument||e).createTextNode(t),Pd=e=>{for(;e.firstChild;)e.firstChild.remove();return e},gn=e=>(e.getAttributeNames().map(t=>e.removeAttribute(t)),Pd(e)),hC=e=>(e?.setAttribute("xmlns:xsl",Xo),e),yC=e=>(e?.setAttribute("xmlns:xhtml",bn),hC(e)),dl=(e,t)=>{const r=e.ownerDocument.createElementNS(e.namespaceURI,t);for(let n of e.attributes)r.setAttribute(n.name,n.value);for(;e.firstChild;)r.append(e.firstChild);return r};function Nr(e){return new DOMParser().parseFromString(e,"application/xml")}function vn(e){return new XMLSerializer().serializeToString(e)}function un(e,t,r,n){const o=i=>e.ownerDocument.createElement(i),a=((i,l,s)=>(l.append(s=o(i)),s))(t,e);return[...r].forEach(i=>a.append(n(i))),a}function bC(e){return e.slot||(e.setAttribute||(e=Xe("span",e.textContent.replaceAll(`
|
|
168
168
|
`,""))),e.setAttribute("slot","")),e}function ar(e,t,r){const n=typeof e;if(n==="string")return Xe(t,e,r);if(n==="number")return Xe(t,""+e,r);if(e instanceof Array){const u=Xe("array","",r);return e.map(a=>u.append(ar(a,t,r))),u}if(e instanceof FormData){const u=Xe("form-data","",r);for(const a of e)u.append(ar(a[1],a[0],r));return u}const o=Xe(t,"",r);for(let u in e)mC(e[u])||typeof e[u]=="function"||e[u]instanceof Window||(typeof e[u]!="object"?o.setAttribute(u,e[u]):o.append(ar(e[u],u,r)));return o}function fl(e){if(kt(e,"*",t=>[...t.childNodes].filter(r=>r.nodeType===3&&r.parentNode.localName!=="style"&&r.data).forEach(r=>{const n=r.data,o=n.matchAll(/{([^}]*)}/g);if(o){let u=0,a=l=>jt(r,l),i=[];if([...o].forEach(l=>{l.index>u&&i.push(a(l.input.substring(u,l.index)));const s=e.querySelector("value-of").cloneNode();s.setAttribute("select",l[1]),i.push(s),u=l.index+l[0].length}),u<n.length&&i.push(a(n.substring(u,n.length))),i.length){for(let l of i)t.insertBefore(l,r);t.removeChild(r)}}})),"all"in e){let t=1;for(let r of e.all)r.setAttribute&&!r.tagName.startsWith("xsl:")&&r.setAttribute("data-dce-id",""+t++)}return e}function gC(e,t="xsl:stylesheet"){if(e.tagName===t||e.documentElement?.tagName===t)return fl(e);const r=Nr(`<xsl:stylesheet version="1.0" xmlns:xsl="${Xo}" xmlns:xhtml="${bn}" xmlns:exsl="${fC}" exclude-result-prefixes="exsl" >
|
|
169
169
|
<xsl:output method="xml" />
|
|
170
170
|
<xsl:template match="/"><dce-root xmlns="${bn}"><xsl:apply-templates select="*"/></dce-root></xsl:template>
|
|
@@ -178,7 +178,7 @@ Unable to find an `+(n===!1?"accessible ":"")+'element with the role "'+t+'"'+l+
|
|
|
178
178
|
<xsl:template mode="sanitize" match="text()"><dce-text><xsl:copy/></dce-text></xsl:template>
|
|
179
179
|
<xsl:template mode="sanitize" match="xsl:value-of|*[name()='slot']"><dce-text><xsl:copy><xsl:apply-templates mode="sanitize" select="*|@*|text()"/></xsl:copy></dce-text></xsl:template>
|
|
180
180
|
<xsl:template mode="sanitize" match="xhtml:*"><xsl:element name="{local-name()}"><xsl:apply-templates mode="sanitize" select="*|@*|text()"/></xsl:element></xsl:template>
|
|
181
|
-
</xsl:stylesheet>`),n=new XSLTProcessor,o=(m=>{kt(m,"script",g=>g.remove());const y=m.content??m.firstElementChild?.content??m.body??m;
|
|
181
|
+
</xsl:stylesheet>`),n=new XSLTProcessor,o=(m=>{kt(m,"script",g=>g.remove());const y=m.content??m.firstElementChild?.content??m.body??m;SC.forEach(g=>kt(y,g,_=>RC(_,y)));const v=m.firstElementChild?.content||m.content,h=g=>{const _=Nr("<xhtml/>"),x=_.importNode(g,!0);return _.replaceChild(x,_.documentElement),yC(x)};if(v){const g=Xe("div");return[...v.childNodes].map(_=>g.append(_.cloneNode(!0))),h(g)}return h(m.documentElement||m.body||m)})(e),u=Nr(`<xsl:stylesheet version="1.0"
|
|
182
182
|
xmlns:xsl="${Xo}"
|
|
183
183
|
xmlns:xhtml="${bn}"
|
|
184
184
|
xmlns:dce="urn:schemas-epa-wg:dce"
|
|
@@ -212,8 +212,8 @@ Unable to find an `+(n===!1?"accessible ":"")+'element with the role "'+t+'"'+l+
|
|
|
212
212
|
<xsl:with-param name="defaultvalue"/>
|
|
213
213
|
</xsl:call-template>
|
|
214
214
|
</xsl:variable>
|
|
215
|
-
</xsl:stylesheet>`);n.importStylesheet(r);const a=n.transformToFragment(o,document),i=(m,y)=>m.querySelector(y),l=i(u,'template[mode="payload"]');if(!a)return console.error("transformation error",{xml:o.outerHTML,xsl:vn(r)});const s=[];[...a.querySelectorAll("dce-root>attribute")].forEach(m=>{const y=dl(m,"xsl:param"),v=Ee(m,"name");l.append(y);let h=Ee(y,"select")?.split("??");h||(h=["//"+v,`'${y.textContent}'`],gn(y),y.setAttribute("name",v));let g;if(h?.length>1){y.removeAttribute("select");const _=i(u,'template[match="ignore"]>choose').cloneNode(!0);gn(_.firstElementChild).append(jt(_,"{"+h[0]+"}")),gn(_.lastElementChild).append(jt(_,"{"+h[1]+"}")),_.firstElementChild.setAttribute("test",h[0]),y.append(_),g=_.cloneNode(!0)}else g=dl(m,"xsl:value-of");g.removeAttribute("name"),m.append(g),m.removeAttribute("select"),s.push(y)}),[...a.querySelectorAll("[value]")].filter(m=>m.getAttribute("value").match(/\{(.*)\?\?(.*)\}/g)).forEach(m=>{const y=Ee(m,"value");y&&m.setAttribute("value",
|
|
216
|
-
`)});const a=this,i=[...this.templateNode.querySelectorAll("[slice]")],l=i.map(c=>Ee(c,"slice")).filter(c=>!c.includes("/")).filter((c,p,m)=>m.indexOf(c)===p).map(Sd).flat(),s=o.reduce((c,p)=>(p.params&&c.push(...p.params),c),[]);class f extends HTMLElement{static get observedAttributes(){return s.map(p=>Ee(p,"name"))}#e=0;connectedCallback(){let p=this.childNodes;if(this.firstElementChild?.tagName==="TEMPLATE"){this.firstElementChild!==this.lastElementChild&&console.error("payload should have TEMPLATE as only child",this.outerHTML);const P=this.firstElementChild;P.remove(),p=P.content.childNodes;for(const b of[...P.content.childNodes])if(b.localName==="style"){const E=
|
|
215
|
+
</xsl:stylesheet>`);n.importStylesheet(r);const a=n.transformToFragment(o,document),i=(m,y)=>m.querySelector(y),l=i(u,'template[mode="payload"]');if(!a)return console.error("transformation error",{xml:o.outerHTML,xsl:vn(r)});const s=[];[...a.querySelectorAll("dce-root>attribute")].forEach(m=>{const y=dl(m,"xsl:param"),v=Ee(m,"name");l.append(y);let h=Ee(y,"select")?.split("??");h||(h=["//"+v,`'${y.textContent}'`],gn(y),y.setAttribute("name",v));let g;if(h?.length>1){y.removeAttribute("select");const _=i(u,'template[match="ignore"]>choose').cloneNode(!0);gn(_.firstElementChild).append(jt(_,"{"+h[0]+"}")),gn(_.lastElementChild).append(jt(_,"{"+h[1]+"}")),_.firstElementChild.setAttribute("test",h[0]),y.append(_),g=_.cloneNode(!0)}else g=dl(m,"xsl:value-of");g.removeAttribute("name"),m.append(g),m.removeAttribute("select"),s.push(y)}),[...a.querySelectorAll("[value]")].filter(m=>m.getAttribute("value").match(/\{(.*)\?\?(.*)\}/g)).forEach(m=>{const y=Ee(m,"value");y&&m.setAttribute("value",PC(y))});for(const m of a.childNodes)l.append(u.importNode(m,!0));[...l.querySelectorAll("template")].forEach(m=>l.ownerDocument.documentElement.append(m));const d=i(u,'call-template[name="slot"]'),c=m=>{const y=d.cloneNode(!0),v=Ee(m,"name");v&&y.firstElementChild.setAttribute("select",`'${v}'`);for(let h of m.childNodes)y.lastElementChild.append(h);return y};kt(l,"slot",m=>m.parentNode.replaceChild(c(m),m));const p=fl(u);return p.params=s,p}async function vC(e){return await new Promise((r,n)=>{const o=new XMLHttpRequest;o.open("GET",e),o.responseType="document",o.onload=()=>{o.readyState===o.DONE&&o.status===200&&r(o.responseXML||Xe("div",o.responseText)),n(o.statusText)},o.addEventListener("error",u=>n(u)),o.send()})}const Sd=e=>e.split("|").map(t=>t.trim()).filter(t=>t),_C=(e,t)=>Sd(t).map(r=>{let n=e.ownerDocument,o=u=>(e.append(u),u);if(r.includes("/")){const u=[],a=n.evaluate(r,e);for(let i;i=a.iterateNext();)u.push(i);return u}return[...e.childNodes].find(u=>u.localName===r)||o(Xe(r,"",n))}).flat();function pl(e,t,r,n){if(!r.sliceProcessed)return r.sliceProcessed=1,_C(e,t??"").map(o=>{const u=e.ownerDocument,a=r.sliceEventSource,i=r.sliceElement,l=()=>[...o.childNodes].filter(s=>s.nodeType===3||s.localName==="value"||s.localName==="form-data").map(s=>s.remove());if(a.getAttributeNames().map(s=>o.setAttribute(s,Ee(a,s))),[...o.childNodes].filter(s=>s.localName==="event").map(s=>s.remove()),"validationMessage"in a&&o.setAttribute("validation-message",a.validationMessage),r.type==="init"&&l(),o.append(ar(r,"event",u)),i.hasAttribute("slice-value")){a.value===void 0?o.removeAttribute("value"):o.setAttribute("value",a.value);const s=ir(Ee(i,"slice-value"),o);l(),o.append(jt(u,s))}else{if("elements"in a)return l(),o.append(ar(new FormData(a),"value",o.ownerDocument)),o;const s=a.value??Ee(i,"value");l(),s==null?[...o.childNodes].filter(f=>f.localName!=="event").map(f=>f.remove()):pC(s)?o.append(jt(u,s)):o.append(ar(s,"value",o.ownerDocument))}return o})}function kt(e,t,r){e.querySelectorAll&&[...e.querySelectorAll(t)].forEach(r)}const wC=async(e,t)=>{if(!e||!e.trim())return[t];if(e.startsWith("#"))return(r=>{if(!r)return[];const n=r.querySelectorAll(e);if(n.length)return[...n];const o=r.getRootNode();return o===r?[]:getByHashId(o)})(t.parentElement);try{const r=await vC(e),n=new URL(e,location).hash;if(n){const o=r.querySelectorAll(n);return o.length?[...o]:[t]}return[r]}catch{return[t]}};function EC(e,t){for(let r of e.attributes)r.namespaceURI?t.setAttributeNS(r.namespaceURI,r.name,r.value):t.setAttribute(r.name,r.value),r.name==="value"&&(t.value=r.value)}function Rd(e,t=0){const r={};for(const n of e.childNodes){const o=Ee(n,"data-dce-id")||n.dceId||0;if(!r[o])o?r[o]=1:(r[o]=n.dceId=++t,n.setAttribute&&n.setAttribute("data-dce-id",n.dceId));else{const u=n.dceId=o+"-"+r[o]++;n.setAttribute&&n.setAttribute("data-dce-id",u)}n.childNodes.length&&Rd(n)}}function xC(e,t,r){r=1*r;for(let n of e.childNodes)if((n.dceId??n.getAttribute("data-dce-id")*1)>r)return e.insertBefore(t,n);e.append(t)}function qd(e,t){if(!t.length)return Pd(e);const r={};for(let n of e.childNodes)r[n.dceId],cl(n)?(n.data.trim(),r[n.dceId||0]=n):r[Ee(n,"data-dce-id")||0]=n;for(let n of[...t]){const o=Ee(n,"data-dce-id")||n.dceId,u=r[o];u?(cl(n)?u.nodeValue!==n.nodeValue&&(u.nodeValue=n.nodeValue):(EC(n,u),(u.childNodes.length||n.childNodes.length)&&qd(u,n.childNodes)),delete r[o]):xC(e,n,o)}for(let n of Object.values(r))n.remove()}function CC(e,t){return e.hasAttribute(t)||e.setAttribute(t,crypto.randomUUID()),e.getAttribute(t)}const PC=e=>[...e?.matchAll(/([^{}]*)(\{)([^}]+)}([^{}]*)/g)].map(r=>`${r[1]}{${Fa(r[3])}}${r[4]}`).join(""),Fa=e=>{if(!e.trim())return e;const t=e.split("??"),r=t.shift(),n=Fa(t.join("??"));return t.length?`concat( ${r} , substring( ${n} , (1+string-length( ${n} )) * string-length( ${r} ) ) )`:e},ir=(e,t)=>{const r=e.split("??");if(r.length>1)return ir(r[0],t)||ir(r[1],t);e=Fa(e);const n=t.ownerDocument.evaluate(e,t);switch(n.resultType){case XPathResult.NUMBER_TYPE:return n.numberValue;case XPathResult.STRING_TYPE:return n.stringValue;case XPathResult.BOOLEAN_TYPE:return n.booleanValue}let o="";for(let u;u=n.iterateNext();)o+=u.textContent;return o},SC="stylesheet,transform,import,include,strip-space,preserve-space,output,key,decimal-format,namespace-alias,template,value-of,copy-of,number,apply-templates,apply-imports,for-each,sort,if,choose,when,otherwise,attribute-set,call-template,with-param,variable,param,text,processing-instruction,element,attribute,comment,copy,message,fallback".split(","),RC=(e,t)=>{const r=Xe("xsl:"+e.localName);for(let n of e.attributes)r.setAttribute(n.name,n.value);for(;e.firstChild;)r.append(e.firstChild);if(e.parentElement)e.parentElement.replaceChild(r,e);else{const n=e.parentElement||t,o=[...n.childNodes];o.forEach((u,a)=>{u===e&&(o[a]=r)}),n.replaceChildren(...o)}};class qC extends HTMLElement{static observedAttributes=["src","tag","hidden"];async connectedCallback(){const t=await wC(Ee(this,"src"),this),r=Ee(this,"tag"),n=r||"dce-"+crypto.randomUUID();for(const c of t)kt(c.templateNode||c.content||c,"style",p=>{const m=p.closest("slot"),y=m?`slot[name="${m.name}"]`:"";p.innerHTML=`${n} ${y}{${p.innerHTML}}`,this.append(p)});const o=t.map(c=>gC(c)),u=o.map((c,p)=>(p=new XSLTProcessor,p.importStylesheet(c),p));Object.defineProperty(this,"xsltString",{get:()=>o.map(c=>vn(c)).join(`
|
|
216
|
+
`)});const a=this,i=[...this.templateNode.querySelectorAll("[slice]")],l=i.map(c=>Ee(c,"slice")).filter(c=>!c.includes("/")).filter((c,p,m)=>m.indexOf(c)===p).map(Sd).flat(),s=o.reduce((c,p)=>(p.params&&c.push(...p.params),c),[]);class f extends HTMLElement{static get observedAttributes(){return s.map(p=>Ee(p,"name"))}#e=0;connectedCallback(){let p=this.childNodes;if(this.firstElementChild?.tagName==="TEMPLATE"){this.firstElementChild!==this.lastElementChild&&console.error("payload should have TEMPLATE as only child",this.outerHTML);const P=this.firstElementChild;P.remove(),p=P.content.childNodes;for(const b of[...P.content.childNodes])if(b.localName==="style"){const E=CC(this,"data-dce-style");b.innerHTML=`${n}[data-dce-style="${E}"]{${b.innerHTML}}`,P.insertAdjacentElement("beforebegin",b)}else b.nodeType===1?P.insertAdjacentElement("beforebegin",b):b.nodeType===3&&P.insertAdjacentText("beforebegin",b.data)}const m=Nr("<datadom/>").documentElement,y=(P,b="")=>(E=>(b&&E.append(jt(m,b)),E))(m.ownerDocument.createElement(P));un(m,"payload",p,bC),this.innerHTML="";const v=un(m,"attributes",this.attributes,P=>y(P.nodeName,P.value));un(m,"dataset",Object.keys(this.dataset),P=>y(P,this.dataset[P]));const h=un(m,"slice",l,P=>y(P,"")),g=P=>ir(P,h);this.xml=m;const _=[],x=()=>{const P={};for(let b;b=_.pop();){const E=Ee(b.sliceElement,"slice");P[E]||(pl(h,E,b),P[E]=b)}Object.keys(P).length!==0&&q()};let S;this.onSlice=P=>{_.push(P),S||(S=setTimeout(()=>{x(),S=0},1))};const q=this.transform=()=>{if(this.#e)debugger;this.#e=1,u.map((b,E)=>{const T=b.transformToFragment(m.ownerDocument,document);return T||console.error(`XSLT transformation error. xsl:
|
|
217
217
|
`,vn(o[E]),`
|
|
218
218
|
xml:
|
|
219
|
-
`,vn(m)),T}).map(b=>{b&&(Rd(b),qd(this,b.childNodes))}),f.observedAttributes.map(b=>{let E=Ee(this.firstElementChild,b);E!==Ee(this,b)&&(this.setAttribute(b,E),this.#t(b,E))}),kt(this,"[slice],[slice-event]",b=>{if(!b.dceInitialized){b.dceInitialized=1;let E=Ee(b,"slice-event");Ee(b,"custom-validity")&&(E+=" change submit"),[...new Set((E||"change").split(" "))].forEach(T=>(b.localName==="slice"?b.parentElement:b).addEventListener(T,j=>{j.sliceElement=b,j.sliceEventSource=j.currentTarget||j.target;const F=pl(h,Ee(j.sliceElement,"slice"),j);kt(this,"[custom-validity]",Z=>{if(!Z.setCustomValidity)return;const te=Ee(Z,"custom-validity");try{const re=te&&ir(te,v);Z.setCustomValidity(re===!0?"":re===!1?"invalid":re)}catch(re){console.error(re,"xPath",te)}});const U=Ee(b,"custom-validity"),H=U&&ir(U,v),ee=H===!0?"":H;if(U){if(b.setCustomValidity?b.setCustomValidity(ee):b.validationMessage=ee,F.map(Z=>Z.setAttribute("validation-message",ee)),j.type==="submit")return H===!0?void 0:(setTimeout(q,1),!!H===H?(H||j.preventDefault(),H):H?(j.preventDefault(),!1):void 0);setTimeout(q,1)}this.onSlice(j)})),(!E||E.includes("init"))&&(b.hasAttribute("slice-value")||b.hasAttribute("value")||b.value?this.onSlice({type:"init",target:b,sliceElement:b,sliceEventSource:b}):b.value=g(Ee(b,"slice")))}}),this.#e=0};q(),x()}#t(p,m){let y=this.xml.querySelector(`attributes>${p}`);y?gn(y).append(jt(y,m)):(y=Xe(p,m,this.xml),this.xml.querySelector("attributes").append(y))}attributeChangedCallback(p,m,y){!this.xml||this.#e||(this.#t(p,y),this.transform())}get dce(){return a}}const d=c=>{window.customElements.get(c)!==f&&window.customElements.define(c,f)};if(r)d(r);else{const c=n;this.setAttribute("tag",c),d(c);const p=document.createElement(c);this.getAttributeNames().forEach(m=>p.setAttribute(m,this.getAttribute(m))),p.append(...[...this.childNodes].filter(m=>m.localName!=="style")),this.append(p)}}get templateNode(){return this.firstElementChild?.tagName==="TEMPLATE"?this.firstElementChild.content:this}get dce(){return this}get xslt(){return Nr(this.xsltString)}}window.customElements.define("custom-element",
|
|
219
|
+
`,vn(m)),T}).map(b=>{b&&(Rd(b),qd(this,b.childNodes))}),f.observedAttributes.map(b=>{let E=Ee(this.firstElementChild,b);E!==Ee(this,b)&&(this.setAttribute(b,E),this.#t(b,E))}),kt(this,"[slice],[slice-event]",b=>{if(!b.dceInitialized){b.dceInitialized=1;let E=Ee(b,"slice-event");Ee(b,"custom-validity")&&(E+=" change submit"),[...new Set((E||"change").split(" "))].forEach(T=>(b.localName==="slice"?b.parentElement:b).addEventListener(T,j=>{j.sliceElement=b,j.sliceEventSource=j.currentTarget||j.target;const F=pl(h,Ee(j.sliceElement,"slice"),j);kt(this,"[custom-validity]",Z=>{if(!Z.setCustomValidity)return;const te=Ee(Z,"custom-validity");try{const re=te&&ir(te,v);Z.setCustomValidity(re===!0?"":re===!1?"invalid":re)}catch(re){console.error(re,"xPath",te)}});const U=Ee(b,"custom-validity"),H=U&&ir(U,v),ee=H===!0?"":H;if(U){if(b.setCustomValidity?b.setCustomValidity(ee):b.validationMessage=ee,F.map(Z=>Z.setAttribute("validation-message",ee)),j.type==="submit")return H===!0?void 0:(setTimeout(q,1),!!H===H?(H||j.preventDefault(),H):H?(j.preventDefault(),!1):void 0);setTimeout(q,1)}this.onSlice(j)})),(!E||E.includes("init"))&&(b.hasAttribute("slice-value")||b.hasAttribute("value")||b.value?this.onSlice({type:"init",target:b,sliceElement:b,sliceEventSource:b}):b.value=g(Ee(b,"slice")))}}),this.#e=0};q(),x()}#t(p,m){let y=this.xml.querySelector(`attributes>${p}`);y?gn(y).append(jt(y,m)):(y=Xe(p,m,this.xml),this.xml.querySelector("attributes").append(y))}attributeChangedCallback(p,m,y){!this.xml||this.#e||(this.#t(p,y),this.transform())}get dce(){return a}}const d=c=>{window.customElements.get(c)!==f&&window.customElements.define(c,f)};if(r)d(r);else{const c=n;this.setAttribute("tag",c),d(c);const p=document.createElement(c);this.getAttributeNames().forEach(m=>p.setAttribute(m,this.getAttribute(m))),p.append(...[...this.childNodes].filter(m=>m.localName!=="style")),this.append(p)}}get templateNode(){return this.firstElementChild?.tagName==="TEMPLATE"?this.firstElementChild.content:this}get dce(){return this}get xslt(){return Nr(this.xsltString)}}window.customElements.define("custom-element",qC);export{YP as e,KP as u,WP as w};
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import{w as d,e as a,u as s}from"./custom-element-BIxkVg7K.js";import"./index-CVRyq5ci.js";function p(n){return new Promise(e=>setTimeout(e,n))}function u(n){const{title:e,body:t}=n;return`
|
|
2
|
+
<fieldset>
|
|
3
|
+
<legend>${e}</legend>
|
|
4
|
+
${t}
|
|
5
|
+
</fieldset>
|
|
6
|
+
`}const h={title:"dom-merge",render:u},o={args:{title:"Chars count in textarea",body:`
|
|
7
|
+
<p>Counter update happens on change event(focus change). The update should not interfere with the input</p>
|
|
8
|
+
<custom-element>
|
|
9
|
+
<form>
|
|
10
|
+
<label>
|
|
11
|
+
<textarea slice="text-container" data-testid="textarea-id">Hello world!</textarea>
|
|
12
|
+
<span> Chars count:
|
|
13
|
+
<code data-testid="counter-id">{string-length(//slice/text-container/text())}</code>
|
|
14
|
+
</span>
|
|
15
|
+
</label>
|
|
16
|
+
<br/><input placeholder="after textarea input, click here " data-testid="refocus-id" />
|
|
17
|
+
</form>
|
|
18
|
+
</custom-element>
|
|
19
|
+
`},play:async({canvasElement:n})=>{const e=o.args.title,t=d(n);await t.findByText(e),await p(100),a(await t.findByTestId("textarea-id")).toBeInTheDocument();const i=t.getByTestId("textarea-id");i.value="",i.focus(),await s.keyboard(e),a(i.value).toEqual(e),a(i.value.length).toEqual(e.length),t.getByTestId("refocus-id").focus(),await p(10),a(t.getByTestId("counter-id").textContent).toEqual(""+e?.length,"counter of symbols")}},l={args:{title:"Word count in HTML input field",body:`
|
|
20
|
+
<p>Counter update happens on keyup event. The update should not interfere with the input</p>
|
|
21
|
+
<custom-element>
|
|
22
|
+
<form>
|
|
23
|
+
<label>
|
|
24
|
+
<input type="text" value="{//txt ?? 'Type time update'}" slice="txt" slice-event="init input" data-testid="input-id">
|
|
25
|
+
|
|
26
|
+
<span> Character count:
|
|
27
|
+
<code data-testid="chars-id"
|
|
28
|
+
>{
|
|
29
|
+
string-length(//slice/txt)
|
|
30
|
+
}</code>
|
|
31
|
+
</span>
|
|
32
|
+
<span> Word count:
|
|
33
|
+
<code data-testid="words-id"
|
|
34
|
+
>{
|
|
35
|
+
string-length(normalize-space(//slice/txt)) -
|
|
36
|
+
string-length(translate(normalize-space(//slice/txt), ' ', '')) + 1
|
|
37
|
+
}</code>
|
|
38
|
+
<!-- The expression first normalizes the string by removing leading and trailing whitespace and
|
|
39
|
+
collapsing internal whitespace into a single space. It then subtracts the length of the string
|
|
40
|
+
with all spaces removed from the length of the original string,
|
|
41
|
+
and adds 1 to account for the last word.
|
|
42
|
+
-->
|
|
43
|
+
</span>
|
|
44
|
+
|
|
45
|
+
</label>
|
|
46
|
+
<p><b>txt</b> slice:</p> <blockquote> {//slice/txt} </blockquote>
|
|
47
|
+
</form>
|
|
48
|
+
</custom-element>
|
|
49
|
+
`},play:async({canvasElement:n})=>{const e=l.args.title,t=d(n);await t.findByText(e);const i=await t.findByTestId("input-id");i.value="",i.focus(),a(i).toBeInTheDocument(),await s.keyboard(e),await p(10),a(i.value).toEqual(e),a(t.getByTestId("chars-id").textContent.trim()).toEqual(""+e.length,"counter of symbols"),a(e.split(" ").length).toEqual(6,"counter of words in text sample"),a(t.getByTestId("words-id").textContent.trim()).toEqual("6","counter of words in render")}},r={args:{title:"Order preserving on 2nd transform",body:`
|
|
50
|
+
<p>IF condition content should be displayed in place where it is defined (not shifted down on the parent children)</p>
|
|
51
|
+
<custom-element>
|
|
52
|
+
<form slice="f1">
|
|
53
|
+
<label>
|
|
54
|
+
<input type="checkbox" name="c1" data-testid="cb1"/>
|
|
55
|
+
click to display #1 bellow
|
|
56
|
+
</label>
|
|
57
|
+
<br data-testid="beforeC1"/>
|
|
58
|
+
<if test="//c1">
|
|
59
|
+
<p data-testid="isC1">#1</p>
|
|
60
|
+
</if>
|
|
61
|
+
<label>
|
|
62
|
+
<input type="checkbox" name="c2" data-testid="cb2"/>
|
|
63
|
+
click to display #2 bellow
|
|
64
|
+
</label>
|
|
65
|
+
<br data-testid="beforeC2"/>
|
|
66
|
+
<if test="//c2">
|
|
67
|
+
<p>#2</p>
|
|
68
|
+
</if>
|
|
69
|
+
</form>
|
|
70
|
+
</custom-element>
|
|
71
|
+
`},play:async({canvasElement:n})=>{const e=r.args.title,t=d(n);await t.findByText(e),await s.click(t.getByTestId("cb1")),await a(await t.findByText("#1")).toBeInTheDocument(),await s.click(t.getByTestId("cb2")),await a(await t.findByText("#2")).toBeInTheDocument(),await a(t.getByTestId("beforeC1").nextElementSibling).toEqual(t.getByTestId("isC1"))}},c={args:{title:"read system validity message",body:`
|
|
72
|
+
<p>validationMessage propagated into slice as 'validation-message' attribute</p>
|
|
73
|
+
<ol>
|
|
74
|
+
<li> type in input field</li>
|
|
75
|
+
<li> delete input field content</li>
|
|
76
|
+
<li> observe the warning in string after input</li>
|
|
77
|
+
<li> Click Next observe the system warning in dropdown over input</li>
|
|
78
|
+
</ol>
|
|
79
|
+
<custom-element>
|
|
80
|
+
<template>
|
|
81
|
+
<form slice="email-form">
|
|
82
|
+
<label> Email
|
|
83
|
+
<input slice="username" slice-event="input" placeholder="non-empty" required data-testid="inp1">
|
|
84
|
+
</label>
|
|
85
|
+
<if test="//username/@validation-message">
|
|
86
|
+
<var data-testid="var1">{//username/@validation-message}</var>
|
|
87
|
+
</if>
|
|
88
|
+
<button data-testid="btn1">Next</button>
|
|
89
|
+
</form>
|
|
90
|
+
</template>
|
|
91
|
+
</custom-element>
|
|
92
|
+
`},play:async({canvasElement:n})=>{const e=c.args.title,t=d(n);await t.findByText(e),await s.type(t.getByTestId("inp1"),"Hi"),await s.clear(t.getByTestId("inp1")),await s.click(t.getByTestId("btn1")),await a(await t.findByTestId("var1")).toBeInTheDocument(),await a(t.getByTestId("var1").textContent).toEqual(t.getByTestId("inp1").validationMessage),await a(t.getByTestId("var1").textContent.length>1).toEqual(!0)}};o.parameters={...o.parameters,docs:{...o.parameters?.docs,source:{originalSource:`{
|
|
93
|
+
args: {
|
|
94
|
+
title: 'Chars count in textarea',
|
|
95
|
+
body: \`
|
|
96
|
+
<p>Counter update happens on change event(focus change). The update should not interfere with the input</p>
|
|
97
|
+
<custom-element>
|
|
98
|
+
<form>
|
|
99
|
+
<label>
|
|
100
|
+
<textarea slice="text-container" data-testid="textarea-id">Hello world!</textarea>
|
|
101
|
+
<span> Chars count:
|
|
102
|
+
<code data-testid="counter-id">{string-length(//slice/text-container/text())}</code>
|
|
103
|
+
</span>
|
|
104
|
+
</label>
|
|
105
|
+
<br/><input placeholder="after textarea input, click here " data-testid="refocus-id" />
|
|
106
|
+
</form>
|
|
107
|
+
</custom-element>
|
|
108
|
+
\`
|
|
109
|
+
},
|
|
110
|
+
play: async ({
|
|
111
|
+
canvasElement
|
|
112
|
+
}) => {
|
|
113
|
+
const titleText = (CharsCountInTextarea.args!.title as string);
|
|
114
|
+
const canvas = within(canvasElement);
|
|
115
|
+
await canvas.findByText(titleText);
|
|
116
|
+
await sleep(100);
|
|
117
|
+
expect(await canvas.findByTestId('textarea-id')).toBeInTheDocument();
|
|
118
|
+
const textarea = canvas.getByTestId('textarea-id');
|
|
119
|
+
textarea.value = '';
|
|
120
|
+
textarea.focus();
|
|
121
|
+
await userEvent.keyboard(titleText);
|
|
122
|
+
expect(textarea.value).toEqual(titleText);
|
|
123
|
+
expect(textarea.value.length).toEqual(titleText.length);
|
|
124
|
+
canvas.getByTestId('refocus-id').focus();
|
|
125
|
+
await sleep(10);
|
|
126
|
+
expect(canvas.getByTestId('counter-id').textContent).toEqual('' + titleText?.length, 'counter of symbols');
|
|
127
|
+
}
|
|
128
|
+
}`,...o.parameters?.docs?.source}}};l.parameters={...l.parameters,docs:{...l.parameters?.docs,source:{originalSource:`{
|
|
129
|
+
args: {
|
|
130
|
+
title: 'Word count in HTML input field',
|
|
131
|
+
body: \`
|
|
132
|
+
<p>Counter update happens on keyup event. The update should not interfere with the input</p>
|
|
133
|
+
<custom-element>
|
|
134
|
+
<form>
|
|
135
|
+
<label>
|
|
136
|
+
<input type="text" value="{//txt ?? 'Type time update'}" slice="txt" slice-event="init input" data-testid="input-id">
|
|
137
|
+
|
|
138
|
+
<span> Character count:
|
|
139
|
+
<code data-testid="chars-id"
|
|
140
|
+
>{
|
|
141
|
+
string-length(//slice/txt)
|
|
142
|
+
}</code>
|
|
143
|
+
</span>
|
|
144
|
+
<span> Word count:
|
|
145
|
+
<code data-testid="words-id"
|
|
146
|
+
>{
|
|
147
|
+
string-length(normalize-space(//slice/txt)) -
|
|
148
|
+
string-length(translate(normalize-space(//slice/txt), ' ', '')) + 1
|
|
149
|
+
}</code>
|
|
150
|
+
<!-- The expression first normalizes the string by removing leading and trailing whitespace and
|
|
151
|
+
collapsing internal whitespace into a single space. It then subtracts the length of the string
|
|
152
|
+
with all spaces removed from the length of the original string,
|
|
153
|
+
and adds 1 to account for the last word.
|
|
154
|
+
-->
|
|
155
|
+
</span>
|
|
156
|
+
|
|
157
|
+
</label>
|
|
158
|
+
<p><b>txt</b> slice:</p> <blockquote> {//slice/txt} </blockquote>
|
|
159
|
+
</form>
|
|
160
|
+
</custom-element>
|
|
161
|
+
\`
|
|
162
|
+
},
|
|
163
|
+
play: async ({
|
|
164
|
+
canvasElement
|
|
165
|
+
}) => {
|
|
166
|
+
const titleText = (WordCountOnType.args!.title as string);
|
|
167
|
+
const canvas = within(canvasElement);
|
|
168
|
+
await canvas.findByText(titleText);
|
|
169
|
+
const input = await canvas.findByTestId('input-id');
|
|
170
|
+
input.value = '';
|
|
171
|
+
input.focus();
|
|
172
|
+
expect(input).toBeInTheDocument();
|
|
173
|
+
await userEvent.keyboard(titleText);
|
|
174
|
+
await sleep(10);
|
|
175
|
+
expect(input.value).toEqual(titleText);
|
|
176
|
+
expect(canvas.getByTestId('chars-id').textContent.trim()).toEqual('' + titleText.length, 'counter of symbols');
|
|
177
|
+
expect(titleText.split(' ').length).toEqual(6, 'counter of words in text sample');
|
|
178
|
+
expect(canvas.getByTestId('words-id').textContent.trim()).toEqual('6', 'counter of words in render');
|
|
179
|
+
}
|
|
180
|
+
}`,...l.parameters?.docs?.source}}};r.parameters={...r.parameters,docs:{...r.parameters?.docs,source:{originalSource:`{
|
|
181
|
+
args: {
|
|
182
|
+
title: 'Order preserving on 2nd transform',
|
|
183
|
+
body: \`
|
|
184
|
+
<p>IF condition content should be displayed in place where it is defined (not shifted down on the parent children)</p>
|
|
185
|
+
<custom-element>
|
|
186
|
+
<form slice="f1">
|
|
187
|
+
<label>
|
|
188
|
+
<input type="checkbox" name="c1" data-testid="cb1"/>
|
|
189
|
+
click to display #1 bellow
|
|
190
|
+
</label>
|
|
191
|
+
<br data-testid="beforeC1"/>
|
|
192
|
+
<if test="//c1">
|
|
193
|
+
<p data-testid="isC1">#1</p>
|
|
194
|
+
</if>
|
|
195
|
+
<label>
|
|
196
|
+
<input type="checkbox" name="c2" data-testid="cb2"/>
|
|
197
|
+
click to display #2 bellow
|
|
198
|
+
</label>
|
|
199
|
+
<br data-testid="beforeC2"/>
|
|
200
|
+
<if test="//c2">
|
|
201
|
+
<p>#2</p>
|
|
202
|
+
</if>
|
|
203
|
+
</form>
|
|
204
|
+
</custom-element>
|
|
205
|
+
\`
|
|
206
|
+
},
|
|
207
|
+
play: async ({
|
|
208
|
+
canvasElement
|
|
209
|
+
}) => {
|
|
210
|
+
const titleText = (OrderPreservingOn2ndTransform.args!.title as string);
|
|
211
|
+
const canvas = within(canvasElement);
|
|
212
|
+
await canvas.findByText(titleText);
|
|
213
|
+
await userEvent.click(canvas.getByTestId('cb1'));
|
|
214
|
+
await expect(await canvas.findByText('#1')).toBeInTheDocument();
|
|
215
|
+
await userEvent.click(canvas.getByTestId('cb2'));
|
|
216
|
+
await expect(await canvas.findByText('#2')).toBeInTheDocument();
|
|
217
|
+
await expect(canvas.getByTestId("beforeC1").nextElementSibling).toEqual(canvas.getByTestId("isC1"));
|
|
218
|
+
}
|
|
219
|
+
}`,...r.parameters?.docs?.source}}};c.parameters={...c.parameters,docs:{...c.parameters?.docs,source:{originalSource:`{
|
|
220
|
+
args: {
|
|
221
|
+
title: 'read system validity message',
|
|
222
|
+
body: \`
|
|
223
|
+
<p>validationMessage propagated into slice as 'validation-message' attribute</p>
|
|
224
|
+
<ol>
|
|
225
|
+
<li> type in input field</li>
|
|
226
|
+
<li> delete input field content</li>
|
|
227
|
+
<li> observe the warning in string after input</li>
|
|
228
|
+
<li> Click Next observe the system warning in dropdown over input</li>
|
|
229
|
+
</ol>
|
|
230
|
+
<custom-element>
|
|
231
|
+
<template>
|
|
232
|
+
<form slice="email-form">
|
|
233
|
+
<label> Email
|
|
234
|
+
<input slice="username" slice-event="input" placeholder="non-empty" required data-testid="inp1">
|
|
235
|
+
</label>
|
|
236
|
+
<if test="//username/@validation-message">
|
|
237
|
+
<var data-testid="var1">{//username/@validation-message}</var>
|
|
238
|
+
</if>
|
|
239
|
+
<button data-testid="btn1">Next</button>
|
|
240
|
+
</form>
|
|
241
|
+
</template>
|
|
242
|
+
</custom-element>
|
|
243
|
+
\`
|
|
244
|
+
},
|
|
245
|
+
play: async ({
|
|
246
|
+
canvasElement
|
|
247
|
+
}) => {
|
|
248
|
+
const titleText = (ReadSystemValidityMessage.args!.title as string);
|
|
249
|
+
const canvas = within(canvasElement);
|
|
250
|
+
await canvas.findByText(titleText);
|
|
251
|
+
await userEvent.type(canvas.getByTestId('inp1'), 'Hi');
|
|
252
|
+
await userEvent.clear(canvas.getByTestId('inp1'));
|
|
253
|
+
await userEvent.click(canvas.getByTestId('btn1'));
|
|
254
|
+
await expect(await canvas.findByTestId('var1')).toBeInTheDocument();
|
|
255
|
+
await expect(canvas.getByTestId("var1").textContent).toEqual(canvas.getByTestId("inp1").validationMessage);
|
|
256
|
+
await expect(canvas.getByTestId("var1").textContent.length > 1).toEqual(true);
|
|
257
|
+
}
|
|
258
|
+
}`,...c.parameters?.docs?.source}}};const y=["CharsCountInTextarea","WordCountOnType","OrderPreservingOn2ndTransform","ReadSystemValidityMessage"];export{o as CharsCountInTextarea,r as OrderPreservingOn2ndTransform,c as ReadSystemValidityMessage,l as WordCountOnType,y as __namedExportsOrder,h as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{w as l,e as a}from"./custom-element-
|
|
1
|
+
import{w as l,e as a}from"./custom-element-BIxkVg7K.js";import"./index-CVRyq5ci.js";function T(t){return new Promise(e=>setTimeout(e,t))}function v(t){const{title:e,body:n}=t;return`
|
|
2
2
|
<fieldset>
|
|
3
3
|
<legend>${e}</legend>
|
|
4
4
|
${n}
|
package/storybook-static/assets/{form.test.stories-3tURbEdv.js → form.test.stories-DsIo1B4n.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{w as i,e as n,u as e}from"./custom-element-
|
|
1
|
+
import{w as i,e as n,u as e}from"./custom-element-BIxkVg7K.js";import"./index-CVRyq5ci.js";function l(a){const{title:t,body:s}=a;return`
|
|
2
2
|
<fieldset>
|
|
3
3
|
<legend>${t}</legend>
|
|
4
4
|
${s}
|