mirror of
https://github.com/proelements/proelements.git
synced 2026-04-28 06:00:40 +00:00
v3.34.0
This commit is contained in:
@@ -24,6 +24,7 @@ __webpack_require__.r(__webpack_exports__);
|
||||
|
||||
|
||||
|
||||
const RESTRICTED_KEYBOARD_SHORTCUT_UNITS = ['auto'];
|
||||
const RESTRICTED_INPUT_KEYS = ['e', 'E', '+', '-'];
|
||||
function notAnEmptySize(value) {
|
||||
return null !== value && undefined !== value && !isNaN(Number(value));
|
||||
@@ -93,7 +94,7 @@ const SizeField = ({
|
||||
const newChar = key.toLowerCase();
|
||||
const updatedBuffer = (unitInputBufferRef.current + newChar).slice(-3);
|
||||
unitInputBufferRef.current = updatedBuffer;
|
||||
const matchedUnit = units.find(u => u.includes(updatedBuffer)) || units.find(u => u.startsWith(newChar)) || units.find(u => u.includes(newChar));
|
||||
const matchedUnit = units.find(u => !RESTRICTED_KEYBOARD_SHORTCUT_UNITS.includes(u) && u.includes(updatedBuffer)) || units.find(u => !RESTRICTED_KEYBOARD_SHORTCUT_UNITS.includes(u) && u.startsWith(newChar)) || units.find(u => !RESTRICTED_KEYBOARD_SHORTCUT_UNITS.includes(u) && u.includes(newChar));
|
||||
if (matchedUnit) {
|
||||
handleUnitChange(matchedUnit);
|
||||
}
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
!function(){"use strict";var e={d:function(t,n){for(var i in n)e.o(n,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:n[i]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{init:function(){return V}});var n=window.elementorV2.editorProps,i=window.elementorV2.editorVariables,r=window.elementorV2.icons,o=window.React;const u="px",a=["px","%","em","rem","vw","vh","auto"],l=e=>{if(!e)return a;const t=s(e);return Array.isArray(t.available_units)&&0!==t.available_units.length?t.available_units.filter((e=>"custom"!==e)):a},s=e=>"union"===e?.kind?e.prop_types[n.sizePropTypeUtil.key].settings:{},c=(e,t,n)=>{if("string"!=typeof e)return"custom"===e?.unit?{size:null,unit:u}:"auto"===e.unit?{size:null,unit:e.unit}:e;const i={size:null,unit:t??u},r=n??(()=>{const e=window;return e.elementor?.config?.supported_size_units??[]})();if("auto"===e)return r.includes(e)?{size:"",unit:e}:i;const o=e.match(/^(-?\d*\.?\d+)([a-z%]+)$/i);if(o){const e=parseFloat(o[1]),t=o[2];if(r.includes(t))return{size:e,unit:t}}return i};var p=window.elementorV2.ui;const d=({value:e,onChange:t,endAdornment:n,onKeyUp:i,onKeyDown:r,type:u})=>o.createElement(p.TextField,{size:"tiny",type:u,fullWidth:!0,value:e,onKeyUp:i,onKeyDown:r,onChange:e=>t(e.target.value),InputProps:{endAdornment:n}});var m=window.elementorV2.editorUi;function y(){return y=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},y.apply(null,arguments)}const f=({options:e,value:t,onClick:n,showPrimaryColor:i})=>{const r=(0,p.usePopupState)({variant:"popover",popupId:(0,o.useId)()});return o.createElement(p.InputAdornment,{position:"end"},o.createElement(v,y({isPrimaryColor:i,size:"small"},(0,p.bindTrigger)(r)),t),o.createElement(p.Menu,y({MenuListProps:{dense:!0}},(0,p.bindMenu)(r)),e.map(((t,i)=>o.createElement(m.MenuListItem,{key:t,onClick:()=>(t=>{n(e[t]),r.close()})(i)},t.toUpperCase())))))},v=(0,p.styled)(p.Button,{shouldForwardProp:e=>"isPrimaryColor"!==e})((({isPrimaryColor:e,theme:t})=>({color:e?t.palette.text.primary:t.palette.text.tertiary,font:"inherit",minWidth:"initial",textTransform:"uppercase"}))),w=["e","E","+","-"];function b(e){return null!=e&&!isNaN(Number(e))}const g=({value:e,onChange:t,propType:n})=>{const i=(e=>e?s(e)?.default_unit??u:u)(n),r=l(n),a=c(e,i??u,r),[p,m]=(0,o.useState)(a);(0,o.useEffect)((()=>{const{size:e,unit:n}=p;t("auto"!==n?null!==e?(({size:e,unit:t})=>"auto"===t?"auto":`${e??""}${t}`)(p):"":"auto")}),[p,t]);const y=e=>{m((t=>"auto"===e?{unit:e,size:null}:{...t,unit:e}))},v=(0,o.useRef)("");return o.createElement(d,{type:"number",value:p.size??"",onChange:e=>{const t=z(e);m((e=>t&&"auto"===e.unit?{size:t,unit:i??u}:{...e,size:t}))},onKeyUp:e=>{const{key:t}=e;if(!/^[a-zA-Z%]$/.test(t))return;e.preventDefault();const n=t.toLowerCase(),i=(v.current+n).slice(-3);v.current=i;const o=r.find((e=>e.includes(i)))||r.find((e=>e.startsWith(n)))||r.find((e=>e.includes(n)));o&&y(o)},onKeyDown:e=>{w.includes(e.key)&&e.preventDefault()},endAdornment:o.createElement(f,{showPrimaryColor:b(p.size)||"auto"===p.unit,options:r,value:p.unit,onClick:y})})},z=e=>""===e.trim()?null:Number(e);var h=window.elementorV2.schema;const P=(0,n.createPropUtils)("global-size-variable",h.z.string());function C(e,t){const n=l(e),{unit:i}=c(t.value);return n.includes(i)}function V(){(0,i.registerVariableType)({valueField:g,icon:r.ExpandDiagonalIcon,propTypeUtil:P,fallbackPropTypeUtil:n.sizePropTypeUtil,variableType:"size",defaultValue:"0px",selectionFilter:(e,t)=>{const n=l(t);return e.filter((e=>{const{unit:t}=c(e.value);return n.includes(t)}))},isCompatible:C,valueTransformer:c})}(window.elementorV2=window.elementorV2||{}).editorVariablesExtended=t}(),window.elementorV2.editorVariablesExtended?.init?.();
|
||||
!function(){"use strict";var e={d:function(t,n){for(var i in n)e.o(n,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:n[i]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{init:function(){return T}});var n=window.elementorV2.editorProps,i=window.elementorV2.editorVariables,r=window.elementorV2.icons,o=window.React;const u="px",l=["px","%","em","rem","vw","vh","auto"],a=e=>{if(!e)return l;const t=s(e);return Array.isArray(t.available_units)&&0!==t.available_units.length?t.available_units.filter((e=>"custom"!==e)):l},s=e=>"union"===e?.kind?e.prop_types[n.sizePropTypeUtil.key].settings:{},c=(e,t,n)=>{if("string"!=typeof e)return"custom"===e?.unit?{size:null,unit:u}:"auto"===e.unit?{size:null,unit:e.unit}:e;const i={size:null,unit:t??u},r=n??(()=>{const e=window;return e.elementor?.config?.supported_size_units??[]})();if("auto"===e)return r.includes(e)?{size:"",unit:e}:i;const o=e.match(/^(-?\d*\.?\d+)([a-z%]+)$/i);if(o){const e=parseFloat(o[1]),t=o[2];if(r.includes(t))return{size:e,unit:t}}return i};var d=window.elementorV2.ui;const p=({value:e,onChange:t,endAdornment:n,onKeyUp:i,onKeyDown:r,type:u})=>o.createElement(d.TextField,{size:"tiny",type:u,fullWidth:!0,value:e,onKeyUp:i,onKeyDown:r,onChange:e=>t(e.target.value),InputProps:{endAdornment:n}});var m=window.elementorV2.editorUi;function y(){return y=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},y.apply(null,arguments)}const f=({options:e,value:t,onClick:n,showPrimaryColor:i})=>{const r=(0,d.usePopupState)({variant:"popover",popupId:(0,o.useId)()});return o.createElement(d.InputAdornment,{position:"end"},o.createElement(v,y({isPrimaryColor:i,size:"small"},(0,d.bindTrigger)(r)),t),o.createElement(d.Menu,y({MenuListProps:{dense:!0}},(0,d.bindMenu)(r)),e.map(((t,i)=>o.createElement(m.MenuListItem,{key:t,onClick:()=>(t=>{n(e[t]),r.close()})(i)},t.toUpperCase())))))},v=(0,d.styled)(d.Button,{shouldForwardProp:e=>"isPrimaryColor"!==e})((({isPrimaryColor:e,theme:t})=>({color:e?t.palette.text.primary:t.palette.text.tertiary,font:"inherit",minWidth:"initial",textTransform:"uppercase"}))),w=["auto"],b=["e","E","+","-"];function g(e){return null!=e&&!isNaN(Number(e))}const z=({value:e,onChange:t,propType:n})=>{const i=(e=>e?s(e)?.default_unit??u:u)(n),r=a(n),l=c(e,i??u,r),[d,m]=(0,o.useState)(l);(0,o.useEffect)((()=>{const{size:e,unit:n}=d;t("auto"!==n?null!==e?(({size:e,unit:t})=>"auto"===t?"auto":`${e??""}${t}`)(d):"":"auto")}),[d,t]);const y=e=>{m((t=>"auto"===e?{unit:e,size:null}:{...t,unit:e}))},v=(0,o.useRef)("");return o.createElement(p,{type:"number",value:d.size??"",onChange:e=>{const t=h(e);m((e=>t&&"auto"===e.unit?{size:t,unit:i??u}:{...e,size:t}))},onKeyUp:e=>{const{key:t}=e;if(!/^[a-zA-Z%]$/.test(t))return;e.preventDefault();const n=t.toLowerCase(),i=(v.current+n).slice(-3);v.current=i;const o=r.find((e=>!w.includes(e)&&e.includes(i)))||r.find((e=>!w.includes(e)&&e.startsWith(n)))||r.find((e=>!w.includes(e)&&e.includes(n)));o&&y(o)},onKeyDown:e=>{b.includes(e.key)&&e.preventDefault()},endAdornment:o.createElement(f,{showPrimaryColor:g(d.size)||"auto"===d.unit,options:r,value:d.unit,onClick:y})})},h=e=>""===e.trim()?null:Number(e);var P=window.elementorV2.schema;const C=(0,n.createPropUtils)("global-size-variable",P.z.string());function V(e,t){const n=a(e),{unit:i}=c(t.value);return n.includes(i)}function T(){(0,i.registerVariableType)({valueField:z,icon:r.ExpandDiagonalIcon,propTypeUtil:C,fallbackPropTypeUtil:n.sizePropTypeUtil,variableType:"size",defaultValue:"0px",selectionFilter:(e,t)=>{const n=a(t);return e.filter((e=>{const{unit:t}=c(e.value);return n.includes(t)}))},isCompatible:V,valueTransformer:c})}(window.elementorV2=window.elementorV2||{}).editorVariablesExtended=t}(),window.elementorV2.editorVariablesExtended?.init?.();
|
||||
Reference in New Issue
Block a user