50 lines
24 KiB
JavaScript
50 lines
24 KiB
JavaScript
|
"use strict";
|
||
|
(self["webpackChunk_woocommerce_storybook"] = self["webpackChunk_woocommerce_storybook"] || []).push([[9735],{
|
||
|
|
||
|
/***/ "../../node_modules/.pnpm/@storybook+blocks@7.6.19_@types+react-dom@18.3.0_@types+react@17.0.71_encoding@0.1.13_react-d_jtsmww46kxnjip66rpujoqkqpi/node_modules/@storybook/blocks/dist/Color-6VNJS4EI.mjs":
|
||
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
||
|
|
||
|
// ESM COMPAT FLAG
|
||
|
__webpack_require__.r(__webpack_exports__);
|
||
|
|
||
|
// EXPORTS
|
||
|
__webpack_require__.d(__webpack_exports__, {
|
||
|
ColorControl: () => (/* binding */ ColorControl),
|
||
|
"default": () => (/* binding */ Color_default)
|
||
|
});
|
||
|
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/@storybook+blocks@7.6.19_@types+react-dom@18.3.0_@types+react@17.0.71_encoding@0.1.13_react-d_jtsmww46kxnjip66rpujoqkqpi/node_modules/@storybook/blocks/dist/chunk-GWAJ4KRU.mjs
|
||
|
var chunk_GWAJ4KRU = __webpack_require__("../../node_modules/.pnpm/@storybook+blocks@7.6.19_@types+react-dom@18.3.0_@types+react@17.0.71_encoding@0.1.13_react-d_jtsmww46kxnjip66rpujoqkqpi/node_modules/@storybook/blocks/dist/chunk-GWAJ4KRU.mjs");
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/react@18.3.1/node_modules/react/index.js
|
||
|
var react = __webpack_require__("../../node_modules/.pnpm/react@18.3.1/node_modules/react/index.js");
|
||
|
;// CONCATENATED MODULE: ../../node_modules/.pnpm/react-colorful@5.6.1_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/react-colorful/dist/index.mjs
|
||
|
function u(){return(u=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)}function c(e,r){if(null==e)return{};var t,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r.indexOf(t=a[n])>=0||(o[t]=e[t]);return o}function i(e){var t=(0,react.useRef)(e),n=(0,react.useRef)(function(e){t.current&&t.current(e)});return t.current=e,n.current}var s=function(e,r,t){return void 0===r&&(r=0),void 0===t&&(t=1),e>t?t:e<r?r:e},f=function(e){return"touches"in e},v=function(e){return e&&e.ownerDocument.defaultView||self},d=function(e,r,t){var n=e.getBoundingClientRect(),o=f(r)?function(e,r){for(var t=0;t<e.length;t++)if(e[t].identifier===r)return e[t];return e[0]}(r.touches,t):r;return{left:s((o.pageX-(n.left+v(e).pageXOffset))/n.width),top:s((o.pageY-(n.top+v(e).pageYOffset))/n.height)}},h=function(e){!f(e)&&e.preventDefault()},m=react.memo(function(o){var a=o.onMove,l=o.onKey,s=c(o,["onMove","onKey"]),m=(0,react.useRef)(null),g=i(a),p=i(l),b=(0,react.useRef)(null),_=(0,react.useRef)(!1),x=(0,react.useMemo)(function(){var e=function(e){h(e),(f(e)?e.touches.length>0:e.buttons>0)&&m.current?g(d(m.current,e,b.current)):t(!1)},r=function(){return t(!1)};function t(t){var n=_.current,o=v(m.current),a=t?o.addEventListener:o.removeEventListener;a(n?"touchmove":"mousemove",e),a(n?"touchend":"mouseup",r)}return[function(e){var r=e.nativeEvent,n=m.current;if(n&&(h(r),!function(e,r){return r&&!f(e)}(r,_.current)&&n)){if(f(r)){_.current=!0;var o=r.changedTouches||[];o.length&&(b.current=o[0].identifier)}n.focus(),g(d(n,r,b.current)),t(!0)}},function(e){var r=e.which||e.keyCode;r<37||r>40||(e.preventDefault(),p({left:39===r?.05:37===r?-.05:0,top:40===r?.05:38===r?-.05:0}))},t]},[p,g]),C=x[0],E=x[1],H=x[2];return (0,react.useEffect)(function(){return H},[H]),react.createElement("div",u({},s,{onTouchStart:C,onMouseDown:C,className:"react-colorful__interactive",ref:m,onKeyDown:E,tabIndex:0,role:"slider"}))}),g=function(e){return e.filter(Boolean).join(" ")},p=function(r){var t=r.color,n=r.left,o=r.top,a=void 0===o?.5:o,l=g(["react-colorful__pointer",r.className]);return react.createElement("div",{className:l,style:{top:100*a+"%",left:100*n+"%"}},react.createElement("div",{className:"react-colorful__pointer-fill",style:{backgroundColor:t}}))},b=function(e,r,t){return void 0===r&&(r=0),void 0===t&&(t=Math.pow(10,r)),Math.round(t*e)/t},_={grad:.9,turn:360,rad:360/(2*Math.PI)},x=function(e){return L(C(e))},C=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:4===e.length?b(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:8===e.length?b(parseInt(e.substring(6,8),16)/255,2):1}},E=function(e,r){return void 0===r&&(r="deg"),Number(e)*(_[r]||1)},H=function(e){var r=/hsla?\(?\s*(-?\d*\.?\d+)(deg|rad|grad|turn)?[,\s]+(-?\d*\.?\d+)%?[,\s]+(-?\d*\.?\d+)%?,?\s*[/\s]*(-?\d*\.?\d+)?(%)?\s*\)?/i.exec(e);return r?N({h:E(r[1],r[2]),s:Number(r[3]),l:Number(r[4]),a:void 0===r[5]?1:Number(r[5])/(r[6]?100:1)}):{h:0,s:0,v:0,a:1}},M=H,N=function(e){var r=e.s,t=e.l;return{h:e.h,s:(r*=(t<50?t:100-t)/100)>0?2*r/(t+r)*100:0,v:t+r,a:e.a}},w=function(e){return K(I(e))},y=function(e){var r=e.s,t=e.v,n=e.a,o=(200-r)*t/100;return{h:b(e.h),s:b(o>0&&o<200?r*t/100/(o<=100?o:200-o)*100:0),l:b(o/2),a:b(n,2)}},q=function(e){var r=y(e);return"hsl("+r.h+", "+r.s+"%, "+r.l+"%)"},k=function(e){var r=y(e);return"hsla("+r.h+", "+r.s+"%, "+r.l+"%, "+r.a+")"},I=function(e){var r=e.h,t=e.s,n=e.v,o=e.a;r=r/360*6,t/=100,n/=100;var a=Math.floor(r),l=n*(1-t),u=n*(1-(r-a)*t),c=n*(1-(1-r+a)*t),i=a%6;return{r:b(255*[n,u,l,l,c,n][i]),g:b(255*[c,n,n,u,l,l][i]),b:b(255*[l,l,c,n,n,u][i]),a:b(o,2)}},O=function(e){var r=/hsva?\(?\s*(-?\d*\.?\d+)(deg|rad|grad|turn)?[,\s]+(-?\d*\.?\d+)%?[,\s]+(-?\d*\.?\d+)%?,?\s*[/\s]*(-?\d*\.?\d+)?(%)?\s*\)?/i.exec(e);return r?A({h:E(r[1],r[2]),s:Number(r[3]),v:Number(r[4]),a:void 0===r
|
||
|
//# sourceMappingURL=index.module.js.map
|
||
|
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/index.js
|
||
|
var color_convert = __webpack_require__("../../node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/index.js");
|
||
|
var color_convert_default = /*#__PURE__*/__webpack_require__.n(color_convert);
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/throttle.js
|
||
|
var throttle = __webpack_require__("../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/throttle.js");
|
||
|
var throttle_default = /*#__PURE__*/__webpack_require__.n(throttle);
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/@storybook+theming@7.6.19_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@storybook/theming/dist/index.mjs + 1 modules
|
||
|
var dist = __webpack_require__("../../node_modules/.pnpm/@storybook+theming@7.6.19_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@storybook/theming/dist/index.mjs");
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/@storybook+components@7.6.19_@types+react-dom@18.3.0_@types+react@17.0.71_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@storybook/components/dist/index.mjs + 1 modules
|
||
|
var components_dist = __webpack_require__("../../node_modules/.pnpm/@storybook+components@7.6.19_@types+react-dom@18.3.0_@types+react@17.0.71_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@storybook/components/dist/index.mjs");
|
||
|
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@storybook+blocks@7.6.19_@types+react-dom@18.3.0_@types+react@17.0.71_encoding@0.1.13_react-d_jtsmww46kxnjip66rpujoqkqpi/node_modules/@storybook/blocks/dist/Color-6VNJS4EI.mjs
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
var Wrapper=dist/* styled */.I4.div({position:"relative",maxWidth:250}),PickerTooltip=(0,dist/* styled */.I4)(components_dist/* WithTooltip */.kR)({position:"absolute",zIndex:1,top:4,left:4}),TooltipContent=dist/* styled */.I4.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"}}),Note=(0,dist/* styled */.I4)(components_dist/* TooltipNote */._)(({theme})=>({fontFamily:theme.typography.fonts.base})),Swatches=dist/* styled */.I4.div({display:"grid",gridTemplateColumns:"repeat(9, 16px)",gap:6,padding:3,marginTop:5,width:200}),SwatchColor=dist/* styled */.I4.div(({theme,active})=>({width:16,height:16,boxShadow:active?`${theme.appBorderColor} 0 0 0 1px inset, ${theme.textMutedColor}50 0 0 0 4px`:`${theme.appBorderColor} 0 0 0 1px inset`,borderRadius:theme.appBorderRadius})),swatchBackground=`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>')`,Swatch=({value,active,onClick,style,...props})=>{let backgroundImage=`linear-gradient(${value}, ${value}), ${swatchBackground}, linear-gradient(#fff, #fff)`;return react.createElement(SwatchColor,{...props,active,onClick,style:{...style,backgroundImage}})},Input=(0,dist/* styled */.I4)(components_dist/* Form */.lV.Input)(({theme})=>({width:"100%",paddingLeft:30,paddingRight:30,boxSizing:"border-box",fontFamily:theme.typography.fonts.base})),ToggleIcon=(0,dist/* styled */.I4)(components_dist/* Icons */.FI)(({theme})=>({position:"absolute",zIndex:1,top:6,right:7,width:20,height:20,padding:4,boxSizing:"border-box",cursor:"pointer",color:theme.input.color})),ColorSpace=(ColorSpace2=>(ColorSpace2.RGB="rgb",ColorSpace2.HSL="hsl",ColorSpace2.HEX="hex",ColorSpace2))(ColorSpace||{}),COLOR_SPACES=Object.values(ColorSpace),COLOR_REGEXP=/\(([0-9]+),\s*([0-9]+)%?,\s*([0-9]+)%?,?\s*([0-9.]+)?\)/,RGB_REGEXP=/^\s*rgba?\(([0-9]+),\s*([0-9]+),\s*([0-9]+),?\s*([0-9.]+)?\)\s*$/i,HSL_REGEXP=/^\s*hsla?\(([0-9]+),\s*([0-9]+)%,\s*([0-9]+)%,?\s*([0-9.]+)?\)\s*$/i,HEX_REGEXP=/^\s*#?([0-9a-f]{3}|[0-9a-f]{6})\s*$/i,SHORTHEX_REGEXP=/^\s*#?([0-9a-f]{3})\s*$/i,ColorPicker={hex:Z,rgb:He,hsl:ue},fallbackColor={hex:"transparent",rgb:"rgba(0, 0, 0, 0)",hsl:"hsla(0, 0%, 0%, 0)"},stringToArgs=value=>{let match=value?.match(COLOR_REGEXP);if(!match)return [0,0,0,1];let[,x,y,z,a=1]=match;return [x,y,z,a].map(Number)},parseValue=value=>{if(!value)return;let valid=!0;if(RGB_REGEXP.test(value)){let[r,g,b,a]=stringToArgs(value),[h,s,l]=color_convert_default().rgb.hsl([r,g,b])||[0,0,0];return {valid,value,keyword:color_convert_default().rgb.keyword([r,g,b]),colorSpace:"rgb",rgb:value,hsl:`hsla(${h}, ${s}%, ${l}%, ${a})`,hex:`#${color_convert_default().rgb.hex([r,g,b]).toLowerCase()}`}}if(HSL_REGEXP.test(value)){let[h,s,l,a]=stringToArgs(value),[r,g,b]=color_convert_default().hsl.rgb([h,s,l])||[0,0,0];return {valid,value,keyword:color_convert_default().hsl.keyword([h,s,l]),colorSpace:"hsl",rgb:`rgba(${r}, ${g}, ${b}, ${a})`,hsl:value,hex:`#${color_convert_default().hsl.hex([h,s,l]).toLowerCase()}`}}let plain=value.replace("#",""),rgb=color_convert_default().keyword.rgb(plain)||color_convert_default().hex.rgb(plain),hsl=color_convert_default().rgb.hsl(rgb),mapped=value;if(/[^#a-f0-9]/i.test(value)?mapped=plain:HEX_REGEXP.test(value)&&(mapped=`#${plain}`),mapped.startsWith("#"))valid=HEX_REGEXP.test(mapped);else try{color_convert_default().keyword.hex(mapped);}catch{valid=!1;}return {valid,value:mapped,keyword:color_convert_default().rgb.keyword(rgb),colorSpace:"hex",rgb:`rgba(${rgb[0]}, ${rgb[1]}, ${rgb[2]}, 1)`,hsl:`hsla(${hsl[0]}, ${hsl[1]}%, ${hsl[2]}%, 1)`,hex:mapped}},getRealValue=(value,color,colorSpace)=>{if(!value||!color?.valid)return fallbackColor[colorSpace];if(colorSpace!=="hex")return color?.[colorSpace]||fallbackColor[colorSpace];if(!color.hex.startsWith("#"))try{return `#${color_convert_default().keyword.hex(color.hex)}`}catch{return fallbackColor.hex
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
/***/ })
|
||
|
|
||
|
}]);
|